Re: Should linuxkpi linux_file_ioctl support flexible array copy?

Zhenlei Huang <[email protected]>
Newsgroups gmane.os.freebsd.devel.hackers
Message-ID <[email protected]>

> On Feb 13, 2026, at 5:56 PM, yi zishun <[email protected]> wrote:
> 
> Hey Hackers, I want to port udmabuf from Linux to FreeBSD, but I
> encountered a problem:
> udmabuf.h declares the interface which I don't want to touch or change:
> 
>         ...
>         struct udmabuf_create_list {
>                 __u32 flags;
>                 __u32 count;
>                 struct udmabuf_create_item list[];
>         };
>         #define UDMABUF_CREATE       _IOW('u', 0x42, struct udmabuf_create)
>         #define UDMABUF_CREATE_LIST  _IOW('u', 0x43, struct udmabuf_create_list)
>         ...
> 
> It has a flexible array and uses `_IOW`, which means the FreeBSD native
> KPI (`cdevsw` ioctl) cannot get the userspace pointer to get the items
> list.
> 
> So I turned to linuxkpi, but unfortunately I found that if I define
> `_IOW`,  Linuxkpi's `linux_file_ioctl` is only allowed to get the kernel
> space pointer, just like the FreeBSD KPI. So I can't copy the flexible
> array from userspace.
> 
> So I have two ways to go:
> 1.Change the command to use `_IO` instead of `_IOW` to prevent copying
> by `sys_ioctl`. This means I will change the ABI.

Probably it does not matter. It is good to keep the ABI stable, well that implies
stable ABI cross different versions of OS, but not different OSes. Am I right ?

> 2.Try to figure out a way to empower linuxkpi to skip `sys_ioctl`
> helping to get the userspace pointer. This will be a big piece of work.

I think make it work first, make it better second !

> 
> Any recommendations on how to handle this gracefully? Thanks~
> 
> (BTW, I'm a kernel rookie hoping to tackle the GSoC 2026 'Port or
> reimplement udmabuf' project. For context, my current WIP code is here:
> https://github.com/yizishun/drm-kmod/blob/dev-udmabuf/drivers/dma-buf/udmabuf.c <https://github.com/yizishun/drm-kmod/blob/dev-udmabuf/drivers/dma-buf/udmabuf.c>)

Best regards,
Zhenlei
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.