Re: [PATCH v4 1/6] fs: add write-stream management ioctls
"Darrick J. Wong" <[email protected]>
| Newsgroups | org.kernel.vger.linux-xfs,org.kernel.vger.linux-block,org.kernel.vger.linux-fsdevel |
|---|---|
| Message-ID | <20260819220526.GA6072@frogsfrogsfrogs> |
On Wed, Aug 19, 2026 at 09:04:59AM +0200, Christoph Hellwig wrote: > On Thu, Jul 30, 2026 at 10:22:11AM -0700, Darrick J. Wong wrote: > > "The third argument is an untyped pointer to memory. It's traditionally > > char *argp (from the days before void * was valid C), and will be so > > named for this discussion." > > That documentation is wrong or at least very incomplete. A pointer > is the typical use, but there are plenty of ioctls passing scalar > values <= sizeof(long), going all the way back to early UNIX days. > > > You can also see this reflected in the discussion of the R/W/WR variants > > of _IO: > > https://docs.kernel.org/driver-api/ioctl.html > > _IO* are optional helpers, and plenty especially older ioctls are > defined without using them. Well, yeah, we don't force anyone to use the _IOR/_IOW/_IOWR helpers. But since they were used here, I thought it worth pointing out. > > Granted your kernel code can treat that argp as an integer and not a > > __user pointer if it wants to, but that goes against most ioctl > > implementations. Further, subsystems that marshal ioctl information for > > passing through to another layer (e.g. fuse) assume that the third > > argument is a pointer and that it can copy sizeof(data_type) bytes at > > that address in and out of the kernel as part of marshalling. > > That is not a good assumption and things will break. I know; fuse is a total mess w.r.t. ioctl handling because it assumes that it can just go ahead and do the userspace accesses. --D