diff mbox series

NFS: handle wait_on_bit_action() errors in nfs_vm_page_mkwrite()

Message ID 20250303140314.1650-1-vulab@iscas.ac.cn (mailing list archive)
State Handled Elsewhere
Headers show
Series NFS: handle wait_on_bit_action() errors in nfs_vm_page_mkwrite() | expand

Commit Message

Wentao Liang March 3, 2025, 2:03 p.m. UTC
Add error handling for wait_on_bit_action() failures in the page
fault path. Return VM_FAULT_SIGBUS instead of proceeding with
folio operations when wait_on_bit_action() fails.

Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 fs/nfs/file.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Markus Elfring March 7, 2025, 5:29 p.m. UTC | #1
> Add error handling for wait_on_bit_action() failures in the page
> fault path. Return VM_FAULT_SIGBUS instead of proceeding with
> folio operations when wait_on_bit_action() fails.

                                             call failed?

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14-rc5#n145

Regards,
Markus
diff mbox series

Patch

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 1bb646752e46..9e492391687b 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -590,6 +590,7 @@  static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf)
 	struct file *filp = vmf->vma->vm_file;
 	struct inode *inode = file_inode(filp);
 	unsigned pagelen;
+	int r;
 	vm_fault_t ret = VM_FAULT_NOPAGE;
 	struct address_space *mapping;
 	struct folio *folio = page_folio(vmf->page);
@@ -607,9 +608,13 @@  static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf)
 		goto out;
 	}
 
-	wait_on_bit_action(&NFS_I(inode)->flags, NFS_INO_INVALIDATING,
+	r = wait_on_bit_action(&NFS_I(inode)->flags, NFS_INO_INVALIDATING,
 			   nfs_wait_bit_killable,
 			   TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
+	if (r) {
+		ret = VM_FAULT_SIGBUS;
+		goto out;
+	}
 
 	folio_lock(folio);
 	mapping = folio->mapping;