Skip to content

NFS: fix RCU and tracing pointer safety

Sean Chang linux-nfs lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 1 replyIn review
  2. v22 patches 3 repliesSuperseded
  3. v12 patches 4 repliesSuperseded

Changes in v3 from the cover letter

- Patch 2: Removed the redundant XPRT_CONNECTED and pointer existence checks as suggested by Benjamin Coddington. Since the comparison is performed while holding sb_lock, the transport's existence is guaranteed, and its connection state does not affect the server's identity.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2NFS: remove redundant __private attribute from nfs_page_classfs/nfs/nfstrace.h+1 -10 replies
2/2NFS: Fix RCU dereference of cl_xprt in nfs_compare_super_addressfs/nfs/super.c+13 -31 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchBenjamin Coddington
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] NFS: fix RCU and tracing pointer safety

This series addresses two Sparse static analysis warnings in the NFS client related to RCU safety and pointer attributes.

The first patch resolves a "dereferencing noderef expression" warning within the nfs_page_class tracepoint by removing a redundant __private attribute that was causing Sparse to complain during trace-buffer assignments.

The second patch fixes an RCU-unsafe dereference in nfs_compare_super_address. It wraps cl_xprt access with rcu_read_lock() and rcu_dereference(). Following reviewer feedback, the RCU critical section is kept minimal, covering only the transport and network namespace checks.

v3:
- Patch 2: Removed the redundant XPRT_CONNECTED and pointer existence checks as suggested by Benjamin Coddington. Since the comparison is performed while holding sb_lock, the transport's existence is guaranteed, and its connection state does not affect the server's identity.

v2:
- Patch 1: Instead of changing the 'req' field type to unsigned long (as in v1), simply remove the redundant __private attribute. This resolves the Sparse warning while preserving the original pointer type.
- Patch 2: Reduced RCU read-side critical section scope to cover only the necessary transport/net-ns checks, as suggested by reviewers.

Sean Chang (2):
NFS: remove redundant __private attribute from nfs_page_class
NFS: Fix RCU dereference of cl_xprt in nfs_compare_super_address

 fs/nfs/nfstrace.h |  2 +-
 fs/nfs/super.c    | 16 +++++++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0