From patchwork Mon Feb 27 17:36:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13153983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D07C6C7EE2E for ; Mon, 27 Feb 2023 17:37:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F128280004; Mon, 27 Feb 2023 12:37:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59DDB280001; Mon, 27 Feb 2023 12:37:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 418A4280004; Mon, 27 Feb 2023 12:37:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 30416280001 for ; Mon, 27 Feb 2023 12:37:27 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E5AE21C36A9 for ; Mon, 27 Feb 2023 17:37:26 +0000 (UTC) X-FDA: 80513778492.24.5F37C94 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf24.hostedemail.com (Postfix) with ESMTP id 2070918001C for ; Mon, 27 Feb 2023 17:37:24 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kE2fXrc4; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 3VOr8YwYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3VOr8YwYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677519445; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Q7njm8z68LI6RSv1P8+cvUE7J2LNjoWsKIE5FW5UVRU=; b=e4qnCnXQx2tclCaXa1BHewujPOXPPUI9YtyuMxee6E9S4tID74tqioGnuSjpkzsrsduVlL wHtedbXZyYTTb3yB3VF2hNwFNBir6KOGHl4qcEIhQG3JRGtzmLdiKyIa6XH+2R1ZU8sGLd W9Q6q4FyHC1oRQ7y4yTD4B/d9uZTipw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kE2fXrc4; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 3VOr8YwYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3VOr8YwYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677519445; a=rsa-sha256; cv=none; b=6l8uyCGTv18esC0J9wzsskakDpVwHZ7EvtTJXwZp3VZjn9e/jTX0eu14izYcKF/MmRePqR YTnFWxojj9HhXpZVTnb8kVkBacmLX8J6WExSMxPjI1YsATvD/y1iu+wBPXrXAdMN/dlGe6 ua/w4XYEUo4iQ5a4L4/zLC4FVJVokPA= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-536be78056eso152400017b3.1 for ; Mon, 27 Feb 2023 09:37:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Q7njm8z68LI6RSv1P8+cvUE7J2LNjoWsKIE5FW5UVRU=; b=kE2fXrc4CKxmWF4clr80N741Ci0xoX5G8lQJgmu9s0G2B1Dy6UfiGdmy87bkmQVz06 s0jNeoaCkSHSjTyAuaLFgp289qeTagMwone0ldYih81KbxqFw8/SoaDnJa0SNDiiUGH5 C2cHTDPFHiMhA/p+opto/zgvEpmwF0hSnXtUorxCz5wzOWx7pG82xGb9d1FeLnZgcBn6 7W1alMlgUF/qdYBONkVV4Ipuqjxo8jbsNMGdOFgbr+6bIzoXMj9Q7PsKDQfKRgxbc6VN kYkd8hTRqF7X5fVDHYhOgBPe6TXfun1LU5P2SsjoAl6axSlRSprAw6j/yFhpk0MslB1+ 5m8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Q7njm8z68LI6RSv1P8+cvUE7J2LNjoWsKIE5FW5UVRU=; b=Ky8iqhpf+UIA7LPXtg7Pz2L70ZwVe2iq+cJHZwW5s1nkPjkYbgVfF20JmRePErl/wg IHhxrK1khTbM4QpEdzYOpvj0UOwczgo0e2rE70KPYCSsyt74r0tyuisu9pgHNI2y4Mzc M4xMU3J9RJ1zrmm1PGBdgNf9HXkAXncg69qYTCA2G7NDwUfl7Xqcs9kZ/Cjt6kXWKmKz JcI9A3NNIziaR9lSDMuQs85bBlWuu1sLJkAu6atnexmj5+/fBrTi9vbdRSH/09PRuucs l0gaZhq06YiZOf8rVA1j1sXxNMtx1Yfx2SEMG05Zb5eXlx48NpmUrV9KZLFLGtn3WWOm fyfQ== X-Gm-Message-State: AO0yUKWkSgI+bBPIX02/DwyFIMvrsGKZOuBIwaPyyRwgA2fzNvdXLP12 Lv+he9SmPlQ+TwBOAVKp9xFaAE7x0yI= X-Google-Smtp-Source: AK7set8BLaXPA95+t3odvktVZcgw7j4RuC8orgkmVPEnGvQUgHaO3AYXobp8iNv8pTyoR4t4ofqJKVALLsQ= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:e1f6:21d1:eead:3897]) (user=surenb job=sendgmr) by 2002:a05:6902:4d4:b0:91d:d6ed:6bd2 with SMTP id v20-20020a05690204d400b0091dd6ed6bd2mr10048648ybs.1.1677519444556; Mon, 27 Feb 2023 09:37:24 -0800 (PST) Date: Mon, 27 Feb 2023 09:36:19 -0800 In-Reply-To: <20230227173632.3292573-1-surenb@google.com> Mime-Version: 1.0 References: <20230227173632.3292573-1-surenb@google.com> X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Message-ID: <20230227173632.3292573-21-surenb@google.com> Subject: [PATCH v4 20/33] kernel/fork: assert no VMA readers during its destruction From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, paulmck@kernel.org, mingo@redhat.com, will@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, chriscli@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, rppt@kernel.org, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, leewalsh@google.com, posk@google.com, michalechner92@googlemail.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Suren Baghdasaryan X-Rspamd-Queue-Id: 2070918001C X-Rspam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NjV/5mYDVxQNzv8D59RwOKgkH9kzChxRsX0SIWMb9BhQBry0slCKIvonKGLsbIKVM0YjrTPdsBN29+VTVNSNRZCLSt7tdgjSyvVh50PgqterY2UooPkG51mXjjrFpyq5tq7Hi6ChXttDiEE0HZ0oNa1JTomucqsOvSPHrJlwOT1wLynQS3/z/lVkE48tBKLvimg279PpvKVaKZkEhziQsQ/nFvPPgxccmAJEwoXLEZ6Ir1WXxkPMbbXT1gCleYdM++YnRuhbply/Au/7l5l43vcqLz3Wl8o9U6HSJ1br/PxSNMzCYEEYy/nrBG5b9j4ZRe1Q6oYs6QVwc7llT9Eq3jHNkFfKIodpm2xcCEZf7Zi1wSLpjHU6GiD36N9NGGwAKZYOZQmak2OQEjUejIw+MFsqiYMw8IrIW5C9y2HMlU9W5Vl9P48ny6H9enYL31bxY7TIHmAAxLyI0emuvFsqx3QyDDvfTf62EOBy4/8gsf8XXavtnOmsAwy30Q27geWflrnXGev2M4EUMO3UBGYT8BhZaVHyqfoGCA1LKMEYi0W4ubee8NgFk3A1a7n+4pYiO1uhBQQiplivjNIyztBkiRQgBNsdEtG3F56aDNlSEQuDFQy6HA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000061, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Assert there are no holders of VMA lock for reading when it is about to be destroyed. Signed-off-by: Suren Baghdasaryan --- kernel/fork.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/fork.c b/kernel/fork.c index e1dd79c7738c..bdb55f25895d 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -491,6 +491,9 @@ static void vm_area_free_rcu_cb(struct rcu_head *head) { struct vm_area_struct *vma = container_of(head, struct vm_area_struct, vm_rcu); + + /* The vma should not be locked while being destroyed. */ + VM_BUG_ON_VMA(rwsem_is_locked(&vma->lock), vma); __vm_area_free(vma); } #endif