Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7820124rwl; Thu, 23 Mar 2023 09:03:34 -0700 (PDT) X-Google-Smtp-Source: AK7set/NGaA1fegNro1i/6bsTh7JFlcUJ1zT7T/ve32TUi5DPcqTPLFbRgZq5EmOLvSqsCZItYQU X-Received: by 2002:a62:18c4:0:b0:625:a34a:89fd with SMTP id 187-20020a6218c4000000b00625a34a89fdmr7804363pfy.16.1679587414573; Thu, 23 Mar 2023 09:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679587414; cv=none; d=google.com; s=arc-20160816; b=veyixqaP07Cskpm+YI2MLbGuDthWb42NFvb/g5IzHLsLolHBhg4vJhiStEb/QaPZP9 0diaYZ7RQmZVjDA+rcWscoUCjQBI5+NHRFL2uprmcG5QbQXxZ2B1pD+iTVmiIZpwZ7lt SzuNn2BHBWOazPD7seUhqDwDZqFtLlW4OaqK7PuWTHss9efeV3+pZG2JaZGA9PuTTJPH b7wvm+evkX/05bioLS3P2qmRRrqeZ/p6lCcK74Dmn1ww1ixPgL+vCqT4v8GKWw2k9VC9 nWc249oCIpHp5VXzRY02N5Qwl5kci3/Qcl0aSIToIAUSAPqXU/7+pFbFoR8ayf73M4RK R7UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=EEMZ8jeTKT28tC1QJo+TQ7bc6XQc5AGlP54XpQhmtSE=; b=xnI/dhN/4ZknV5gwM1iVwtASchi0hnngvZKBXZGyOxCdZoTR/q0/oacNi5DcpDKvLm OWrsQ5sbvGdoY+NicfUj8Q6koOdkoxJean7eOZrAU+udRykVEtQtFYWf4sFUTsZBTup1 C1Abdz9DrQmqSLXVjl6S2RiWBCLI216gbvU/daTIuornRM+Ey9QNKA0FpFpFWEQwSnAi gAx0uZF8faqAkmjtbb1DhKAn/SOr9B14DPWg2dowNriLsvBXfchqWM8PzWc03PNNFa76 cGMSIrkrG24xhuRDSxnc/x9KZ+fGZABUC1SItyBew+1DrO6UH5XsK4MhWRPCG6lIflLV BzVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o6-20020a056a00214600b006254bb74922si15766380pfk.328.2023.03.23.09.03.15; Thu, 23 Mar 2023 09:03:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232230AbjCWP7g (ORCPT + 99 others); Thu, 23 Mar 2023 11:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbjCWP7e (ORCPT ); Thu, 23 Mar 2023 11:59:34 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55A841026A; Thu, 23 Mar 2023 08:59:33 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Pj95D4BBmz4f3jqM; Thu, 23 Mar 2023 23:59:28 +0800 (CST) Received: from k01.huawei.com (unknown [10.67.174.197]) by APP4 (Coremail) with SMTP id gCh0CgC3aq5fdxxktQW3Fw--.25283S2; Thu, 23 Mar 2023 23:59:29 +0800 (CST) From: Xu Kuohai To: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Subject: [PATCH bpf-next v2 0/2] bpf: add bound tracking for BPF_MOD Date: Fri, 24 Mar 2023 00:58:40 -0400 Message-Id: <20230324045842.729719-1-xukuohai@huaweicloud.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgC3aq5fdxxktQW3Fw--.25283S2 X-Coremail-Antispam: 1UD129KBjvdXoWruFyfKr1UXF1kWrW7Cw47CFg_yoWDtFcEya 93tasYvFnxJFnYqFZakF17WrWqkw4UKFyrJF42qrW7XFn7Jr1FgFs5Gry5Ja4DKFWrXrZ7 JF9xtayvvrnIkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbs8YFVCjjxCrM7AC8VAFwI0_Gr0_Xr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l87I20VAvwVAaII0Ic2I_Grv_XF1l8c AvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWD JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVW0oV Cq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG 8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2js IE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY 1x02628vn2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s 026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_ GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20x vEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280 aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43 ZEXa7IU8L2-5UUUUU== X-CM-SenderInfo: 50xn30hkdlqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=2.5 required=5.0 tests=DATE_IN_FUTURE_12_24, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu Kuohai dst_reg is marked as unknown when BPF_MOD instruction is verified, causing the following bpf prog to be incorrectly rejected. 0: r0 = 0 1: r0 %= 1 // r0 is marked as unknown 2: r1 = 0 3: r1 += 1 4: if r1 < r0 goto pc-2 // verifier concludes the loop is unbounded 5: exit To teach verifier to accept the above prog, this series adds bound tracking for BPF_MOD. v2: - fix build warning reported by kernel test robot [0] - add two more cases and update commit message [0] https://lore.kernel.org/oe-kbuild-all/202303060036.zK05OC5M-lkp@intel.com v1: https://lore.kernel.org/bpf/20230306033119.2634976-1-xukuohai@huaweicloud.com Xu Kuohai (2): bpf: add bound tracking for BPF_MOD selftests/bpf: check if verifier tracks dst_reg bound for BPF_MOD kernel/bpf/verifier.c | 98 ++++++- tools/testing/selftests/bpf/verifier/mod.c | 320 +++++++++++++++++++++ 2 files changed, 413 insertions(+), 5 deletions(-) create mode 100644 tools/testing/selftests/bpf/verifier/mod.c -- 2.30.2