BPF List
 help / color / mirror / Atom feed
* [PATCH bpf v2 0/3] Pin iterator link when opening iterator
@ 2022-11-11  6:34 Hou Tao
  2022-11-11  6:34 ` [PATCH bpf v2 1/3] bpf: " Hou Tao
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Hou Tao @ 2022-11-11  6:34 UTC (permalink / raw)
  To: bpf, Yonghong Song
  Cc: Martin KaFai Lau, Andrii Nakryiko, Song Liu, Hao Luo,
	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, however to prevent such UAF problem from happening again for
bpf iterator, just pinning iterator link when opening iterator, so after
doing the necessary reference acquisitions in .attach_target() there will
be unnecessary to pin iteration target again in .init_seq_private() for
each iterator type. Also adding a selftests to demonstrate the UAF
problem when iterating a dead cgroup.

Comments are always welcome.

Change Log:
v2:
 * 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/T/#t

Hou Tao (3):
  bpf: Pin iterator link when opening iterator
  selftests/bpf: Add cgroup helper remove_cgroup()
  selftests/bpf: Add test for cgroup iterator on a dead cgroup

 kernel/bpf/bpf_iter.c                         | 21 +++--
 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(+), 7 deletions(-)

-- 
2.29.2


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

end of thread, other threads:[~2022-11-18 18:59 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-11  6:34 [PATCH bpf v2 0/3] Pin iterator link when opening iterator Hou Tao
2022-11-11  6:34 ` [PATCH bpf v2 1/3] bpf: " Hou Tao
2022-11-11 16:31   ` Yonghong Song
2022-11-11 17:24     ` Hao Luo
2022-11-15 19:16   ` Martin KaFai Lau
2022-11-16  1:37     ` Alexei Starovoitov
2022-11-16  2:40       ` Hou Tao
2022-11-16  5:43         ` Alexei Starovoitov
2022-11-16  6:56           ` Hou Tao
2022-11-16  2:48       ` Hao Luo
2022-11-16  7:24         ` Hou Tao
2022-11-17  6:48         ` Martin KaFai Lau
2022-11-18  1:52           ` Hou Tao
2022-11-18  7:34             ` Martin KaFai Lau
2022-11-18 18:57               ` Hao Luo
2022-11-16  2:39     ` Hou Tao
2022-11-11  6:34 ` [PATCH bpf v2 2/3] selftests/bpf: Add cgroup helper remove_cgroup() Hou Tao
2022-11-11  6:34 ` [PATCH bpf v2 3/3] selftests/bpf: Add test for cgroup iterator on a dead cgroup Hou Tao
2022-11-11 18:00   ` Hao Luo

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