From patchwork Wed Feb 1 07:13:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 51201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp242290dyf; Tue, 31 Jan 2023 23:22:16 -0800 (PST) X-Google-Smtp-Source: AK7set/my6i7Sp+UTB85HcqxH1chr5/26hFfvoCszCG6JFED+OppZOWCN7ZnMaPdwfYQdhHwbaI1 X-Received: by 2002:a17:90a:35d:b0:229:f4e3:9586 with SMTP id 29-20020a17090a035d00b00229f4e39586mr1305570pjf.1.1675236136150; Tue, 31 Jan 2023 23:22:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675236136; cv=none; d=google.com; s=arc-20160816; b=MvbE30dALto9OIG1s+U62dDkLjy/aah0tTNsLd5E2ldu10Ixfs+FyJxLcRbld6zUq+ K1RAcJevmKpo4mB3Dzj+TDiHj1XFBkjV2rHbvH9hiAlFCKiLoEFsXzdHm4dwjWAlfXTU 3qaSeDqe22jUD+si9RUUsQ8ja3xAoR+j3cD9iZ0pSIK66HOwfxITiVE4pSSVpXe/hSFv KEWABeFubVuKKqoPDLh+uWpdwtSHxjDjKAZe/ORJYcbt12fOQDwZmNiDsLvEH9xHK8BM BhNFM2M2PNLVIxJ9Ym7uvdRRPtq527zPiuVeCf05q88ZdgzMjR2wb2amyXbDHRMvpEFS MQ5Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=4BmlzaxYuvz6yK8Z6bcg8GUmZ6rvSFskLQ6yKMJuJi8=; b=ymzPdG7B8uUULyrii/eTpxGnJPd6Jlw/EN9Fp+cAYXS+AFQD2LKb/da8z9L3butdg+ g1wJg5jdO4rHi3dGOly/8tddC3zP9/D2nxhN6CiHUiDYwUlMLbylmHIYjBbTMT98VcoZ xV5Ex3+8jqwtPRhAKpIdJTg0RzyDJEtyzQEEqMS/mVKH/iUo/yIMWi9/UPIfjnOlM3MS iN/moq4UG51TaD1zFCZ7VrgiJhuBCKtl65wtiI4H2ezTTpCL5wcJF6huaoiwrhRrCIGd 0UQEYLSbed/C83l/MLFdYdTlLplsSLRSG9E8KEdEY8j38T8nDMV5ESEKr1PDGZPtGoT0 3Cdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mz3312IU; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a63714f000000b004d056225b6fsi17509627pgn.811.2023.01.31.23.22.03; Tue, 31 Jan 2023 23:22:16 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=Mz3312IU; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231754AbjBAHNW (ORCPT + 99 others); Wed, 1 Feb 2023 02:13:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbjBAHNU (ORCPT ); Wed, 1 Feb 2023 02:13:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B191BCDDD for ; Tue, 31 Jan 2023 23:13:17 -0800 (PST) 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 4D1B86145B for ; Wed, 1 Feb 2023 07:13:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22D8AC433A7; Wed, 1 Feb 2023 07:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675235596; bh=UPrLvL4ctKw2Zf8x33aGj+iLuYJwq7287ZPxq8Zg168=; h=From:To:Cc:Subject:Date:From; b=Mz3312IUQ5/0tcPHhFquBbNjEDv/3z4S5zZO3oQz4G39WhdyHktBotvzo5lQtiaNS obp/n6yQ3QCQW+IjyxrC5ukCBpxgpnn3cAU36QQA6DzjXcj68m3JpBFOP1ztVLrhpO 6DUFzKA7pXJi7c+qx2ezUaHCEybW5jtkxdrRHYVBWlOvPrb/1KHJ8j1M+inlIcA5rM NHBhTEUi7D+mLe1Q43Qrq+wBYPItJfNFXqjhT/F44MTx6axLHoGV1hec4pDjao4eUV AHPDcebmiulhVFwOayux8GwWpiaYpoVxjkaQmjeGrkBqIsGY0Dc4/3QN/0+g6a1IcH NZa6Mm7gBCCyQ== From: Arnd Bergmann To: Andrey Ryabinin , Andrew Morton , Kuan-Ying Lee Cc: Arnd Bergmann , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Marco Elver , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] kasan: use %zd format for printing size_t Date: Wed, 1 Feb 2023 08:13:04 +0100 Message-Id: <20230201071312.2224452-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756612406865486586?= X-GMAIL-MSGID: =?utf-8?q?1756612406865486586?= From: Arnd Bergmann The size_t type depends on the architecture, so %lu does not work on most 32-bit ones: In file included from include/kunit/assert.h:13, from include/kunit/test.h:12, from mm/kasan/report.c:12: mm/kasan/report.c: In function 'describe_object_addr': include/linux/kern_levels.h:5:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=] mm/kasan/report.c:270:9: note: in expansion of macro 'pr_err' 270 | pr_err("The buggy address is located %d bytes %s of\n" | ^~~~~~ Fixes: 0e301731f558 ("kasan: infer allocation size by scanning metadata") Signed-off-by: Arnd Bergmann Reviewed-by: Randy Dunlap Tested-by: Randy Dunlap Reviewed-by: Andrey Konovalov --- mm/kasan/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index e0492124e90a..89078f912827 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -268,7 +268,7 @@ static void describe_object_addr(const void *addr, struct kasan_report_info *inf } pr_err("The buggy address is located %d bytes %s of\n" - " %s%lu-byte region [%px, %px)\n", + " %s%zu-byte region [%px, %px)\n", rel_bytes, rel_type, region_state, info->alloc_size, (void *)object_addr, (void *)(object_addr + info->alloc_size)); }