{"id":814279,"url":"http://patchwork.ozlabs.org/api/patches/814279/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/8c3d5513-6171-3e68-56df-1efd0e87f071@solarflare.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<8c3d5513-6171-3e68-56df-1efd0e87f071@solarflare.com>","list_archive_url":null,"date":"2017-09-15T13:37:38","name":"[net] bpf/verifier: reject BPF_ALU64|BPF_END","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"ce2e50853540df4a71b251d634a98701dfe2101a","submitter":{"id":61177,"url":"http://patchwork.ozlabs.org/api/people/61177/?format=json","name":"Edward Cree","email":"ecree@solarflare.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/8c3d5513-6171-3e68-56df-1efd0e87f071@solarflare.com/mbox/","series":[{"id":3312,"url":"http://patchwork.ozlabs.org/api/series/3312/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=3312","date":"2017-09-15T13:37:38","name":"[net] bpf/verifier: reject BPF_ALU64|BPF_END","version":1,"mbox":"http://patchwork.ozlabs.org/series/3312/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814279/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814279/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xtxSM2Y6dz9sRm\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 15 Sep 2017 23:43:31 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751583AbdIONn3 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 15 Sep 2017 09:43:29 -0400","from dispatch1-us1.ppe-hosted.com ([148.163.129.52]:59386 \"EHLO\n\tdispatch1-us1.ppe-hosted.com\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1751561AbdIONn1 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 15 Sep 2017 09:43:27 -0400","from dispatch1-us1.ppe-hosted.com (localhost.localdomain\n\t[127.0.0.1])\n\tby dispatch1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server)\n\twith ESMTP id D82ACC10CE\n\tfor <netdev@vger.kernel.org>; Fri, 15 Sep 2017 13:37:45 +0000 (UTC)","from pure.maildistiller.com (dispatch1.mdlocal [10.7.20.164])\n\tby dispatch1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server)\n\twith ESMTP id 6E4C860075; Fri, 15 Sep 2017 13:37:45 +0000 (UTC)","from mx4-us4.ppe-hosted.com (filterqueue.mdlocal [10.7.20.246])\n\tby pure.maildistiller.com (Proofpoint Essentials ESMTP Server) with\n\tESMTPS id 5797F1C006D; Fri, 15 Sep 2017 13:37:44 +0000 (UTC)","from webmail.solarflare.com (webmail.solarflare.com\n\t[12.187.104.26])\n\t(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx4-us4.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with\n\tESMTPS id 1B47FB80054; Fri, 15 Sep 2017 13:37:44 +0000 (UTC)","from ec-desktop.uk.solarflarecom.com (10.17.20.45) by\n\tocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server\n\t(TLS) id 15.0.1044.25; Fri, 15 Sep 2017 06:37:41 -0700"],"X-Greylist":"delayed 342 seconds by postgrey-1.27 at vger.kernel.org;\n\tFri, 15 Sep 2017 09:43:27 EDT","X-Virus-Scanned":"Proofpoint Essentials engine","From":"Edward Cree <ecree@solarflare.com>","Subject":"[PATCH net] bpf/verifier: reject BPF_ALU64|BPF_END","To":"David Miller <davem@davemloft.net>","CC":"netdev <netdev@vger.kernel.org>, Daniel Borkmann <daniel@iogearbox.net>","Message-ID":"<8c3d5513-6171-3e68-56df-1efd0e87f071@solarflare.com>","Date":"Fri, 15 Sep 2017 14:37:38 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101\n\tThunderbird/45.1.0","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","X-Originating-IP":"[10.17.20.45]","X-ClientProxiedBy":"ocex03.SolarFlarecom.com (10.20.40.36) To\n\tocex03.SolarFlarecom.com (10.20.40.36)","X-MDID":"1505482664-wgdW9759IWLn","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Neither ___bpf_prog_run nor the JITs accept it.\nAlso adds a new test case.\n\nFixes: 17a5267067f3 (\"bpf: verifier (add verifier core)\")\nSigned-off-by: Edward Cree <ecree@solarflare.com>\n---\n kernel/bpf/verifier.c                       |  3 ++-\n tools/testing/selftests/bpf/test_verifier.c | 16 ++++++++++++++++\n 2 files changed, 18 insertions(+), 1 deletion(-)","diff":"diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c\nindex 477b693..799b245 100644\n--- a/kernel/bpf/verifier.c\n+++ b/kernel/bpf/verifier.c\n@@ -2292,7 +2292,8 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)\n \t\t\t}\n \t\t} else {\n \t\t\tif (insn->src_reg != BPF_REG_0 || insn->off != 0 ||\n-\t\t\t    (insn->imm != 16 && insn->imm != 32 && insn->imm != 64)) {\n+\t\t\t    (insn->imm != 16 && insn->imm != 32 && insn->imm != 64) ||\n+\t\t\t    BPF_CLASS(insn->code) == BPF_ALU64) {\n \t\t\t\tverbose(\"BPF_END uses reserved fields\\n\");\n \t\t\t\treturn -EINVAL;\n \t\t\t}\ndiff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c\nindex 8eb0995..26f3250 100644\n--- a/tools/testing/selftests/bpf/test_verifier.c\n+++ b/tools/testing/selftests/bpf/test_verifier.c\n@@ -6629,6 +6629,22 @@ static struct bpf_test tests[] = {\n \t\t.result = REJECT,\n \t\t.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,\n \t},\n+\t{\n+\t\t\"invalid 64-bit BPF_END\",\n+\t\t.insns = {\n+\t\t\tBPF_MOV32_IMM(BPF_REG_0, 0),\n+\t\t\t{\n+\t\t\t\t.code  = BPF_ALU64 | BPF_END | BPF_TO_LE,\n+\t\t\t\t.dst_reg = BPF_REG_0,\n+\t\t\t\t.src_reg = 0,\n+\t\t\t\t.off   = 0,\n+\t\t\t\t.imm   = 32,\n+\t\t\t},\n+\t\t\tBPF_EXIT_INSN(),\n+\t\t},\n+\t\t.errstr = \"BPF_END uses reserved fields\",\n+\t\t.result = REJECT,\n+\t},\n };\n \n static int probe_filter_length(const struct bpf_insn *fp)\n","prefixes":["net"]}