Commit 1f7ed54
libbpf: offset global arena data into the arena if possible
Currently, libbpf places global arena data at the very beginning of
the arena mapping. Stray NULL dereferences into the arena then find
valid data and lead to silent corruption instead of causing an arena
page fault. The data is placed in the mapping at load time, preventing
us from reserving the region using bpf_arena_reserve_pages().
Adjust the arena logic to attempt placing the data from an offset within
the arena (currently 16 pages in) instead of the very beginning. If
placing the data at an offset would lead to an allocation failure due
to global data being as large as the entire arena, progressively reduce
the offset down to 0 until placement succeeds.
Adjust existing arena tests in the same commit to account for the new
global data offset. New tests that explicitly consider the new feature
are introduced in the next patch.
Signed-off-by: Emil Tsalapatis <[email protected]>1 parent fb183e2 commit 1f7ed54
File tree
2 files changed
+37
-7
lines changed- tools
- lib/bpf
- testing/selftests/bpf/progs
2 files changed
+37
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
757 | 757 | | |
758 | 758 | | |
759 | 759 | | |
| 760 | + | |
760 | 761 | | |
761 | 762 | | |
762 | 763 | | |
| |||
2991 | 2992 | | |
2992 | 2993 | | |
2993 | 2994 | | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
2994 | 2998 | | |
| 2999 | + | |
2995 | 3000 | | |
2996 | 3001 | | |
2997 | | - | |
| 3002 | + | |
2998 | 3003 | | |
2999 | 3004 | | |
3000 | 3005 | | |
| |||
3006 | 3011 | | |
3007 | 3012 | | |
3008 | 3013 | | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
3009 | 3025 | | |
3010 | 3026 | | |
3011 | 3027 | | |
| |||
4663 | 4679 | | |
4664 | 4680 | | |
4665 | 4681 | | |
4666 | | - | |
| 4682 | + | |
4667 | 4683 | | |
4668 | 4684 | | |
4669 | 4685 | | |
| |||
5624 | 5640 | | |
5625 | 5641 | | |
5626 | 5642 | | |
5627 | | - | |
| 5643 | + | |
| 5644 | + | |
5628 | 5645 | | |
5629 | 5646 | | |
5630 | 5647 | | |
| |||
10557 | 10574 | | |
10558 | 10575 | | |
10559 | 10576 | | |
10560 | | - | |
10561 | | - | |
| 10577 | + | |
| 10578 | + | |
| 10579 | + | |
| 10580 | + | |
| 10581 | + | |
10562 | 10582 | | |
10563 | 10583 | | |
10564 | 10584 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
219 | 229 | | |
220 | 230 | | |
221 | 231 | | |
| |||
0 commit comments