Skip to content

Commit

Permalink
IB/umad: make sure write()s have sufficient data
Browse files Browse the repository at this point in the history
Make sure that userspace passes in enough data when sending a MAD.  We
always copy at least sizeof (struct ib_user_mad) + IB_MGMT_RMPP_HDR
bytes from userspace, so anything less is definitely invalid.  Also,
if the length is less than this limit, it's possible for the second
copy_from_user() to get a negative length and trigger a BUG().

Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
Roland Dreier committed Nov 18, 2005
1 parent 48fd0d1 commit eabc779
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/infiniband/core/user_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
int ret, length, hdr_len, copy_offset;
int rmpp_active = 0;

if (count < sizeof (struct ib_user_mad))
if (count < sizeof (struct ib_user_mad) + IB_MGMT_RMPP_HDR)
return -EINVAL;

length = count - sizeof (struct ib_user_mad);
Expand Down

0 comments on commit eabc779

Please sign in to comment.