Commit 8b7468f3 authored by Andi Kleen's avatar Andi Kleen Committed by David S. Miller

[NET]: Clean up socket filter compat handling.

parent 8fac33ce
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <net/compat.h> #include <net/compat.h>
#define AA(__x) ((unsigned long)(__x))
static inline int iov_from_user_compat_to_kern(struct iovec *kiov, static inline int iov_from_user_compat_to_kern(struct iovec *kiov,
struct compat_iovec *uiov32, struct compat_iovec *uiov32,
int niov) int niov)
...@@ -393,31 +391,27 @@ static int do_set_attach_filter(int fd, int level, int optname, ...@@ -393,31 +391,27 @@ static int do_set_attach_filter(int fd, int level, int optname,
struct compat_sock_fprog *fprog32 = (struct compat_sock_fprog *)optval; struct compat_sock_fprog *fprog32 = (struct compat_sock_fprog *)optval;
struct sock_fprog kfprog; struct sock_fprog kfprog;
mm_segment_t old_fs; mm_segment_t old_fs;
compat_uptr_t uptr;
unsigned int fsize;
int ret; int ret;
compat_uptr_t ptr;
if (!access_ok(VERIFY_READ, fprog32, sizeof(*fprog32)) || if (!access_ok(VERIFY_READ, fprog32, sizeof(*fprog32)) ||
__get_user(kfprog.len, &fprog32->len) || __get_user(kfprog.len, &fprog32->len) ||
__get_user(uptr, &fprog32->filter)) __get_user(ptr, &fprog32->filter))
return -EFAULT; return -EFAULT;
kfprog.filter = compat_ptr(ptr);
fsize = kfprog.len * sizeof(struct sock_filter); if (kfprog.len * sizeof(struct sock_filter) < kfprog.len)
kfprog.filter = (struct sock_filter *)kmalloc(fsize, GFP_KERNEL); return -EINVAL;
if (kfprog.filter == NULL)
return -ENOMEM; if (verify_area(VERIFY_READ, kfprog.filter,
if (copy_from_user(kfprog.filter, compat_ptr(uptr), fsize)) { kfprog.len * sizeof(struct sock_filter)))
kfree(kfprog.filter);
return -EFAULT; return -EFAULT;
}
old_fs = get_fs(); old_fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
ret = sys_setsockopt(fd, level, optname, ret = sys_setsockopt(fd, level, optname,
(char *)&kfprog, sizeof(kfprog)); (char *)&kfprog, sizeof(kfprog));
set_fs(old_fs); set_fs(old_fs);
kfree(kfprog.filter);
return ret; return ret;
} }
......
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