mbox series

[bpf-next,v5,00/10] Fix accessing syscall arguments

Message ID 20220209021745.2215452-1-iii@linux.ibm.com (mailing list archive)
Headers show
Series Fix accessing syscall arguments | expand

Message

Ilya Leoshkevich Feb. 9, 2022, 2:17 a.m. UTC
libbpf now has macros to access syscall arguments in an
architecture-agnostic manner, but unfortunately they have a number of
issues on non-Intel arches, which this series aims to fix.

v1: https://lore.kernel.org/bpf/20220201234200.1836443-1-iii@linux.ibm.com/
v1 -> v2:
* Put orig_gpr2 in place of args[1] on s390 (Vasily).
* Fix arm64, powerpc and riscv (Heiko).

v2: https://lore.kernel.org/bpf/20220204041955.1958263-1-iii@linux.ibm.com/
v2 -> v3:
* Undo args[1] change (Andrii).
* Rename PT_REGS_SYSCALL to PT_REGS_SYSCALL_REGS (Andrii).
* Split the riscv patch (Andrii).

v3: https://lore.kernel.org/bpf/20220204145018.1983773-1-iii@linux.ibm.com/
v3 -> v4:
* Undo arm64's and s390's user_pt_regs changes.
* Use struct pt_regs when vmlinux.h is available (Andrii).
* Use offsetofend for accessing orig_gpr2 and orig_x0 (Andrii).
* Move libbpf's copy of offsetofend to a new header.
* Fix riscv's __PT_FP_REG.
* Use PT_REGS_SYSCALL_REGS in test_probe_user.c.
* Test bpf_syscall_macro with userspace headers.
* Use Naveen's suggestions and code in patches 5 and 6.
* Add warnings to arm64's and s390's ptrace.h (Andrii).

v4: https://lore.kernel.org/bpf/20220208051635.2160304-1-iii@linux.ibm.com/
v4 -> v5:
* Go back to v3.
* Do not touch arch headers.
* Use CO-RE struct flavors to access orig_x0 and orig_gpr2.
* Fail compilation if non-CO-RE macros are used to access the first
  syscall parameter on arm64 and s390.
* Fix accessing frame pointer on riscv.

Ilya Leoshkevich (10):
  selftests/bpf: Fix an endianness issue in bpf_syscall_macro test
  libbpf: Add PT_REGS_SYSCALL_REGS macro
  selftests/bpf: Use PT_REGS_SYSCALL_REGS in bpf_syscall_macro
  libbpf: Fix accessing syscall arguments on powerpc
  libbpf: Fix riscv register names
  libbpf: Fix accessing syscall arguments on riscv
  selftests/bpf: Skip test_bpf_syscall_macro:syscall_arg1 on arm64 and
    s390
  libbpf: Allow overriding PT_REGS_PARM1{_CORE}_SYSCALL
  libbpf: Fix accessing the first syscall argument on arm64
  libbpf: Fix accessing the first syscall argument on s390

 tools/lib/bpf/bpf_tracing.h                   | 42 ++++++++++++++++++-
 .../bpf/prog_tests/test_bpf_syscall_macro.c   |  4 ++
 .../selftests/bpf/progs/bpf_syscall_macro.c   |  9 +++-
 3 files changed, 51 insertions(+), 4 deletions(-)

Comments

