summaryrefslogtreecommitdiff
path: root/include/linux/compiler-clang.h
diff options
context:
space:
mode:
authorKumar Kartikeya Dwivedi <memxor@gmail.com>2022-03-05 01:46:41 +0300
committerAlexei Starovoitov <ast@kernel.org>2022-03-06 02:29:35 +0300
commit24d5bb806c7e2c0b9972564fd493069f612d90dd (patch)
tree82d229ab2932ad5baf5e92dd9472cc404f3868ab /include/linux/compiler-clang.h
parente1fad0ff46b32819d30cb487f1d39ba24e515843 (diff)
downloadlinux-24d5bb806c7e2c0b9972564fd493069f612d90dd.tar.xz
bpf: Harden register offset checks for release helpers and kfuncs
Let's ensure that the PTR_TO_BTF_ID reg being passed in to release BPF helpers and kfuncs always has its offset set to 0. While not a real problem now, there's a very real possibility this will become a problem when more and more kfuncs are exposed, and more BPF helpers are added which can release PTR_TO_BTF_ID. Previous commits already protected against non-zero var_off. One of the case we are concerned about now is when we have a type that can be returned by e.g. an acquire kfunc: struct foo { int a; int b; struct bar b; }; ... and struct bar is also a type that can be returned by another acquire kfunc. Then, doing the following sequence: struct foo *f = bpf_get_foo(); // acquire kfunc if (!f) return 0; bpf_put_bar(&f->b); // release kfunc ... would work with the current code, since the btf_struct_ids_match takes reg->off into account for matching pointer type with release kfunc argument type, but would obviously be incorrect, and most likely lead to a kernel crash. A test has been included later to prevent regressions in this area. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20220304224645.3677453-5-memxor@gmail.com
Diffstat (limited to 'include/linux/compiler-clang.h')
0 files changed, 0 insertions, 0 deletions