From nobody Mon Feb 9 14:32:02 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 999FF1D14E2 for ; Thu, 26 Dec 2024 17:07:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735232848; cv=none; b=t+sshnDsyIRZK2qBoOUlHtoSuhUXgarWlm6BJOMuQJ8AkJrurkAL08LQTi3Yk4jilgvhmV6pYH4caD9/wlrBhqABDuEknpfw0/Ox92GMznPLe1gax2Hk134oBbzSMyNQRaLQNalFF8nx7PAy9f8fbj1IU5rAHNeIiHdehPsZv1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735232848; c=relaxed/simple; bh=7fZMRb/YbbjOi0MmTg3pGeQUEUL0PmuVszXd/0QvBig=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bDzFhZ7n8WHu+Bxi5n2+4mGj3iWKTlSj0XkWT7E725mExXFZ/E1uHWAmLZ8gSAQKLVSFST5UbUUfENvo6yGRJMh2Q0Wjcg4KyskWgb2QmDDq+3V7Sp7cE8fY5+dJ+m7U1CuMkKZysRuA1XM7XjuYjRkiyBsKG39and2qfekt5oY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kzunHBQV; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kzunHBQV" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2162259a5dcso144834575ad.3 for ; Thu, 26 Dec 2024 09:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1735232846; x=1735837646; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=g5ywt//znwFKMBkiU95FpNYi4gj0LeYvCae6lfTb4Ek=; b=kzunHBQVkRfVFNXbgQGUT5jPyCC20z7B7knCDh1wwFgMhNvqSl/guiaZyHb8fjFSSL uBNpcikpRGLZ6Su2H+yv32SsgS5q0Z/GGOpXB5mk7c/zF8jdHQaW5rumOR8puU3e7/IL 32G309NInGCrqG/pALwo1E5QKAgE1AWhAYyp/dTew7LT/Br9QYehYqZ5PVeo7yLMgQEZ b1pJPQCNVEPxCYJfTSj0Zh65YGiJLHT4fl01sfd3RJ6kivy0xQOgxlB9kxlinCKRQjI1 bu1B6SBcqYwaj9o+qK5HnKOjebrkr55dSOX8mOpTqHxeKayhwLSZei2zA6vCJYpm5wKi Adig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735232846; x=1735837646; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g5ywt//znwFKMBkiU95FpNYi4gj0LeYvCae6lfTb4Ek=; b=U0bK2La4hwgZ7/5F/Z8/ehz7Fs/dmI8ZY5tBh82NpBerYoHKFC8z7RYDsc+ZQ3S1mZ nVWYWPf3Yx5c4/Hselir623QXAbcGMVWirgeo7g1r4ZtYEUvbQ6Ckz2ziCCWiNd8j6MZ G4Xfpi348AVsih06DknNqpbppPykIM8cDunHDsXjLz4FS0fi9GdnXQAsgqv2VOkpI3C3 FceeNCnVR4ALt4T8yxjwas/dPswhdvUlDTJ3VwR9OY7tGLTdrrVACR19i7hPHEVupams MWOrFoZRhrj14evntGZkryG2tefoTqd5Tyu/VkSBc5z1yTFoViwyzoCoLjvU9KhP902v h2tw== X-Forwarded-Encrypted: i=1; AJvYcCWRAC6p3QzAKrdiI/wUavNr00CL6RQbJ8qXrt2BZ874PxpI9Vuqr4NSnBoGz5oexxTirYxzHyCN9pkHyfw=@vger.kernel.org X-Gm-Message-State: AOJu0YxH/Sm5yQaGsYdI11uAcEyX1rJxgZN6ZQMAJbn7ZOvG2WCY3rvH RqRh6mOx+Wv6oKwiguZengKUgzirAVKBGh8lMyKJ5qjL99nJDzYWSgChmnGAAINND8tStQl+9KJ RMw== X-Google-Smtp-Source: AGHT+IE/h3it9ewL3ohy9Py+t9rkxMgblJxIK9ZNryUZhJOqjESQSzvwpTa/5zazFY30vveAdTUiPRQAGfg= X-Received: from pgjs19.prod.google.com ([2002:a63:f053:0:b0:800:502a:791c]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d589:b0:216:45b9:439b with SMTP id d9443c01a7336-219e6f28486mr336700685ad.50.1735232845994; Thu, 26 Dec 2024 09:07:25 -0800 (PST) Date: Thu, 26 Dec 2024 09:06:58 -0800 In-Reply-To: <20241226170710.1159679-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241226170710.1159679-1-surenb@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241226170710.1159679-7-surenb@google.com> Subject: [PATCH v7 06/17] mm/nommu: fix the last places where vma is not locked before being attached From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: peterz@infradead.org, willy@infradead.org, liam.howlett@oracle.com, lorenzo.stoakes@oracle.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mjguzik@gmail.com, oliver.sang@intel.com, mgorman@techsingularity.net, david@redhat.com, peterx@redhat.com, oleg@redhat.com, dave@stgolabs.net, paulmck@kernel.org, brauner@kernel.org, dhowells@redhat.com, hdanton@sina.com, hughd@google.com, lokeshgidra@google.com, minchan@google.com, jannh@google.com, shakeel.butt@linux.dev, souravpanda@google.com, pasha.tatashin@soleen.com, klarasmodin@gmail.com, corbet@lwn.net, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com, surenb@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" nommu configuration has two places where vma gets attached to the vma tree without write-locking it. Add the missing locks to ensure vma is always locked before it's attached. Signed-off-by: Suren Baghdasaryan --- mm/nommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/nommu.c b/mm/nommu.c index 72c8c505836c..1754e84e5758 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -1189,6 +1189,7 @@ unsigned long do_mmap(struct file *file, goto error_just_free; =20 setup_vma_to_mm(vma, current->mm); + vma_start_write(vma); current->mm->map_count++; /* add the VMA to the tree */ vma_iter_store(&vmi, vma, true); @@ -1356,6 +1357,7 @@ static int split_vma(struct vma_iterator *vmi, struct= vm_area_struct *vma, =20 setup_vma_to_mm(vma, mm); setup_vma_to_mm(new, mm); + vma_start_write(new); vma_iter_store(vmi, new, true); mm->map_count++; return 0; --=20 2.47.1.613.gc27f4b7a9f-goog