Skip to content

Commit f1f241e

Browse files
borkmanngregkh
authored andcommitted
bpf: Move cgroup iterator helpers to bpf.h
[ Upstream commit 9621e60 ] Move them into bpf.h given we also need them in core code. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/r/20250730234733.530041-3-daniel@iogearbox.net Signed-off-by: Alexei Starovoitov <ast@kernel.org> Stable-dep-of: abad3d0 ("bpf: Fix oob access in cgroup local storage") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f13441c commit f1f241e

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

include/linux/bpf-cgroup.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ to_cgroup_bpf_attach_type(enum bpf_attach_type attach_type)
7777
extern struct static_key_false cgroup_bpf_enabled_key[MAX_CGROUP_BPF_ATTACH_TYPE];
7878
#define cgroup_bpf_enabled(atype) static_branch_unlikely(&cgroup_bpf_enabled_key[atype])
7979

80-
#define for_each_cgroup_storage_type(stype) \
81-
for (stype = 0; stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++)
82-
8380
struct bpf_cgroup_storage_map;
8481

8582
struct bpf_storage_buffer {
@@ -518,8 +515,6 @@ static inline int bpf_percpu_cgroup_storage_update(struct bpf_map *map,
518515
#define BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock, level, optname, optval, optlen, \
519516
kernel_optval) ({ 0; })
520517

521-
#define for_each_cgroup_storage_type(stype) for (; false; )
522-
523518
#endif /* CONFIG_CGROUP_BPF */
524519

525520
#endif /* _BPF_CGROUP_H */

include/linux/bpf.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,20 @@ enum btf_field_type {
205205
BPF_WORKQUEUE = (1 << 10),
206206
};
207207

208+
enum bpf_cgroup_storage_type {
209+
BPF_CGROUP_STORAGE_SHARED,
210+
BPF_CGROUP_STORAGE_PERCPU,
211+
__BPF_CGROUP_STORAGE_MAX
212+
#define MAX_BPF_CGROUP_STORAGE_TYPE __BPF_CGROUP_STORAGE_MAX
213+
};
214+
215+
#ifdef CONFIG_CGROUP_BPF
216+
# define for_each_cgroup_storage_type(stype) \
217+
for (stype = 0; stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++)
218+
#else
219+
# define for_each_cgroup_storage_type(stype) for (; false; )
220+
#endif /* CONFIG_CGROUP_BPF */
221+
208222
typedef void (*btf_dtor_kfunc_t)(void *);
209223

210224
struct btf_field_kptr {
@@ -1028,14 +1042,6 @@ struct bpf_prog_offload {
10281042
u32 jited_len;
10291043
};
10301044

1031-
enum bpf_cgroup_storage_type {
1032-
BPF_CGROUP_STORAGE_SHARED,
1033-
BPF_CGROUP_STORAGE_PERCPU,
1034-
__BPF_CGROUP_STORAGE_MAX
1035-
};
1036-
1037-
#define MAX_BPF_CGROUP_STORAGE_TYPE __BPF_CGROUP_STORAGE_MAX
1038-
10391045
/* The longest tracepoint has 12 args.
10401046
* See include/trace/bpf_probe.h
10411047
*/

0 commit comments

Comments
 (0)