DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH] tap: check that file is BPF arch before extracting
Date: Sun,  7 Jan 2024 09:40:10 -0800	[thread overview]
Message-ID: <20240107174010.8278-1-stephen@networkplumber.org> (raw)

The script to extract BPF instructions from compiled ELF file
would break if the ELF file was incorrectly built.
Add simple check to give better message.

Fixes: 4e679a5f1212 ("net/tap: add infrastructure to build BPF filter")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/tap/bpf/bpf_extract.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/tap/bpf/bpf_extract.py b/drivers/net/tap/bpf/bpf_extract.py
index b630c42b809f..72c15cf7ad12 100644
--- a/drivers/net/tap/bpf/bpf_extract.py
+++ b/drivers/net/tap/bpf/bpf_extract.py
@@ -77,6 +77,8 @@ def main():
         write_header(out, args.source)
         for path in args.file:
             elffile = ELFFile(open_input(path))
+            if elffile['e_machine'] != 'EM_BPF':
+                sys.exit(f'{path} is not BPF')
             sections = load_sections(elffile)
             for name, insns in sections:
                 dump_section(name, insns, out)
-- 
2.43.0


                 reply	other threads:[~2024-01-07 17:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240107174010.8278-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.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).