[openib-general] Re: [RFC] [PATCH] user_mad: Support RMPP on send side

Hal Rosenstock halr at voltaire.com
Wed May 18 21:16:59 PDT 2005


On Wed, 2005-05-18 at 19:04, Roland Dreier wrote:
> This looks OK to check in with one small comment on the following:
> 
> -	if (copy_to_user(buf, &packet->mad, sizeof packet->mad))
> +	if (copy_to_user(buf, &packet->mad,
> +			 min(count, packet->length +
> +			     sizeof (struct ib_user_mad))))
>  		ret = -EFAULT;
>  	else
> -		ret = sizeof packet->mad;
> +		ret = count;
> 
> This code will truncate a received MAD that is bigger than the buffer
> passed into read(), but return the full size of the packet.  I don't
> think read() is allowed to do this: the return value can be at most
> the count value passed in by the user.

Is this really true ? Sean's idea for the receive side for RMPP was to
return the buffer size needed if the buffer supplied was too small.

> I think we have two options: truncate and return the actual amount of
> data read to the user, or return an error if the user's buffer is too
> small.

Now that you've pointed this out, is it really useful to truncate the
buffer ? It seems like an error if the user buffer is too small for the
packet received. Can a user do anything useful with a partial packet ?

-- Hal




More information about the general mailing list