lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <32dbb1b7-8f9d-4025-9f74-be04b31e2816@kernel.org>
Date: Thu, 8 May 2025 10:00:48 +0100
From: Quentin Monnet <qmo@...nel.org>
To: Daniel Borkmann <daniel@...earbox.net>,
 Martin KaFai Lau <martin.lau@...ux.dev>, bpf@...r.kernel.org
Cc: 'Alexei Starovoitov ' <ast@...nel.org>,
 'Andrii Nakryiko ' <andrii@...nel.org>, netdev@...r.kernel.org,
 kernel-team@...a.com, Takshak Chahande <ctakshak@...a.com>
Subject: Re: [PATCH bpf-next] bpftool: Fix cgroup command to only show cgroup
 bpf programs

2025-05-07 23:00 UTC+0200 ~ Daniel Borkmann <daniel@...earbox.net>
> On 5/7/25 10:32 PM, Martin KaFai Lau wrote:
>> From: Martin KaFai Lau <martin.lau@...nel.org>
>>
>> The netkit program is not a cgroup bpf program and should not be shown
>> in the output of the "bpftool cgroup show" command.
>>
>> However, if the netkit device happens to have ifindex 3,
>> the "bpftool cgroup show" command will output the netkit
>> bpf program as well:
>>
>>> ip -d link show dev nk1
>> 3: nk1@if2: ...
>>      link/ether ...
>>      netkit mode ...
>>
>>> bpftool net show
>> tc:
>> nk1(3) netkit/peer tw_ns_nk2phy prog_id 469447
>>
>>> bpftool cgroup show /sys/fs/cgroup/...
>> ID       AttachType      AttachFlags     Name
>> ...      ...                             ...
>> 469447   netkit_peer                     tw_ns_nk2phy
>>
>> The reason is that the target_fd (which is the cgroup_fd here) and
>> the target_ifindex are in a union in the uapi/linux/bpf.h. The bpftool
>> iterates all values in "enum bpf_attach_type" which includes
>> non cgroup attach types like netkit. The cgroup_fd is usually 3 here,
>> so the bug is triggered when the netkit ifindex just happens
>> to be 3 as well.
>>
>> The bpftool's cgroup.c already has a list of cgroup-only attach type
>> defined in "cgroup_attach_types[]". This patch fixes it by iterating
>> over "cgroup_attach_types[]" instead of "__MAX_BPF_ATTACH_TYPE".
>>
>> Cc: Quentin Monnet <qmo@...nel.org>
>> Reported-by: Takshak Chahande <ctakshak@...a.com>
>> Signed-off-by: Martin KaFai Lau <martin.lau@...nel.org>
> 
> Outch, good catch!
> 
> Acked-by: Daniel Borkmann <daniel@...earbox.net>
> 


Nice one indeed, thanks!

Reviewed-by: Quentin Monnet <qmo@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