2004-06-14 17:55:06

by Steve French (smfltc)

[permalink] [raw]
Subject: __user and iov_base

The commonly used kernel structure iovec includes a field iov_base which
is:
void __user *iov_base

Unfortunately some of the places that use this are sockets calls from
kernel code in which it would be awkward to do extra memcpy to a user
buffer (from a kernel buffer, perhaps created in a different process)
just to avoid a sparse warning. Although it works fine to set
myiovec.iov_base = (char *)some_buffer;
this generates a warning message in the sparse tool since iov_base
includes the __user modifier, and the kernel buffer you are sending does
not..

If a buffer is never used in user space, and is potentially recycled
(via mempools) for use by more than one process, then it can't be passed
around as an __user buffer, but is it ok to simply do
myiovec.iov_base = (__user char *)some_buffer;
or is there another preferred way to handle kernel to __user
mappings/casts?

For the cifs vfs this would eliminate the last sparse warnings.



2004-06-14 18:30:22

by Al Viro

[permalink] [raw]
Subject: Re: __user and iov_base

On Mon, Jun 14, 2004 at 12:53:18PM -0500, Steve French wrote:
> If a buffer is never used in user space, and is potentially recycled
> (via mempools) for use by more than one process, then it can't be passed
> around as an __user buffer, but is it ok to simply do
> myiovec.iov_base = (__user char *)some_buffer;
> or is there another preferred way to handle kernel to __user
> mappings/casts?

Yes - leave them alone. The warning points to real problem with the
interface; ergo, it should not disappear until there's a clean solution
(if ever).