Commit f8f8a727 authored by Al Viro's avatar Al Viro

get_compat_bpf_fprog(): don't copyin field-by-field

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 5da028a8
...@@ -313,15 +313,15 @@ struct sock_fprog __user *get_compat_bpf_fprog(char __user *optval) ...@@ -313,15 +313,15 @@ struct sock_fprog __user *get_compat_bpf_fprog(char __user *optval)
{ {
struct compat_sock_fprog __user *fprog32 = (struct compat_sock_fprog __user *)optval; struct compat_sock_fprog __user *fprog32 = (struct compat_sock_fprog __user *)optval;
struct sock_fprog __user *kfprog = compat_alloc_user_space(sizeof(struct sock_fprog)); struct sock_fprog __user *kfprog = compat_alloc_user_space(sizeof(struct sock_fprog));
compat_uptr_t ptr; struct compat_sock_fprog f32;
u16 len; struct sock_fprog f;
if (!access_ok(VERIFY_READ, fprog32, sizeof(*fprog32)) || if (copy_from_user(&f32, fprog32, sizeof(*fprog32)))
!access_ok(VERIFY_WRITE, kfprog, sizeof(struct sock_fprog)) || return NULL;
__get_user(len, &fprog32->len) || memset(&f, 0, sizeof(f));
__get_user(ptr, &fprog32->filter) || f.len = f32.len;
__put_user(len, &kfprog->len) || f.filter = compat_ptr(f32.filter);
__put_user(compat_ptr(ptr), &kfprog->filter)) if (copy_to_user(kfprog, &f, sizeof(struct sock_fprog)))
return NULL; return NULL;
return kfprog; return kfprog;
......
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