tap: check that file is BPF arch before extracting
PATCH 1/1 tap: check that file is BPF arch before extracting
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 <[email protected]>
--- drivers/net/tap/bpf/bpf_extract.py | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/tap/bpf/bpf_extract.py +2 -0
@@ -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)
Signature · 1 line
2.43.0