git: bd29b7b2b980 - releng/15.2 - linux: Handle OOB accesses in bsd_to_linux_errno()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 17:10:05 UTC
The branch releng/15.2 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=bd29b7b2b98017ec21cd7b11865d1b5c224f7057
commit bd29b7b2b98017ec21cd7b11865d1b5c224f7057
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-11-16 00:14:21 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-17 17:09:18 +0000
linux: Handle OOB accesses in bsd_to_linux_errno()
Such accesses can be triggered via ptrace(PT_SET_SC_RET).
Approved by: re (cperciva)
Reported by: Dennys Kaluzny Pereira <dennyskaluzny@gmail.com>
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 8f024e97cabf7497dc047538db9c6be9067752a1)
(cherry picked from commit c48a331e54794310fe05dddcb0719cdba1f5b1c3)
---
sys/compat/linux/linux_errno.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sys/compat/linux/linux_errno.c b/sys/compat/linux/linux_errno.c
index f04f694e5bec..7f0d102b93d5 100644
--- a/sys/compat/linux/linux_errno.c
+++ b/sys/compat/linux/linux_errno.c
@@ -1,4 +1,3 @@
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
@@ -10,10 +9,10 @@
int
bsd_to_linux_errno(int error)
{
-
- KASSERT(error >= 0 && error <= ELAST,
- ("%s: bad error %d", __func__, error));
-
+ if (__predict_false(error < 0 || error > ELAST)) {
+ printf("%s: unhandled value %d\n", __func__, error);
+ return (-LINUX_EINVAL);
+ }
return (linux_errtbl[error]);
}