Re: bpf: Question about odd BPF verifier behaviour

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

 



On Mon, Feb 27, 2023 at 7:04 PM KP Singh <kpsingh@xxxxxxxxxx> wrote:
>
> On Mon, Feb 27, 2023 at 6:32 PM Andrii Nakryiko
> <andrii.nakryiko@xxxxxxxxx> wrote:
> >
> > On Mon, Feb 27, 2023 at 6:17 AM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
> > >
> > > On Sun, 2023-02-26 at 03:03 +0200, Eduard Zingerman wrote:
> > > > On Sat, 2023-02-25 at 20:50 +0000, Matt Bobrowski wrote:
> > > > > Sorry Eduard, I replied late last night although the email bounced due
> > > > > to exceeding the mail char limit. Let's try attaching a compressed
> > > > > variant of the requested files, which includes the compiled kernel's
> > > > > BTF and the kernel's config.
> > > >
> > > > Hi Matt,
> > > >
> > > > I tried using your config but still can't reproduce the issue.
> > > > Will try to do it using debian 12 chroot tomorrow or on Monday.
> > >
> > > Hi Matt,
> > >
> > > Short update:
> > > I've reproduced the issue with multiple STRUCT 'linux_binprm' BTF IDs
> > > in Debian testing chroot, thank you for providing all details.
> > > Attaching the instructions in the end of the email.
> > > Need some time to analyze pahole behavior.
> > >
> >
> > Try using [0] to pinpoint what actually is different between any two
> > linux_binprm definitions. I've hacked up this "tool" last time I had
> > to pinpoint where two BTF types diverge, maybe it will save you a bit
> > of time as well. I'd like to put this functionality into btfdump
> > ([1]), but I didn't get to it yet, unfortunately.
> >
>
> It's not just linux_binprm but a bunch of other structs (quite a lot
> of them that seem to diverge)

It also does not seem to matter if I build the kernel with gcc or
clang, my suspicion went to an underlying dependency (libdw /
elfutils) I tried recompiling these from HEAD and downgrading the
package version too, but to no avail.

