Bug 295571 - linuxulator: return EBADF for O_PATH mmap()
Summary: linuxulator: return EBADF for O_PATH mmap()
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-emulation (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-05-25 08:49 UTC by YAO, Xin
Modified: 2026-05-28 19:54 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description YAO, Xin 2026-05-25 08:49:31 UTC
The Linuxulator currently returns incorrect error codes when some file-descriptor
based operations are attempted on an O_PATH descriptor.

In particular, LTP open13 expects these operations to fail with EBADF, matching
Linux behavior, but FreeBSD currently returns different errors:

- mmap() on an O_PATH fd returns EACCES
- fgetxattr() on an O_PATH fd returns EOPNOTSUPP

The same issue also affects other fd-based xattr operations, which should follow
the same O_PATH semantics for consistency:

 - fsetxattr()
 - fremovexattr()
 - flistxattr()

This appears to be a Linux compatibility bug rather than a functional limitation.
For mmap(), the Linuxulator does not currently reject path_fileops descriptors early with EBADF. For xattr operations, the code reaches the extattr path and 
returns the underlying FreeBSD error instead of recognizing that an O_PATH fd is
not a valid data-access descriptor for these operations.


This is only to track the fix for mmap() 
See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295537
Comment 1 YAO, Xin 2026-05-25 09:01:56 UTC
Addressed by https://github.com/freebsd/freebsd-src/pull/2233 according to the comments on https://github.com/freebsd/freebsd-src/pull/2181
Comment 2 commit-hook freebsd_committer freebsd_triage 2026-05-28 19:51:05 UTC
A commit in branch main references this bug:

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(+)
Comment 3 Pouria Mousavizadeh Tehrani freebsd_committer freebsd_triage 2026-05-28 19:54:29 UTC
Waiting on PR2181-2182