BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/3] bpf: Pin the start cgroup for cgroup iterator
@ 2022-11-21  7:34 Hou Tao
  2022-11-21  7:34 ` [PATCH bpf-next v3 1/3] bpf: Pin the start cgroup in cgroup_iter_seq_init() Hou Tao
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Hou Tao @ 2022-11-21  7:34 UTC (permalink / raw)
  To: bpf, Martin KaFai Lau, Hao Luo, Yonghong Song
  Cc: Andrii Nakryiko, Song Liu, Alexei Starovoitov, Daniel Borkmann,
	KP Singh, Stanislav Fomichev, Jiri Olsa, John Fastabend, houtao1

From: Hou Tao <houtao1@huawei.com>

Hi,

The patchset tries to fix the potential use-after-free problem in cgroup
iterator. The problem is similar with the UAF problem fixed in map
iterator and the fix is also similar: pinning the iterated resource in
.init_seq_private() and unpinning it in .fini_seq_private(). An
alternative fix is pinning iterator link when opening iterator fd, but
it will make iterator link still being visible after the close of
iterator link fd and the behavior is different with other link types, so
just fixing the bug alone by pinning the start cgroup when creating
cgroup iterator. Also adding a selftests to demonstrate the UAF problem
when iterating a dead cgroup.

Comments are always welcome.

Change Log:
v3:
 * Target bpf-next instead of bpf
 * Patch 1: Use the solution proposed in v1, because pinning iterator
   link will make it behaving different with other link types.
 * Patch 3: Add Acked-by from Hao Luo

v2: https://lore.kernel.org/bpf/20221111063417.1603111-1-houtao@huaweicloud.com/
 * Patch 1: Pinning iterator link when opening iterator, instead of
   acquiring the reference of start cgroup in cgroup_iter_seq_init().
 * Patch 2 & 3: Address comments from Yonghong Song and add Acked-by tag

v1: https://lore.kernel.org/bpf/20221107074222.1323017-1-houtao@huaweicloud.com/

Hou Tao (3):
  bpf: Pin the start cgroup in cgroup_iter_seq_init()
  selftests/bpf: Add cgroup helper remove_cgroup()
  selftests/bpf: Add test for cgroup iterator on a dead cgroup

 kernel/bpf/cgroup_iter.c                      | 14 ++++
 tools/testing/selftests/bpf/cgroup_helpers.c  | 19 +++++
 tools/testing/selftests/bpf/cgroup_helpers.h  |  1 +
 .../selftests/bpf/prog_tests/cgroup_iter.c    | 76 +++++++++++++++++++
 4 files changed, 110 insertions(+)

-- 
2.29.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-21 16:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-21  7:34 [PATCH bpf-next v3 0/3] bpf: Pin the start cgroup for cgroup iterator Hou Tao
2022-11-21  7:34 ` [PATCH bpf-next v3 1/3] bpf: Pin the start cgroup in cgroup_iter_seq_init() Hou Tao
2022-11-21 16:27   ` Yonghong Song
2022-11-21  7:34 ` [PATCH bpf-next v3 2/3] selftests/bpf: Add cgroup helper remove_cgroup() Hou Tao
2022-11-21  7:34 ` [PATCH bpf-next v3 3/3] selftests/bpf: Add test for cgroup iterator on a dead cgroup Hou Tao
2022-11-21 16:50 ` [PATCH bpf-next v3 0/3] bpf: Pin the start cgroup for cgroup iterator patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox