git: 118067f51c11 - main - extattr_list*: avoid panic with absurd buffer lengths
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Nov 2026 10:07:05 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=118067f51c111390dbc54760d781cd14a10c499e
commit 118067f51c111390dbc54760d781cd14a10c499e
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-11-13 10:06:52 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-13 10:06:52 +0000
extattr_list*: avoid panic with absurd buffer lengths
Apply a layered defence:
- Reject nbytes > IOSIZE_MAX in user_extattr_list_fd and
user_extattr_list_path.
- In extattr_list_vp require auiop->uio_resid to be non-negative.
Effort: CHERI upstreaming
Reviewed by: markj
Reported by: llm-postcr
MFC after: 3 days
Sponsored by: Innovate UK
Fixes: 6453d4240f6b ("vfs: Export exattr methods to reuse by Linuxulator")
Differential Revision: https://reviews.freebsd.org/D61461
---
sys/kern/vfs_extattr.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index 70da1cdf56e2..e5a087bc0fff 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -737,7 +737,7 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, struct uio *auiop,
sizep = NULL;
cnt = 0;
if (auiop != NULL) {
- if (auiop->uio_resid > IOSIZE_MAX)
+ if (auiop->uio_resid < 0 || auiop->uio_resid > IOSIZE_MAX)
return (EINVAL);
cnt = auiop->uio_resid;
} else
@@ -787,6 +787,9 @@ user_extattr_list_fd(struct thread *td, int fd, int attrnamespace, void *data,
struct uio auio, *auiop;
struct iovec aiov;
+ if (nbytes > IOSIZE_MAX)
+ return (EINVAL);
+
if (data != NULL) {
aiov.iov_base = data;
aiov.iov_len = nbytes;
@@ -870,6 +873,9 @@ user_extattr_list_path(struct thread *td, const char *path, int attrnamespace,
struct uio auio, *auiop;
struct iovec aiov;
+ if (nbytes > IOSIZE_MAX)
+ return (EINVAL);
+
if (data != NULL) {
aiov.iov_base = data;
aiov.iov_len = nbytes;