Andrii Nakryiko Feb. 9, 2022, 5:39 a.m. UTC | #1
On Tue, Feb 8, 2022 at 6:17 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> libbpf now has macros to access syscall arguments in an
> architecture-agnostic manner, but unfortunately they have a number of
> issues on non-Intel arches, which this series aims to fix.
>
> v1: https://lore.kernel.org/bpf/20220201234200.1836443-1-iii@linux.ibm.com/
> v1 -> v2:
> * Put orig_gpr2 in place of args[1] on s390 (Vasily).
> * Fix arm64, powerpc and riscv (Heiko).
>
> v2: https://lore.kernel.org/bpf/20220204041955.1958263-1-iii@linux.ibm.com/
> v2 -> v3:
> * Undo args[1] change (Andrii).
> * Rename PT_REGS_SYSCALL to PT_REGS_SYSCALL_REGS (Andrii).
> * Split the riscv patch (Andrii).
>
> v3: https://lore.kernel.org/bpf/20220204145018.1983773-1-iii@linux.ibm.com/
> v3 -> v4:
> * Undo arm64's and s390's user_pt_regs changes.
> * Use struct pt_regs when vmlinux.h is available (Andrii).
> * Use offsetofend for accessing orig_gpr2 and orig_x0 (Andrii).
> * Move libbpf's copy of offsetofend to a new header.
> * Fix riscv's __PT_FP_REG.
> * Use PT_REGS_SYSCALL_REGS in test_probe_user.c.
> * Test bpf_syscall_macro with userspace headers.
> * Use Naveen's suggestions and code in patches 5 and 6.
> * Add warnings to arm64's and s390's ptrace.h (Andrii).
>
> v4: https://lore.kernel.org/bpf/20220208051635.2160304-1-iii@linux.ibm.com/
> v4 -> v5:
> * Go back to v3.
> * Do not touch arch headers.
> * Use CO-RE struct flavors to access orig_x0 and orig_gpr2.
> * Fail compilation if non-CO-RE macros are used to access the first
>   syscall parameter on arm64 and s390.
> * Fix accessing frame pointer on riscv.
>
> Ilya Leoshkevich (10):
>   selftests/bpf: Fix an endianness issue in bpf_syscall_macro test
>   libbpf: Add PT_REGS_SYSCALL_REGS macro
>   selftests/bpf: Use PT_REGS_SYSCALL_REGS in bpf_syscall_macro
>   libbpf: Fix accessing syscall arguments on powerpc
>   libbpf: Fix riscv register names
>   libbpf: Fix accessing syscall arguments on riscv
>   selftests/bpf: Skip test_bpf_syscall_macro:syscall_arg1 on arm64 and
>     s390
>   libbpf: Allow overriding PT_REGS_PARM1{_CORE}_SYSCALL
>   libbpf: Fix accessing the first syscall argument on arm64
>   libbpf: Fix accessing the first syscall argument on s390
>

Applied to bpf-next with few adjustments in patches 8-10, thanks. I'll
sync all this to Github shortly to run it through s390x CI tests as
well.

>  tools/lib/bpf/bpf_tracing.h                   | 42 ++++++++++++++++++-
>  .../bpf/prog_tests/test_bpf_syscall_macro.c   |  4 ++
>  .../selftests/bpf/progs/bpf_syscall_macro.c   |  9 +++-
>  3 files changed, 51 insertions(+), 4 deletions(-)
>
> --
> 2.34.1
>
patchwork-bot+netdevbpf@kernel.org Feb. 9, 2022, 5:40 a.m. UTC | #2
Hello:

This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Wed,  9 Feb 2022 03:17:35 +0100 you wrote:
> libbpf now has macros to access syscall arguments in an
> architecture-agnostic manner, but unfortunately they have a number of
> issues on non-Intel arches, which this series aims to fix.
> 
> v1: https://lore.kernel.org/bpf/20220201234200.1836443-1-iii@linux.ibm.com/
> v1 -> v2:
> * Put orig_gpr2 in place of args[1] on s390 (Vasily).
> * Fix arm64, powerpc and riscv (Heiko).
> 
> [...]

Here is the summary with links:
  - [bpf-next,v5,01/10] selftests/bpf: Fix an endianness issue in bpf_syscall_macro test
    https://git.kernel.org/bpf/bpf-next/c/4fc49b51ab9d
  - [bpf-next,v5,02/10] libbpf: Add PT_REGS_SYSCALL_REGS macro
    https://git.kernel.org/bpf/bpf-next/c/c5a1ffa0da76
  - [bpf-next,v5,03/10] selftests/bpf: Use PT_REGS_SYSCALL_REGS in bpf_syscall_macro
    https://git.kernel.org/bpf/bpf-next/c/3f928cab927c
  - [bpf-next,v5,04/10] libbpf: Fix accessing syscall arguments on powerpc
    https://git.kernel.org/bpf/bpf-next/c/f07f1503469b
  - [bpf-next,v5,05/10] libbpf: Fix riscv register names
    https://git.kernel.org/bpf/bpf-next/c/5c101153bfd6
  - [bpf-next,v5,06/10] libbpf: Fix accessing syscall arguments on riscv
    https://git.kernel.org/bpf/bpf-next/c/cf0b5b276923
  - [bpf-next,v5,07/10] selftests/bpf: Skip test_bpf_syscall_macro:syscall_arg1 on arm64 and s390
    https://git.kernel.org/bpf/bpf-next/c/9e45a377f29b
  - [bpf-next,v5,08/10] libbpf: Allow overriding PT_REGS_PARM1{_CORE}_SYSCALL
    https://git.kernel.org/bpf/bpf-next/c/60d16c5ccb81
  - [bpf-next,v5,09/10] libbpf: Fix accessing the first syscall argument on arm64
    https://git.kernel.org/bpf/bpf-next/c/fbca4a2f6497
  - [bpf-next,v5,10/10] libbpf: Fix accessing the first syscall argument on s390
    https://git.kernel.org/bpf/bpf-next/c/1f22a6f9f9a0

You are awesome, thank you!