mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 16:38:12 +00:00
bee4b7e626
This adds a selftest that ensures that modify_return tracing programs cannot be attached to freplace programs. The security_ prefix is added to the freplace program because that would otherwise let it pass the check for modify_return. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/160138355713.48470.3811074984255709369.stgit@toke.dk
15 lines
396 B
C
15 lines
396 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
#include <bpf/bpf_endian.h>
|
|
|
|
volatile __u64 test_get_constant = 0;
|
|
SEC("freplace/get_constant")
|
|
int security_new_get_constant(long val)
|
|
{
|
|
if (val != 123)
|
|
return 0;
|
|
test_get_constant = 1;
|
|
return test_get_constant; /* original get_constant() returns val - 122 */
|
|
}
|
|
char _license[] SEC("license") = "GPL";
|