public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: "Marat Khalili" <marat.khalili@huawei.com>,
	"Morten Brørup" <mb@smartsharesystems.com>,
	"Christophe Fontaine" <cfontain@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	Wathsala Vithanage <wathsala.vithanage@arm.com>
Subject: RE: [PATCH] bpf/arm64: support packet data load instructions
Date: Wed, 18 Mar 2026 18:10:40 +0000	[thread overview]
Message-ID: <78da248e82a54be6882d37efeff23add@huawei.com> (raw)
In-Reply-To: <ba8f317961494ce9af15a9108aa3693b@huawei.com>



> 
> > > I suggest the following logic in pseudo-code:
> > >
> > > static void
> > > emit_ld_mbuf(struct a64_jit_ctx *ctx, uint32_t op, uint8_t tmp1,
> > > uint8_t tmp2,
> > > 	uint8_t src, int32_t imm)
> > > {
> > > 	// ...
> > >
> > > 	/* r1 = off: for ABS use imm, for IND use src + imm */
> > > 	if (mode == BPF_ABS) {
> > > 		assert imm >= 0, "verified by verifier"
> > > 		emit MOV W1, #<imm>
> > > 	} else {
> > > 		/* add signed imm to the source register */
> > > 		emit(s) X1 = src + #<imm>
> > > 		/* verify dynamically that offset is within the domain of
> > > __rte_pktmbuf_read */
> > > 		emit(s) jump_to_epilogue if X1 <s 0 || X1 > INT32_MAX

Shouldn't it be UINT32_MAX?

> > > 	}
> > >
> > > 	// ...
> > > }

I wonder does x86 jit and VM perform that check?
If not, then it is probably not fair to demand that patch to fix these things for arm:
It probably has to be another patch that will fix that issue for all targets (vm, x86, arm).
After all - it wouldn't cause any memory corruption, right?
In the worst case (wraparound) bpf will read some valid data from the
unexpected location in the packet instead of simply returning 0.
BTW, I think we still need to add check for overflow in __rte_pktmbuf_read() -
bpf jit is not the only user of it. 
Unless, of-course, we want rte_pktmbuf_read() to work with wrapped-around values. 

> >
> > I don't know if it's the sum of src+imm that determines special meaning, or it's
> the imm itself.
> > If it's the imm itself, a simple fix would be to update the validator's .imm.max
> values for BPF_IND
> > from UINT32_MAX to INT32_MAX.
> >
> 
> Even if we do it (I have no particular opinion), it won't prevent sum of 64-bit
> register and immediate from being negative or greater than the range of values
> supported by 32-bit argument of __rte_pktmbuf_read.

  reply	other threads:[~2026-03-18 18:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 12:20 [PATCH] bpf/arm64: support packet data load instructions Christophe Fontaine
2026-03-17  9:07 ` David Marchand
2026-03-18 11:59 ` Marat Khalili
2026-03-18 12:54   ` Morten Brørup
2026-03-18 13:07     ` Marat Khalili
2026-03-18 13:39       ` Morten Brørup
2026-03-18 15:34         ` Christophe Fontaine
2026-03-18 16:16           ` Marat Khalili
2026-03-18 16:37             ` Morten Brørup
2026-03-18 16:43               ` Marat Khalili
2026-03-18 18:10                 ` Konstantin Ananyev [this message]
2026-03-19  9:20                   ` Morten Brørup
2026-03-18 23:13     ` Stephen Hemminger
2026-03-19 11:44 ` [PATCH v2 0/2] " Christophe Fontaine
2026-03-19 11:44   ` [PATCH v2 1/2] bpf/arm64: fix offset type to allow a negative jump Christophe Fontaine
2026-03-19 11:44   ` [PATCH v2 2/2] bpf/arm64: support packet data load instructions Christophe Fontaine
2026-03-23  8:15     ` Christophe Fontaine
2026-03-23  9:26       ` Marat Khalili
2026-04-09 22:11       ` Wathsala Vithanage

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=78da248e82a54be6882d37efeff23add@huawei.com \
    --to=konstantin.ananyev@huawei.com \
    --cc=cfontain@redhat.com \
    --cc=dev@dpdk.org \
    --cc=marat.khalili@huawei.com \
    --cc=mb@smartsharesystems.com \
    --cc=wathsala.vithanage@arm.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