Skip to content
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

Closed
wants to merge 12 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: libbpf: Fix accessing syscall arguments
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=611184

@kernel-patches-bot
Copy link
Author

Master branch: 227a071
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611184
version: 2

@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=611184 expired. Closing PR.

@kernel-patches-bot
Copy link
Author

Master branch: 227a071
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611310
version: 3

@kernel-patches-bot
Copy link
Author

Master branch: b5e975d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611310
version: 3

@kernel-patches-bot
Copy link
Author

Master branch: 976a38e
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611310
version: 3

@kernel-patches-bot
Copy link
Author

Master branch: 976a38e
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611310
version: 3

Nobody and others added 7 commits February 4, 2022 18:29
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>
@kernel-patches-bot
Copy link
Author

Master branch: 0908a66
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611310
version: 3

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>
@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=611310 irrelevant now. Closing PR.

@kernel-patches-bot kernel-patches-bot deleted the series/611184=>bpf-next branch February 5, 2022 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants