From patchwork Tue May 23 12:27:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: zangyangyang1 X-Patchwork-Id: 13252196 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C87D2C7EE26 for ; Tue, 23 May 2023 12:30:00 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1q1R9K-0008Cb-49; Tue, 23 May 2023 12:29:58 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q1R9I-0008CV-FS for linux-f2fs-devel@lists.sourceforge.net; Tue, 23 May 2023 12:29:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=pe4ze5rVfqtT4ULguXNLs0qPP9ZwsJwEiwoK9dIEiGk=; b=AUuCOyQOMRDFQ4B7h8oT0p0O2/ 4ZJ7JFLDpOCcwZJdKHWcjxABFF1PQdyLTfer5rpkMSSDQIi1wUoX+clShgG5zlBFgI+FjUiygGPwC wHwZRF0W/W4QHw/5a6fzYzM4+wyLmgU1H8/gur72IWsEyDmuZdAq4WPXzdFrbhmqJRcg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pe4ze5rVfqtT4ULguXNLs0qPP9ZwsJwEiwoK9dIEiGk=; b=P/6pxulj+yjVNiB1ooJO70g/v4 CpTjKAagk19VKnZUZ1A6TxGE+93FbH/rkYY7erUTOruCe+s+0tVPg03/B3i/xRX2YBelmca1Dl3j8 /pecg4N4j7E9BSbhquLpJiwxUGhEJVB6WD87sWLa2RnI0xl/HHAD7ZD4PyXb1gRQtlRo=; Received: from outboundhk.mxmail.xiaomi.com ([118.143.206.88]) by sfi-mx-2.v28.lw.sourceforge.com with esmtp (Exim 4.95) id 1q1R9E-0007Ax-NQ for linux-f2fs-devel@lists.sourceforge.net; Tue, 23 May 2023 12:29:56 +0000 X-IronPort-AV: E=Sophos;i="6.00,186,1681142400"; d="scan'208";a="55880734" Received: from hk-mbx11.mioffice.cn (HELO xiaomi.com) ([10.56.21.121]) by outboundhk.mxmail.xiaomi.com with ESMTP; 23 May 2023 20:29:45 +0800 Received: from BJ-MBX12.mioffice.cn (10.237.8.132) by HK-MBX11.mioffice.cn (10.56.21.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 23 May 2023 20:29:44 +0800 Received: from zyy.mioffice.cn (10.237.8.11) by BJ-MBX12.mioffice.cn (10.237.8.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 23 May 2023 20:29:44 +0800 To: Date: Tue, 23 May 2023 20:27:20 +0800 Message-ID: <20230523122720.1628122-1-zangyangyang1@xiaomi.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.237.8.11] X-ClientProxiedBy: BJ-MBX04.mioffice.cn (10.237.8.124) To BJ-MBX12.mioffice.cn (10.237.8.132) X-Headers-End: 1q1R9E-0007Ax-NQ Subject: [f2fs-dev] [PATCH v2] f2fs_io: Fix integer multiplication overflow error in fiemap X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: zangyangyang1 via Linux-f2fs-devel From: zangyangyang1 Reply-To: zangyangyang1 Cc: jaegeuk@kernel.org, zangyangyang1@xiaomi.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net When using fiemap to obtain the block address of files larger than 2GB ((2147483647+1) bytes), an integer multiplication overflow error will occur. This issue is caused by the following code: start = atoi(argv[1]) * F2FS_BLKSIZE; length = atoi(argv[2]) * F2FS_BLKSIZE; Signed-off-by: zangyangyang1 Reviewed-by: Chao Yu --- Changes since v1: - Use type casting --- tools/f2fs_io/f2fs_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.40.1 #/******±¾Óʼþ¼°Æ丽¼þº¬ÓÐСÃ×¹«Ë¾µÄ±£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгöµÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈκÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØй¶¡¢¸´ÖÆ¡¢»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾Óʼþ£¡ This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/# diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c index 5bc0baf..958d684 100644 --- a/tools/f2fs_io/f2fs_io.c +++ b/tools/f2fs_io/f2fs_io.c @@ -809,8 +809,8 @@ static void do_fiemap(int argc, char **argv, const struct cmd_desc *cmd) } memset(fm, 0, sizeof(struct fiemap)); - start = atoi(argv[1]) * F2FS_BLKSIZE; - length = atoi(argv[2]) * F2FS_BLKSIZE; + start = (u64)atoi(argv[1]) * F2FS_BLKSIZE; + length = (u64)atoi(argv[2]) * F2FS_BLKSIZE; fm->fm_start = start; fm->fm_length = length;