From patchwork Sun Jan 7 17:40:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 135794 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3253B43859; Sun, 7 Jan 2024 18:40:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F06E8402E0; Sun, 7 Jan 2024 18:40:23 +0100 (CET) Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by mails.dpdk.org (Postfix) with ESMTP id 691D0402B1 for ; Sun, 7 Jan 2024 18:40:22 +0100 (CET) Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-36082f3cb05so3494775ab.0 for ; Sun, 07 Jan 2024 09:40:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704649221; x=1705254021; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tcge0VUustk0V228dQFL6PE7gSA2i8qGq1GfD4QH++k=; b=DD4ZLaExPD52ACphPJt+cYfzFhOxgH/UWfqA0KHP3DkBW8uoz3+vqSX0UkyBCUcXIZ +P3CIBH8BED3J3r54Zp0s9Inn/biW1z9Y3netdhAjBjgqaltVf25tE09z1r66bwS3YMC sxvwPoAdwSQqKsDmx6wh+wdXzX8tzpMLP4Cf/8iThjPnlXxr/Oo9OcPZtmZ6mhmjra7Z yAmBNsCsv8p9MViosEHsMsmfBpFCZQy08H0oZ3Qv4XnPuxDmIi7KfCjSwQPEM2Bp1+WM hY4oSrWnK7EVuWE5Etp33/a/qREFKZ1QcfLA2Lm4TZVYR2q8rwX+OkCepxhEjmrw1GGW xClA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704649221; x=1705254021; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tcge0VUustk0V228dQFL6PE7gSA2i8qGq1GfD4QH++k=; b=bnM+S3mw7wICkTG9mL+jpMAIT3RHPrC5B2xgAZAhWDV7bnP5QUAGjK2xspQ3DGcsMe VVGnWruuexESXQwNGabTBc6qZcsXIV2DO1WBQPNnjI6vQ/aeX8dMpPmthMfysmT3ILbU kHubNDgk3idnmPm0Pd4EMZQpkO8jpvG5dPwPNAM201XPGX0zsMG5o3QWxCHDEx0iuXA4 qfPF69Jy19GqFRWsFNeXgR5h5luRB/x61bl9F2w95sLiaa+1u19nA7z8n2UEuOEm3ch9 r6iP61UQIXqyUp/sPg1J+i9lYq9iB8HkhmvTjJFhvIBbs1Z+ubc+41Ll9eQfcaL8QMD0 dJag== X-Gm-Message-State: AOJu0YwDgUTJ4QkbE2hzuto7Yw5TYLKJZow7GOWabqdwet/xKIUud8Vc bgqsELuciYbmPH72ptMj9SQWlnmOpyC/XcM3ILWxGxLTWkE= X-Google-Smtp-Source: AGHT+IEtomcvGA2JPJ6acdgAG2B5S6R+FewPsBHwQgLZ7kVbklWjqEQbZfFERWrmUUkFdDjR+rqIYA== X-Received: by 2002:a05:6e02:2387:b0:360:7403:3cca with SMTP id bq7-20020a056e02238700b0036074033ccamr3596242ilb.51.1704649221657; Sun, 07 Jan 2024 09:40:21 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id k6-20020a170902c40600b001cfc50e5afesm4654294plk.23.2024.01.07.09.40.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 09:40:21 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH] tap: check that file is BPF arch before extracting Date: Sun, 7 Jan 2024 09:40:10 -0800 Message-ID: <20240107174010.8278-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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)