>
> [...]
> WARN: multiple IDs found for 'sock_common': 4400, 53212 - using 4400
> WARN: multiple IDs found for 'request_sock': 4458, 53257 - using 4458
> WARN: multiple IDs found for 'task_struct': 265, 55830 - using 265
> WARN: multiple IDs found for 'file': 474, 55854 - using 474
> WARN: multiple IDs found for 'vm_area_struct': 480, 55857 - using 480
> WARN: multiple IDs found for 'seq_file': 670, 55891 - using 670
> WARN: multiple IDs found for 'sock': 3623, 55918 - using 3623
> WARN: multiple IDs found for 'sk_buff': 3095, 56014 - using 3095
> WARN: multiple IDs found for 'fib6_info': 8129, 56069 - using 8129
> WARN: multiple IDs found for 'inode': 854, 56092 - using 854
> WARN: multiple IDs found for 'path': 886, 56121 - using 886
> WARN: multiple IDs found for 'cgroup': 913, 56130 - using 913
> WARN: multiple IDs found for 'xdp_buff': 3838, 56558 - using 3838
> WARN: multiple IDs found for 'socket': 3848, 56563 - using 3848
> WARN: multiple IDs found for 'sock_common': 4400, 56890 - using 4400
> WARN: multiple IDs found for 'request_sock': 4458, 56938 - using 4458
> WARN: multiple IDs found for 'task_struct': 265, 58141 - using 265
> WARN: multiple IDs found for 'inode': 854, 58153 - using 854
> WARN: multiple IDs found for 'path': 886, 58182 - using 886
> WARN: multiple IDs found for 'file': 474, 58207 - using 474
> WARN: multiple IDs found for 'vm_area_struct': 480, 58210 - using 480
> WARN: multiple IDs found for 'seq_file': 670, 58389 - using 670
> WARN: multiple IDs found for 'task_struct': 265, 58862 - using 265
> WARN: multiple IDs found for 'file': 474, 58889 - using 474
> WARN: multiple IDs found for 'vm_area_struct': 480, 58892 - using 480
> WARN: multiple IDs found for 'inode': 854, 58954 - using 854
> WARN: multiple IDs found for 'path': 886, 58983 - using 886
> WARN: multiple IDs found for 'cgroup': 913, 58992 - using 913
> WARN: multiple IDs found for 'seq_file': 670, 59157 - using 670
> WARN: multiple IDs found for 'sock': 3623, 59309 - using 3623
> WARN: multiple IDs found for 'sk_buff': 3095, 59312 - using 3095
> WARN: multiple IDs found for 'xdp_buff': 3838, 59699 - using 3838
> WARN: multiple IDs found for 'socket': 3848, 59704 - using 3848
> WARN: multiple IDs found for 'sock_common': 4400, 60021 - using 4400
> WARN: multiple IDs found for 'request_sock': 4458, 60066 - using 4458
> WARN: multiple IDs found for 'file': 474, 60890 - using 474
> WARN: multiple IDs found for 'task_struct': 265, 60900 - using 265
> WARN: multiple IDs found for 'vm_area_struct': 480, 60932 - using 480
> WARN: multiple IDs found for 'inode': 854, 60962 - using 854
> WARN: multiple IDs found for 'path': 886, 60991 - using 886
> WARN: multiple IDs found for 'cgroup': 913, 61000 - using 913
> WARN: multiple IDs found for 'seq_file': 670, 61174 - using 670
> WARN: multiple IDs found for 'task_struct': 265, 62225 - using 265
> WARN: multiple IDs found for 'file': 474, 62256 - using 474
> WARN: multiple IDs found for 'vm_area_struct': 480, 62259 - using 480
> WARN: multiple IDs found for 'seq_file': 670, 62289 - using 670
> WARN: multiple IDs found for 'inode': 854, 62573 - using 854
> WARN: multiple IDs found for 'path': 886, 62602 - using 886
> [...]
>
>   BTF     .btf.vmlinux.bin.o
>
> seems to take 10+ minutes. Something seems off here, it seems like the
> deduplication is failing for a lot of types which causes pahole to run
> for so long.
>
> My pahole is at:
>
> 431df45 ("btfdiff: Exclude Rust CUs since those are not yet being
> converted to BTF on the Linux kernel")
>
> Clang at:
>
> 9e5bfa1ae30b ("[AArch64] Add some tests for multiple uses of extended
> vector extracts. NFC")
>
> and kernel at:
>
> 68bfd65fb98d ("Merge branch 'move SYS() macro to test_progs.h and run
> mptcp in a dedicated netns'")
>
> and I am using the same config as vmtest.sh.
>
> I was able to "fix" this with using clang 16.x and the following hacky pahole:
>
> 030e3b4 - core: Add DW_TAG_unspecified_type to tag__is_tag_type() set
> (HEAD) (2023-02-26 Arnaldo Carvalho de Melo)
> f20515b - dwarves: support DW_TAG_atomic_type (2023-02-26 David Lamparter)
> de24234 - pahole: Prep 1.24 (tag: v1.24) (2022-08-22 Arnaldo Carvalho de Melo)
> d6c9528 - dwarf_loader: Encode char type as signed (2022-08-10 Yonghong Song)
>
> and the the following patch on top:
>
> diff --git a/btf_encoder.c b/btf_encoder.c
> index daa8e3b..3a29a67 100644
> --- a/btf_encoder.c
> +++ b/btf_encoder.c
> @@ -939,6 +939,8 @@ static int btf_encoder__encode_tag(struct
> btf_encoder *encoder, struct tag *tag,
>                 return btf_encoder__add_enum_type(encoder, tag, conf_load);
>         case DW_TAG_subroutine_type:
>                 return btf_encoder__add_func_proto(encoder,
> tag__ftype(tag), type_id_off);
> +        case DW_TAG_unspecified_type:
> +                return 0;
>         default:
>                 fprintf(stderr, "Unsupported DW_TAG_%s(0x%x)\n",
>                         dwarf_tag_name(tag->tag), tag->tag);
> diff --git a/dwarves.h b/dwarves.h
> index f18a639..b1dc556 100644
> --- a/dwarves.h
> +++ b/dwarves.h
> @@ -544,10 +544,8 @@ static inline int tag__is_tag_type(const struct tag *tag)
>                tag->tag == DW_TAG_reference_type ||
>                tag->tag == DW_TAG_restrict_type ||
>                tag->tag == DW_TAG_subroutine_type ||
> -              tag->tag == DW_TAG_unspecified_type ||
>                tag->tag == DW_TAG_volatile_type ||
>                tag->tag == DW_TAG_atomic_type ||
> -              tag->tag == DW_TAG_unspecified_type ||
>                tag->tag == DW_TAG_LLVM_annotation;
>  }
>
> Now this is not a clean build and still has errors like:
>
> tag__recode_dwarf_type: couldn't find 0xe82f542 type for 0xe82f4d2 (subprogram)!
> tag__recode_dwarf_type: couldn't find 0xe82f542 type for 0xe82f4e2 (subprogram)!
>
>
>
>
> >   [0] https://github.com/libbpf/libbpf-bootstrap/tree/btfdiff-hack
> >   [1] https://github.com/anakryiko/btfdump
> >
> >
> > > Thanks,
> > > Eduard
> > >
> > > --
> > >
> > > host root:
> > >   mkdir bookworm
> > >   sudo debootstrap testing bookworm/ http://deb.debian.org/debian/
> > >   sudo mount -t proc proc bookworm/proc/
> > >   sudo mount -t sysfs sys bookworm/sys/
> > >   sudo chroot bookworm/ /bin/bash
> > >
> >
> > [...]




[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