Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp938468pxb; Wed, 6 Apr 2022 04:51:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaLAzJ4bY6boxNRpkA7/bxmC8MY7BiQVt69yRgdCzCNDl4vPTjsFm+bBRYdYzAC9WDeMtn X-Received: by 2002:a17:90b:3a92:b0:1c6:64a5:a403 with SMTP id om18-20020a17090b3a9200b001c664a5a403mr9383570pjb.89.1649245898128; Wed, 06 Apr 2022 04:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649245898; cv=none; d=google.com; s=arc-20160816; b=B5y19puSB7GEUXEgB5JMlCGbYB9+lS2gnevwcD4IfJDgUhMpWtkVidfWGHkTHNOHIC RPeN8s2ys4491UaliilZZxaBV9k5SEJZDPj91RkFm5dEbUgI9NQLvu0H57b6+mXN1uZE 1xsqKEi0pjbC4iYdMBqaVZbJHEnHHgcx5Q/QEW/LZ1+4j8mzsR5BnVClnrrgqw5XymBq LL97xtVW8nha98or7k4LSbeDC9H58GpKS/DicZUvhCkLL8xd8Bdafa5QFak16p5J7w+t cXsPWbwjrTU4VYooofrE7yaNuo9xUq01OH9+q9sNV5vAewZVYnC5JlZBm+or+BRLjdss NyQQ== 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=SM1i6Ki6RB0aoOtsz/F5LVHpBXAHm/Q8rggDBbK1LDA=; b=A0HVp+oZ+d6saIhxYVoTlcUEGJ8E9lZxrB/F9Mi9uyJElG1WBIBwriQr5JenuWlnLG 4zmpvck36iBD0xzIO1KAc4FZrzAuUgncyOwJq3dEzEQd9qqYvWOvCpDJQI4Z54Q05Yjv KCyuy2hP5QMI/NXK9T3OAmVFdN//YEjLVOK1I2MXl8gDd/WVtiwqNjJ+0EAQnvCflQp9 j6CYXXS/pOyKCLfPyBQkYPCQ5KJcyScxjBxLiN0jRC09ySEEv8BkmaCatUvBXTfoXtoI MkzaJEEHe5ynjvkfEDEJTpBm7ec9kjsu4W0TRl+ZSXgr6TpzTHFuvH50WtqpZDTcrZfp x+Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RvMd4SR+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d1-20020a170902cec100b001569c5e2d6bsi10400425plg.164.2022.04.06.04.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:51:38 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RvMd4SR+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 367CC46BC80; Wed, 6 Apr 2022 03:11:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1582804AbiDEXts (ORCPT + 99 others); Tue, 5 Apr 2022 19:49:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348985AbiDEJsv (ORCPT ); Tue, 5 Apr 2022 05:48:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F132C64E1; Tue, 5 Apr 2022 02:38:41 -0700 (PDT) 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 8E6906164D; Tue, 5 Apr 2022 09:38:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99305C385A0; Tue, 5 Apr 2022 09:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151521; bh=y8AOTC6sTdb6/nebPxGC0Z5oRFc9dGBNvGBNOkLEvWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RvMd4SR+EnR2plUr6j941YRKlYJU22YI6QVbzOrJiQTepqVklByyVzbhU3xzrpq3B nnngN5Sfu+1HU7hIErm7SY+uy++FzhWS7Ii1Cy9GJkRdFJKsQh3eiElOG1RXCNw7hB wXBEDDg7ym6hC5HbF11IYUjR0Yusg0+BJnA8KwtY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Daniel Borkmann , Yonghong Song , Sasha Levin Subject: [PATCH 5.15 444/913] libbpf: Fix signedness bug in btf_dump_array_data() Date: Tue, 5 Apr 2022 09:25:06 +0200 Message-Id: <20220405070353.154997066@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 From: Dan Carpenter [ Upstream commit 4172843ed4a38f97084032f74f07b2037b5da3a6 ] The btf__resolve_size() function returns negative error codes so "elem_size" must be signed for the error handling to work. Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data") Signed-off-by: Dan Carpenter Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20220208071552.GB10495@kili Signed-off-by: Sasha Levin --- tools/lib/bpf/btf_dump.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c index 8c9325802793..c1182dd94677 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -1829,14 +1829,15 @@ static int btf_dump_array_data(struct btf_dump *d, { const struct btf_array *array = btf_array(t); const struct btf_type *elem_type; - __u32 i, elem_size = 0, elem_type_id; + __u32 i, elem_type_id; + __s64 elem_size; bool is_array_member; elem_type_id = array->type; elem_type = skip_mods_and_typedefs(d->btf, elem_type_id, NULL); elem_size = btf__resolve_size(d->btf, elem_type_id); if (elem_size <= 0) { - pr_warn("unexpected elem size %d for array type [%u]\n", elem_size, id); + pr_warn("unexpected elem size %lld for array type [%u]\n", elem_size, id); return -EINVAL; } -- 2.34.1