Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp117025pxb; Wed, 1 Sep 2021 23:41:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy59GGkTIYsduIIG1jiQHWaesRDVpvsvB1Ls7jYuUGFQR49GS31KN1YprSle5alc5z6y2GF X-Received: by 2002:aa7:c70c:: with SMTP id i12mr1999219edq.256.1630564875233; Wed, 01 Sep 2021 23:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630564875; cv=none; d=google.com; s=arc-20160816; b=wH37b9UEcKurRFZFb39mV2x6bTRud53wnlnQx/3V1j292QmQo7ZroArNxGX1t/XxqA 6UXFhsDERVbMouilrpbzKgpWs18nOPcNJgISLNPAU+OHDI1a0yfEuW7LBshv6ilikER8 jll1yUFzEWLDFw4BmOJL1wWsQ7jbNB+15bn3gQGctlaFxARk1iD29ojxio+sszqJdeDH +EWKdt0lL6VWEMlqmvOtIPDltbkZf+xDzOrQvH5ZAz5kXFavGT3iouNUZ9Mg4QbOoaEJ t5dsbJRY5y5F9sAuG5C296VoLjISriC4t053qsDUO9789EAd9SWRqI+oVLkq6GSLfEVe Ku8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=OKx+4zujPGdQsFHolH2LtAgY6xTIoecXoU+5vZFWyCE=; b=HXFaVglIQBDZRhxIajlXx5/9Pmxplb6TP9mA1E0pxieUrI9f0wRAx1HvpH4sCrQpmD 2qxggV9Zuzou3hqPc5kWm5A6Gh5INJU7B8sbLCzSPDdat57KmMb4PZ1GD3h+tlSi+crY a4b3pxo8LgLVJ+3bvATtcI2pD6uz+NZPo4HPz/eE2FLdIVYdY58cA3gqKubRcHiqlQOH DV7/ejZ5xgur6jAYVxpTb9CUBg6Z2BEE+31oz6B6rNJhpzrFd6i+XSRuD2iWZDbs7vLt NMpW1gvWzk+hLFxU+PbqoQ2X1VRDXjqKUueVxzg+hSBMkC8pIwsvUAOf46tl3U6CvYix edzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si988961ejy.710.2021.09.01.23.40.50; Wed, 01 Sep 2021 23:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242358AbhIBGio (ORCPT + 99 others); Thu, 2 Sep 2021 02:38:44 -0400 Received: from smtp23.cstnet.cn ([159.226.251.23]:59916 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241529AbhIBGin (ORCPT ); Thu, 2 Sep 2021 02:38:43 -0400 Received: from localhost.localdomain (unknown [124.16.138.128]) by APP-03 (Coremail) with SMTP id rQCowABHyo0pcTBhUXPEAA--.41173S2; Thu, 02 Sep 2021 14:37:29 +0800 (CST) From: jiasheng To: linux-kernel@vger.kernel.org Cc: jiasheng Subject: [PATCH] bpf: Add env_type_is_resolved() in front of env_stack_push() in btf_resolve() Date: Thu, 2 Sep 2021 06:37:28 +0000 Message-Id: <1630564648-552423-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: rQCowABHyo0pcTBhUXPEAA--.41173S2 X-Coremail-Antispam: 1UD129KBjvdXoWruw4UKr4fArWUKw48uw4fuFg_yoWkArg_K3 W8uF1rGwsxKFsaya1jvw4furW2k3yYqFn7Za1aqFs8G3s8WF15Jrn8Xas3JrsrGrWkKrZF vFZ8G3s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-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have found that in the complied files env_stack_push() appear more than 10 times, and under at least 90% circumstances that env_type_is_resolved() and env_stack_push() appear in pairs. For example, they appear together in the btf_modifier_resolve() of the file complie from 'kernel/bpf/btf.c'. But we have found that in the btf_resolve(), there is only env_stack_push() instead of the pair. Therefore, we consider that the env_type_is_resolved() might be forgotten. Signed-off-by: jiasheng --- kernel/bpf/btf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index f982a9f0..454c249 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -4002,7 +4002,8 @@ static int btf_resolve(struct btf_verifier_env *env, int err = 0; env->resolve_mode = RESOLVE_TBD; - env_stack_push(env, t, type_id); + if (env_type_is_resolved(env, type_id)) + env_stack_push(env, t, type_id); while (!err && (v = env_stack_peak(env))) { env->log_type_id = v->type_id; err = btf_type_ops(v->t)->resolve(env, v); -- 2.7.4