From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FEE0C433DF for ; Wed, 8 Jul 2020 01:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E34A20774 for ; Wed, 8 Jul 2020 01:54:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="Qw/3Cscq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729289AbgGHByF (ORCPT ); Tue, 7 Jul 2020 21:54:05 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:3840 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728067AbgGHByE (ORCPT ); Tue, 7 Jul 2020 21:54:04 -0400 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0681s4Te031902 for ; Tue, 7 Jul 2020 18:54:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=K+Oo9hwlKMkvex1M4HMNzYaLyUtmW78Tyf9o//cHJi0=; b=Qw/3CscqsR++LppbmDFGAdpxAuC4dvxu1yNNej9yf6d/NP0+/qKPWtpDaAm2S5hQC78L a+VCCDOl05ViiNJfZApND0hGHUr+POgYe8NBZvx3fTsR7soz5T+BMRTVYdkAAyf7ME7r kiEVuNB2h+U6EXh/fwl+pikBC4d6mHhvtX4= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 3239r9mxbb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 07 Jul 2020 18:54:04 -0700 Received: from intmgw005.03.ash8.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:11d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 7 Jul 2020 18:53:23 -0700 Received: by devbig012.ftw2.facebook.com (Postfix, from userid 137359) id AE16F2EC39F5; Tue, 7 Jul 2020 18:53:22 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Andrii Nakryiko Smtp-Origin-Hostname: devbig012.ftw2.facebook.com To: , , , CC: , , Andrii Nakryiko , Matthew Lim Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH bpf-next 1/6] libbpf: make BTF finalization strict Date: Tue, 7 Jul 2020 18:53:13 -0700 Message-ID: <20200708015318.3827358-2-andriin@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200708015318.3827358-1-andriin@fb.com> References: <20200708015318.3827358-1-andriin@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-07_15:2020-07-07,2020-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 suspectscore=25 impostorscore=0 adultscore=0 phishscore=0 mlxlogscore=625 clxscore=1015 priorityscore=1501 lowpriorityscore=0 spamscore=0 malwarescore=0 mlxscore=0 cotscore=-2147483648 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007080010 X-FB-Internal: deliver Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org With valid ELF and valid BTF, there is no reason (apart from bugs) why BT= F finalization should fail. So make it strict and return error if it fails.= This makes CO-RE relocation more reliable, as they are not going to be just silently skipped, if BTF finalization failed. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/libbpf.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 4ea7f4f1a691..f4a1cf7f4873 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -2473,19 +2473,11 @@ static int bpf_object__finalize_btf(struct bpf_ob= ject *obj) return 0; =20 err =3D btf__finalize_data(obj, obj->btf); - if (!err) - return 0; - - pr_warn("Error finalizing %s: %d.\n", BTF_ELF_SEC, err); - btf__free(obj->btf); - obj->btf =3D NULL; - btf_ext__free(obj->btf_ext); - obj->btf_ext =3D NULL; - - if (libbpf_needs_btf(obj)) { - pr_warn("BTF is required, but is missing or corrupted.\n"); - return -ENOENT; + if (err) { + pr_warn("Error finalizing %s: %d.\n", BTF_ELF_SEC, err); + return err; } + return 0; } =20 --=20 2.24.1