Re: [PATCH bpf-next v3 06/15] selftests/bpf: bad_struct_ops test

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

 



On Tue, 2024-03-05 at 11:29 -0800, Andrii Nakryiko wrote:
> On Mon, Mar 4, 2024 at 2:52 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
> > 
> > When loading struct_ops programs kernel requires BTF id of the
> > struct_ops type and member index for attachment point inside that
> > type. This makes it not possible to have same BPF program used in
> > struct_ops maps that have different struct_ops type.
> > Check if libbpf rejects such BPF objects files.
> > 
> > Signed-off-by: Eduard Zingerman <eddyz87@xxxxxxxxx>
> > ---
> >  .../selftests/bpf/bpf_testmod/bpf_testmod.c   | 24 +++++++++++++
> >  .../selftests/bpf/bpf_testmod/bpf_testmod.h   |  4 +++
> >  .../selftests/bpf/prog_tests/bad_struct_ops.c | 35 +++++++++++++++++++
> >  .../selftests/bpf/progs/bad_struct_ops.c      | 25 +++++++++++++
> >  4 files changed, 88 insertions(+)
> >  create mode 100644 tools/testing/selftests/bpf/prog_tests/bad_struct_ops.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/bad_struct_ops.c
> > 
> 
> CI reports kernel crashes, so please check that, but overall things look good:
> 
> Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

Newly added test case struct_ops_multi_pages does not define
bpf_testmod_ops->test_1 field for struct_ops map,
so the following code from my patch caused null pointer dereference:

       563  static int bpf_dummy_reg(void *kdata)
       564  {
       565          struct bpf_testmod_ops *ops = kdata;
       566
       567          ops->test_1();

Fixed by adding "if (ops)" check.

[...]





[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