Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2062419imm; Mon, 28 May 2018 00:30:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrcru5xukDPfnHhYAxFsgTXDzDN/qazZQfqgt1etLcOjIRrbuZRBPxdDYslp9y+aIu7KOCB X-Received: by 2002:a17:902:a703:: with SMTP id w3-v6mr12858495plq.111.1527492601416; Mon, 28 May 2018 00:30:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527492601; cv=none; d=google.com; s=arc-20160816; b=bi70hunIqpK4qynmifj2kIzRdqMFRpnba7iLWNX3q78odSGcsojIaZYgHnNG+1XE6V OW4CrKcRRObEpvA0uQPV3mvY9wx3LFWK2eSKf2xJPEpIHZKzTOtCNfwOIkTug7TsHIrr TJwGoSGDV0DvbldMuOUJPGpj2TPHDi8jfTCQnnxdimeSYRarXGDii4Wax5BMWzCAIqI2 QCWdChW1ZdF98U6wcqtbyLJ36Xr6gDO/QxVKv5y83n3MuTmCsDY/h/6LEPMwAC1oXaOd 5gp+K/zKIIDmhikg4JdvIFvo/NJzr39d1QNVfsZYwmvjHQZK0AUezLz6vPv+YOHfyHMw u3oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=tgHraNz6+AOhuYXj6YZeskPWCcbxYg1X9Xb5HI496a0=; b=0poo4GCSOuiM3qrkEpMrxGPKth8MFhm6LiR4zXEBrRgA0BAh5xeY3RD+qQfiEC6fG8 hEryfWOg1uLGfa4y5PRjph4P836+B9Rbpb2PP3mHz5PJ78EHjxeLC/S0BqctCg2JMIAr p6vrNbuq4CldzMVrnVZyfBr16uv3KXWyFEpv18lGM4Y/xIoB3kuHQwLu7DtencSrbj+H OCx9JZ1MnfPUaglIxot8K38xV/2xe3iBAKrgQapH7+cbIvr2Mh3H/bumiBBkNwYWKoYP swNs1r+jL0u0uqvNg55ZzF6MZThLx3jyn3etmPA94nffI8ip8R2dPShCJvocIcTHJ5Wh Xinw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k2-v6si29670078plt.374.2018.05.28.00.29.44; Mon, 28 May 2018 00:30:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753708AbeE1H3e (ORCPT + 99 others); Mon, 28 May 2018 03:29:34 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:40816 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753302AbeE1H3d (ORCPT ); Mon, 28 May 2018 03:29:33 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 4380B6B1F325C; Mon, 28 May 2018 15:29:30 +0800 (CST) Received: from [127.0.0.1] (10.134.22.195) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.382.0; Mon, 28 May 2018 15:29:23 +0800 Subject: Re: [PATCH] f2fs-tools: fix overflow bug of start_sector when computing zone_align_start_offset To: Yunlong Song , , , CC: , , , , , References: <1527322189-114752-1-git-send-email-yunlong.song@huawei.com> From: Chao Yu Message-ID: Date: Mon, 28 May 2018 15:29:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1527322189-114752-1-git-send-email-yunlong.song@huawei.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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"? 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", >