All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <kafai@fb.com>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	David Miller <davem@davemloft.net>, <kernel-team@fb.com>
Subject: [PATCH v3 bpf-next 1/3] bpf: Account for insn->off when doing bpf_probe_read_kernel
Date: Wed, 6 Nov 2019 17:46:40 -0800	[thread overview]
Message-ID: <20191107014640.384083-1-kafai@fb.com> (raw)
In-Reply-To: <20191107014639.384014-1-kafai@fb.com>

In the bpf interpreter mode, bpf_probe_read_kernel is used to read
from PTR_TO_BTF_ID's kernel object.  It currently missed considering
the insn->off.  This patch fixes it.

Fixes: 2a02759ef5f8 ("bpf: Add support for BTF pointers to interpreter")
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
 kernel/bpf/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 97e37d82a1cc..c1fde0303280 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1569,7 +1569,7 @@ static u64 __no_fgcse ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn, u6
 #undef LDST
 #define LDX_PROBE(SIZEOP, SIZE)							\
 	LDX_PROBE_MEM_##SIZEOP:							\
-		bpf_probe_read_kernel(&DST, SIZE, (const void *)(long) SRC);	\
+		bpf_probe_read_kernel(&DST, SIZE, (const void *)(long) (SRC + insn->off));	\
 		CONT;
 	LDX_PROBE(B,  1)
 	LDX_PROBE(H,  2)
-- 
2.17.1


  reply	other threads:[~2019-11-07  1:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07  1:46 [PATCH v3 bpf-next 0/3] bpf: Add array support to btf_struct_access Martin KaFai Lau
2019-11-07  1:46 ` Martin KaFai Lau [this message]
2019-11-07  2:45   ` [PATCH v3 bpf-next 1/3] bpf: Account for insn->off when doing bpf_probe_read_kernel Andrii Nakryiko
2019-11-07  5:57   ` Alexei Starovoitov
2019-11-07  1:46 ` [PATCH v3 bpf-next 2/3] bpf: Add array support to btf_struct_access Martin KaFai Lau
2019-11-07  2:41   ` Andrii Nakryiko
2019-11-07 17:22     ` Martin Lau
2019-11-07 17:26       ` Andrii Nakryiko
2019-11-07  1:46 ` [PATCH v3 bpf-next 3/3] bpf: Add cb access in kfree_skb test Martin KaFai Lau
2019-11-07  2:50   ` Andrii Nakryiko
2019-11-07 17:29     ` Martin Lau

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=20191107014640.384083-1-kafai@fb.com \
    --to=kafai@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.