Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3655151rwe; Mon, 17 Apr 2023 01:11:09 -0700 (PDT) X-Google-Smtp-Source: AKy350ZkRi19yTfBKntxbRbwGlWjL0D2Uy36a4rU5/txizJXDfeP1RhBc1/NXXbqBZkBdrTlXwIp X-Received: by 2002:a17:903:214c:b0:1a6:c81d:5f4d with SMTP id s12-20020a170903214c00b001a6c81d5f4dmr3860145ple.10.1681719068943; Mon, 17 Apr 2023 01:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681719068; cv=none; d=google.com; s=arc-20160816; b=flVwsChStwsfXtJYMxxNzSC00lY+GkXyDPPFf2Qg4gZJileTykooTA2HcuRL5GWAQ7 22CHKi4ZfpM1ZXHVSCuDU3k7GQpaWVrMqp7OZGon/RvU2lP3Xs0aJKFqpgVg/PZP7N9L Z19P2qWPOSvW/De89C7QxNkLT2WkQPaYO0WaRFC5j/Lx/VpgXX4wVp7GqZD5VNtGeBDZ O1yrtl7HBbUcBazuMoGbeLIQ+fIPXwoa2ld8zLFR47KcXkH+d5P2A4CvDy9yrGIIrNSQ ccBY1h+N+S94dKuWYCjCzntvWDtP6TC3mBDJlf3Y/n6txjSIAxZ19wqBz4TugoLsr007 wS7A== 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=hr7bhkX+Epn2YWYx/+oT337obKjgENzwcgRHzhBp9VI=; b=OC+r2e7/8TDyhhoBWzy3/swfTKCXwZx4S9Oh4fzoLaYgazvrBBszsGgteIhj72gTGw /DZd1e1gTG7c50tcxI7wX610jIL4DurNZjwMaPgxC0ovW24ptb4vuPveJmKivE82Rtf7 lE/1xrSPx43U6e1EepRJr3auv+m/tId8sp91Jy/lx7vB/oxIkUouiY1HynwNZ9v2QmDE QU5e2mORcUTIEHhWgNfkI/g7kn//I8dSmbDa5QBU/FgUunij6PoGHurwMZ/sD7cvutBW Esg68ChlUfoukDK3gI9GEnOcyZf1qZvWBxlyXptVIaT39jFz5Khwb/aaoyn2iRuTTY8a fmXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=bJXY+7hD; 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 bd4-20020a170902830400b001a1ced49c70si10552338plb.369.2023.04.17.01.10.57; Mon, 17 Apr 2023 01:11:08 -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=bJXY+7hD; 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 S230042AbjDQIIN (ORCPT + 99 others); Mon, 17 Apr 2023 04:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbjDQIIL (ORCPT ); Mon, 17 Apr 2023 04:08:11 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B9924C21 for ; Mon, 17 Apr 2023 01:08:10 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id b2-20020a17090a6e0200b002470b249e59so14343099pjk.4 for ; Mon, 17 Apr 2023 01:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1681718889; x=1684310889; 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=hr7bhkX+Epn2YWYx/+oT337obKjgENzwcgRHzhBp9VI=; b=bJXY+7hDuLaSpYXxwM/yztjf06sBYybcq8xuD8cBmDItLAyd9PmLi0XpAUmOy6xHv+ dpbs4n5YrNyNLE6256NVjkOrdAV6ktoGBOmDZ9w7UHcKgAIC3bNX800RYlnF+U6pPF5d m21gfVGUIQGEEs5qowWSv8XTYGM8zmGWtv7OcI8aqDLWt1uQ5wboTfo0EHtda091FaMw 6iUnxdRbHa9aD3jdgBxyNYqLNz1cG0soqrHKFcaTf2LvRmOHyJ/96GhZ3Rzurl4r7P1p jipg6Ig8ym6ndYHYqs4TO55xszkUOh8WKQYAKfRyxwSrUHA7J+aT64DOXYKx+0vk10q/ DqBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681718889; x=1684310889; 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=hr7bhkX+Epn2YWYx/+oT337obKjgENzwcgRHzhBp9VI=; b=ZEICND6007Ybai55tJyxBDEjVGwl5Z4W6uTnxfuaDymvok8IW7Pt7AlS58gyT5dVD3 TjPwgzlH+d68JS9HXBsXk/9fUOmawgqBiKNHNbNoqBdu3z5CEq5jmq83lhAGClZoh49n IGQ49eatHZ7+tkToHBw+ChNPzKarJ1zFnpmeCOUKZknkdS3OgPAUWMcu2B/tgIuPXgOP k+GM2YttZsVc3aXs1bLZUR9idHEmLLa2ZzzOykzlvJW408cTBGMPdNBa9F81YtwkkCyn S++uzEiC7X0eXdA8III590+VilzLXfFTUaU1yG75QinYHtcXM44+QaAVgdyyLO4DvGoc i8Dg== X-Gm-Message-State: AAQBX9cxqgYKoWSKaDZTYE/L+QvdfgzS60c2t1zPdHcZv4bTXYmTv0Q7 kqohMv3eqBvuFP7rK1dyPiVgsUJh2mTlBb3pYGa+TA== X-Received: by 2002:a17:902:db09:b0:19e:6cb9:4c8f with SMTP id m9-20020a170902db0900b0019e6cb94c8fmr15803413plx.41.1681718889687; Mon, 17 Apr 2023 01:08:09 -0700 (PDT) Received: from C02F52LSML85.bytedance.net ([139.177.225.238]) by smtp.gmail.com with ESMTPSA id jc3-20020a17090325c300b0019a97a4324dsm7114135plb.5.2023.04.17.01.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 01:08:09 -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 1/2] bpf: support access variable length array of integer type Date: Mon, 17 Apr 2023 16:07:48 +0800 Message-Id: <20230417080749.39074-2-zhoufeng.zf@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20230417080749.39074-1-zhoufeng.zf@bytedance.com> References: <20230417080749.39074-1-zhoufeng.zf@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 After this commit: bpf: Support variable length array in tracing programs (9c5f8a1008a1) Trace programs can access variable length array, but for structure type. This patch adds support for integer type. Example: Hook load_balance struct sched_domain { ... unsigned long span[]; } The access: sd->span[0]. Co-developed-by: Chengming Zhou Signed-off-by: Chengming Zhou Signed-off-by: Feng Zhou --- kernel/bpf/btf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 027f9f8a3551..a0887ee44e89 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -6157,11 +6157,13 @@ static int btf_struct_walk(struct bpf_verifier_log *log, const struct btf *btf, if (off < moff) goto error; - /* Only allow structure for now, can be relaxed for - * other types later. - */ + /* allow structure and integer */ t = btf_type_skip_modifiers(btf, array_elem->type, NULL); + + if (btf_type_is_int(t)) + return WALK_SCALAR; + if (!btf_type_is_struct(t)) goto error; -- 2.20.1