Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3628600pxb; Mon, 24 Jan 2022 13:54:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOW3ozlBDj6iryZIVJAJS7InunJNZluCpiXI52Mva2CFHEbLKYNfhm2sPr4QDqnKvY7aGV X-Received: by 2002:a17:90b:3508:: with SMTP id ls8mr286398pjb.216.1643061270550; Mon, 24 Jan 2022 13:54:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061270; cv=none; d=google.com; s=arc-20160816; b=NEiaANfsZVGbQpAgYsjid5b2HRaPKJO63oY/WqqGqXvXsYxoubDHKv2HElJdOmkyeN n4Peni8vt/H349RRNpdiCFeeM5ZksTMQQrW9zQt1JIZLUbYJbV7/M1PRxho25N7Ol3qO ehsJOSIZPe5OwUz5qgaopGFfJ+nIr3ebEf2tMavcFllMzCi0yvow2zc6YBwZ5cLl+PRx xDZMorDJTg4K8AV5O9sGFhh4bDCzX4iUI4UYVl0VnrHNqIwVT5aOkihwqn/yoqSR6fI0 +ULJ9W1tdedHSwwqFQIr1iFS9cOo8QpJXzaXmVdWSeSAKHMCg6ADKi7nIuhlH8/1Uted YgWA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KaZZpm17XMv2DPMD7ATvaDMHSoRqvrIEIfH2+Xr/APQ=; b=E5kqPvsM/X2L30aAWBgzl98bo2XnMVuzUEH1HeCQ3Vd+Nmi1Zjq/X4BT4fJKTiZry0 x+Umj3z6Io0RUma3O6U9aqUYuBlr0Ui2cahX05BEHrHhHYRQCUIjnZyjSJHDvwTtY3BB 7kbHvKKIxmLekzzpDv/i9kim4Zb3tizIO2FIzdyYTl6QqoaLc7JIQctciBjb3wxndRWq O8t3iC4hatjomtFuWs3TRjjJn8iiemBtEy+caEUmTpDGfdAvhXdgNFwR1O6vI/LTJLKe 9Llr/imMlvUqRHA9krzw83X6tg+EFHMUILMmABAvA/k+R12CUfvU8o1hjyr3rt5+3Ics 2FEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rqfL0qM2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g191si14472790pgc.494.2022.01.24.13.54.16; Mon, 24 Jan 2022 13:54:30 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rqfL0qM2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1457204AbiAXVlL (ORCPT + 99 others); Mon, 24 Jan 2022 16:41:11 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:55816 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1445470AbiAXVDi (ORCPT ); Mon, 24 Jan 2022 16:03:38 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B9A00612E9; Mon, 24 Jan 2022 21:03:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E62AC340E8; Mon, 24 Jan 2022 21:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058211; bh=O3Mm+E9WAl3ZojjyLaoVq+63RC1/Ltx/9eK75UIsuGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rqfL0qM2s8lvJAHeyrUShdDeuotW/8dr+AK/6a6KDmVP/vwJgnzYi95s7S0aCAWVK Tvt7AuF/k+41bKnXOzRSqw6XWRkExLglMnx30RAlyNaGmwQOcgQJtAInOitgV2PAb+ xY3eOjTMwWozBW4a8k1BAmrJvfFqN+msMqs4bNio= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexei Starovoitov , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.16 0215/1039] libbpf: Clean gen_loaders attach kind. Date: Mon, 24 Jan 2022 19:33:24 +0100 Message-Id: <20220124184132.566260527@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexei Starovoitov [ Upstream commit 19250f5fc0c283892a61f3abf9d65e6325f63897 ] The gen_loader has to clear attach_kind otherwise the programs without attach_btf_id will fail load if they follow programs with attach_btf_id. Fixes: 67234743736a ("libbpf: Generate loader program out of BPF ELF file.") Signed-off-by: Alexei Starovoitov Signed-off-by: Andrii Nakryiko Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20211201181040.23337-12-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- tools/lib/bpf/gen_loader.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/gen_loader.c b/tools/lib/bpf/gen_loader.c index 5aad39e92a7a5..4ac65afc99e50 100644 --- a/tools/lib/bpf/gen_loader.c +++ b/tools/lib/bpf/gen_loader.c @@ -993,9 +993,11 @@ void bpf_gen__prog_load(struct bpf_gen *gen, debug_ret(gen, "prog_load %s insn_cnt %d", attr.prog_name, attr.insn_cnt); /* successful or not, close btf module FDs used in extern ksyms and attach_btf_obj_fd */ cleanup_relos(gen, insns); - if (gen->attach_kind) + if (gen->attach_kind) { emit_sys_close_blob(gen, attr_field(prog_load_attr, attach_btf_obj_fd)); + gen->attach_kind = 0; + } emit_check_err(gen); /* remember prog_fd in the stack, if successful */ emit(gen, BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_7, -- 2.34.1