Message ID | 982f816ee3459f533f093db134c74e4779880901.1376847403.git.ydroneaud@opteya.com (mailing list archive) |
---|---|
State | Rejected |
Headers | show |
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index ecc6fad..92f2248 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -1573,10 +1573,10 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf, if (copy_from_user(&hdr, buf, sizeof(hdr))) return -EFAULT; - if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table)) + if (hdr.in + sizeof(hdr) > len) return -EINVAL; - if (hdr.in + sizeof(hdr) > len) + if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table)) return -EINVAL; if (!ucma_cmd_table[hdr.cmd])
Like uverbs, check the length parameter before the command type. Signed-off-by: Yann Droneaud <ydroneaud@opteya.com> Link: http://mid.gmane.org/cover.1376847403.git.ydroneaud@opteya.com --- drivers/infiniband/core/ucma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)