Received: by 10.213.65.68 with SMTP id h4csp2118566imn; Sun, 8 Apr 2018 20:09:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx48/JERgmTVIoYklvW6wlYda9UIBlcYXenjMVQLewCPJuwTVX0By2AWAZ6NiIr0Cm3y212+l X-Received: by 2002:a17:902:d20a:: with SMTP id t10-v6mr3577145ply.151.1523243396152; Sun, 08 Apr 2018 20:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243396; cv=none; d=google.com; s=arc-20160816; b=iWNz/OHK2q2KXAOq8Awne/LLZL1S/SxZ1WuM+XoPHgplOJq/ra1CwfMM/KJmhEVDeT v15ydKwPzdKXMtfIDvM/itjFLqj7PKHdAXzR+AU0Vh7Py7ZD5uLkDBVsMKDXbrXNVh0f f8qKdXIRlvZdjJ88mlbe9RRm3e6WophD85ctZa7GQf6+VTIk1lbprI/+Z7g6HKhV7Euq q7FIHEfx4wQs/wPvY1l3XB2l+HfZUQK9WyaR7oWdlPO1u6X5p1ee45wGfoh8oVOaNFxj +yIHKs4oWx6TnNkdICYsUswtZxDOJjwjb7jhZn8gZhxWJGoMkGotSqjkS6t21ChUzp72 lIEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=w5pntFqxEK0g2iVpeLEv7/LkYRZmPpjrpE0Ut9lCSpo=; b=Gzcl/HkcJwq+94tJgVMjTsVxpB+bBC9ks0ulgM9pHFV7y6e2Uzj5/2BOySW+hU5HpJ KhCJxxUa/u36boUPExaHACk4MeI5oSj02q17kqUxUlEE/osBC+a2c9WYzw/6x+oanlr3 42XiEYadeU+H5Z8Hps47jvp+bEnrIC4MrzWMUj8Svr46dMT+PpKUph4EPYeI/1KtdNqL 4xgpbF88szi7P8kVIFY7P7gFe8q7vlED10Gclkf+gEZUTqEJ4HqjxuoKzspMQ9W8x1X+ w9HAytz/tdixXZ5FmRyHMQYdvFTkam3MeDTD67Y4IyCr52JFQbQArOVCB8wXdVDh0XvL 1m2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Vocgb9QO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t20si12082971pfj.320.2018.04.08.20.09.19; Sun, 08 Apr 2018 20:09:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Vocgb9QO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756586AbeDIBqT (ORCPT + 98 others); Sun, 8 Apr 2018 21:46:19 -0400 Received: from mail-bl2nam02on0118.outbound.protection.outlook.com ([104.47.38.118]:14317 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932471AbeDIAej (ORCPT ); Sun, 8 Apr 2018 20:34:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=w5pntFqxEK0g2iVpeLEv7/LkYRZmPpjrpE0Ut9lCSpo=; b=Vocgb9QOSW2KaIgy3N+i+ZzdY65vimd4NqAv80lXxjyYuOSjqktw3+UqxVRSk7Pqf3Q/HxhpPfa4vsQF8vX1rBAKI02WKMikBqjRRZxHKLRKpu3aQEjGxQIQS/WB9g6Cy/GYK/NhV6V0uzkuOD7WAMq/VtT19b1ADNAg+lQe1/w= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0984.namprd21.prod.outlook.com (52.132.133.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:34:36 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:34:36 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Yonghong Song , Daniel Borkmann , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 272/293] bpf: fix selftests/bpf test_kmod.sh failure when CONFIG_BPF_JIT_ALWAYS_ON=y Thread-Topic: [PATCH AUTOSEL for 4.9 272/293] bpf: fix selftests/bpf test_kmod.sh failure when CONFIG_BPF_JIT_ALWAYS_ON=y Thread-Index: AQHTz5lm2UCPUaEyv0Ws2L+A7gIfDg== Date: Mon, 9 Apr 2018 00:26:27 +0000 Message-ID: <20180409002239.163177-272-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0984;7:v5FVpQOpyTKRdwro9li+/jt9AHy+Z5MbYUEj533081kwSvlzE3rkqg2S1zdW/idBgCzMNZ5Fu7Y82PmDijS0yLMeXUg1zbGNI1CW4RcNNKWddPtOZ9UNyGEH1TdTcC115FaYtV/icbvl9+e2wV1oNbZbuZeHDuqcHwmvAy6BGs5uMufRMWCDmFkob6HlF3ceucZsUf3KE1olW8cDrqg8JfpYwWlHZ4LbIR3d4xpZhFk3Jmf+6hQLOMiOESAmRMWc;20:hRZoKagJroS/+v7Cva8GI8zl7Pv+6AHZseraoFN0cN8ImEvrscZDFEMoBh226vrOBMi0WgDRB57K73qN6BgbiFNqUaUIAY+tWRheWKvuJhIouaMUjDudcrAzaALb3k+KsxOHJmOVXP36/mAQuLhmEV/Ia2EP/8LjHgAod7OuOrg= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 4eb69a25-7a57-4ca7-a002-08d59db1abdc x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0984; x-ms-traffictypediagnostic: DM5PR2101MB0984: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(265634631926514)(67672495146484); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0984;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0984; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(366004)(39380400002)(346002)(376002)(199004)(189003)(26005)(99286004)(2906002)(14454004)(97736004)(59450400001)(8676002)(81156014)(81166006)(8936002)(6512007)(106356001)(76176011)(186003)(3280700002)(10090500001)(36756003)(6506007)(66066001)(3660700001)(72206003)(478600001)(6666003)(53936002)(2900100001)(105586002)(102836004)(2501003)(110136005)(54906003)(5250100002)(486006)(1076002)(25786009)(6116002)(6436002)(11346002)(6486002)(22452003)(4326008)(446003)(7736002)(86362001)(305945005)(2616005)(476003)(68736007)(3846002)(86612001)(5660300001)(10290500003)(107886003)(316002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0984;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 5NlCR/BEPcrjHxn71OxPj71i85/j6hPpw+aN++Fmfbq1CM18WtVVUmPktvJTIr8ES0ddy691gVtckEQhERfXkW9CPLDGFX/WZqMYYzK1IfXOU7Wh/7lKBTBNn+APpoSFxK4u3lMDQkUUuRQILKpR47aIRvYWVLjJTSRWOVkQTn5Gx/VrD4D6QKwwCpyxkSegeel+4R0z/mP4zY0UQ5dOHCdc4BbKIC0hIanZq2rC8+UpiD7IIVB2mj3fjDtKqv7AnJWlk280sqvduGjMOUIJfnn3aY3M2wSvhOPik0MJBhNi/05dOcfurCBHLjjknqiKacK5vduf/HdAERksPM8oAylGhjG/qihu/l43rOMypACg8XygVGSY4CNX+lhtsPFg24eIDWxEwIjg+SuqPN+wPAdoxUZ6mQJd65QlMVF8hm0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4eb69a25-7a57-4ca7-a002-08d59db1abdc X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:26:27.9414 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0984 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yonghong Song [ Upstream commit 09584b406742413ac4c8d7e030374d4daa045b69 ] With CONFIG_BPF_JIT_ALWAYS_ON is defined in the config file, tools/testing/selftests/bpf/test_kmod.sh failed like below: [root@localhost bpf]# ./test_kmod.sh sysctl: setting key "net.core.bpf_jit_enable": Invalid argument [ JIT enabled:0 hardened:0 ] [ 132.175681] test_bpf: #297 BPF_MAXINSNS: Jump, gap, jump, ... FAIL to = prog_create err=3D-524 len=3D4096 [ 132.458834] test_bpf: Summary: 348 PASSED, 1 FAILED, [340/340 JIT'ed] [ JIT enabled:1 hardened:0 ] [ 133.456025] test_bpf: #297 BPF_MAXINSNS: Jump, gap, jump, ... FAIL to = prog_create err=3D-524 len=3D4096 [ 133.730935] test_bpf: Summary: 348 PASSED, 1 FAILED, [340/340 JIT'ed] [ JIT enabled:1 hardened:1 ] [ 134.769730] test_bpf: #297 BPF_MAXINSNS: Jump, gap, jump, ... FAIL to = prog_create err=3D-524 len=3D4096 [ 135.050864] test_bpf: Summary: 348 PASSED, 1 FAILED, [340/340 JIT'ed] [ JIT enabled:1 hardened:2 ] [ 136.442882] test_bpf: #297 BPF_MAXINSNS: Jump, gap, jump, ... FAIL to = prog_create err=3D-524 len=3D4096 [ 136.821810] test_bpf: Summary: 348 PASSED, 1 FAILED, [340/340 JIT'ed] [root@localhost bpf]# The test_kmod.sh load/remove test_bpf.ko multiple times with different settings for sysctl net.core.bpf_jit_{enable,harden}. The failed test #297 of test_bpf.ko is designed such that JIT always fails. Commit 290af86629b2 (bpf: introduce BPF_JIT_ALWAYS_ON config) introduced the following tightening logic: ... if (!bpf_prog_is_dev_bound(fp->aux)) { fp =3D bpf_int_jit_compile(fp); #ifdef CONFIG_BPF_JIT_ALWAYS_ON if (!fp->jited) { *err =3D -ENOTSUPP; return fp; } #endif ... With this logic, Test #297 always gets return value -ENOTSUPP when CONFIG_BPF_JIT_ALWAYS_ON is defined, causing the test failure. This patch fixed the failure by marking Test #297 as expected failure when CONFIG_BPF_JIT_ALWAYS_ON is defined. Fixes: 290af86629b2 (bpf: introduce BPF_JIT_ALWAYS_ON config) Signed-off-by: Yonghong Song Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- lib/test_bpf.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index 98da7520a6aa..1586dfdea809 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -83,6 +83,7 @@ struct bpf_test { __u32 result; } test[MAX_SUBTESTS]; int (*fill_helper)(struct bpf_test *self); + int expected_errcode; /* used when FLAG_EXPECTED_FAIL is set in the aux *= / __u8 frag_data[MAX_DATA]; }; =20 @@ -1900,7 +1901,9 @@ static struct bpf_test tests[] =3D { }, CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, { }, - { } + { }, + .fill_helper =3D NULL, + .expected_errcode =3D -EINVAL, }, { "check: div_k_0", @@ -1910,7 +1913,9 @@ static struct bpf_test tests[] =3D { }, CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, { }, - { } + { }, + .fill_helper =3D NULL, + .expected_errcode =3D -EINVAL, }, { "check: unknown insn", @@ -1921,7 +1926,9 @@ static struct bpf_test tests[] =3D { }, CLASSIC | FLAG_EXPECTED_FAIL, { }, - { } + { }, + .fill_helper =3D NULL, + .expected_errcode =3D -EINVAL, }, { "check: out of range spill/fill", @@ -1931,7 +1938,9 @@ static struct bpf_test tests[] =3D { }, CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, { }, - { } + { }, + .fill_helper =3D NULL, + .expected_errcode =3D -EINVAL, }, { "JUMPS + HOLES", @@ -2023,6 +2032,8 @@ static struct bpf_test tests[] =3D { CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, { }, { }, + .fill_helper =3D NULL, + .expected_errcode =3D -EINVAL, }, { "check: LDX + RET X", @@ -2033,6 +2044,8 @@ static struct bpf_test tests[] =3D { CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, { }, { }, + .fill_helper =3D NULL, + .expected_errcode =3D -EINVAL, }, { /* Mainly checking JIT here. */ "M[]: alt STX + LDX", @@ -2207,6 +2220,8 @@ static struct bpf_test tests[] =3D { CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, { }, { }, + .fill_helper =3D NULL, + .expected_errcode =3D -EINVAL, }, { /* Passes checker but fails during runtime. */ "LD [SKF_AD_OFF-1]", @@ -4803,6 +4818,7 @@ static struct bpf_test tests[] =3D { { }, { }, .fill_helper =3D bpf_fill_maxinsns4, + .expected_errcode =3D -EINVAL, }, { /* Mainly checking JIT here. */ "BPF_MAXINSNS: Very long jump", @@ -4858,10 +4874,15 @@ static struct bpf_test tests[] =3D { { "BPF_MAXINSNS: Jump, gap, jump, ...", { }, +#ifdef CONFIG_BPF_JIT_ALWAYS_ON + CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, +#else CLASSIC | FLAG_NO_DATA, +#endif { }, { { 0, 0xababcbac } }, .fill_helper =3D bpf_fill_maxinsns11, + .expected_errcode =3D -ENOTSUPP, }, { "BPF_MAXINSNS: ld_abs+get_processor_id", @@ -5632,7 +5653,7 @@ static struct bpf_prog *generate_filter(int which, in= t *err) =20 *err =3D bpf_prog_create(&fp, &fprog); if (tests[which].aux & FLAG_EXPECTED_FAIL) { - if (*err =3D=3D -EINVAL) { + if (*err =3D=3D tests[which].expected_errcode) { pr_cont("PASS\n"); /* Verifier rejected filter as expected. */ *err =3D 0; --=20 2.15.1