Skip to contentSkip to conversation

bcachefs: fs-ioctl: Fix copy_to_user() error code

PATCH Applied Dan Carpenter 2 participants 2 messages Sep 15, 2023 – Sep 19, 2023 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcachefs: fs-ioctl: Fix copy_to_user() error code

The copy_to_user() function returns the number of bytes that it wasn't able to copy but we want to return -EFAULT to the user.

Fixes e0750d947352 ("bcachefs: Initial commit")
---
 fs/bcachefs/fs-ioctl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/bcachefs/fs-ioctl.c +4 -1
index 141bcced031e..0679b2f79fd6 100644
@@ -122,7 +122,10 @@ static int bch2_ioc_fsgetxattr(struct bch_inode_info *inode,
 
 	fa.fsx_projid = inode->ei_qid.q[QTYP_PRJ];
 
-	return copy_to_user(arg, &fa, sizeof(fa));
+	if (copy_to_user(arg, &fa, sizeof(fa)))
+		return -EFAULT;
+
+	return 0;
 }
 
 static int fssetxattr_inode_update_fn(struct btree_trans *trans,
Signature · 1 line
2.39.2
#1 lore raw
Quoted 5 lines · Dan Carpenter

The copy_to_user() function returns the number of bytes that it wasn't able to copy but we want to return -EFAULT to the user.

Fixes e0750d947352 ("bcachefs: Initial commit")

Thanks, applied