Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp577944rwl; Fri, 7 Apr 2023 01:56:44 -0700 (PDT) X-Google-Smtp-Source: AKy350aRgr9iHoMtN2dFUuzYoq63cHoCLmgPoVphHKlHi17Pge/7EC5oveZocMVVjywEJn8xSxrH X-Received: by 2002:a17:906:190d:b0:948:dfb5:50df with SMTP id a13-20020a170906190d00b00948dfb550dfmr1742064eje.8.1680857804510; Fri, 07 Apr 2023 01:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680857804; cv=none; d=google.com; s=arc-20160816; b=V2YRLPt0GszF37ha/nuAOd2OJeybzN3HcdeGwUIqrKOaMR55+IBrumZAeUAcla3KY3 BzjcN8WB8WBpOcXj1PLPUQAf7al+TbkMTIDcDCGunTT6bkrD+enhGKVn2QAPmyt2a4F6 ayTK7Vt9B81NnuV8xrFTQSXUcMgmvTxEHrA4yH4xAAbB1oegM09g2MjYpBuNV+DfqjPH SS9zdM2ahDAFg/xJnjAuvcoU0N7PCks7LnVGf/IZ5ih/F34AmBrFHeJqmYHMzyf2ji0F /u1VU+27Y6Gdf8+P5XkdEqCbdyZCXtTenjH4fCQhyNUfQsHEiqSgbpYX0N2+LG9EuUEF qWLg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vmjzgy6aRksKW2xHyWe1W6xO2vj0DerqrAUjE2I1iOw=; b=OnGQwzlooWun1YPevEh3x0HUwML/DvO/J8PgoZWXb4EaBxU9GGQBxpjJDjtfI1g1uc thCxLJLrZPbDXzBkZMx1ffZ3x9kL1S9BSoh/uSxJS6YzDuUkFEjkbCqhcuUIculAp+O9 r3OpWyayqiHQV9qicBioFO6he11AutjXi0oIYYxZ0WhYjI49O+K1E9a/9Dq4+D8RvgL2 p/1wgNg9ZZ8qEFHcyMifYRfgQYCwMp8rN0Yq6KTVh6lOJYyS+KjyjhVBHnT8iFd1+kgA 8LR28/51ijPf7piHL/PsUayBG6XZZH10C6Y+Qku/BJh2Yf0NmpGfyXembQHzqDU4Zy/I NU+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=D7NDS8dK; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l17-20020a170906645100b00932e989991bsi2145927ejn.643.2023.04.07.01.56.19; Fri, 07 Apr 2023 01:56:44 -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; dkim=pass header.i=@bytedance.com header.s=google header.b=D7NDS8dK; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240322AbjDGIrh (ORCPT + 99 others); Fri, 7 Apr 2023 04:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240393AbjDGIrZ (ORCPT ); Fri, 7 Apr 2023 04:47:25 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C4EA9748 for ; Fri, 7 Apr 2023 01:47:02 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id q15-20020a17090a2dcf00b0023efab0e3bfso882420pjm.3 for ; Fri, 07 Apr 2023 01:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1680857222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vmjzgy6aRksKW2xHyWe1W6xO2vj0DerqrAUjE2I1iOw=; b=D7NDS8dKRGJ65goddWwG9CqMSD3PDMJMp6enwZTFKi+nO6FFMuwSsw3m2T1n4vkPTp HkBrY14lcDLfUQfG6oOO3I3J/ATOHIxtuQwDTK8NSbPMlyOWnMaCSSfM/reVGS3C4ttc bzPXlQzGp4stv7e6glHHV8KwpORktD/97cn9Wzm/gqXlf+gh/gRLJ+Dw1RN1j6q1cCve X+wDp9Sdrju9gE1WCxz+tzrYRLE15l8MnNSwbycno2B7aahP8IQTXhUgvNkjHqf0tijZ qR98ylGmO1iEGInPNMoNvnt6B1+mz36qWZrtzVjSoKkAP29j064oU6uTrzrR9RJBVFTF PXRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680857222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vmjzgy6aRksKW2xHyWe1W6xO2vj0DerqrAUjE2I1iOw=; b=sDUUj0erBNKV3Ug15kBqRWP5PG0nSLwcDQvGRoHzA885XRa67Rl4iGCubuh7btWD2L DtDVOdm103ty01wRtkn/FWW5xm1zO3EunYrrvqK7EFc/vL8qwQVy3TK1AVhywzBPjbA1 7Z9AqdEJWp7rrP18/zd+LLOtM9UNbgGx8X16B12YJnA9M4adVjYW3ylnwkrjtVpLkpHA j4qA7rZojO9IuaqS7bKbpC9vVmUCirxkGt2rBsdE2RanhW8kIABLgdi5ZB9+/aeSeyI0 vHjmw4FO8n72iP7lQPb2owzNTIWCW+XlF6ciLNb0ptWaepfcjEW29uNYTsmA+HPiL3X4 Jlbw== X-Gm-Message-State: AAQBX9fqAhXbxzHUOyPNmhUlAt2cXYP59h/P2FUn3uzTRrqT0f9LGOoF uEtX0T0De6eNgvs7SDjk7cWyAw== X-Received: by 2002:a17:90b:1bd1:b0:23c:fef0:d441 with SMTP id oa17-20020a17090b1bd100b0023cfef0d441mr1578447pjb.33.1680857221702; Fri, 07 Apr 2023 01:47:01 -0700 (PDT) Received: from C02F52LSML85.bytedance.net ([139.177.225.238]) by smtp.gmail.com with ESMTPSA id s13-20020a17090a5d0d00b0023b3d80c76csm2333676pji.4.2023.04.07.01.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 01:47:01 -0700 (PDT) From: Feng zhou To: martin.lau@linux.dev, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mykolal@fb.com, shuah@kernel.org Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, yangzhenze@bytedance.com, wangdongdong.6@bytedance.com, zhouchengming@bytedance.com, zhoufeng.zf@bytedance.com Subject: [PATCH v2 2/2] selftests/bpf: Add test to access u32 ptr argument in tracing program Date: Fri, 7 Apr 2023 16:46:08 +0800 Message-Id: <20230407084608.62296-3-zhoufeng.zf@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20230407084608.62296-1-zhoufeng.zf@bytedance.com> References: <20230407084608.62296-1-zhoufeng.zf@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 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: Feng Zhou Adding verifier test for accessing u32 pointer argument in tracing programs. The test program loads 1nd argument of bpf_fentry_test9 function which is u32 pointer and checks that verifier allows that. Co-developed-by: Chengming Zhou Signed-off-by: Chengming Zhou Signed-off-by: Feng Zhou --- net/bpf/test_run.c | 8 +++++++- .../testing/selftests/bpf/verifier/btf_ctx_access.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index f1652f5fbd2e..68bdfc041a7b 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -541,6 +541,11 @@ int noinline bpf_fentry_test8(struct bpf_fentry_test_t *arg) return (long)arg->a; } +__bpf_kfunc u32 bpf_fentry_test9(u32 *a) +{ + return *a; +} + __bpf_kfunc int bpf_modify_return_test(int a, int *b) { *b += 1; @@ -855,7 +860,8 @@ int bpf_prog_test_run_tracing(struct bpf_prog *prog, bpf_fentry_test5(11, (void *)12, 13, 14, 15) != 65 || bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111 || bpf_fentry_test7((struct bpf_fentry_test_t *)0) != 0 || - bpf_fentry_test8(&arg) != 0) + bpf_fentry_test8(&arg) != 0 || + bpf_fentry_test9(&retval) != 0) goto out; break; case BPF_MODIFY_RETURN: diff --git a/tools/testing/selftests/bpf/verifier/btf_ctx_access.c b/tools/testing/selftests/bpf/verifier/btf_ctx_access.c index 6340db6b46dc..0484d3de040d 100644 --- a/tools/testing/selftests/bpf/verifier/btf_ctx_access.c +++ b/tools/testing/selftests/bpf/verifier/btf_ctx_access.c @@ -10,3 +10,16 @@ .expected_attach_type = BPF_TRACE_FENTRY, .kfunc = "bpf_modify_return_test", }, + +{ + "btf_ctx_access u32 pointer accept", + .insns = { + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, 0), /* load 1nd argument value (u32 pointer) */ + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, + .result = ACCEPT, + .prog_type = BPF_PROG_TYPE_TRACING, + .expected_attach_type = BPF_TRACE_FENTRY, + .kfunc = "bpf_fentry_test9", +}, -- 2.20.1