[PATCH] 9p: cap xattr max size to XATTR_SIZE_MAX

From: Dominique Martinet
Date: Mon Mar 04 2024 - 07:43:05 EST


We probably shouldn't ever get an xattr bigger than that, and the current check
of SSIZE_MAX is a bit too large.

Cc: Christian Brauner <brauner@xxxxxxxxxx>
Cc: xingwei lee <xrivendell7@xxxxxxxxx>
Cc: sam sun <samsun1006219@xxxxxxxxx
Signed-off-by: Dominique Martinet <asmadeus@xxxxxxxxxxxxx>
---
fs/9p/xattr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c
index 8604e3377ee7..97f60b73bf16 100644
--- a/fs/9p/xattr.c
+++ b/fs/9p/xattr.c
@@ -37,8 +37,8 @@ ssize_t v9fs_fid_xattr_get(struct p9_fid *fid, const char *name,
if (attr_size > buffer_size) {
if (buffer_size)
retval = -ERANGE;
- else if (attr_size > SSIZE_MAX)
- retval = -EOVERFLOW;
+ else if (attr_size > XATTR_SIZE_MAX)
+ retval = -E2BIG;
else /* request to get the attr_size */
retval = attr_size;
} else {

---
base-commit: be3193e58ec210b2a72fb1134c2a0695088a911d
change-id: 20240304-xattr_maxsize-edf98c1a8c19

Best regards,
--
Dominique Martinet | Asmadeus