summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAaron Tomlin <atomlin@atomlin.com>2026-04-19 06:09:44 +0300
committerKumar Kartikeya Dwivedi <memxor@gmail.com>2026-04-19 14:52:34 +0300
commitad35d8018669fd2eea76e3f74eb050fd3d2fb690 (patch)
tree6264fb009b1288901d47c1faf5faeb8cf0fa447e /include
parenteb5249b12507246dc959945454cd1be8d7dc3795 (diff)
downloadlinux-ad35d8018669fd2eea76e3f74eb050fd3d2fb690.tar.xz
libbpf: Report error when a negative kprobe offset is specified
In attach_kprobe(), the parsing logic uses sscanf() to extract the target function name and offset from the section definition. Currently, if a user specifies a negative offset (e.g., SEC("kprobe/func+-100")), the input is not explicitly caught and reported as an error. This commit updates the logic to explicitly notify the user when a negative integer is provided. To facilitate this check, the offset variable is changed from unsigned long to long so that sscanf() can accurately capture a negative input for evaluation. If a negative offset is detected, the loader will now print an informative warning stating that the offset must be non-negative, and return -EINVAL. Additionally, free(func) is called in this new error path to prevent a memory leak, as the function name string is dynamically allocated by sscanf(). Fixes: e3f9bc35ea7e9 ("libbpf: Allow decimal offset for kprobes") Signed-off-by: Aaron Tomlin <atomlin@atomlin.com> Acked-by: Mykyta Yatsenko <yatsenko@meta.com> Link: https://lore.kernel.org/bpf/20260419030944.1423642-1-atomlin@atomlin.com Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions