Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 May 2026 19:50:10 +0000
From:      Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Cc:        YAO, Xin <mr.yaoxin@outlook.com>
Subject:   git: 30c85b7cb9fc - main - linuxulator: return EBADF for O_PATH mmap()
Message-ID:  <6a189c72.24675.5cfb4a79@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by pouria:

URL: https://cgit.FreeBSD.org/src/commit/?id=30c85b7cb9fc52492f2b3a3ae4e0b16ed717c58a

commit 30c85b7cb9fc52492f2b3a3ae4e0b16ed717c58a
Author:     YAO, Xin <mr.yaoxin@outlook.com>
AuthorDate: 2026-05-07 06:39:16 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-05-28 19:47:04 +0000

    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
---
 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 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);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a189c72.24675.5cfb4a79>