treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / test_probe_user.c
blobd556b1572cc66dbd9d3885ab1024a7f328cfde1d
1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/ptrace.h>
4 #include <linux/bpf.h>
6 #include <netinet/in.h>
8 #include <bpf/bpf_helpers.h>
9 #include <bpf/bpf_tracing.h>
10 #include "bpf_trace_helpers.h"
12 static struct sockaddr_in old;
14 SEC("kprobe/__sys_connect")
15 int BPF_KPROBE(handle_sys_connect)
17 void *ptr = (void *)PT_REGS_PARM2(ctx);
18 struct sockaddr_in new;
20 bpf_probe_read_user(&old, sizeof(old), ptr);
21 __builtin_memset(&new, 0xab, sizeof(new));
22 bpf_probe_write_user(ptr, &new, sizeof(new));
24 return 0;
27 char _license[] SEC("license") = "GPL";