From nobody Fri Oct 10 17:34:18 2025 Received: from neil.brown.name (neil.brown.name [103.29.64.221]) (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 1973C18A6AD; Fri, 13 Jun 2025 02:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.29.64.221 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749783158; cv=none; b=QHR3l3CftiSNdHbQFZsavZ7Jc4/oaTtyz/Z2qxM46ixbLEXwdLDaMgvcZRGDAoWKMNPIecQzdJiKyikos3aviA5NBOcN23aLvQ7nN0FNeVUDtgcZncIOSK7tcQqjIi6XQN+MF/E0Xu7cKDRfoFIWeHtsmMVqWpIHi3y2eUlZ0Bk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749783158; c=relaxed/simple; bh=QyazcMeLFCkjCNo07nRBEmSyIRcBs2tA3az6DgTS+js=; h=Content-Type:MIME-Version:From:To:Cc:Subject:Date:Message-id; b=V0E0MPIfD4yjEg4PpzB1FIlEvFy2fqXaHANRNYDTIl3pi66FMX50WaRxzJeYrpGsUK1xeV9gGsVNnRn4pWrJfcQ6xprsDoMLjGJC0bT5efhRSWa2pkOT8EzWLqaBQvquF/UTWn+IX9xRopuIrT3Rub0Ph+hLoyBs7Q1kS+3gjGc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brown.name; spf=pass smtp.mailfrom=neil.brown.name; arc=none smtp.client-ip=103.29.64.221 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=neil.brown.name Received: from 196.186.233.220.static.exetel.com.au ([220.233.186.196] helo=home.neil.brown.name) by neil.brown.name with esmtp (Exim 4.95) (envelope-from ) id 1uPuWv-009nYt-2o; Fri, 13 Jun 2025 02:52:33 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "NeilBrown" To: Al Viro , Kees Cook , Joel Granados Cc: linux-fsdevel@vger.kernel.org, LKML Subject: [PATCH] proc_sysctl: remove RCU annotations for accessing ->sysctl Date: Fri, 13 Jun 2025 12:52:32 +1000 Message-id: <174978315268.608730.1330012617868311392@noble.neil.brown.name> The ->sysctl field of a procfs inode is only set when the inode is created, and when it is being evicted. In both these cases there cannot be concurrent accesses and so using RCU_INIT_POINTER() and rcu_dereference() is misleading. I discovered this with some devel code which called d_same_name() without holding the rcu_read_lock() - rcu_dereference() triggered a warning. In mainline ->d_compare is called from d_alloc_parallel() without rcu_read_lock() after taking ->d_lock. It is conceivable that the d_inode will have been set while waiting for that lock so mainline could trigger the same warning. This patch removes those accessor call. Note that the sysctl field is not marked __rcu so sparse complains too. Signed-off-by: NeilBrown --- fs/proc/inode.c | 2 +- fs/proc/proc_sysctl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/inode.c b/fs/proc/inode.c index a3eb3b740f76..c3991dd314d9 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -42,7 +42,7 @@ static void proc_evict_inode(struct inode *inode) =20 head =3D ei->sysctl; if (head) { - RCU_INIT_POINTER(ei->sysctl, NULL); + ei->sysctl =3D NULL; proc_sys_evict_inode(inode, head); } } diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index cc9d74a06ff0..976d7605560f 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -928,7 +928,7 @@ static int proc_sys_compare(const struct dentry *dentry, return 1; if (memcmp(name->name, str, len)) return 1; - head =3D rcu_dereference(PROC_I(inode)->sysctl); + head =3D PROC_I(inode)->sysctl; return !head || !sysctl_is_seen(head); } =20 --=20 2.49.0