Re: [PATCH] bpf: Remove unused field initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 21, 2022 at 12:13 PM Ricardo Ribalda <ribalda@xxxxxxxxxxxx> wrote:
>
> Hi Stanislav
>
> On Wed, 21 Dec 2022 at 21:10, Stanislav Fomichev <sdf@xxxxxxxxxx> wrote:
> >
> > On Wed, Dec 21, 2022 at 11:55 AM Ricardo Ribalda <ribalda@xxxxxxxxxxxx> wrote:
> > >
> > > Maxlen is used by standard proc_handlers such as proc_dointvec(), but in this
> > > case we have our own proc_handler. Remove the initialization.
> >
> > Are you sure?
> >
> > bpf_stats_handler
> >   proc_dointvec_minmax
> >     do_proc_dointvec
> >       __do_proc_dointvec
> >         vleft = table->maxlen / sizeof(*i);
>
> I believe do_proc_dointvec is using the value from:
>
> struct ctl_table tmp = {
>   .maxlen=sixeof(val);
> }

Oh, you're right, I've missed that!

Acked-by: Stanislav Fomichev <sdf@xxxxxxxxxx>

> >
> > Maybe we should really do the following instead?
> >
> > .maxlen: sizeof(int)
> >
> > ?
> >
> > > Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
> > > ---
> > > bpf: Trivial remove of unitialised field.
> > >
> > > I have inspired myself in your code and heritaded this bug :). Fixing this
> > > here so none else makes the same mistake.
> > >
> > > To: Alexei Starovoitov <ast@xxxxxxxxxx>
> > > To: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
> > > To: John Fastabend <john.fastabend@xxxxxxxxx>
> > > To: Andrii Nakryiko <andrii@xxxxxxxxxx>
> > > To: Martin KaFai Lau <martin.lau@xxxxxxxxx>
> > > To: Song Liu <song@xxxxxxxxxx>
> > > To: Yonghong Song <yhs@xxxxxx>
> > > To: KP Singh <kpsingh@xxxxxxxxxx>
> > > To: Stanislav Fomichev <sdf@xxxxxxxxxx>
> > > To: Hao Luo <haoluo@xxxxxxxxxx>
> > > To: Jiri Olsa <jolsa@xxxxxxxxxx>
> > > Cc: bpf@xxxxxxxxxxxxxxx
> > > Cc: linux-kernel@xxxxxxxxxxxxxxx
> > > ---
> > >  kernel/bpf/syscall.c | 1 -
> > >  1 file changed, 1 deletion(-)
> > >
> > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > > index 35972afb6850..8e55456bd648 100644
> > > --- a/kernel/bpf/syscall.c
> > > +++ b/kernel/bpf/syscall.c
> > > @@ -5319,7 +5319,6 @@ static struct ctl_table bpf_syscall_table[] = {
> > >         {
> > >                 .procname       = "bpf_stats_enabled",
> > >                 .data           = &bpf_stats_enabled_key.key,
> > > -               .maxlen         = sizeof(bpf_stats_enabled_key),
> > >                 .mode           = 0644,
> > >                 .proc_handler   = bpf_stats_handler,
> > >         },
> > >
> > > ---
> > > base-commit: b6bb9676f2165d518b35ba3bea5f1fcfc0d969bf
> > > change-id: 20221221-bpf-syscall-58d1ac3f817a
> > >
> > > Best regards,
> > > --
> > > Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
>
>
>
> --
> Ricardo Ribalda



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux