Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp666854pxb; Tue, 5 Apr 2022 18:00:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPDwzwscyt6DSQZUw3XYQKIH5pmblwEy46G4Wucqv9PlvF0dC+aHiJqDgsdbEMhMgJOQtA X-Received: by 2002:a05:6402:26c8:b0:419:2e54:9262 with SMTP id x8-20020a05640226c800b004192e549262mr6205921edd.61.1649206802069; Tue, 05 Apr 2022 18:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206802; cv=none; d=google.com; s=arc-20160816; b=jLEVg/sjD2R387mQYHAsiwkSOQezssgxoVErUr11pnxWV2ZBp0LH/+9mtGBERRDcww djoxMIbcMkur5XEDr4JRKtT3Uoj/hFDANMxqxQUXxtAS/wWD2DCrkyJ5NbiXn9Fq2HMd cqvM6F2ZPzDSUEc4ZO2TeMRlT7DNiX3jqY+XcDpSxINpULqakgmFgXGYnlRxU2DjR4ZS GzITQJIX8w1e6BA4wMEO17v3+S/0xP1IrsCkLTQb8W3pSfroH4rWnmoSFjLpmthz4Kvm 2ZlutLOd4/vBLHNYolb5DSVRvdepngu+USUC6UM1ptnDBSCnhzr5J4+cLXyHFb6+z/Ae +Yvg== 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=GYiF06Qq+dfiI8MOpTYlYJI5MqqtsY+9WAKOPQoMdF8=; b=OYJQYVQR6zfEQtTWCrVS5pp35X2zDiPRSUUqmGyTfC1H3kPldVGSZYrkXQujlKSC5f AUVoRezz2Uua9mjFRDKweBUG3irbRC8e4TAzChMgZqrZm3+U3EoodwyidaQu1hoEbiDm xjIsku6wGCN0fiIAo3avvlTMJYBMOMmGPNo35uiURR+6MbiY0E1/pxFdtU31+pjj1Kaj d14Pi6RieT/yaPL9M4cZ8QjRhuLTolP5mIO8Yq2zf9+F0heqv0nHFVRYMqVdQ1crukU0 JS+qze+W3/vgLQJlWZSs1z7TI8HJe9uREhZ7hZc2wTTVnC9srY0otusI/oXEW//R60jw 2+KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=drkf5XnC; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020a1709061b0700b006e7fe2ddfcdsi4604511ejg.428.2022.04.05.17.59.36; Tue, 05 Apr 2022 18:00:02 -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=@linuxfoundation.org header.s=korg header.b=drkf5XnC; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385337AbiDEMcd (ORCPT + 99 others); Tue, 5 Apr 2022 08:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236039AbiDEI7o (ORCPT ); Tue, 5 Apr 2022 04:59:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C9BD255AD; Tue, 5 Apr 2022 01:53:26 -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 686A961003; Tue, 5 Apr 2022 08:53:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F464C385A1; Tue, 5 Apr 2022 08:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148804; bh=H9YrjQMoX5Tf6SSBBMB7UlmEDAvSUYEDqi5RKX3WyUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=drkf5XnCtuu/i0gsjDOculEyi+1o2DbOlrtuiYLSxRZ1BVo+R34bRnkMSLTJXG2Pz lQAm91b3xnda71JxELX7yekbhxCQCQ7lS1q3twzGtpmA0ApL6PqTCwhEa0Mvr3ku7h tDJxg6lJ+4Oxfn1HNrznByckURrggCQUlthQYNr0= 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.16 0487/1017] libbpf: Fix signedness bug in btf_dump_array_data() Date: Tue, 5 Apr 2022 09:23:20 +0200 Message-Id: <20220405070408.754584448@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 5cae71600631..700dfd362c4a 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -1839,14 +1839,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