Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3089137pxb; Mon, 4 Apr 2022 07:32:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU2KXMNNSRRiwTDNyB2EtRw0NzFcz7w7XmlVUWtvsaGr/kX/84UoFUhv/P0PsUC5PBg0VY X-Received: by 2002:a17:906:9755:b0:6e4:b9da:2e2a with SMTP id o21-20020a170906975500b006e4b9da2e2amr291895ejy.755.1649082773629; Mon, 04 Apr 2022 07:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649082773; cv=none; d=google.com; s=arc-20160816; b=M2U2peiv8oaBfLdRgoB12XViwULZAyHAXKJIecWXMjqZ0ceL9EuNCHjQ3p6rjNjljq pya7gnkrFpTmdCAtv5eomLan71/M5cmzZ/lHJ1FhGUgdcoZqsf6suclIiuszAzKLAVMR fbZspqiQbdmEuf73fnYf5L/nu74BWlaNi9xO1RtI4HiViqvSdntQ/0l+PIgn5G3zg5z0 iHwAcEBdi7hopUcHztHETxU6r+Xo/uEHSbBZwsmjuH3pOvaW6qLFNDVfsl5EjDRQkQnv NE0Is3Qd66gj7H4/9TusD6oxCFgnlZOGoVj7jpumXi7lI1xvFZjuU96ejbs5nwxLnYnN piZw== 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=yNiMC9MxNAVqib+SZgJ64s5pZC15kZoqX/VkezsKZbU=; b=DJ7Wow5BfvXwV2Hxymjy8ktjuDPPcIjMAQdeC5RWKXD4Nsj6QNy3YtHD07wA+b9cRO UcXWK2IQPYClNeK902jx4/DgFFCsXcO8VvlIJZDJNxSHUKdIIJ1MsJ78GZi54dgvIutE Y/82qLNaTlAGtcPy9s0ITySbWjxYKifJc4T7GlPjz7KX8iIG8ZR9iRboIwcX+yxMv6Zr 3ZNDASfocKIrTYh+uOqAEBciWi6AOEKx3VMd3f22ABBQD0kANGuEwTQGJr23g/WMRYea Z1+1fVyEGqf8QgwZdWSSOLpjM9Kr45IH5lA2vFOzESgQ58I5gOCRcw/aRLi/Mj1L3J5+ 3Q6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=A7WqEwsD; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b25-20020a17090630d900b006e0d34b7dadsi6972789ejb.943.2022.04.04.07.32.25; Mon, 04 Apr 2022 07:32:53 -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=@gmail.com header.s=20210112 header.b=A7WqEwsD; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376834AbiDDAzh (ORCPT + 99 others); Sun, 3 Apr 2022 20:55:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240987AbiDDAzf (ORCPT ); Sun, 3 Apr 2022 20:55:35 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2DEB639B; Sun, 3 Apr 2022 17:53:39 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id y10so7506674pfa.7; Sun, 03 Apr 2022 17:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yNiMC9MxNAVqib+SZgJ64s5pZC15kZoqX/VkezsKZbU=; b=A7WqEwsD/aUvHQ8X6WMd/LHTc2iOpLbQ6RzOtzK+70OO4r0OV1gzSUvIJ/eUBN/kZm LbDrm7jb3wjUd6pK3xKf3Brk2/rfiNQSMcag3JOEunkqcdFrlpV84yDNeZEl6R2p63fX vDenSLEN+t+QqnvXbjtyCT58Orv1T5ldIX3I9XNcELLSe1C+zDQsOX3I3QQeIWOvI1Os OD6IoUwl+jLZA7M6J2+VAr+oB15JkdTZ5m613Uf/MpgHc074HxXytLwVoo1L/36DNMTB IF+B92/88WWTfhi2YE+K0VDHPXA9z3GWoXkIo+qR+dn29G7i/EuOtOpKOJ97vIk7XwsP l7XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yNiMC9MxNAVqib+SZgJ64s5pZC15kZoqX/VkezsKZbU=; b=O+NpRXd8pziBh59mwKT+z+t2ND9VYjQQ93n9BfTdNIELCLmTaBjYR1iDRJ7Uoj70zY 0CdgjoML7pHLNTbLgl3TIaNdWnnOaNQszgyP6ADqaPIo3NeCqWFdcNpHSs1mVJ1IFyqZ p0nLdS4D7olzPkHiVKsMDdOZT1w9lIbdVO8P9y6HfjDlbTRkl842bMFWaIHnsF6XUslU 34b72HblCNd7cWkw+Du1LZg2iAhGYE/86WAxFOEQcDv16cXUQ32bgS1YFE2IPeCqINH+ nMtEZ3kbloPnBYYyXo6ypIRikYQ14WNbaxm5kMvBEgTmYDMwrV96Vz68mruvkTE5coty oBgA== X-Gm-Message-State: AOAM53210pCQ5qOP7eBge3c8aXjNYpROWp8AT/Ku6qBZPGYRAhA2BvPF PAMSEelwcE5q2WpPwMLmGGU= X-Received: by 2002:a05:6a00:1581:b0:4fa:e6d4:c3e6 with SMTP id u1-20020a056a00158100b004fae6d4c3e6mr21250956pfk.84.1649033619443; Sun, 03 Apr 2022 17:53:39 -0700 (PDT) Received: from localhost.localdomain ([223.74.191.143]) by smtp.gmail.com with ESMTPSA id d24-20020a637358000000b003823aefde04sm8658355pgn.86.2022.04.03.17.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 17:53:38 -0700 (PDT) From: Yuntao Wang To: andrii.nakryiko@gmail.com Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, kafai@fb.com, kpsingh@kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, songliubraving@fb.com, toke@redhat.com, yhs@fb.com, ytcoode@gmail.com Subject: [PATCH bpf-next v3] libbpf: Don't return -EINVAL if hdr_len < offsetofend(core_relo_len) Date: Mon, 4 Apr 2022 08:53:20 +0800 Message-Id: <20220404005320.1723055-1-ytcoode@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Since core relos is an optional part of the .BTF.ext ELF section, we should skip parsing it instead of returning -EINVAL if header size is less than offsetofend(struct btf_ext_header, core_relo_len). Signed-off-by: Yuntao Wang --- v1 -> v2: skip core relos if hdr_len < offsetofend(core_relo_len) v2 -> v3: fix comment style tools/lib/bpf/btf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index 1383e26c5d1f..d124e9e533f0 100644 --- a/tools/lib/bpf/btf.c +++ b/tools/lib/bpf/btf.c @@ -2826,10 +2826,8 @@ struct btf_ext *btf_ext__new(const __u8 *data, __u32 size) if (err) goto done; - if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len)) { - err = -EINVAL; - goto done; - } + if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len)) + goto done; /* skip core relos parsing */ err = btf_ext_setup_core_relos(btf_ext); if (err) -- 2.35.1