mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
libbpf: Add OPTS_VALID() for log_opts in bpf_map_create
There should be an OPTS_VALID() check for log_opts before extracting its
fields.
If no such OPTS_VALID() check and an application compiled against a future
libbpf header passes a log_opts with new, non-zero fields to libbpf.so,
those fields will be ignored silently.
Fixes: 702259006f ("libbpf: Add syscall common attributes support for map_create")
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Link: https://lore.kernel.org/r/20260518145446.6794-4-leon.hwang@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
f05ddc6771
commit
b4844cb6d1
|
|
@ -246,6 +246,9 @@ int bpf_map_create(enum bpf_map_type map_type,
|
|||
attr.excl_prog_hash_size = OPTS_GET(opts, excl_prog_hash_size, 0);
|
||||
|
||||
log_opts = OPTS_GET(opts, log_opts, NULL);
|
||||
if (!OPTS_VALID(log_opts, bpf_log_opts))
|
||||
return libbpf_err(-EINVAL);
|
||||
|
||||
if (log_opts && feat_supported(NULL, FEAT_BPF_SYSCALL_COMMON_ATTRS)) {
|
||||
memset(&attr_common, 0, attr_common_sz);
|
||||
attr_common.log_buf = ptr_to_u64(OPTS_GET(log_opts, buf, NULL));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user