Page MenuHomeFreeBSD

linuxkpi: Support flexible array members in ioctl
Needs ReviewPublic

Authored by zishun.yi.dev_gmail.com on Tue, Feb 17, 1:46 PM.
Tags
None
Referenced Files
F145608593: D55328.diff
Sun, Feb 22, 3:08 AM
Unknown Object (File)
Wed, Feb 18, 9:22 AM
Subscribers

Details

Reviewers
obiwac
zlei
bz
Group Reviewers
linuxkpi
Summary

The Linux ioctl scheme passes raw user-space pointers to drivers,
natively supporting Flexible Array Members (FAM). In contrast, linuxkpi
currently relies on FreeBSD's sys_ioctl automatic copying. It provides a
"fake" pointer backed by fixed-size kernel memory, which fails for FAMs
and does not fully conform to Linux ioctl semantics.

This patch adds a fallback mechanism in linux_remap_address() that uses
the original user-space pointer when access exceeds the pre-copied
kernel buffer.

I do a simple static scan of Linux 6.19 UAPI headers indicates that more
than 30 structures across subsystems (including KVM, USB, and DRM) rely
on this pattern. It seems like a valuable compatibility improvement for
future driver ports like udmabuf.

Link: https://mail-archive.freebsd.org/cgi/getmsg.cgi?fetch=408318+0+archive/2026/freebsd-hackers/20260216.freebsd-hackers
Signed-off-by: Zishun Yi <zishun.yi.dev@gmail.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70728
Build 67611: arc lint + arc unit