Message ID | 2a56d66cf4b9430982e81233f49d6c54988df056.1652772731.git.esyr@redhat.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | Fix 32-bit arch and compat support for the kprobe_multi attach type | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-VM_Test-3 | success | Logs for Kernel LATEST on z15 with gcc |
bpf/vmtest-bpf-next-PR | success | PR summary |
bpf/vmtest-bpf-next-VM_Test-1 | success | Logs for Kernel LATEST on ubuntu-latest with gcc |
bpf/vmtest-bpf-next-VM_Test-2 | success | Logs for Kernel LATEST on ubuntu-latest with llvm-15 |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 11 this patch: 11 |
netdev/cc_maintainers | success | CCed 14 of 14 maintainers |
netdev/build_clang | success | Errors and warnings before: 9 this patch: 9 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/verify_fixes | success | Fixes tag looks correct |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 11 this patch: 11 |
netdev/checkpatch | warning | WARNING: line length of 83 exceeds 80 columns |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | fail | Was 0 now: 1 |
On Tue, May 17, 2022 at 12:36 AM Eugene Syromiatnikov <esyr@redhat.com> wrote: > > For compat processes, userspace size for syms pointers is different. > Provide compat handling for copying array elements from the user space. > > Fixes: 0dcac272540613d4 ("bpf: Add multi kprobe link") > Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com> > --- > kernel/trace/bpf_trace.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c > index a93a54f..9d3028a 100644 > --- a/kernel/trace/bpf_trace.c > +++ b/kernel/trace/bpf_trace.c > @@ -2253,6 +2253,24 @@ struct user_syms { > char *buf; > }; > > +static inline int get_arr_ptr(unsigned long *p, > + unsigned long __user *uaddr, u32 idx) no need for inline, let compiler decide on inlining > +{ > + if (unlikely(in_compat_syscall())) { not sure unlikely() is justified for code... > + compat_uptr_t __user *compat_uaddr = (compat_uptr_t __user *)uaddr; > + compat_uptr_t val; > + int err; > + > + err = __get_user(val, compat_uaddr + idx); > + if (!err) > + *p = val; > + > + return err; > + } else { > + return __get_user(*p, uaddr + idx); > + } > +} > + > static int copy_user_syms(struct user_syms *us, unsigned long __user *usyms, u32 cnt) > { > unsigned long __user usymbol; > @@ -2270,7 +2288,7 @@ static int copy_user_syms(struct user_syms *us, unsigned long __user *usyms, u32 > goto error; > > for (p = buf, i = 0; i < cnt; i++) { > - if (__get_user(usymbol, usyms + i)) { > + if (get_arr_ptr(&usymbol, usyms, i)) { > err = -EFAULT; > goto error; > } > -- > 2.1.4 >
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index a93a54f..9d3028a 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -2253,6 +2253,24 @@ struct user_syms { char *buf; }; +static inline int get_arr_ptr(unsigned long *p, + unsigned long __user *uaddr, u32 idx) +{ + if (unlikely(in_compat_syscall())) { + compat_uptr_t __user *compat_uaddr = (compat_uptr_t __user *)uaddr; + compat_uptr_t val; + int err; + + err = __get_user(val, compat_uaddr + idx); + if (!err) + *p = val; + + return err; + } else { + return __get_user(*p, uaddr + idx); + } +} + static int copy_user_syms(struct user_syms *us, unsigned long __user *usyms, u32 cnt) { unsigned long __user usymbol; @@ -2270,7 +2288,7 @@ static int copy_user_syms(struct user_syms *us, unsigned long __user *usyms, u32 goto error; for (p = buf, i = 0; i < cnt; i++) { - if (__get_user(usymbol, usyms + i)) { + if (get_arr_ptr(&usymbol, usyms, i)) { err = -EFAULT; goto error; }
For compat processes, userspace size for syms pointers is different. Provide compat handling for copying array elements from the user space. Fixes: 0dcac272540613d4 ("bpf: Add multi kprobe link") Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com> --- kernel/trace/bpf_trace.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)