[openib-general] Re: [PATCH][RFC/v1][9/12] Add InfiniBand userspace MAD support

Greg KH greg at kroah.com
Mon Nov 22 14:50:33 PST 2004


On Mon, Nov 22, 2004 at 07:14:11AM -0800, Roland Dreier wrote:
> Add a driver that provides a character special device for each
> InfiniBand port.  This device allows userspace to send and receive
> MADs via write() and read() (with some control operations implemented
> as ioctls).

Do you really need these ioctls?

For example:

> +static int ib_umad_ioctl(struct inode *inode, struct file *filp,
> +			 unsigned int cmd, unsigned long arg)
> +{
> +	switch (cmd) {
> +	case IB_USER_MAD_GET_ABI_VERSION:
> +		return put_user(IB_USER_MAD_ABI_VERSION,
> +				(u32 __user *) arg) ? -EFAULT : 0;

This could be in a sysfs file, right?

> +	case IB_USER_MAD_REGISTER_AGENT:
> +		return ib_umad_reg_agent(filp->private_data, arg);
> +	case IB_USER_MAD_UNREGISTER_AGENT:
> +		return ib_umad_unreg_agent(filp->private_data, arg);

You are letting any user, with any privilege register or unregister an
"agent"?

And shouldn't you lock your list of agent ids when adding or removing
one, or are you relying on the BKL of the ioctl call?  If so, please
document this.

Also, these "agents" seem to be a type of filter, right?  Is there no
other way to implement this than an ioctl?

thanks,

greg k-h



More information about the general mailing list