Re: Should linuxkpi linux_file_ioctl support flexible array copy?

"Bjoern A. Zeeb" <[email protected]>
Newsgroups gmane.os.freebsd.devel.hackers
Message-ID <[email protected]>
On Fri, 13 Feb 2026, yi zishun wrote:

Hi,

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

Let me ask two totally different questions:

(a) is this udmabuf or u-dma-buf?
(b) what are the expected consumers for your code?

/bz

-- 
Bjoern A. Zeeb                                                     r15:7
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.