mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-23 14:24:25 +08:00
7cb29b1c99
Add two test cases, one pass read only map value pointer to global func, which should be rejected. The same code checks it for kfunc, so that is covered as well. Second one tries to use the missing check for PTR_TO_MEM's MEM_RDONLY flag and tries to write to a read only memory pointer. Without prior patches, both of these tests fail. Reviewed-by: Hao Luo <haoluo@google.com> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20220319080827.73251-5-memxor@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
17 lines
248 B
C
17 lines
248 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
#include <vmlinux.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
__noinline int foo(int *p)
|
|
{
|
|
return p ? (*p = 42) : 0;
|
|
}
|
|
|
|
const volatile int i;
|
|
|
|
SEC("tc")
|
|
int test_cls(struct __sk_buff *skb)
|
|
{
|
|
return foo((int *)&i);
|
|
}
|