Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp5127976pxb; Tue, 28 Sep 2021 11:05:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc2O76chcykM9ETPxBgO6Yucbch9bPBZkQuJg++V8hhuY1+IZfEtCLX4Y8y6Ds8I9u0UTK X-Received: by 2002:a17:906:b10d:: with SMTP id u13mr8581346ejy.135.1632852359353; Tue, 28 Sep 2021 11:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632852359; cv=none; d=google.com; s=arc-20160816; b=yJSSes5QwT2auI3L16Dyv5T/55znfhP0l8XRh5Uv4FSMgHVi9vaami7RtLXbTS6NHt 9hnHv2cxzFzKSZ7Jq2dP7M0v24vqsCX0YJY2Xew0mTtxLgYcz4HIUfUz7Xrp+m8usKD0 mUvHJ+4CYA0DE6ir2r+8NLyGYkYcGVKCtfBxPRAH/1VGY+B7dMsA515nsf3LvWAbZrH4 nvXGkUXQfFtnC7MJtKlWnyFRmiH6E8KlTFid7lc0ISPuc46ooH61cDNWXIzELRdwJUU8 jJ79zGJs0DP7Pp9KbjeXuRB+9r8D/Lf61eWr8yAoYdx0m5berEh7SKL56GY9uA292WXw rPmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=g5T99dSi8dQg7Ihj73OPFwSxUQ8IoNsRLiLCuXcEeJA=; b=WaYFn4fXns0aEq8L1W2wvUuiPlkLM4ejgL+dQQGxtj7/XSMDQoWXrmXAyyZlSUy67B hM0CE9aWBY4ALe/z8jAmC8nyTF2W88frKX6WE9URuF0Ux3uxCsM6Fb7hYTS9zrr8BQqp mNnglwd7Sal+XoF/RGbfFOcC7mBn+oXRh1lgxuMuRJYzOD5JGFVfSGndSpyVtH7/+5R2 8LunJGQptzNSlgd+bw/ZtRqWsRR6zwcP1l8/5okwT1jNVyoJsmeIB5MXpq496d3/LcHh XEe0oBEC12iWWTa9CFSMnO2nejCLzVU5p4eoNdiQuoQv1Uc2M/sbX9yPVmXkNV+3Bx3v 7BGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=feRVhuQr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds7si8196956ejc.58.2021.09.28.11.05.34; Tue, 28 Sep 2021 11:05:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=feRVhuQr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242167AbhI1SEz (ORCPT + 99 others); Tue, 28 Sep 2021 14:04:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236453AbhI1SEz (ORCPT ); Tue, 28 Sep 2021 14:04:55 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44258C06161C; Tue, 28 Sep 2021 11:03:15 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id y28so95315094lfb.0; Tue, 28 Sep 2021 11:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=g5T99dSi8dQg7Ihj73OPFwSxUQ8IoNsRLiLCuXcEeJA=; b=feRVhuQrnABDU9OFTZis+TLDGYP84edOeNQwPxivaL2HddIGcbpZgooKDI0Myzrt03 wUbZeRozpkRjFGrM6X5lvQYP+XdHxaVWJ20/+OluttkOaOGnP7I85JdpEU2ex2+Z0BH2 rd1DKjv7E2gpRL9aFZhjmi+T16hu+zw8NtNObzyhIw/qU/CXPps48W3R9aR0kcpiGA7N 3BwGHNq7Y0rH9oerCZP1MUHSgPnyLGfq5j1uqJBcTdkviPg1XK6zcKuo+d0OcnYEWouT eeHTRd6c0DSKS5qcnR0UckSV13kACdQTlyqh+6VT/YBsE9zGRcTBo9GgwViW5MQFpfe+ DZxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g5T99dSi8dQg7Ihj73OPFwSxUQ8IoNsRLiLCuXcEeJA=; b=7Brh9abHOdPTpAypkZeAt/TMJ8UWcYvjPlaFZ2OBn4knQ/G38bANuH9pnVUy8quRSm Ve348552/imIVIoEtp5DHZzKQf0yCBz3Mu/AhpEIDwHKTbfnKu8rfSyYTL0pBa7KvEHE KuZNYSdQOPVtquKwkLDcR+C40lWC29kEPkMGT0q0MVnq9zdWpOqP45fA6HwsQwN+4uxf jH8MhDnmXU15Y3iMrGwFyiFP7ogGitwylpYD+aea+htWYQHVeqTQHY0/ucJiHG6Yds5T WY19PHMqVU2CQVoVgRtOpYuH2bAbJDE54UvEC4brzgvDK0Sw2DcZKI1hqS17ok+jjafb SNbQ== X-Gm-Message-State: AOAM530uCiFH2VAzak6RjD/BxoL0i5imAcXFOh4mq+izCDK0+g145DJh xsXSdBEjT6Ju5zOhOgyuZEM6areF0M4= X-Received: by 2002:ac2:420d:: with SMTP id y13mr4466243lfh.527.1632852193604; Tue, 28 Sep 2021 11:03:13 -0700 (PDT) Received: from kari-VirtualBox (85-23-89-224.bb.dnainternet.fi. [85.23.89.224]) by smtp.gmail.com with ESMTPSA id i8sm1986394lfb.227.2021.09.28.11.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 11:03:13 -0700 (PDT) Date: Tue, 28 Sep 2021 21:03:11 +0300 From: Kari Argillander To: Konstantin Komarov Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 2/3] fs/ntfs3: Reject mount if boot's cluster size < media sector size Message-ID: <20210928180311.eu5pldpiuio7ssah@kari-VirtualBox> References: <228cbe20-87d6-4020-55fb-111d22e2b487@paragon-software.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <228cbe20-87d6-4020-55fb-111d22e2b487@paragon-software.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 08:18:07PM +0300, Konstantin Komarov wrote: > If we continue to work in this case, then we can corrupt fs. > Remember to add fixes tag. > Signed-off-by: Konstantin Komarov > --- > fs/ntfs3/super.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c > index aff90f70e7bf..890c5d9d6d60 100644 > --- a/fs/ntfs3/super.c > +++ b/fs/ntfs3/super.c > @@ -763,9 +763,20 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size, > sbi->mft.lbo = mlcn << sbi->cluster_bits; > sbi->mft.lbo2 = mlcn2 << sbi->cluster_bits; > > - if (sbi->cluster_size < sbi->sector_size) > + /* Compare boot's cluster and sector. */ > + if (sbi->cluster_size < boot_sector_size) This should actually be in patch 3/3 as this has nothing to do with bug fix and bug fix is most important thing to be seperated and as you have do be front in the series. After that Reviewed-by: Kari Argillander > goto out; > > + /* Compare boot's cluster and media sector. */ > + if (sbi->cluster_size < sector_size) { > + /* No way to use ntfs_get_block in this case. */ > + ntfs_err( > + sb, > + "Failed to mount 'cause NTFS's cluster size (%u) is less than media sector size (%u)", > + sbi->cluster_size, sector_size); > + goto out; > + } > + > sbi->cluster_mask = sbi->cluster_size - 1; > sbi->cluster_mask_inv = ~(u64)sbi->cluster_mask; > sbi->record_size = record_size = boot->record_size < 0 > -- > 2.33.0 > >