Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4009899imm; Tue, 29 May 2018 19:34:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ8Mtu20zkUXLrWblw86pg1FmmE9Dhqq9qo/pljdcba/egRC1/wErOkjIij4ASgmqgU8gPE X-Received: by 2002:a17:902:6503:: with SMTP id b3-v6mr940243plk.147.1527647684680; Tue, 29 May 2018 19:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527647684; cv=none; d=google.com; s=arc-20160816; b=j1w0P/xSSBN+yo3KzF3+b7b0mzXcLDmOV3+xN9MtUUKQ5aaAEfjWYT2qcRPhv10Rcd aiCKgvlzr7jQd4VSFUWNVdAvvsEaEk+fAMP2XhUICG6rUhAHQo18N5IsJlVEpgfO7ivd 9w1Yto+q1DUxdLCdko3k+CYRmdhmjX95PJJhqtkp48TG02DfQoSLNM4VDnkiXNJ3vwwA tSQKy5V6pmbWBNuTwQSsoME1n5/nxjkMFu9HM9dQH3gSqN7wVPZ9H1W+Ghr4RYDcfdU1 U+cErcBs/m/6KYzv34l9slg9xG3p5NVlQ2207XsrB27enKk8ZnL6/tncuu176rRGBV/9 h6cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=ppPzPPLLbrD9bEa2oHvlZBgJkdXlBXv+Q6MnYwS6/PA=; b=L7LDb1MZsJTcBMRgPt3inm5OuFMBcJEAzW4HibNL3bCUQOnjqvzaN+PCrET64QJSkf 6L+2MRObrL3j1r92mwZ+PIG1FnZt4npc7qytEbscCMVkrV7nlyCObgsnHa/N0yWa9HLW rw6gk70VPSq3zFDehbSNt89bhpetmhZY8exR0CAy5xPm3zIVG+gbCAx1/DzAtAkxRBqy bTI2cecVrOU1fp7RMSDB9+F1XP+IGl1OPBOTc+MPgELopIpXSQQmQIyv+0+Ln58prVrJ Ne/3wwahDbaSk5A69fAw1sp9mYhL0l6u9peFYs5eFxXBg7XwOxnt2Zrz5Sg1ao7UebaS M0eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lakt/Mkg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1-v6si25891936pgr.30.2018.05.29.19.34.29; Tue, 29 May 2018 19:34:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lakt/Mkg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1754031AbeE3CeB (ORCPT + 99 others); Tue, 29 May 2018 22:34:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:43854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750821AbeE3Cd7 (ORCPT ); Tue, 29 May 2018 22:33:59 -0400 Received: from localhost (unknown [104.132.1.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A211D20880; Wed, 30 May 2018 02:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527647638; bh=cHDAFOX9h0wN0WKERfj+opv0IQKmpcj+62KgeBswhmI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Lakt/MkgtA3bc6rQSD6pX5aTRuieS9oXlsTe7YHElqOoLlHemEF3QFWpByw17+i4W ANpidBYl5f8tE7gUyd/QtJqbct/t2gszPV3wBloSEGt1AwWjCH2yKhrdVh/2intMu3 xaR+RtnGwSrrwEtYXYAkcRGseYEU88s+fYKQER1o= Date: Tue, 29 May 2018 19:33:57 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Yunlong Song , chao@kernel.org, yunlong.song@icloud.com, miaoxie@huawei.com, bintian.wang@huawei.com, shengyong1@huawei.com, heyunlei@huawei.com, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] f2fs-tools: fix overflow bug of start_sector when computing zone_align_start_offset Message-ID: <20180530023357.GB39056@jaegeuk-macbookpro.roam.corp.google.com> References: <1527322189-114752-1-git-send-email-yunlong.song@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/28, Chao Yu wrote: > On 2018/5/26 16:09, Yunlong Song wrote: > > zone_align_start_offset should be u64, but config.start_sector is u32, > > so it may be overflow when computing zone_align_start_offset. > > Could you rebase this patch on top of "f2fs-tools: fix to match with the > start_sector"? Yes, please. I updated dev-test. :P > > Thanks, > > > > > Signed-off-by: Yunlong Song > > --- > > fsck/resize.c | 7 ++++--- > > mkfs/f2fs_format.c | 4 ++-- > > 2 files changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/fsck/resize.c b/fsck/resize.c > > index d285dd7..8ac7d45 100644 > > --- a/fsck/resize.c > > +++ b/fsck/resize.c > > @@ -11,7 +11,8 @@ > > > > static int get_new_sb(struct f2fs_super_block *sb) > > { > > - u_int32_t zone_size_bytes, zone_align_start_offset; > > + u_int32_t zone_size_bytes; > > + u_int64_t zone_align_start_offset; > > u_int32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa; > > u_int32_t sit_segments, nat_segments, diff, total_meta_segments; > > u_int32_t total_valid_blks_available; > > @@ -27,10 +28,10 @@ static int get_new_sb(struct f2fs_super_block *sb) > > > > zone_size_bytes = segment_size_bytes * segs_per_zone; > > zone_align_start_offset = > > - (c.start_sector * c.sector_size + > > + ((u_int64_t) c.start_sector * c.sector_size + > > 2 * F2FS_BLKSIZE + zone_size_bytes - 1) / > > zone_size_bytes * zone_size_bytes - > > - c.start_sector * c.sector_size; > > + (u_int64_t) c.start_sector * c.sector_size; > > > > set_sb(segment_count, (c.target_sectors * c.sector_size - > > zone_align_start_offset) / segment_size_bytes / > > diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c > > index 0a99a77..f045e23 100644 > > --- a/mkfs/f2fs_format.c > > +++ b/mkfs/f2fs_format.c > > @@ -212,10 +212,10 @@ static int f2fs_prepare_super_block(void) > > set_sb(block_count, c.total_sectors >> log_sectors_per_block); > > > > zone_align_start_offset = > > - (c.start_sector * c.sector_size + > > + ((u_int64_t) c.start_sector * c.sector_size + > > 2 * F2FS_BLKSIZE + zone_size_bytes - 1) / > > zone_size_bytes * zone_size_bytes - > > - c.start_sector * c.sector_size; > > + (u_int64_t) c.start_sector * c.sector_size; > > > > if (c.start_sector % c.sectors_per_blk) { > > MSG(1, "\t%s: Align start sector number to the page unit\n", > >