summaryrefslogtreecommitdiff
path: root/scripts/lib/kdoc/kdoc_re.py
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2025-07-07 08:25:07 -0700
committerAlexei Starovoitov <ast@kernel.org>2025-07-07 08:25:08 -0700
commit6e5cae9ddae7f14f5bffc34d12f45af756f86658 (patch)
treed4cda7b8249802c2b1bbbfc7de47889fe4e9ee5d /scripts/lib/kdoc/kdoc_re.py
parent03fe01ddd1d8be7799419ea5e5f228a0186ae8c2 (diff)
parent68cca81fd57fd9f5b8fd8da0dccd1d00522592f9 (diff)
Merge branch 'bpf-additional-use-cases-for-untrusted-ptr_to_mem'
Eduard Zingerman says: ==================== bpf: additional use-cases for untrusted PTR_TO_MEM This patch set introduces two usability enhancements leveraging untrusted pointers to mem: - When reading a pointer field from a PTR_TO_BTF_ID, the resulting value is now assumed to be PTR_TO_MEM|MEM_RDONLY|PTR_UNTRUSTED instead of SCALAR_VALUE, provided the pointer points to a primitive type. - __arg_untrusted attribute for global function parameters, allowed for pointer arguments of both structural and primitive types: - For structural types, the attribute produces PTR_TO_BTF_ID|PTR_UNTRUSTED. - For primitive types, it yields PTR_TO_MEM|MEM_RDONLY|PTR_UNTRUSTED. Here are examples enabled by the series: struct foo { int *arr; }; ... p = bpf_core_cast(..., struct foo); bpf_for(i, 0, ...) { ... p->arr[i] ... // load at any offset is allowed } int memcmp(void *a __arg_untrusted, void *b __arg_untrusted, size_t n) { bpf_for(i, 0, n) if (a[i] - b[i]) // load at any offset is allowed return ...; return 0; } The patch-set was inspired by Anrii's series [1]. The goal of that series was to define a generic global glob_match function, capable to accept any pointer type: __weak int glob_match(const char *pat, const char *str); char filename_glob[32]; void foo(...) { ... task = bpf_get_current_task_btf(); filename = task->mm->exe_file->f_path.dentry->d_name.name; ... match_glob(filename_glob, // pointer to map value filename) ... // scalar } At the moment, there is no straightforward way to express such a function. This patch-set makes it possible to define it as follows: __weak int glob_match(const char *pat __arg_untrusted, const char *str __arg_untrusted); [1] https://github.com/anakryiko/linux/tree/bpf-mem-cast Changelog: v1: https://lore.kernel.org/bpf/20250702224209.3300396-1-eddyz87@gmail.com/ v1 -> v2: - Added safety check in btf_prepare_func_args() to ensure that only struct or primitive types could be combined with __arg_untrusted (Alexei). - Removed unnecessary 'continue' btf_check_func_arg_match() (Alexei). - Added test cases for __arg_untrusted pointers to enum and __arg_untrusted combined with non-kernel type (Kumar). - Added acks from Kumar. ==================== Link: https://patch.msgid.link/20250704230354.1323244-1-eddyz87@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'scripts/lib/kdoc/kdoc_re.py')
0 files changed, 0 insertions, 0 deletions