git: 33101b0ed7c8 - releng/15.2 - extattr_list*: avoid panic with absurd buffer lengths
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 19:51:54 UTC
The branch releng/15.2 has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=33101b0ed7c872bca561d1c2bb8da1ba02abc1a6
commit 33101b0ed7c872bca561d1c2bb8da1ba02abc1a6
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-11-13 10:06:52 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-11-17 19:50:41 +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.
Approved by: re (cperciva)
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
(cherry picked from commit 118067f51c111390dbc54760d781cd14a10c499e)
(cherry picked from commit 0967b36fe7837e4b1727ec1230ef1ee28ea6db8c)
---
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 1fe7494f3998..1614b15db553 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -693,7 +693,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
@@ -735,6 +735,9 @@ sys_extattr_list_fd(struct thread *td, struct extattr_list_fd_args *uap)
struct uio auio, *auiop;
struct iovec aiov;
+ if (uap->nbytes > IOSIZE_MAX)
+ return (EINVAL);
+
if (uap->data != NULL) {
aiov.iov_base = uap->data;
aiov.iov_len = uap->nbytes;
@@ -813,6 +816,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;