Commit ab6c637
bpf: Fix a bpf_kptr_xchg() issue with local kptr
When reviewing local percpu kptr support, Alexei discovered a bug
wherea bpf_kptr_xchg() may succeed even if the map value kptr type and
locally allocated obj type do not match ([1]). Missed struct btf_id
comparison is the reason for the bug. This patch added such struct btf_id
comparison and will flag verification failure if types do not match.
[1] https://lore.kernel.org/bpf/20230819002907.io3iphmnuk43xblu@macbook-pro-8.dhcp.thefacebook.com/#t
Reported-by: Alexei Starovoitov <ast@kernel.org>
Fixes: 738c96d ("bpf: Allow local kptrs to be exchanged via bpf_kptr_xchg")
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230822050053.2886960-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>1 parent d565183 commit ab6c637
1 file changed
Lines changed: 15 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4990 | 4990 | | |
4991 | 4991 | | |
4992 | 4992 | | |
4993 | | - | |
| 4993 | + | |
4994 | 4994 | | |
4995 | 4995 | | |
4996 | | - | |
4997 | | - | |
4998 | | - | |
| 4996 | + | |
| 4997 | + | |
| 4998 | + | |
| 4999 | + | |
| 5000 | + | |
| 5001 | + | |
| 5002 | + | |
| 5003 | + | |
| 5004 | + | |
4999 | 5005 | | |
5000 | 5006 | | |
5001 | 5007 | | |
5002 | 5008 | | |
5003 | | - | |
5004 | | - | |
5005 | | - | |
5006 | | - | |
5007 | 5009 | | |
5008 | 5010 | | |
5009 | 5011 | | |
| |||
5016 | 5018 | | |
5017 | 5019 | | |
5018 | 5020 | | |
5019 | | - | |
| 5021 | + | |
5020 | 5022 | | |
5021 | 5023 | | |
5022 | 5024 | | |
| |||
7916 | 7918 | | |
7917 | 7919 | | |
7918 | 7920 | | |
7919 | | - | |
| 7921 | + | |
| 7922 | + | |
| 7923 | + | |
| 7924 | + | |
7920 | 7925 | | |
7921 | 7926 | | |
7922 | 7927 | | |
| |||
0 commit comments