Skip to content

Commit

Permalink
staging: lustre: echo_copy.._lsm() dereferences userland pointers dir…
Browse files Browse the repository at this point in the history
…ectly

missing get_user()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Al Viro authored and Greg Kroah-Hartman committed Dec 1, 2015
1 parent cc4c60c commit 9225c0b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions drivers/staging/lustre/lustre/obdecho/echo_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@ static int
echo_copyout_lsm(struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob)
{
struct lov_stripe_md *ulsm = _ulsm;
struct lov_oinfo **p;
int nob, i;

nob = offsetof(struct lov_stripe_md, lsm_oinfo[lsm->lsm_stripe_count]);
Expand All @@ -1279,19 +1280,21 @@ echo_copyout_lsm(struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob)
if (copy_to_user(ulsm, lsm, sizeof(*ulsm)))
return -EFAULT;

for (i = 0; i < lsm->lsm_stripe_count; i++) {
if (copy_to_user(ulsm->lsm_oinfo[i], lsm->lsm_oinfo[i],
sizeof(lsm->lsm_oinfo[0])))
for (i = 0, p = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++, p++) {
struct lov_oinfo __user *up;
if (get_user(up, ulsm->lsm_oinfo + i) ||
copy_to_user(up, *p, sizeof(struct lov_oinfo)))
return -EFAULT;
}
return 0;
}

static int
echo_copyin_lsm(struct echo_device *ed, struct lov_stripe_md *lsm,
void *ulsm, int ulsm_nob)
struct lov_stripe_md __user *ulsm, int ulsm_nob)
{
struct echo_client_obd *ec = ed->ed_ec;
struct lov_oinfo **p;
int i;

if (ulsm_nob < sizeof(*lsm))
Expand All @@ -1306,11 +1309,10 @@ echo_copyin_lsm(struct echo_device *ed, struct lov_stripe_md *lsm,
((__u64)lsm->lsm_stripe_size * lsm->lsm_stripe_count > ~0UL))
return -EINVAL;

for (i = 0; i < lsm->lsm_stripe_count; i++) {
if (copy_from_user(lsm->lsm_oinfo[i],
((struct lov_stripe_md *)ulsm)-> \
lsm_oinfo[i],
sizeof(lsm->lsm_oinfo[0])))
for (i = 0, p = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++, p++) {
struct lov_oinfo __user *up;
if (get_user(up, ulsm->lsm_oinfo + i) ||
copy_from_user(*p, up, sizeof(struct lov_oinfo)))
return -EFAULT;
}
return 0;
Expand Down

0 comments on commit 9225c0b

Please sign in to comment.