* [PATCH] tap: check that file is BPF arch before extracting
@ 2024-01-07 17:40 Stephen Hemminger
0 siblings, 0 replies; only message in thread
From: Stephen Hemminger @ 2024-01-07 17:40 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
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>
---
| 2 ++
1 file changed, 2 insertions(+)
--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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-07 17:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-07 17:40 [PATCH] tap: check that file is BPF arch before extracting Stephen Hemminger
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).