From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202846; b=rJuI5WKJzOCezNcf0QyaZ06/OKyGayzrFQ7U5+nlKK4bGlKlfc5iylTSrI75N+aYuANI EeMw2tRiSAvtfGBW27k1Ns8rUl5K9d6nAHW1uBJ7c+e7Xv221Ja4Qqs5/QpiVYv3IdlN5 AI1iGLhx9CYHtA++KRhqUyU3RZR4WJmKcm9pvFFex0EtJJbJK7eV7xuKXiZgsBiZaovfo 7gav0UGyokRSB+6r06EiKP5QpJoqcuLpLIpEHh6DTUsgUs45WNpT9QGayrVhCk5j+pUN5 mswVNGWvN5OhLlGY3d1E5eciAnjKXSm/8O7O0ZXx0J8jj/kPioQvOojh7R/w3tHCGRQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796202846; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:Content-Transfer-Encoding:User-Agent:MIME-Version; bh=jijJLW+j3+x/lzyEMsdrDq2RyW059CdRkFzYk6q6Xng=; b=CWergfea1vYAamDlf+ptY9dTNgTYsXpVFiEuLff3SQby5tq3eZ5LITlPUd8U2Ozoo3Nf rdWTW6JcCYFJ9lbZOBrw7iRDtHcII7NudzKjq95qS3HQREfT96igFewjtLyqhkYDrYNPE tXk+S0jSzTlEQ/xjz7YG0/3SOvxP+wIaPIfMG0vAWltEyC6PPpJtkF48tGR2KZDoQ7gPI n2O6p4MEiDuxfMV5yKc+3KxNqvSz+3lnF3mh6eSNZnRck5GGcAkdOxZgeGyrWmtt6subf sECS/OA6aay0uWL2gScRyGA8LeWLu0hErmaCOb4WlUYwsttDnNgbS0UTLc6saQqE+Yg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=amutable.com; spf=pass smtp.mailfrom=amutable.com; dkim=pass header.d=amutable-com.20260707.gappssmtp.com header.i=@amutable-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b="D/OVDzjk"; arc=none smtp.remote-ip=209.85.208.43 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8BA7606A31A for ; Wed, 2 Dec 2026 09:14:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E8BA7606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=amutable.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amutable.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amutable-com.20260707.gappssmtp.com header.i=@amutable-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=D/OVDzjk Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-6b587538a37so19219477a12.2 for ; Wed, 02 Dec 2026 01:14:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amutable-com.20260707.gappssmtp.com; s=20260707; t=1796202844; x=1796807644; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to:content-type; bh=jijJLW+j3+x/lzyEMsdrDq2RyW059CdRkFzYk6q6Xng=; b=D/OVDzjkqmxnuSJx7uiePk9cDK0jZ0qRz/5QmPFKcV21hDWHt/2yAseMc1GrY1ip6L moECoAYu9fHEl8K37OTP4xoBYV+m7S5gy5ap7wE26Qp5aU4SuPpWAXb4r+5Ewg8cZO6H WJDuuaqrJs+ell9srllemd3VPH2kTtva+WL/WSNb4WzKKJ5yydKWxi82StYJVF5l7kdJ g2096u8nKaZNhNzPwlCJoX7nUYsdv0XDuIdhaIk4hfjKwMuRNLzWW2tEvjq1yWrDcznw EKZ1pwwecDWi8cFKOko/hwBQz0+zeh7bTCrXqZo0TEJ7eKfmbqiE8mtfad47Bjqe3MJq Bq2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796202844; x=1796807644; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=jijJLW+j3+x/lzyEMsdrDq2RyW059CdRkFzYk6q6Xng=; b=1NkcbhuTbBUnn2q2OWQyO5/FXqhKmNagIPMSNI7oKt4ms6Oq22c/21VdrxmeuNJ/Zq CHD2qGn2YFzZsF4C3xLw7lRQgStLRXrkJL5EiGX+bkk/olj4zzaG1A8owG8EfNNur85A xg67Jvj6Ri16Zxuszgp19HQmPBc/nnlzsy0jA896ln+FIAFTXjG8bt9z6Gplw8N0GZDK O9vLxtm6ephIGeHYf5iF8uBjWLwa2SGzZdViHxFC1225fCkd+Qsx0rQ7yJvkkLj+V8JC rlJ+qPQMsybOik1KHPHU/6l0gLKRGfRBNgm5NLQr8qNXo6z/dz8TDw7M/dxtD1uK7keh Ny2Q== X-Forwarded-Encrypted: i=1; AL+hErGGOfFqKmzsUV8JoOHGAA77x5baYNS015IsgaHF7z+p5VsG5feybqkaOUMZwjmtV7rENtg7/2pIsO8ggkw=@vger.kernel.org X-Gm-Message-State: APuU4Z+XMjXzu2gosU9+p2oqEF12S1L/iTibMy1Yew+Q006hA39E3xth pFaxOcpMj3ye6Nd4PNkDady11SOH1Q9wXtDqG0E/whfmwCkSmXg2facoFMEOmJY9ANkq X-Gm-Gg: AZFdTZfleQ5nF4wMuepkYCBtZt3+Lzg7jTAJqiyVD7LET1mNWr7bynzbWcqdsKWWSxz D3KO4Lgr7E1jGi71Zd1A55MQc2ciPUmqpBxPfngaIOQdu0wSQXZGo+u3HzNp8v6ZCDsFSYj3wb/ sDUW/OwmFrY7qF4I6yznHnN2ewH9Byx9NKuQj1mXsOlxnKsKo+gOq/r6+ceTAeWn1v9e1ciuHxX xzOiq70e513CqynIt6zoEswo8ohDVvP5WUic6zRFSDdYz9sbzveMCrKL1LxNYyGVmR0fcUqBjli vibeQarj9BIX5jOxIhm1RuBlDUfDKGrx/KYTRo3nXIRlatZCHdVkk38SGXyv+aogLrr+nxuTIIA FJpjuXOEcY2vbl2/v4HQbIboCYX5kJnRI0SQLB1gb+8TcEoQ7zTrxlCbw8g9D5Hpfp4I/xMf2bx jcrpd1vBmQ2ePQu8THt7wm+MqD1P7znL34RZDt8MzQEiTohjerSTW+bDTph98DatA25MrH1l1iC YWJcdvqKwNaQOWS8F2oOidjw1ljKhfsLI26LxXgZiX/mc4pYurGnimh5hji9NqYW4Ms8PFmV2iI XwiyOevDyQlwdC3qeUQLm37Ca+nGIbB/nuR+ECRJKP9MYJFYmgz0MOuhK8492oKhtw== X-Received: by 2002:a05:6402:1ecf:b0:6ba:92c4:2314 with SMTP id 4fb4d7f45d1cf-6ba92c42493mr22436825a12.11.1796202844141; Wed, 02 Dec 2026 01:14:04 -0800 (PST) Received: from [10.0.0.233] (tmo-084-240.customers.d1-online.com. [80.187.84.240]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6bb1aca67c8sm9756700a12.0.2026.12.02.01.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 01:14:03 -0800 (PST) Message-ID: <18d869004cfc1715943434d8b8257fcd2d7fbbbf.camel@amutable.com> Subject: Re: [PATCH] proc: fix data-race in proc_invalidate_siblings_dcache() From: Alexander Mikhalitsyn To: Christian Brauner , linux-fsdevel@vger.kernel.org Cc: Alexander Viro , Jan Kara , linux-kernel@vger.kernel.org, syzbot+c477bc599c896b5de237@syzkaller.appspotmail.com Date: Wed, 02 Dec 2026 10:14:01 +0100 In-Reply-To: <20261201-work-procfs-kcsan_siblings-v1-1-5b6de990d05d@kernel.org> References: <20261201-work-procfs-kcsan_siblings-v1-1-5b6de990d05d@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-0+deb13u1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Tue, 2026-12-01 at 11:46 +0100, Christian Brauner wrote: > proc_invalidate_siblings_dcache() reads the head of the sibling inode > list without holding the list's lock while an inode on that list can > be > evicted and removed from it at the same time: >=20 > =C2=A0 BUG: KCSAN: data-race in proc_invalidate_siblings_dcache / > proc_pid_evict_inode >=20 > =C2=A0 write (marked) to 0xffff8881048a01d0 of 8 bytes by task 6951 on cp= u > 0: > =C2=A0=C2=A0 __hlist_del include/linux/list.h:1045 [inline] > =C2=A0=C2=A0 hlist_del_init_rcu include/linux/rculist.h:238 [inline] > =C2=A0=C2=A0 proc_pid_evict_inode+0x7c/0xd0 fs/proc/base.c:1918 > =C2=A0=C2=A0 proc_evict_inode+0x45/0xa0 fs/proc/inode.c:41 > =C2=A0=C2=A0 evict+0x301/0x570 fs/inode.c:829 > =C2=A0=C2=A0 iput_final fs/inode.c:2036 [inline] > =C2=A0=C2=A0 iput+0x44f/0x5d0 fs/inode.c:2085 > =C2=A0=C2=A0 dentry_unlink_inode+0x29a/0x2b0 fs/dcache.c:510 > =C2=A0=C2=A0 dentry_kill+0x135/0x4f0 fs/dcache.c:857 > =C2=A0=C2=A0 finish_dput+0x9f/0x1d0 fs/dcache.c:1032 > =C2=A0=C2=A0 dput+0x43/0x50 fs/dcache.c:1073 > =C2=A0=C2=A0 proc_invalidate_siblings_dcache+0x1e6/0x2c0 fs/proc/inode.c:= 143 > =C2=A0=C2=A0 proc_flush_pid+0x1d/0x30 fs/proc/base.c:3457 > =C2=A0=C2=A0 release_task+0xa0c/0xba0 kernel/exit.c:292 > =C2=A0=C2=A0 exit_notify kernel/exit.c:781 [inline] > =C2=A0=C2=A0 do_exit+0xd64/0x1530 kernel/exit.c:992 >=20 > =C2=A0 read to 0xffff8881048a01d0 of 8 bytes by task 5112 on cpu 1: > =C2=A0=C2=A0 proc_invalidate_siblings_dcache+0x2a/0x2c0 fs/proc/inode.c:1= 14 > =C2=A0=C2=A0 proc_flush_pid+0x1d/0x30 fs/proc/base.c:3457 > =C2=A0=C2=A0 release_task+0xa0c/0xba0 kernel/exit.c:292 > =C2=A0=C2=A0 wait_task_zombie kernel/exit.c:1285 [inline] > =C2=A0=C2=A0 wait_consider_task+0x1131/0x1630 kernel/exit.c:1512 >=20 > =C2=A0 value changed: 0xffff8881071611b0 -> 0xffff88810718e530 >=20 > That's benign. Proc inodes are freed after an RCU grace period, the > list entry is removed under the lock so a second hlist_del_init_rcu() > is a nop, and igrab() fails for an inode that is being evicted. But > the > head is an RCU protected pointer that we read under rcu_read_lock(). > So > read it with rcu_dereference() like hlist_for_each_entry_rcu() does. > That also gets rid of the sparse warning about assigning an __rcu > pointer to a plain one. >=20 > Reported-by: syzbot+c477bc599c896b5de237@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3Dc477bc599c896b5de237 > Fixes: 26dbc60f385f ("proc: Generalize proc_sys_prune_dcache into > proc_prune_siblings_dcache") > Signed-off-by: Christian Brauner (Amutable) Looks good to me. Please feel free to add: Reviewed-by: Alexander Mikhalitsyn > --- > =C2=A0fs/proc/inode.c | 2 +- > =C2=A01 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/fs/proc/inode.c b/fs/proc/inode.c > index 02aa3e5f8c930..7c402acad6692 100644 > --- a/fs/proc/inode.c > +++ b/fs/proc/inode.c > @@ -115,7 +115,7 @@ void proc_invalidate_siblings_dcache(struct > hlist_head *inodes, spinlock_t *lock > =C2=A0 struct super_block *old_sb =3D NULL; > =C2=A0 > =C2=A0 rcu_read_lock(); > - while ((node =3D hlist_first_rcu(inodes))) { > + while ((node =3D rcu_dereference(hlist_first_rcu(inodes)))) { > =C2=A0 struct proc_inode *ei =3D hlist_entry(node, struct > proc_inode, sibling_inodes); > =C2=A0 struct super_block *sb; > =C2=A0 struct inode *inode; >=20 > --- > base-commit: 9cf8c00eb41ff7cbedf3a3ee9ba77fd49d7dfb06 > change-id: 20261201-work-procfs-kcsan_siblings-b9dddc86fcac