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

Hal Rosenstock halr at voltaire.com
Thu May 19 03:43:10 PDT 2005


On Thu, 2005-05-19 at 03:23, Michael S. Tsirkin wrote:
> Quoting r. Roland Dreier <roland at topspin.com>:
> > Subject: Re: [RFC] [PATCH] user_mad: Support RMPP on send side
> > 
> > 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.
> > 
> > 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.
> > 
> >  - R.
> > 
> 
> If you truncate, how will the user know the MAD was truncated?

The length returned. Roland is saying to fix it is one option (rather
than ret = count). 

I'm now questioning whether that is useful behavior. Would a subsequent
read get the next part of the packet and the user piece them together ?
If not, then this should be an error for this case (which is the second
option). I am leaning towards that unless someone has an objection to
that behavior.

-- Hal




More information about the general mailing list