diff options
| author | YAO, Xin <mr.yaoxin@outlook.com> | 2026-05-07 06:39:16 +0000 |
|---|---|---|
| committer | Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org> | 2026-05-28 19:47:04 +0000 |
| commit | 30c85b7cb9fc52492f2b3a3ae4e0b16ed717c58a (patch) | |
| tree | 102711ce99800ae8b5ee5e4fa2524efa890437df | |
| parent | a172f9e5b3cf41882f087f6c5311dc068d9d6b54 (diff) | |
linuxulator: return EBADF for O_PATH mmap()
This fixes LTP open13, which expects O_PATH mmap() to fail
with EBADF, but FreeBSD returned EACCES.
Signed-off-by: YAO, Xin <mr.yaoxin@outlook.com>
PR: 295571
Reviewed by: kib
Pull-Request: https://github.com/freebsd/freebsd-src/pull/2233
| -rw-r--r-- | sys/compat/linux/linux_mmap.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_mmap.c b/sys/compat/linux/linux_mmap.c index a8e790a29da4..9fecb6ebb2ad 100644 --- a/sys/compat/linux/linux_mmap.c +++ b/sys/compat/linux/linux_mmap.c @@ -63,6 +63,10 @@ static int linux_mmap_check_fp(struct file *fp, int flags, int prot, int maxprot) { + /* Linux returns EBADF if mmap() is called on an O_PATH file descriptor */ + if (fp->f_ops == &path_fileops) + return (EBADF); + /* Linux mmap() just fails for O_WRONLY files */ if ((fp->f_flag & FREAD) == 0) return (EACCES); |
