Skip to content

Commit

Permalink
IB/uverbs: Check input length in flow steering uverbs
Browse files Browse the repository at this point in the history
Since ib_copy_from_udata() doesn't check yet the available input data
length before accessing userspace memory, an explicit check of this
length is required to prevent:

- reading past the user provided buffer,
- underflow when subtracting the expected command size from the input
  length.

This will ensure the newly added flow steering uverbs don't try to
process truncated commands.

Link: http://marc.info/?i=cover.1386798254.git.ydroneaud@opteya.com>
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
  • Loading branch information
Yann Droneaud authored and Roland Dreier committed Dec 20, 2013
1 parent 98a3751 commit 6bcca3d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/infiniband/core/uverbs_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2649,6 +2649,9 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
void *ib_spec;
int i;

if (ucore->inlen < sizeof(cmd))
return -EINVAL;

if (ucore->outlen < sizeof(resp))
return -ENOSPC;

Expand Down Expand Up @@ -2799,6 +2802,9 @@ int ib_uverbs_ex_destroy_flow(struct ib_uverbs_file *file,
struct ib_uobject *uobj;
int ret;

if (ucore->inlen < sizeof(cmd))
return -EINVAL;

ret = ib_copy_from_udata(&cmd, ucore, sizeof(cmd));
if (ret)
return ret;
Expand Down

0 comments on commit 6bcca3d

Please sign in to comment.