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-next>] [day] [month] [year] [list]
Date:   Sun, 27 Aug 2023 15:20:53 +0800
From:   Chuyi Zhou <zhouchuyi@...edance.com>
To:     bpf@...r.kernel.org
Cc:     ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
        martin.lau@...nel.org, linux-kernel@...r.kernel.org,
        Chuyi Zhou <zhouchuyi@...edance.com>
Subject: [RFC PATCH bpf-next 0/4] Add Open-coded process and css iters

In some BPF usage scenarios, it will be useful to iterate the process and
css directly in the BPF program. One of the expected scenarios is
customizable OOM victim selection via BPF[1].

Inspired by Dave's task_vma iter[2], this patchset adds three types of
open-coded iterator kfuncs:

1. bpf_for_each(process, p). Just like for_each_process(p) in kernel to
itearing all tasks in the system with rcu_read_lock().

2. bpf_for_each(css_task, task, css). It works like
css_task_iter_{start, next, end} and would be used to iterating
tasks/threads under a css.

3. bpf_for_each(css, pos, root_css, {PRE, POST}). It works like
css_next_descendant_{pre, post} to iterating all descendant css.

BPF programs can use these kfuncs directly or through bpf_for_each macro.

link[1]: https://lore.kernel.org/lkml/20230810081319.65668-1-zhouchuyi@bytedance.com/
link[2]: https://lore.kernel.org/all/20230810183513.684836-1-davemarchevsky@fb.com/

Chuyi Zhou (4):
  bpf: Introduce css_task open-coded iterator kfuncs
  bpf: Introduce process open coded iterator kfuncs
  bpf: Introduce css_descendant open-coded iterator kfuncs
  selftests/bpf: Add tests for open-coded task and css iter

 include/uapi/linux/bpf.h                      |  13 ++
 kernel/bpf/helpers.c                          |   9 ++
 kernel/bpf/task_iter.c                        | 109 ++++++++++++++++
 tools/include/uapi/linux/bpf.h                |  13 ++
 tools/lib/bpf/bpf_helpers.h                   |  18 +++
 .../testing/selftests/bpf/prog_tests/iters.c  | 123 ++++++++++++++++++
 .../testing/selftests/bpf/progs/iters_task.c  |  83 ++++++++++++
 7 files changed, 368 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/progs/iters_task.c

-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