afs: Fix afs_atcell_get_link() to handle RCU pathwalk
authorDavid Howells <dhowells@redhat.com>
Thu, 6 Mar 2025 08:46:57 +0000 (08:46 +0000)
committerDavid Howells <dhowells@redhat.com>
Mon, 10 Mar 2025 09:46:53 +0000 (09:46 +0000)
commit823869e1e61607ab0d433de3c8abed221dc80a5e
treed2b170a71004d62824f7c6cb88dc06fbe7ffefe6
parent1e15510b71c99c6e49134d756df91069f7d18141
afs: Fix afs_atcell_get_link() to handle RCU pathwalk

The ->get_link() method may be entered under RCU pathwalk conditions (in
which case, the dentry pointer is NULL).  This is not taken account of by
afs_atcell_get_link() and lockdep will complain when it tries to lock an
rwsem.

Fix this by marking net->ws_cell as __rcu and using RCU access macros on it
and by making afs_atcell_get_link() just return a pointer to the name in
RCU pathwalk without taking net->cells_lock or a ref on the cell as RCU
will protect the name storage (the cell is already freed via call_rcu()).

Fixes: 30bca65bbbae ("afs: Make /afs/@cell and /afs/.@cell symlinks")
Reported-by: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/r/20250310094206.801057-2-dhowells@redhat.com/
fs/afs/cell.c
fs/afs/dynroot.c
fs/afs/internal.h
fs/afs/proc.c