lkml.org 
[lkml]   [2019]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 2/3] bpf: use copy_struct_from_user() in bpf_prog_get_info_by_fd()y
On Tue, Oct 15, 2019 at 10:25:49PM -0700, Alexei Starovoitov wrote:
> On Wed, Oct 16, 2019 at 05:44:31AM +0200, Christian Brauner wrote:
> > In v5.4-rc2 we added a new helper (cf. [1]) copy_struct_from_user().
> > This helper is intended for all codepaths that copy structs from
> > userspace that are versioned by size. bpf_prog_get_info_by_fd() does
> > exactly what copy_struct_from_user() is doing.
> > Note that copy_struct_from_user() is calling min() already. So
> > technically, the min_t() call could go. But the info_len is used further
> > below so leave it.
> >
> > [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper")
> > Cc: Alexei Starovoitov <ast@kernel.org>
> > Cc: Daniel Borkmann <daniel@iogearbox.net>
> > Cc: bpf@vger.kernel.org
> > Acked-by: Aleksa Sarai <cyphar@cyphar.com>
> > Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
> > ---
> > /* v1 */
> > Link: https://lore.kernel.org/r/20191009160907.10981-3-christian.brauner@ubuntu.com
> >
> > /* v2 */
> > Link: https://lore.kernel.org/r/20191016004138.24845-3-christian.brauner@ubuntu.com
> > - Alexei Starovoitov <ast@kernel.org>:
> > - remove unneeded initialization
> >
> > /* v3 */
> > unchanged
> > ---
> > kernel/bpf/syscall.c | 9 +++------
> > 1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > index 40edcaeccd71..151447f314ca 100644
> > --- a/kernel/bpf/syscall.c
> > +++ b/kernel/bpf/syscall.c
> > @@ -2306,20 +2306,17 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
> > union bpf_attr __user *uattr)
> > {
> > struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info);
> > - struct bpf_prog_info info = {};
> > + struct bpf_prog_info info;
> > u32 info_len = attr->info.info_len;
> > struct bpf_prog_stats stats;
> > char __user *uinsns;
> > u32 ulen;
> > int err;
> >
> > - err = bpf_check_uarg_tail_zero(uinfo, sizeof(info), info_len);
> > + info_len = min_t(u32, sizeof(info), info_len);
> > + err = copy_struct_from_user(&info, sizeof(info), uinfo, info_len);
>
> really?! min?!
> Frankly I'm disappointed in quality of these patches.
> Especially considering it's v3.

Ok, then I'm sorry.

Christian

\
 
 \ /
  Last update: 2019-10-16 09:31    [W:0.048 / U:5.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site