summaryrefslogtreecommitdiff
path: root/fs/nfs/file.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-07-11 09:17:02 +0200
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2024-07-17 13:15:35 -0400
commitfada32ed6dbc748f447c8d050a961b75d946055a (patch)
tree14c49571a5db26af0fb4ad12e9648868578360c4 /fs/nfs/file.c
parent39c910a430370fd25d5b5e4b2f4b24581a705499 (diff)
nfs: pass explicit offset/count to trace events
nfs_folio_length is unsafe to use without having the folio locked and a check for a NULL ->f_mapping that protects against truncations and can lead to kernel crashes. E.g. when running xfstests generic/065 with all nfs trace points enabled. Follow the model of the XFS trace points and pass in an explŃ–cit offset and length. This has the additional benefit that these values can be more accurate as some of the users touch partial folio ranges. Fixes: eb5654b3b89d ("NFS: Enable tracing of nfs_invalidate_folio() and nfs_launder_folio()") Reported-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r--fs/nfs/file.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 0e2f87120cb8..9aa2ab218c0a 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -436,7 +436,7 @@ static void nfs_invalidate_folio(struct folio *folio, size_t offset,
/* Cancel any unstarted writes on this page */
nfs_wb_folio_cancel(inode, folio);
folio_wait_private_2(folio); /* [DEPRECATED] */
- trace_nfs_invalidate_folio(inode, folio);
+ trace_nfs_invalidate_folio(inode, folio_pos(folio) + offset, length);
}
/*
@@ -504,7 +504,8 @@ static int nfs_launder_folio(struct folio *folio)
folio_wait_private_2(folio); /* [DEPRECATED] */
ret = nfs_wb_folio(inode, folio);
- trace_nfs_launder_folio_done(inode, folio, ret);
+ trace_nfs_launder_folio_done(inode, folio_pos(folio),
+ folio_size(folio), ret);
return ret;
}