From c82158548843f4ba36d020b8cef341428e460293 Mon Sep 17 00:00:00 2001 From: "YAO, Xin" Date: Thu, 7 May 2026 14:39:16 +0800 Subject: [PATCH] linuxulator: return EBADF for O_PATH mmap() This fixes LTP open13, which expects O_PATH mmap() to fail with EBADF, but FreeBSD returned EACCES. PR: 295571 Signed-off-by: YAO, Xin --- sys/compat/linux/linux_mmap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/compat/linux/linux_mmap.c b/sys/compat/linux/linux_mmap.c index a8e790a29da43f..9fecb6ebb2ad3e 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);