From patchwork Tue Feb 8 07:15:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12738243 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D2F3C433EF for ; Tue, 8 Feb 2022 07:16:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238671AbiBHHQc (ORCPT ); Tue, 8 Feb 2022 02:16:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231494AbiBHHQb (ORCPT ); Tue, 8 Feb 2022 02:16:31 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F0D7C0401F1; Mon, 7 Feb 2022 23:16:30 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2186M4FQ020227; Tue, 8 Feb 2022 07:16:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : content-type : mime-version; s=corp-2021-07-09; bh=9IUHIz/MJtbdj8GPXFb6j1FuJC6T0Q0UHR8KdT/rHyQ=; b=U5lJdrRa4We60xmTRPRloFaWotXtWF8oAsEFcqtfgvz0H16KOdga9zJQbFttU4l8o+Ed r8ncgcjk6F/PzPfeF+xBTCZmJZVo/UvrFyvEzKUWNHrcYNiaD6G1z1iERNEQa6QL1XLh OKtRjbLILcY8JaQUANlUjPWqC5ZeBXUXIsZLe4+LRIobxObHCxRmDPyVyD09X5c8Mq88 XK6ICO8rKiuq0Jasp2jOizMVJ6e+NcSLsj+40xBi8iW2QGVSTAVNQtOO1WnxhTIrhMcE 6z2ZGlu8pfB0o+pLOcEIP5VesSjQ+g98q7+dA1v+II8YblOKP/CmqDbfnTd6RNObSZGq 9A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e366wsxn5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:16:08 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 2187BuPU093651; Tue, 8 Feb 2022 07:16:07 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2105.outbound.protection.outlook.com [104.47.55.105]) by userp3030.oracle.com with ESMTP id 3e1ebyk6an-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:16:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aTZih34O/uimJIp7lybT+aacgVekho0gUXS/jxFKtvrj2OuFQ5p9P7UWvtImR5LsuhPdRemSzKNciBsf9hGMruno5y/hT2PiWSgwG+ielhdgg8u5c1sg6tpGbHyg0g+Q1xP8FE/Kptoj+L9YJwX7csgYu5D6hU/klPC3v3O7anqgIC/gDw/ELfh0wiuFwFNMYGs8JS+8T4Hl8iRHTJ+942jS04Kz5sELSGGbguNj1aca/U/Cst2l2bMJHsoVChs0a4d9f+EXJMLrEhT1cmZj2JRhY0jQJN53F8f2HVgSiArDvWX6Vvaa5yaAiIUemCKpSLBWL6wwQmHervZ6ju5PxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9IUHIz/MJtbdj8GPXFb6j1FuJC6T0Q0UHR8KdT/rHyQ=; b=hInCMAh6bspwHVkrHDLpNAQ6wyF6EJzH/1z7YlxYx72PmwjgDW1eRt62JdEMoUT8aOE2r7XCXAD0mtH427B6WR2aeRNxsBakKu8sWqVYjEKufJypV4ztqI8hLF7rodjba+xfCsZqvJLTeV9NLiyr+VGrslla3w5ku2CgIqdzhbJPYvsmzdvfFYCY+Pr/BtMs6eVmZzF+EVwPRkUZ4Kz1o0ho20Hf0M4N3WYKb7acHN5rENwOeFi8ylLWlsLs561fc1UwdbO7WlWUwW8wJvzIdfKeAZ6Knzv22of4+zSvb4S+9OJ9OYF4odqFNoOSGzb1eGWqOl6D6KBGlA1BQEWxIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9IUHIz/MJtbdj8GPXFb6j1FuJC6T0Q0UHR8KdT/rHyQ=; b=JClcj/WLIGZXRSLS+4f9MrFnH9pWX1lmADtjFbwZLyUTCIt86jjSdEtm5KIhS899FGH0/7BPXPu24addgbNiw8Nw3S2/Ogqojre6ce8uFXWo9cUoaaLwNCV3ATuOJhfUJbSB5JF0pLS17nDS8C7KvxKIkOz2XaP0UTguz7ycWuE= Received: from MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) by CY4PR10MB1269.namprd10.prod.outlook.com (2603:10b6:910:5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Tue, 8 Feb 2022 07:16:04 +0000 Received: from MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::e5a5:8f49:7ec4:b7b8]) by MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::e5a5:8f49:7ec4:b7b8%5]) with mapi id 15.20.4951.018; Tue, 8 Feb 2022 07:16:04 +0000 Date: Tue, 8 Feb 2022 10:15:52 +0300 From: Dan Carpenter To: Alexei Starovoitov , Alan Maguire Cc: Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , bpf@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] libbpf: Fix signedness bug in btf_dump_array_data() Message-ID: <20220208071552.GB10495@kili> Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-ClientProxiedBy: AM0PR02CA0124.eurprd02.prod.outlook.com (2603:10a6:20b:28c::21) To MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c22c9a1a-22b3-412c-d2b9-08d9ead2de47 X-MS-TrafficTypeDiagnostic: CY4PR10MB1269:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1z+zlUaJSowqiJ3yKdcv27ZrFSpZIyYZeyXxr1X/nxezC090UGJHZQob8U6YZWTGuPCD+DMdwa+Du8sminzdr9how0Mv6hgBMPGYCQ0IpP5nGQATVcY9tsVtJtAPyjX/0aEWRhdVMp7R2QEn2DNmDnrHoLCn1fsS4ckzfLKibYn+9d/G28dL65iUktNT2mo9DtbzUHLt/WYRsUULR/rL5CfjzfilVgkCSjfw3LCjVNqRWSnXixXBrLwYxYLisLQKTnKLyh/Xd6+SJwCw9Koj49DYwdbwQtW/yvUe4hxffUe2IeG9VIZlyXoGliWslxezG4d8RIIKTb6gOfBPfFlPIaP332e6tar9t3F+UrP/RX45NvccmPrKJQzb1F9CH98o1R0BkOoZCMH6WBPYA/lHS0QxQxvH/XnUfIriVbInHOezomDlSj4EskSiVpC45pRoV4usIGzn9YgHnW7jkrGxdeiiewHsldHvTIdNm23OlwZlRMo2A91qFMJLT/g7A6olkwME+ouJcKEKKcyWpkGgRXLRY/yxOOb3C1m6i2/pu8RJBjafgfsB3WoQmaJLlEn03gVJdYTw3F/J814rLZC736RhWwgVXw+GFtqRh4NOeZCV1H+DfSZVc0e1rnpR3BXCtF7xU+plpVyrymuIPFbkSA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2365.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(7916004)(366004)(6636002)(1076003)(33716001)(38100700002)(2906002)(33656002)(44832011)(186003)(7416002)(86362001)(316002)(6486002)(83380400001)(8936002)(8676002)(66476007)(5660300002)(66556008)(66946007)(54906003)(508600001)(110136005)(52116002)(6506007)(6512007)(6666004)(4326008)(9686003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F5X6321PDOD2+/gWDd/qAdfGaKCqe5DNTNeblKtYkrIKdQRSRRIcq8xnb2hBlahzhv4HC56OEJ/U6onfHKRL3aP1mvTxqFHL9h3HglYjapWpXydk1tZhKfFEAINMQ5tjJ4jwoWFB/HQa7mOtgbpNR5FOfDGyPW/39iTlTbc0DStCUbpMeD9bbYWxFM5D/wqfrcItNgVBc5KtdtVjsu/mZi0fcj1tQs7u3CSdxfdlZhJMeedIhgT6awVjILOrB87xPUPvz8lzykVC4KIgFSnZgViHJna3YhhPKyA7LZD3ltZA0iUrhWzniYcv3im+CUPxxj4gAO4NPWc+DQU0vOy4Vfuw16hLzlp3IJZ/iIJw4LiHbF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owyNOoul1+uY8lFkgzBkE9vc4JVQzOHFvF+5b2Z9VyEVxjDN/lZqitMNvppq18yyPvoU7zjOmaup62Kr9TT7A4xj2rKUwAgR7ZBSEA/u9E9VR4sTICbViNw9r97pZG8u16zZATwaVKv7CFB3JHQjB9VglpVRdbmkE96J5uv8cAIM5gJe57Ku+mU9xfSfRjwjmX+CklQlb18MexvpaeQBefGVk4p/Sn0aeHf4FFmVkWpWATNeIrAqm7Uku9tIlGKQz9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c22c9a1a-22b3-412c-d2b9-08d9ead2de47 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2365.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 07:16:04.4010 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: S35jtOpIXbnNITGlR7eGalVrQByRVJyO0poTmgpkA5WK50EStqbxlvnciN7IOOjeFT1+AW5rkKvS4niyQHLKb3gNRWjSV5TTTJEtYW6JqO8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1269 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10251 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080038 X-Proofpoint-GUID: lyHKAIWJPes3Uh0YKglVovXBNh8RG44F X-Proofpoint-ORIG-GUID: lyHKAIWJPes3Uh0YKglVovXBNh8RG44F Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net 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 Acked-by: Yonghong Song --- 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 b9a3260c83cb..55aed9e398c3 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -1861,14 +1861,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; }