Commit 2d5c91e
bpf: rdonly_untrusted_mem for btf id walk pointer leafs
When processing a load from a PTR_TO_BTF_ID, the verifier calculates
the type of the loaded structure field based on the load offset.
For example, given the following types:
struct foo {
struct foo *a;
int *b;
} *p;
The verifier would calculate the type of `p->a` as a pointer to
`struct foo`. However, the type of `p->b` is currently calculated as a
SCALAR_VALUE.
This commit updates the logic for processing PTR_TO_BTF_ID to instead
calculate the type of p->b as PTR_TO_MEM|MEM_RDONLY|PTR_UNTRUSTED.
This change allows further dereferencing of such pointers (using probe
memory instructions).
Suggested-by: Alexei Starovoitov <[email protected]>
Acked-by: Kumar Kartikeya Dwivedi <[email protected]>
Signed-off-by: Eduard Zingerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>1 parent b9d44bc commit 2d5c91e
File tree
3 files changed
+12
-1
lines changed- kernel/bpf
- tools/testing/selftests/bpf/prog_tests
3 files changed
+12
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6915 | 6915 | | |
6916 | 6916 | | |
6917 | 6917 | | |
| 6918 | + | |
6918 | 6919 | | |
6919 | 6920 | | |
6920 | 6921 | | |
| |||
7156 | 7157 | | |
7157 | 7158 | | |
7158 | 7159 | | |
| 7160 | + | |
| 7161 | + | |
7159 | 7162 | | |
7160 | 7163 | | |
7161 | 7164 | | |
| |||
7228 | 7231 | | |
7229 | 7232 | | |
7230 | 7233 | | |
| 7234 | + | |
| 7235 | + | |
| 7236 | + | |
7231 | 7237 | | |
7232 | 7238 | | |
7233 | 7239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2814 | 2814 | | |
2815 | 2815 | | |
2816 | 2816 | | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
2817 | 2822 | | |
2818 | 2823 | | |
2819 | 2824 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
0 commit comments