From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B9F3606D2FB for ; Tue, 3 Nov 2026 14:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=2xtPAEff; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ljtTrKrz DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Cc:To:Subject: From:Message-ID:MIME-Version:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=ED7DfxpP0C+3U90pEocB+hyI9bQg1Q/rMH3eRirphfo=; b=2xtPAEffK7scCt8KWb/gVikDIY 7OIW/ccSTreGPzBNK2roo7XUgsArNtm8yAsoa6xGF+jdCYCKBAEiHO008g+ZCjFMh4gMib7g6p6Vy AMPeUPtWj/rtF4IPs5Oh8X1llAlMSE4XY/xloRuE6aBtNYKd30fByYGmbgSZV3Y82xn4O3+tU8Xr2 8I+TRUgBSTRiNQt3YrPHuG6vCMP+nSPCjcqtYAJ16zzxSTR0zcpB5DW6H9uush6Xwgf0CiTNPlAAl 1cH1sKHcmZKX1EBhc5qkOIS+DeTxlJdgSd8KdoieLxj2nQbhLRZWcfj+HXHNqEZdK4BSve5E5Qv5w kwtyoITQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOFod-00000002lxB-48Jj; Tue, 03 Nov 2026 14:48:47 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOFoa-00000002lrz-0xIm for kexec@lists.infradead.org; Tue, 03 Nov 2026 14:48:46 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 9D10860616; Tue, 3 Nov 2026 14:48:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E4781F000C1; Tue, 3 Nov 2026 14:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793717323; bh=ED7DfxpP0C+3U90pEocB+hyI9bQg1Q/rMH3eRirphfo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ljtTrKrzjwh9bmTgB/C4QRv4lPNCmDXb0oGrnMVLkXCeEPfpYMq2XwmiskAtwQlsK oR+9Ko1Pl3b/OoYpR0JTmvi3u4DF0d6V6KQt841p42E0GJwXEsp4zexEhStpCZGKot pkJLfSa1M3AMrCCthqht9MFhgLn+Yh9p8Octt6Ghr3uXvq/2JhHMONBnt+SmQKq34t I08bZ2ixHGY9RHmh/bJlC1bBT/o22sClyAftWhJVYpDvJ2AVldTnb++uYWhQYb014k kzsT0ppwzb8VRvjDyZBpKuGuVZJ8s3MbvTiItwdFL05JRwkjFnFrqSpfLfwR7+VZN8 /LmgWCZM8tKSQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RFC 36/38] selftests/proc: check that faulting sysctl accesses don't hold up removal To: "Christian Brauner" Cc: "Linus Torvalds" , "Jann Horn" , "Josef Bacik" , "Chris Mason" , "Jeff Layton" , NeilBrown , "Eric Dumazet" , "Thomas Gleixner" , "Al Viro" , "Jonathan Corbet" , "Christoph Hellwig" , "Greg Kroah-Hartman" , "Joel Granados" , "Kees Cook" , "Jan Kara" , "Jan Kara" , linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, coreteam@netfilter.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org, linux-sound@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-hwmon@vger.kernel.org, linux-mm@kvack.org, linux-usb@vger.kernel.org, samba-technical@lists.samba.org, sparclinux@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-serial@vger.kernel.org, "Takashi Iwai" , linux-input@vger.kernel.org, linux-raid@vger.kernel.org, linux-ext4@vger.kernel.org, linux-modules@vger.kernel.org, "Chuck Lever" , tytso@mit.edu, dmitry.torokhov@gmail.com, "Petr Pavlu" , "Anna Schumaker" , yukuai@fygo.io, "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" In-Reply-To: <20261102-work-procfs-bugfixes-v1-36-59422ed3e465@kernel.org> References: <20261102-work-procfs-bugfixes-v1-0-59422ed3e465@kernel.org> <20261102-work-procfs-bugfixes-v1-36-59422ed3e465@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 03 Nov 2026 14:48:40 +0000 X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "kexec" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: - [Medium] selftests/proc: getdents test faults in dir_emit_dots() before e= ntry lookup -- commit fc0ab3f791b6ab04b43d13e015f97882092d54fc Author: Christian Brauner selftests/proc: check that faulting sysctl accesses don't hold up removal This commit adds a proc selftest using userfaultfd and a tun device in a new network namespace to verify that page faults during read(), write(), and getdents64() on /proc/sys do not block sysctl table unregistration. > diff --git a/tools/testing/selftests/proc/proc-remove-slow-sysctl.c b/too= ls/testing/selftests/proc/proc-remove-slow-sysctl.c > new file mode 100644 > index 0000000000000..e1b1fd19a07ab > --- /dev/null > +++ b/tools/testing/selftests/proc/proc-remove-slow-sysctl.c > @@ -0,0 +1,213 @@ [ ... ] > +TEST_F(proc_sys_slow, getdents) > +{ > + struct worker w =3D { > + .op =3D SYSCTL_GETDENTS, > + .len =3D BUF_PAGES * self->psz, > + }; > + > + w.fd =3D open(CONF_PATH, O_RDONLY | O_DIRECTORY | O_CLOEXEC); > + ASSERT_GE(w.fd, 0); > + stall_and_remove(_metadata, self, &w); > + > + /* What was looked up before the removal still arrives, then nothing. */ > + EXPECT_GT(w.ret, 0); [Severity: Medium] Does TEST_F(proc_sys_slow, getdents) in tools/testing/selftests/proc/proc-remove-slow-sysctl.c actually fault on a looked-up sysctl entry, or does it fault inside dir_emit_dots() before any entry is looked up? In FIXTURE_SETUP(proc_sys_slow), only the first page of self->buf is registered with userfaultfd. When TEST_F(proc_sys_slow, getdents) opens CONF_PATH, w.fd starts at file position 0 and is passed directly to stall_and_remove() -> work_thread() -> getdents64(). In fs/proc/proc_sysctl.c:proc_sys_readdir(), dir_emit_dots() runs before sysctl_dir_next(): fs/proc/proc_sysctl.c:proc_sys_readdir() { ... if (!dir_emit_dots(file, ctx)) return 0; if (cursor && cursor->pos =3D=3D ctx->pos) { err =3D sysctl_dir_next(ctl_dir, &d, cursor->name, cursor->len); } else { loff_t pos =3D 2; err =3D sysctl_dir_next(ctl_dir, &d, NULL, 0); ... } Because ctx->pos is 0, dir_emit_dots() writes "." at the start of self->buf and triggers the single userfaultfd page fault before sysctl_dir_next() is called and while d.head is still NULL. While work_thread() is sleeping in dir_emit_dots(), stall_and_remove() clos= es self->tun (which unregisters CONF_PATH and marks ctl_dir->header as unregistering) and resolves the fault on the first page with UFFDIO_ZEROPAG= E. When work_thread() resumes, dir_emit_dots() finishes emitting "." and "..", sysctl_dir_next() immediately returns -ENOENT, and getdents64() returns the 48 bytes from the dot entries without ever entering the entry-emission loop. Should TEST_F(proc_sys_slow, getdents) advance w.fd past "." and ".." first (for example with lseek(w.fd, 2, SEEK_SET)) before calling stall_and_remove= () so the fault occurs in dir_emit() after sysctl_dir_next() and proc_sys_fill_dirent() have looked up an entry? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261102-work-procf= s-bugfixes-v1-0-59422ed3e465@kernel.org?part=3D36