Skip to content

Commit 5a0f663

Browse files
yonghong-songAlexei Starovoitov
authored andcommitted
compiler_types: Define __rcu as __attribute__((btf_type_tag("rcu")))
Currently, without rcu attribute info in BTF, the verifier treats rcu tagged pointer as a normal pointer. This might be a problem for sleepable program where rcu_read_lock()/unlock() is not available. For example, for a sleepable fentry program, if rcu protected memory access is interleaved with a sleepable helper/kfunc, it is possible the memory access after the sleepable helper/kfunc might be invalid since the object might have been freed then. To prevent such cases, introducing rcu tagging for memory accesses in verifier can help to reject such programs. To enable rcu tagging in BTF, during kernel compilation, define __rcu as attribute btf_type_tag("rcu") so __rcu information can be preserved in dwarf and btf, and later can be used for bpf prog verification. Acked-by: KP Singh <kpsingh@kernel.org> Acked-by: Martin KaFai Lau <martin.lau@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/r/20221124053206.2373141-1-yhs@fb.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent f471748 commit 5a0f663

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/linux/compiler_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
4949
# endif
5050
# define __iomem
5151
# define __percpu BTF_TYPE_TAG(percpu)
52-
# define __rcu
52+
# define __rcu BTF_TYPE_TAG(rcu)
53+
5354
# define __chk_user_ptr(x) (void)0
5455
# define __chk_io_ptr(x) (void)0
5556
/* context/locking */

0 commit comments

Comments
 (0)