[Bug 295571] compat/linux: return EBADF for O_PATH mmap()

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 25 May 2026 08:49:31 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295571

            Bug ID: 295571
           Summary: compat/linux: return EBADF for O_PATH mmap()
           Product: Base System
           Version: 16.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: mr.yaoxin@outlook.com

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

-- 
You are receiving this mail because:
You are the assignee for the bug.