bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Denhardt <ian@zenhack.net>
To: ast@kernel.org, daniel@iogearbox.net, bpf@vger.kernel.org,
	netdev@vger.kernel.org
Subject: [PATCH 1/2] tools, bpf_asm: Hard error on out of range jumps.
Date: Tue, 23 Feb 2021 21:15:31 -0500	[thread overview]
Message-ID: <af571eef0bc5d33180879c0c81a7d1b26431b915.1614134213.git.ian@zenhack.net> (raw)
In-Reply-To: <cover.1614134213.git.ian@zenhack.net>

Per discussion at:

https://lore.kernel.org/bpf/c964892195a6b91d20a67691448567ef528ffa6d.camel@linux.ibm.com/T/#t

...this was originally introduced as a warning due to concerns about
breaking existing code, but a hard error probably makes more sense,
especially given that concerns about breakage were only speculation.
---
 tools/bpf/bpf_exp.y | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/bpf/bpf_exp.y b/tools/bpf/bpf_exp.y
index 8d48e896be50..8d03e5245da5 100644
--- a/tools/bpf/bpf_exp.y
+++ b/tools/bpf/bpf_exp.y
@@ -549,9 +549,11 @@ static uint8_t bpf_encode_jt_jf_offset(int off, int i)
 {
 	int delta = off - i - 1;
 
-	if (delta < 0 || delta > 255)
-		fprintf(stderr, "warning: insn #%d jumps to insn #%d, "
+	if (delta < 0 || delta > 255) {
+		fprintf(stderr, "error: insn #%d jumps to insn #%d, "
 				"which is out of range\n", i, off);
+		exit(1);
+	}
 	return (uint8_t) delta;
 }
 
-- 
2.30.1


  reply	other threads:[~2021-02-24  2:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24  2:36 [PATCH 0/2] More strict error checking in bpf_asm Ian Denhardt
2021-02-24  2:15 ` Ian Denhardt [this message]
2021-02-24  9:30   ` [PATCH 1/2] tools, bpf_asm: Hard error on out of range jumps Ilya Leoshkevich
2021-02-24  2:24 ` [PATCH 2/2] tools, bpf_asm: exit non-zero on errors Ian Denhardt
2021-02-24 20:34 ` [PATCH 0/2] More strict error checking in bpf_asm Daniel Borkmann
2021-02-24 21:15 [PATCH 0/2] More strict error checking in bpf_asm (v2) Ian Denhardt
2021-02-24  2:15 ` [PATCH 1/2] tools, bpf_asm: Hard error on out of range jumps Ian Denhardt
2021-02-24 21:24 [PATCH 0/2] More strict error checking in bpf_asm (v3) Ian Denhardt
2021-02-24  2:15 ` [PATCH 1/2] tools, bpf_asm: Hard error on out of range jumps Ian Denhardt

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=af571eef0bc5d33180879c0c81a7d1b26431b915.1614134213.git.ian@zenhack.net \
    --to=ian@zenhack.net \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).