Skip to content

Commit

Permalink
[NETFILTER]: x_tables: don't use __copy_{from,to}_user on unchecked m…
Browse files Browse the repository at this point in the history
…emory in compat layer

Noticed by Linus Torvalds <[email protected]>

Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
kaber authored and davem330 committed May 4, 2006
1 parent 7582e9d commit 7800007
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions net/ipv4/netfilter/ip_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ static int compat_copy_entry_to_user(struct ipt_entry *e,
ret = -EFAULT;
origsize = *size;
ce = (struct compat_ipt_entry __user *)*dstptr;
if (__copy_to_user(ce, e, sizeof(struct ipt_entry)))
if (copy_to_user(ce, e, sizeof(struct ipt_entry)))
goto out;

*dstptr += sizeof(struct compat_ipt_entry);
Expand All @@ -1459,9 +1459,9 @@ static int compat_copy_entry_to_user(struct ipt_entry *e,
goto out;
ret = -EFAULT;
next_offset = e->next_offset - (origsize - *size);
if (__put_user(target_offset, &ce->target_offset))
if (put_user(target_offset, &ce->target_offset))
goto out;
if (__put_user(next_offset, &ce->next_offset))
if (put_user(next_offset, &ce->next_offset))
goto out;
return 0;
out:
Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/x_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ int xt_compat_match(void *match, void **dstptr, int *size, int convert)
case COMPAT_TO_USER:
pm = (struct xt_entry_match *)match;
msize = pm->u.user.match_size;
if (__copy_to_user(*dstptr, pm, msize)) {
if (copy_to_user(*dstptr, pm, msize)) {
ret = -EFAULT;
break;
}
Expand Down Expand Up @@ -366,7 +366,7 @@ int xt_compat_target(void *target, void **dstptr, int *size, int convert)
case COMPAT_TO_USER:
pt = (struct xt_entry_target *)target;
tsize = pt->u.user.target_size;
if (__copy_to_user(*dstptr, pt, tsize)) {
if (copy_to_user(*dstptr, pt, tsize)) {
ret = -EFAULT;
break;
}
Expand Down

0 comments on commit 7800007

Please sign in to comment.