-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libbpf: Fix accessing syscall arguments #2512
Conversation
Master branch: 227a071 |
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=611184 expired. Closing PR. |
Master branch: 227a071 |
6310538
to
cda27da
Compare
Master branch: b5e975d |
cda27da
to
cdc930e
Compare
Master branch: 976a38e |
cdc930e
to
4616fbe
Compare
Master branch: 976a38e |
4616fbe
to
9327936
Compare
orig_x0 is needed in order to access the first syscall argument from eBPF programs. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
user_pt_regs is used by eBPF in order to access userspace registers - see commit 466698e ("s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type"). In order to access the first syscall argument from eBPF programs, we need to export orig_gpr2. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Acked-by: Heiko Carstens <hca@linux.ibm.com>
bpf_syscall_macro reads a long argument into an int variable, which produces a wrong value on big-endian systems. Fix by reading the argument into an intermediate long variable first. Fixes: 77fc033 ("selftests/bpf: Add a test to confirm PT_REGS_PARM4_SYSCALL") Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Some architectures have a special way to access the first syscall argument. There already exists __PT_PARM4_REG_SYSCALL for the fourth argument, so define a similar macro for the first one. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Some architectures pass a pointer to struct pt_regs to syscall handlers, others unpack it into individual function parameters. Introduce a macro to describe what a particular arch does, using `passing pt_regs *` as a default. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Ensure that PT_REGS_SYSCALL_REGS works correctly. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Master branch: 0908a66 |
On arm64, the first syscall argument should be accessed via orig_x0 (see arch/arm64/include/asm/syscall.h). Currently regs[0] is used instead, leading to bpf_syscall_macro test failure. Reported-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
powerpc's syscall handlers get "unpacked" arguments instead of a struct pt_regs pointer. Indicate this to libbpf using PT_REGS_SYSCALL_REGS macro. Reported-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
riscv registers are accessed via struct user_regs_struct, not struct pt_regs. The program counter member in this struct is called pc, not epc. Fixes: 3cc31d7 ("libbpf: Normalize PT_REGS_xxx() macro definitions") Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
riscv's syscall handlers get "unpacked" arguments instead of a struct pt_regs pointer. Indicate this to libbpf using PT_REGS_SYSCALL_REGS macro. Reported-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
On s390, the first syscall argument should be accessed via orig_gpr2 (see arch/s390/include/asm/syscall.h). Currently gpr[2] is used instead, leading to bpf_syscall_macro test failure. Reported-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
9327936
to
e979b38
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=611310 irrelevant now. Closing PR. |
Pull request for series with
subject: libbpf: Fix accessing syscall arguments
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=611184