]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: Refactor stack map trace depth calculation into helper function
authorArnaud Lecomte <contact@arnaud-lcm.com>
Sat, 25 Oct 2025 19:28:58 +0000 (19:28 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:02:42 +0000 (14:02 +0100)
commit8fc78e468f9e4dfaa278a84d0b349e2f773aa19b
tree1111b22b53095aae489013101e6b0059f9a0daa0
parent8f4e27e870960cdc102e3e9ad89517f3c42ab8ae
bpf: Refactor stack map trace depth calculation into helper function

[ Upstream commit e17d62fedd10ae56e2426858bd0757da544dbc73 ]

Extract the duplicated maximum allowed depth computation for stack
traces stored in BPF stacks from bpf_get_stackid() and __bpf_get_stack()
into a dedicated stack_map_calculate_max_depth() helper function.

This unifies the logic for:
- The max depth computation
- Enforcing the sysctl_perf_event_max_stack limit

No functional changes for existing code paths.

Signed-off-by: Arnaud Lecomte <contact@arnaud-lcm.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Acked-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/bpf/20251025192858.31424-1-contact@arnaud-lcm.com
Stable-dep-of: 23f852daa4ba ("bpf: Fix stackmap overflow check in __bpf_get_stackid()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/stackmap.c