Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp753139rdd; Tue, 9 Jan 2024 20:44:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFLzGvOFSVbi1+OMvurIFnv7XsldvnQoVfrK+SjPCrJA7ZVsWBs2O3FGXfYiR8xN/ut5zi X-Received: by 2002:a50:8714:0:b0:557:7861:bc45 with SMTP id i20-20020a508714000000b005577861bc45mr60077edb.58.1704861851249; Tue, 09 Jan 2024 20:44:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704861851; cv=none; d=google.com; s=arc-20160816; b=OTGAuS7MqWbwOn86A4Oeigi6tVWz8nT5ILJPPVNide2BdP4sXVMbpUDBd86IEWgtIS JLsWaEe6kSMhd43But/6I7meBkjHYpiOfIzPpqy2mqfj/J3+OXYmYYa2H9yYGdYS5BZc lG6Oz9oDrAZEL3rQlhYwxnbks4IMgIj/kLTISSaeJG1l93srqy+VEK350hi54yV0lUBK QgPUe/zhWaToObI2h49bySZ3e6Tpmx/ihee8gJaAP/G6KQbFc5ADpk0vdZ7cZ30xl2/K R2tKayiqEKKGGAIy2VOgnRQ6WhMp3a/M6YsWmAnvhXm1iK1owz/hz/1l2NKEIEL8rlGy DN7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=a98SBlfyuCmd0WZZ+VG6huLrUV93OVJqcKaohtdthgc=; fh=LMPwU/4hhkS+Qz85D9uXjb7AKNbd+UzgIL8vBaQU2VQ=; b=rF0iuIDiejy1jRlagonz6m4zmoCN83RoI306zk3j3kbwlMqGzjIA5bMNrLxlHShBNb m2dD8pv8e3VKlweaBEy6pvz6RMwiErPG+yl3ozBLZ+l/TFaxjajIHNa/rLg1xB/WOYRb bQUA25KmQTYwcfyfaadqaBpR/r49kqJJ1SDr9ssFRTbtklF8+wOzlEU4u1iwwHlg047c lR4KVGq08ql0OK7GjFuOprcPJW7F4AA/qORA7RBw0/GFmNY2OQa1H7YigvPni9F65B1n xAw1XlYbV4TiKq+ZAZ9ZlVjqvC0x/c/HlVo5jNheUENybgo4BCv6iKmgHo/w9ZU58MB1 au2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="Xz/QTWGU"; spf=pass (google.com: domain of linux-kernel+bounces-21708-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21708-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y16-20020a056402271000b005558e0f997esi1463624edd.676.2024.01.09.20.44.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 20:44:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21708-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="Xz/QTWGU"; spf=pass (google.com: domain of linux-kernel+bounces-21708-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21708-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F310D1F25B42 for ; Wed, 10 Jan 2024 04:44:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E15BD2E0; Wed, 10 Jan 2024 04:43:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Xz/QTWGU" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B053A6FAF; Wed, 10 Jan 2024 04:43:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FFFCC433F1; Wed, 10 Jan 2024 04:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1704861837; bh=RKClabnfbCkpoH3vhzF2N9v90yEPu3odm1xJiTbC6Qk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Xz/QTWGUo/6dZ6/hjpWWoB0F1FjKRq+euouAygBcGRWgToVFGW3nslnADnZ/9K87p 7fu3CoEto8PtfPTdNEMs5pUtTcZ6fMFi4NqNiJn6qtFCwjZWrY1FbOOx1J8sUIuzsH Ngz4WszWViXwj6voGoRqpPneYmWIfr6RJ3V2k7Fc= Date: Tue, 9 Jan 2024 20:43:56 -0800 From: Andrew Morton To: Sean Christopherson Cc: Muhammad Usama Anjum , David Hildenbrand , Andrei Vagin , Peter Xu , Hugh Dickins , Suren Baghdasaryan , Ryan Roberts , Kefeng Wang , "Liam R. Howlett" , =?UTF-8?Q?"Micha=C5=82_Miros=C5=82aw"?= , Stephen Rothwell , Arnd Bergmann , kernel@collabora.com, syzbot+81227d2bd69e9dedb802@syzkaller.appspotmail.com, stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] fs/proc/task_mmu: move mmu notification mechanism inside mm lock Message-Id: <20240109204356.6c088124a9ba0ce0b5a4bb00@linux-foundation.org> In-Reply-To: References: <20240109112445.590736-1-usama.anjum@collabora.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 9 Jan 2024 08:28:06 -0800 Sean Christopherson wrote: > > - /* Protection change for the range is going to happen. */ > > - if (p.arg.flags & PM_SCAN_WP_MATCHING) { > > - mmu_notifier_range_init(&range, MMU_NOTIFY_PROTECTION_VMA, 0, > > - mm, p.arg.start, p.arg.end); > > - mmu_notifier_invalidate_range_start(&range); > > - } > > - > > for (walk_start = p.arg.start; walk_start < p.arg.end; > > walk_start = p.arg.walk_end) { > > long n_out; > > Nit, might be worth moving > > struct mmu_notifier_range range; > > inside the loop to guard against stale usage, but that's definitely optional. Yes, I think that's nicer. --- a/fs/proc/task_mmu.c~fs-proc-task_mmu-move-mmu-notification-mechanism-inside-mm-lock-fix +++ a/fs/proc/task_mmu.c @@ -2432,7 +2432,6 @@ static long pagemap_scan_flush_buffer(st static long do_pagemap_scan(struct mm_struct *mm, unsigned long uarg) { - struct mmu_notifier_range range; struct pagemap_scan_private p = {0}; unsigned long walk_start; size_t n_ranges_out = 0; @@ -2450,6 +2449,7 @@ static long do_pagemap_scan(struct mm_st for (walk_start = p.arg.start; walk_start < p.arg.end; walk_start = p.arg.walk_end) { + struct mmu_notifier_range range; long n_out; if (fatal_signal_pending(current)) { _ I'm surprised this code doesn't generate a might-be-used-uninitialized warning. I guess gcc got smarter.