BPF List
 help / color / mirror / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, "Martin KaFai Lau" <kafai@fb.com>,
	"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@chromium.org>,
	"Stanislav Fomichev" <sdf@google.com>,
	"Hao Luo" <haoluo@google.com>, "Xu Kuohai" <xukuohai@huawei.com>,
	"Will Deacon" <will@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Pu Lehui" <pulehui@huawei.com>, "Björn Töpel" <bjorn@kernel.org>,
	"Lee Jones" <lee@kernel.org>
Subject: Re: [PATCHv2 bpf 1/2] bpf: Add checkip argument to bpf_arch_text_poke
Date: Fri, 01 Dec 2023 15:36:26 +0100	[thread overview]
Message-ID: <59c3a7732d729c36c4134fc47723042e3bdafada.camel@linux.ibm.com> (raw)
In-Reply-To: <20231128092850.1545199-2-jolsa@kernel.org>

On Tue, 2023-11-28 at 10:28 +0100, Jiri Olsa wrote:
> We need to be able to skip ip address check for caller in following
> changes. Adding checkip argument to allow that.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  arch/arm64/net/bpf_jit_comp.c   |  3 ++-
>  arch/riscv/net/bpf_jit_comp64.c |  5 +++--
>  arch/s390/net/bpf_jit_comp.c    |  3 ++-
>  arch/x86/net/bpf_jit_comp.c     | 24 +++++++++++++-----------
>  include/linux/bpf.h             |  2 +-
>  kernel/bpf/arraymap.c           |  8 ++++----
>  kernel/bpf/core.c               |  2 +-
>  kernel/bpf/trampoline.c         | 12 ++++++------
>  8 files changed, 32 insertions(+), 27 deletions(-)

[...]

> --- a/arch/x86/net/bpf_jit_comp.c
> +++ b/arch/x86/net/bpf_jit_comp.c
> @@ -435,19 +435,21 @@ static int __bpf_arch_text_poke(void *ip, enum
> bpf_text_poke_type t,
>  }
>  
>  int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,
> -                      void *old_addr, void *new_addr)
> +                      void *old_addr, void *new_addr, bool checkip)
>  {
> -       if (!is_kernel_text((long)ip) &&
> -           !is_bpf_text_address((long)ip))
> -               /* BPF poking in modules is not supported */
> -               return -EINVAL;
> +       if (checkip) {
> +               if (!is_kernel_text((long)ip) &&
> +                   !is_bpf_text_address((long)ip))
> +                       /* BPF poking in modules is not supported */
> +                       return -EINVAL;
>  
> -       /*
> -        * See emit_prologue(), for IBT builds the trampoline hook is
> preceded
> -        * with an ENDBR instruction.
> -        */
> -       if (is_endbr(*(u32 *)ip))
> -               ip += ENDBR_INSN_SIZE;
> +               /*
> +                * See emit_prologue(), for IBT builds the trampoline
> hook is preceded
> +                * with an ENDBR instruction.
> +                */
> +               if (is_endbr(*(u32 *)ip))
> +                       ip += ENDBR_INSN_SIZE;

Do we really want to skip the IP adjustment too?

> +       }
>  
>         return __bpf_arch_text_poke(ip, t, old_addr, new_addr);
>  }

[...]

  parent reply	other threads:[~2023-12-01 14:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-28  9:28 [PATCHv2 bpf 0/2] bpf: Fix prog_array_map_poke_run map poke update Jiri Olsa
2023-11-28  9:28 ` [PATCHv2 bpf 1/2] bpf: Add checkip argument to bpf_arch_text_poke Jiri Olsa
2023-11-28 21:24   ` Stanislav Fomichev
2023-11-29 14:05     ` Jiri Olsa
2023-11-29 14:55       ` Jiri Olsa
2023-11-29 18:10         ` Stanislav Fomichev
2023-12-01  9:10           ` Jiri Olsa
2023-12-01 14:36   ` Ilya Leoshkevich [this message]
2023-12-03 20:50     ` Jiri Olsa
2023-11-28  9:28 ` [PATCHv2 bpf 2/2] bpf: Fix prog_array_map_poke_run map poke update Jiri Olsa
2023-11-28 22:44 ` [PATCHv2 bpf 0/2] " Ilya Leoshkevich
2023-11-29 13:23   ` Jiri Olsa
2023-12-01 13:13     ` Jiri Olsa
2023-12-01 14:31       ` Ilya Leoshkevich
2023-12-01 14:52         ` Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59c3a7732d729c36c4134fc47723042e3bdafada.camel@linux.ibm.com \
    --to=iii@linux.ibm.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=lee@kernel.org \
    --cc=nathan@kernel.org \
    --cc=pulehui@huawei.com \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=will@kernel.org \
    --cc=xukuohai@huawei.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox