From patchwork Fri May 20 11:37:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shung-Hsi Yu X-Patchwork-Id: 12856677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DA51C433EF for ; Fri, 20 May 2022 11:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348597AbiETLiy (ORCPT ); Fri, 20 May 2022 07:38:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348618AbiETLiQ (ORCPT ); Fri, 20 May 2022 07:38:16 -0400 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2DC915A75D for ; Fri, 20 May 2022 04:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1653046691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nUgKGJ3O0a2AcI0M7Li2xW8xlIFt0nekuPR5p7Jv008=; b=GBIC7seTjc4cfYsw+nxpgknwvnSs8U4wxSAlRfeKJZJ8Ur8jtCRDMQ0oVemZZcu/bry6fM RK2dMB0RhUaTkLq7Sho+BNCI4NVIPH95NxcsqWiQ0ZI/kiLVTY5IZjMZtIOPrMJtxlVNJm QpTSaUMTmAa7WohVzbrKtzky13QZjgc= Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2057.outbound.protection.outlook.com [104.47.14.57]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-20-xSRJOZfWPQaJ_cWg9diAQw-1; Fri, 20 May 2022 13:38:09 +0200 X-MC-Unique: xSRJOZfWPQaJ_cWg9diAQw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VM5Xoy+UaQPnNlVGzIO4679rwjwD7qjZRqZH3LOCdyrSFvWOlC9A0cDEwc2ehm8SYccyyLFDNF2x6irS6JiYwCsC5O64/wYNMJk8ai32VA2GAC8Z0kDUdt0Gln/7jSpXeJRIrkt+U1E9EJJD9KN2c5pdp2pU66QJ7xLTYQs3wgDSIz78Us3eHy2alDoi+K6XrF/e6OychbwK1qIzuiUUfWPscTOwggonoXlZ8H8+lN9Mpua+YJLIvdcBYcXZ5YIsxbf/WHn4h4T3Vo5xhX8Af2KwiUTCGfc7RHfsdIJnQcxt5KHGiQc6DREJo0/dppeqbo8Oh1VdIqnWz+ag+8ML6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Xmzjpod21e6Cbz4kt7krDw3PSKbJIqoBQQasfgfdzH0=; b=FLnsmrU3b/QBBbmHZ3FUouMr5nacQm7ZhrTFLo1L+8VsfrBpnmLVoAksdVrpZ/PPkIvlZpnGnBzxQbwnQDrOKGod2PipBuqTKOJR3aEIi3M8hDNZjj3LHsHkbmAX9xIo82L8TwhFVzAvq1YURknLETBu/UbLkCgrT7V2ll5GEMq6Ht4LKB+up8VNcFAvCrGWx4XR25S7rEI8Dknsg9uMLYl/wFBQTEISqpcaTd/t+sAvSVRTCBHD8B5FogbOvsCgvIglk/Osxln+cbpdyDlbSJ8fUbLXpmMMCDRUab7DhYAenA+8H/n88AePc5gLOH/QlZzl0+9U4yMZeSUFtUjdVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DB9PR04MB8107.eurprd04.prod.outlook.com (2603:10a6:10:243::20) by VI1PR04MB6014.eurprd04.prod.outlook.com (2603:10a6:803:c9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.17; Fri, 20 May 2022 11:38:06 +0000 Received: from DB9PR04MB8107.eurprd04.prod.outlook.com ([fe80::40a2:1b77:8319:a7fa]) by DB9PR04MB8107.eurprd04.prod.outlook.com ([fe80::40a2:1b77:8319:a7fa%5]) with mapi id 15.20.5273.016; Fri, 20 May 2022 11:38:06 +0000 From: Shung-Hsi Yu To: Shung-Hsi Yu , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org CC: Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Subject: [PATCH bpf-next 4/4] selftests/bpf: add reason of rejection in ld_imm64 Date: Fri, 20 May 2022 19:37:28 +0800 Message-ID: <20220520113728.12708-5-shung-hsi.yu@suse.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220520113728.12708-1-shung-hsi.yu@suse.com> References: <20220520113728.12708-1-shung-hsi.yu@suse.com> X-ClientProxiedBy: AM5PR0502CA0010.eurprd05.prod.outlook.com (2603:10a6:203:91::20) To DB9PR04MB8107.eurprd04.prod.outlook.com (2603:10a6:10:243::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1f51714-7f93-4ca1-63d0-08da3a5534e1 X-MS-TrafficTypeDiagnostic: VI1PR04MB6014:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3HDc22kyX/23JRo+VeW6sX8hz01WC2XlEhzFUZ5+uTPAVUuR7b3l/hvrqTCAQLALlezN9/CDan9eh8qCvZh/CUMOqCwkxm3784vcvMl1aJgNAgdAfd6KmRBiOUXtqAePr+ZoG5ohLTuMlqOBgVW2yreGcLODa19paKMwC0Q20oawS8MwYd/COuGTIOSSDscMPnKzpApfqnPmg5RDBGZcfd0blCwvgi++vnzgXONiNnHsa9x7tbrC67Bhzm+YwCQLGHlvtqLZSvivsNiw5waXS96sLTKcoNvTlx1f5BTuL0JmU8vNoQpprD5h+CNgq1mACPQPCJC3E3ktBl4tnxM0pT4igjRfu11Fe/Fj/uCoeejrgq2aj1xEQ/M+0kOaPKv0uwweJSjGjl87uINc9jq7WeWchDannPXbJW5+N3BGlZ9n9tHAoZOtu0NbNUJAZJBywo9LSPQv2+q250OZKUjqW0Wj1E41qZ6GB3JxSYvxOAP3tIMjtiSkTtlNsInRpb/wzGX0r2RhzVaUu5fuRGsP7uEjDouu0zoY9RfcoYs5T5jIQoz+iQ5Svcrv8OKoz412Wl0jKFs6umHYJoF8/3HNTGF6Ozh0adXfIjuCos/1XMt5/yodOw87XlAYK1x9tJOG+4/YEPc9lilTXBoxkcYkbw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB8107.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(508600001)(5660300002)(38100700002)(36756003)(66476007)(8936002)(66556008)(66946007)(7416002)(8676002)(86362001)(4326008)(186003)(6486002)(83380400001)(1076003)(2616005)(26005)(2906002)(316002)(54906003)(6512007)(6666004)(6506007);DIR:OUT;SFP:1101; X-MS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ey/uuUEDC9ukFq3++2Fg+uSDoZSH18m2swoovwHeFzWgP0bARF+cztVUgAISSAnX28+zQQE9KvCj/PGpLCdC4Lp0WR9YTfh4Mrz7+ls0FVkQt1BxjNkW9ngcDEQ3Hs9PSmsm64TbK9UIsgTIsSexEJ6u2okcX9yEP80KXESJP6jdyo00HV2qYbNHwYxYkRTffWwTHyYDgHL4K5QJxIAZMCAqAvE1aw+GlhEVS6+9Kyq1GAg54gNbZPsQXuKOg5yznrjhiLUQCgJon9jAycYb5K9++arJMSyvPC4tycpcqMy90MueELrZ8s7rCZ3/6juWmDN9bn+d6NLraPb90QLlH8vkU6CWyRyQ5KXuzXDiG8pTCSe9bomb8OxtPwv5HUFkm6S3ImxVE1en0NhjKQDXbRnZrGsEN9le0Lz5HiJXwABnW5y9YNpay6UyuWQsK3NQizXWzFx2P2V7ShETa2tP6Tf5haiZv/v2AT56yoOVUEG3ZcxLUFpjv8RwtjuZX9GDZY6w7LTXlye7oyVXqWej+SOh4W9K2ucQBUBJadAIhpO4zUYJ2nMm2c4G4uNAZpZnMZBkI2chfUQdfBSaCx/fyI4aQQktzAXgb9JcjV9+Rfvrr+tsmZY8x3/k1Xekdb0yZVRoCSb8xnDhB//YNqAcHbEKu/Zbcsu7+mQBBz11Le84SfRU1WT4X5QgMe01Q+Cnh55sWHRMQ13ZSaihelwNWA== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1f51714-7f93-4ca1-63d0-08da3a5534e1 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB8107.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2022 11:38:06.1101 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: K6aHrWjv2aPSAzCmP6OGJK2/r52hPVIny4FIJNq56hKMhFzPpJtN9uDtE51+wl93kC2Eah1eWcV7/plD5PWQpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6014 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org It may not be immediately clear why that ld_imm64 test cases are rejected, especially for test1 and test2 where JMP to the 2nd instruction of BPF_LD_IMM64 is performed. Add brief explaination of why each test case in verifier/ld_imm64.c should be rejected. Signed-off-by: Shung-Hsi Yu --- .../testing/selftests/bpf/verifier/ld_imm64.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/verifier/ld_imm64.c b/tools/testing/selftests/bpf/verifier/ld_imm64.c index f9297900cea6..021312641aaf 100644 --- a/tools/testing/selftests/bpf/verifier/ld_imm64.c +++ b/tools/testing/selftests/bpf/verifier/ld_imm64.c @@ -1,5 +1,6 @@ +/* Note: BPF_LD_IMM64 is composed of two instructions of class BPF_LD */ { - "test1 ld_imm64", + "test1 ld_imm64: reject JMP to 2nd instruction of BPF_LD_IMM64", .insns = { BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 1), BPF_LD_IMM64(BPF_REG_0, 0), @@ -14,7 +15,7 @@ .result = REJECT, }, { - "test2 ld_imm64", + "test2 ld_imm64: reject JMP to 2nd instruction of BPF_LD_IMM64", .insns = { BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 1), BPF_LD_IMM64(BPF_REG_0, 0), @@ -28,7 +29,7 @@ .result = REJECT, }, { - "test3 ld_imm64", + "test3 ld_imm64: reject incomplete BPF_LD_IMM64 instruction", .insns = { BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 1), BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0), @@ -42,7 +43,7 @@ .result = REJECT, }, { - "test4 ld_imm64", + "test4 ld_imm64: reject incomplete BPF_LD_IMM64 instruction", .insns = { BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0), BPF_EXIT_INSN(), @@ -70,7 +71,7 @@ .retval = 1, }, { - "test8 ld_imm64", + "test8 ld_imm64: reject 1st off!=0", .insns = { BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 1, 1), BPF_RAW_INSN(0, 0, 0, 0, 1), @@ -80,7 +81,7 @@ .result = REJECT, }, { - "test9 ld_imm64", + "test9 ld_imm64: reject 2nd off!=0", .insns = { BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1), BPF_RAW_INSN(0, 0, 0, 1, 1), @@ -90,7 +91,7 @@ .result = REJECT, }, { - "test10 ld_imm64", + "test10 ld_imm64: reject 2nd dst_reg!=0", .insns = { BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1), BPF_RAW_INSN(0, BPF_REG_1, 0, 0, 1), @@ -100,7 +101,7 @@ .result = REJECT, }, { - "test11 ld_imm64", + "test11 ld_imm64: reject 2nd src_reg!=0", .insns = { BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1), BPF_RAW_INSN(0, 0, BPF_REG_1, 0, 1), @@ -113,6 +114,7 @@ "test12 ld_imm64", .insns = { BPF_MOV64_IMM(BPF_REG_1, 0), + /* BPF_REG_1 is interpreted as BPF_PSEUDO_MAP_FD */ BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1), BPF_RAW_INSN(0, 0, 0, 0, 0), BPF_EXIT_INSN(), @@ -121,7 +123,7 @@ .result = REJECT, }, { - "test13 ld_imm64", + "test13 ld_imm64: 2nd src_reg!=0", .insns = { BPF_MOV64_IMM(BPF_REG_1, 0), BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),