Commit 89596f20 authored by Kulikov Vasiliy's avatar Kulikov Vasiliy Committed by Linus Torvalds

i2o: check return code from put_user()

Check return value of put_user() and return -EFAULT if it failed.
Original comment "We did a get user...so assuming mem is ok...is this
bad?" is incorrect because memory can be read only.
Signed-off-by: default avatarKulikov Vasiliy <segooon@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d929dc2b
...@@ -111,9 +111,9 @@ static int i2o_cfg_gethrt(unsigned long arg) ...@@ -111,9 +111,9 @@ static int i2o_cfg_gethrt(unsigned long arg)
len = 8 + ((hrt->entry_len * hrt->num_entries) << 2); len = 8 + ((hrt->entry_len * hrt->num_entries) << 2);
/* We did a get user...so assuming mem is ok...is this bad? */ if (put_user(len, kcmd.reslen))
put_user(len, kcmd.reslen); ret = -EFAULT;
if (len > reslen) else if (len > reslen)
ret = -ENOBUFS; ret = -ENOBUFS;
else if (copy_to_user(kcmd.resbuf, (void *)hrt, len)) else if (copy_to_user(kcmd.resbuf, (void *)hrt, len))
ret = -EFAULT; ret = -EFAULT;
...@@ -147,8 +147,9 @@ static int i2o_cfg_getlct(unsigned long arg) ...@@ -147,8 +147,9 @@ static int i2o_cfg_getlct(unsigned long arg)
lct = (i2o_lct *) c->lct; lct = (i2o_lct *) c->lct;
len = (unsigned int)lct->table_size << 2; len = (unsigned int)lct->table_size << 2;
put_user(len, kcmd.reslen); if (put_user(len, kcmd.reslen))
if (len > reslen) ret = -EFAULT;
else if (len > reslen)
ret = -ENOBUFS; ret = -ENOBUFS;
else if (copy_to_user(kcmd.resbuf, lct, len)) else if (copy_to_user(kcmd.resbuf, lct, len))
ret = -EFAULT; ret = -EFAULT;
...@@ -208,8 +209,9 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type) ...@@ -208,8 +209,9 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type)
return -EAGAIN; return -EAGAIN;
} }
put_user(len, kcmd.reslen); if (put_user(len, kcmd.reslen))
if (len > reslen) ret = -EFAULT;
else if (len > reslen)
ret = -ENOBUFS; ret = -ENOBUFS;
else if (copy_to_user(kcmd.resbuf, res, len)) else if (copy_to_user(kcmd.resbuf, res, len))
ret = -EFAULT; ret = -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment