From patchwork Wed Dec 6 15:08:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4180102vqy; Wed, 6 Dec 2023 07:25:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5kAq9FVvDcXDXYUVBBXHCYQ+ni5S/+3pkFinX+AIRHGnuGSZ7yXH/icbSYiKkGuCbaper X-Received: by 2002:a17:902:7e8e:b0:1d0:6ffd:e2ec with SMTP id z14-20020a1709027e8e00b001d06ffde2ecmr970325pla.134.1701876355410; Wed, 06 Dec 2023 07:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701876355; cv=none; d=google.com; s=arc-20160816; b=BCBBhNOc0yiPjU3FM/KJyK+/XgFOKZ2ixl6std5sIAsNzs5StxbnNuzklUT1s4zU4x 0cE5kddSsMH1GG2WMXJ5fU3LCu9F8/8sVVtDOD/bTynaQ7MuTdlhrA3pnO7MJbO7C0zV 5Ntf7Nq5QFgjxGCkSGA0ZHf7fKWzSaouK6YW9H+ZhJ73o2A7N8WNH0JCmMHwLGB9r6Mk MCTqUZGA37vrLZIAstZSrAO32hScrLT10h5lhkpcNCg6REGqCwlZNXXNC7lXYTJyIBb9 n73IRuQXI3XvviK7MIstDjV323e6egLO8DNvyT2t/rwVu1vLUB7WEQ33knDlTni0k5T8 ++Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=h7CldxQv2S5Mzb+cgzMS8C/4d3oWIhrtzyaVf9z57fs=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=Uha5thnvwph9rIupjBgdxj8e4uQbs9pLD80sR0DRqu7T2CwvVNaFRd5yvH5rH9JRxJ jIgfAzZyaqStY2KuY2ifHIGFoY4S4t7ZXoVR54bAnJHLZVkOhgZ4i+aMM30Crm7OUQ1I SkTEH2Phg/tY7wHqADExJk/Q4/a4j7iLpREAdotnlhKw+hfejVMZBaPQht1aGmge3UeP N+bUG2YAiKyhjusVxFthJQOf3uQzcBinPsT+pZKNYAyTyzD969Mv4j0oeYqDaQR9hInB GnRSUWvEew9NJxMoxCflEmK2nAp/WU/9HP3heQw59xHQE9Ur4hOIJYKF4kDb50A7rxwr r+Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=FtCj3ZeR; dkim=pass header.i=@paragon-software.com header.s=mail header.b=eyslm8PS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ij8-20020a170902ab4800b001d065c68f06si8609270plb.494.2023.12.06.07.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:25:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=FtCj3ZeR; dkim=pass header.i=@paragon-software.com header.s=mail header.b=eyslm8PS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BF8CB8029122; Wed, 6 Dec 2023 07:14:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442523AbjLFPOO (ORCPT + 99 others); Wed, 6 Dec 2023 10:14:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379244AbjLFPOK (ORCPT ); Wed, 6 Dec 2023 10:14:10 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2355DD64; Wed, 6 Dec 2023 07:14:16 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id DCC301D47; Wed, 6 Dec 2023 15:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701874953; bh=h7CldxQv2S5Mzb+cgzMS8C/4d3oWIhrtzyaVf9z57fs=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=FtCj3ZeRaBPZiv12dqOADExR+OT9YeqY3/k6OC2QQKJ9fE5ai7DN/5guAiwZgrx0Y jzP8+1cDoiXU1I2OILGI8oMrFGQ8Mzot78sQq7PJSr+NK9SifuC9zxxEqJPwFMUUQW 5WoniFgJM0xApmStxoud0SP6WIR1lmABVdHpzCw8= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 243202117; Wed, 6 Dec 2023 15:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875337; bh=h7CldxQv2S5Mzb+cgzMS8C/4d3oWIhrtzyaVf9z57fs=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=eyslm8PSDjgl/rJxNS7F5ffPQA97GTxlXUWYf2oWGY5RTCsYMvvFyqCsElJpRYSwz 6npCQYykuV9udtf+8QOPyVk307zBuOQjVyLCP2+qixg9ZdLjMW9bmjegmNrIfmBVN8 0V/6teX8F6muUqbGlKbZHgFBNOh1lspt8A1CwIIE= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:08:56 +0300 Message-ID: <53c3c86f-c816-4747-9262-592c3ddc6660@paragon-software.com> Date: Wed, 6 Dec 2023 18:08:56 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 01/16] fs/ntfs3: Improve alternative boot processing Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:14:28 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784546701212678541 X-GMAIL-MSGID: 1784546701212678541 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/super.c | 35 +++++++++++++++++------------------  1 file changed, 17 insertions(+), 18 deletions(-)      /* Save original dev_size. Used with alternative boot. */ @@ -873,11 +874,11 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,      sbi->volume.blocks = dev_size >> PAGE_SHIFT; -    bh = ntfs_bread(sb, 0); +read_boot: +    bh = ntfs_bread(sb, boot_block);      if (!bh) -        return -EIO; +        return boot_block ? -EINVAL : -EIO; -check_boot:      err = -EINVAL;      /* Corrupted image; do not read OOB */ @@ -1108,26 +1109,24 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,      }  out: -    if (err == -EINVAL && !bh->b_blocknr && dev_size0 > PAGE_SHIFT) { +    brelse(bh); + +    if (err == -EINVAL && !boot_block && dev_size0 > PAGE_SHIFT) {          u32 block_size = min_t(u32, sector_size, PAGE_SIZE);          u64 lbo = dev_size0 - sizeof(*boot); -        /* -          * Try alternative boot (last sector) -         */ -        brelse(bh); - -        sb_set_blocksize(sb, block_size); -        bh = ntfs_bread(sb, lbo >> blksize_bits(block_size)); -        if (!bh) -            return -EINVAL; - +        boot_block = lbo >> blksize_bits(block_size);          boot_off = lbo & (block_size - 1); -        hint = "Alternative boot"; -        dev_size = dev_size0; /* restore original size. */ -        goto check_boot; +        if (boot_block && block_size >= boot_off + sizeof(*boot)) { +            /* +             * Try alternative boot (last sector) +             */ +            sb_set_blocksize(sb, block_size); +            hint = "Alternative boot"; +            dev_size = dev_size0; /* restore original size. */ +            goto read_boot; +        }      } -    brelse(bh);      return err;  } diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 9153dffde950..09d61c6c90aa 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -866,6 +866,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,      u16 fn, ao;      u8 cluster_bits;      u32 boot_off = 0; +    sector_t boot_block = 0;      const char *hint = "Primary boot"; From patchwork Wed Dec 6 15:09:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4168749vqy; Wed, 6 Dec 2023 07:10:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7Ee76Zc6bvCVdMb+mb7UkBL+P5EyWQk6fEjW9VIoGl5B/5ZFg+t9eGZ0FhH1fjCweK9dg X-Received: by 2002:a05:6a20:c19e:b0:18f:97c:8254 with SMTP id bg30-20020a056a20c19e00b0018f097c8254mr1090039pzb.94.1701875400586; Wed, 06 Dec 2023 07:10:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875400; cv=none; d=google.com; s=arc-20160816; b=bIAXZPEBHq4YC/aaqwRMBpxuE0UpJeBZMFRzuuUuJxA6unlgixvKPCPZyj6KfV8n9I JZIsih0JxmSSS4uDo4VSI27jHGbnrKqaFmJQvZ8feeJzOgFgrRk64kFe5En1aIOXlm3l M+VtyuOzBJiNndohbsQNyBztT1J5cYv7R8nN4ES2AD82zXroRkSr0wKL2mQvt/22iMPv bPqmiqBC9/U4ArOpSIBwEnTuH/c6rodKyPyhxOeUow/7MvRprryImJpBedGSwLpp9JhM PI7BEaM8013e2wKXTcAiiQfGrVbk34IkmSSYmweBYURJVm4MlUhP68AHxMIU6GZ4wdGi ORiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=Ifmg2OmIcc1e099M3eAc7+M0D09LHndtu4YB0fZ10AE=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=kG7Gy/Tr3JAxZ4xy25G3JiXpvNKbZLDSOJbdOxSSt77IwE13apLWwO2EzhrVRGnxqr eSYuzeekRJg/daa+h13kX8VYUscnp6d8v/lEOTGsyi7n9swCiqsDJNo5d33JpA0qmOn5 3/DzGjW+FmPnvLJuc7CSN9pur/YOrJI0I0RyJ+p1zS/BYiPPrvaa6CBls9FDIirTKKPq 9TOtjBLcrTYSrS4DC7jvx+n2V86ulPsBcBCHydYxEU14IkKDpvbyoKD3jxS00Vv0cB7i tYj0vI8bFp2uqUeKDcUJTr1fYeRWV591kJ5UqxZpSr2NIJOOB2sqOniTtv759t5vQASh hFVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=CM28fQWf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id h36-20020a63f924000000b005be1955657esi49418pgi.127.2023.12.06.07.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:10:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=CM28fQWf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 74C208030E7E; Wed, 6 Dec 2023 07:09:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442414AbjLFPJm (ORCPT + 99 others); Wed, 6 Dec 2023 10:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442406AbjLFPJl (ORCPT ); Wed, 6 Dec 2023 10:09:41 -0500 X-Greylist: delayed 99 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 06 Dec 2023 07:09:48 PST Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02ADDC6; Wed, 6 Dec 2023 07:09:47 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 75DD71E1A; Wed, 6 Dec 2023 15:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875001; bh=Ifmg2OmIcc1e099M3eAc7+M0D09LHndtu4YB0fZ10AE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=CM28fQWfl2jtqKv/4Q00K5fqN1XehGPo+klnsLEdY+l3HE67RQZYkzBqf6GrkQUfr djhTyaAxCW/vH267eQpmpDRK6Px0x/CmTqlYadmRB8vyT2X9uyiv7/Ivcky6dxEE49 O+rzp55tAH/NRfKemZdi/99Qye5kO0nISMZtbgX8= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:09:45 +0300 Message-ID: Date: Wed, 6 Dec 2023 18:09:45 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 02/16] fs/ntfs3: Modified fix directory element type detection Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:09:51 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545699663998634 X-GMAIL-MSGID: 1784545699663998634 Unfortunately reparse attribute is used for many purposes (several dozens). It is not possible here to know is this name symlink or not. To get exactly the type of name we should to open inode (read mft). getattr for opened file (fstat) correctly returns symlink. Signed-off-by: Konstantin Komarov ---  fs/ntfs3/dir.c | 30 +++++++++++++++++++++++++-----  1 file changed, 25 insertions(+), 5 deletions(-) +        } +    }      return !dir_emit(ctx, (s8 *)name, name_len, ino, dt_type);  } diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index ec0566b322d5..22ede4da0450 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -309,11 +309,31 @@ static inline int ntfs_filldir(struct ntfs_sb_info *sbi, struct ntfs_inode *ni,          return 0;      } -    /* NTFS: symlinks are "dir + reparse" or "file + reparse" */ -    if (fname->dup.fa & FILE_ATTRIBUTE_REPARSE_POINT) -        dt_type = DT_LNK; -    else -        dt_type = (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG; +    /* +     * NTFS: symlinks are "dir + reparse" or "file + reparse" +     * Unfortunately reparse attribute is used for many purposes (several dozens). +     * It is not possible here to know is this name symlink or not. +     * To get exactly the type of name we should to open inode (read mft). +     * getattr for opened file (fstat) correctly returns symlink. +     */ +    dt_type = (fname->dup.fa & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG; + +    /* +     * It is not reliable to detect the type of name using duplicated information +     * stored in parent directory. +     * The only correct way to get the type of name - read MFT record and find ATTR_STD. +     * The code below is not good idea. +     * It does additional locks/reads just to get the type of name. +     * Should we use additional mount option to enable branch below? +     */ +    if ((fname->dup.fa & FILE_ATTRIBUTE_REPARSE_POINT) && +        ino != ni->mi.rno) { +        struct inode *inode = ntfs_iget5(sbi->sb, &e->ref, NULL); +        if (!IS_ERR_OR_NULL(inode)) { +            dt_type = fs_umode_to_dtype(inode->i_mode); +            iput(inode); From patchwork Wed Dec 6 15:10:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4169700vqy; Wed, 6 Dec 2023 07:11:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEU4zPEuSH6D3CVvzHY6H1irT+HDWcGfmMDKgj3IxNxA8zvDIysXoWA0//2fheVvSPOlmbL X-Received: by 2002:a17:902:da83:b0:1d0:5ed4:4bf with SMTP id j3-20020a170902da8300b001d05ed404bfmr1210854plx.54.1701875465171; Wed, 06 Dec 2023 07:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875465; cv=none; d=google.com; s=arc-20160816; b=tEGm5nPfusghMxlyTmdxQLbPvp2wIKirnIgamOpkhl8XS6me0NIBoRGhmSACF66G+n vhPqetlgxi8SWpiiIF/jgEJaA/7UdLwYE054On7I7ZvqmWP1ckmGYG4L6ZkKgqredxGs voUqe5OnEs5AHluA7SdHIMPH4MMiQZtDzUJitzbZF3s/fQIX4r/O6+G0eA/vlJN7WPmv JoNfIj8QZ1Tj4fkSqX6eljJyGKs+Oy85dyAy/eRpJqtjcH6M0Zz+6kI4i4j1soLr7NY5 6QYLXhAW7E3a1N4FtYUF37M4yUO9waP5tgYKp/Te8ZPBjHtdB374wt0z2kfFDLOE8uWL YATQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=/GAY4vh49Ey49PjOB0D7aW4BJClWKFEVXZZb9RVpvm8=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=WBOgke/osX4EjJmpY2Vk+zBDsxBkuwxa1e3UkULv9RQnxaeGRR0s8GrjYoATwT3A+W WIcSNXnstZr5mHV02Zc46LcWqCNNkRbtY5jrxbjrTjgw71gsf2f+SXz/oOToX5xLuibL f3MEh4/NxYS+fVgn+E9mgi8tySxwi+V3A5hmtMmIThqTF7VjUZARPDIk/JpdMpTeBhzh fht9tfsRZSiLUrbFLrcMn6+U5Eh5hhwAAllUqFxKMfDLZMbKZYJIVAIYCRGlLtS1VypX veybmpkMqkMw9e05ENj2/AfXTTcge6fMAwxfG4w0syX7rGAAxiMgLeyk6EFD1aGwJt4h 7SKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=bV1feHdO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id w8-20020a170902904800b001cfd4c10e47si11364995plz.8.2023.12.06.07.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:11:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=bV1feHdO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 927D38096D8A; Wed, 6 Dec 2023 07:10:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442459AbjLFPK1 (ORCPT + 99 others); Wed, 6 Dec 2023 10:10:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442448AbjLFPKV (ORCPT ); Wed, 6 Dec 2023 10:10:21 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31BBADE; Wed, 6 Dec 2023 07:10:27 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id D92B11E1A; Wed, 6 Dec 2023 15:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875040; bh=/GAY4vh49Ey49PjOB0D7aW4BJClWKFEVXZZb9RVpvm8=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=bV1feHdOoc85vxuNTcRIuuIj4OKvvVliIheZoWfeIjMagZtKTIExoG1tZP5GKcmcC 2Xm3LxPkbcoWDpxWt3fxCzNeybO3lNj/Zk/uh1gmH2/1enCbGpFcHF7wyUjchAGCIv 2RCP2b2+LXWKnHQCqKpaT1lY7nUqnYMKO5UJM8XU= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:10:24 +0300 Message-ID: Date: Wed, 6 Dec 2023 18:10:24 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 03/16] fs/ntfs3: Improve ntfs_dir_count Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:10:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545767350775436 X-GMAIL-MSGID: 1784545767350775436 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/dir.c | 10 +++-------  1 file changed, 3 insertions(+), 7 deletions(-)          *is_empty = true; @@ -563,7 +561,7 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs,                  fles += 1;          } -        if (vbo >= i_size) +        if (bit >= max_indx)              goto out;          err = indx_used_bit(&ni->dir, ni, &bit); @@ -573,8 +571,7 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs,          if (bit == MINUS_ONE_T)              goto out; -        vbo = (u64)bit << index_bits; -        if (vbo >= i_size) +        if (bit >= max_indx)              goto out;          err = indx_read(&ni->dir, ni, bit << ni->dir.idx2vbn_bits, @@ -584,7 +581,6 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs,          hdr = &node->index->ihdr;          bit += 1; -        vbo = (u64)bit << ni->dir.idx2vbn_bits;      }  out: diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index 22ede4da0450..726122ecd39b 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -515,11 +515,9 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs,      struct INDEX_HDR *hdr;      const struct ATTR_FILE_NAME *fname;      u32 e_size, off, end; -    u64 vbo = 0;      size_t drs = 0, fles = 0, bit = 0; -    loff_t i_size = ni->vfs_inode.i_size;      struct indx_node *node = NULL; -    u8 index_bits = ni->dir.index_bits; +    size_t max_indx = ni->vfs_inode.i_size >> ni->dir.index_bits;      if (is_empty) From patchwork Wed Dec 6 15:10:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4169998vqy; Wed, 6 Dec 2023 07:11:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxgCtrxxKM8PQRSICN4UbyqWNM9Uob3kciFAlwDn4PF9moF+ZNu4JddXCIZordB09WP3+c X-Received: by 2002:a05:6a20:4308:b0:187:a4df:4e57 with SMTP id h8-20020a056a20430800b00187a4df4e57mr872947pzk.20.1701875485653; Wed, 06 Dec 2023 07:11:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875485; cv=none; d=google.com; s=arc-20160816; b=CYUu301kUtm5klNh9aVLXZ/7hKeqZ+kKo7j2rHn/zWswdJ03BNI+9W2fXHRyxuJ4lX sZF5aQgbYm6ILVxuhd2Ckc63waugt2zXYmfPx/6lDKwwsUU4g+lHjaG/bIw+2wq6R9on ic1mzNO9AwCoSbzI+qgsbM1DvFtEh796o8OICZt0JtAHrA6Wm2ufb28MfozxziTr0pay hPEZhFaf5U3WvlJVGr5z/VxZW2bmZDPX5ey/XpIqiBGwnwuwGU7WG+LBb2ns9AV4Hf4L noFNjlBj0OqiTBI/g1yceEXsu93zJZRQYLGosWBO20sSDzKG3Typ9oxUyyk19t4t/9xZ H2rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=mAuuCGMqlStfHaypyBJ9iLMuzcr3BmzULzMWMwWTRuE=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=IWA0UVGpdN5YXg7E1H4UVSRZQCk8SYZf+ANw7SeUIXaFr3bwWNVh021/tQQ2RAZtYk OuurRsc/JSBMjbBGdyj2dEERPLKlYy0Kv2U7OBZGup1shxSJR3P4NDIOoq3EkBAZbB81 erWwvnnEotx96JgQvsHfRHtVzAJSuwN87YmWAwD32ONecEJsE0/XXsejeZRxb+8P7oe6 bmXAZgRCYWBUvtvrFlEIXfDjMrk4UwhpyRVmBF0g8LrH9ufmBdKd7cczEc/QqsxSFtej DeL50xaHsnb+57bieJU9La9iQuqRfXuO71aQ9qOWL7i5tVTLwWLrc4NMidRM04N8s34o yaiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=bLupnkpL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id fd34-20020a056a002ea200b006be04b8c3basi89838pfb.178.2023.12.06.07.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:11:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=bLupnkpL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DF89F81BFCC1; Wed, 6 Dec 2023 07:11:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379097AbjLFPLJ (ORCPT + 99 others); Wed, 6 Dec 2023 10:11:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379221AbjLFPKs (ORCPT ); Wed, 6 Dec 2023 10:10:48 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 096DCD5B; Wed, 6 Dec 2023 07:10:54 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 751C91E1A; Wed, 6 Dec 2023 15:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875068; bh=mAuuCGMqlStfHaypyBJ9iLMuzcr3BmzULzMWMwWTRuE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=bLupnkpLf7fzkUc2Zt5omBwLubjPcPeYPgaJ3tqLEQExUyjSso2/GDYWv58+hM9Zd fhwCheq3GPFBlwishCkRPuzN547xVQMTB6CcNxkddptzAQzbiVxJDeavPAQdzRFKtx 4XYrwbbISqytrtKzvacmxjfRMfH0G33BplXtpoVE= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:10:52 +0300 Message-ID: <8cb671f9-252b-443b-a903-ca62c9097533@paragon-software.com> Date: Wed, 6 Dec 2023 18:10:52 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 04/16] fs/ntfs3: Correct hard links updating when dealing with DOS neams Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:11:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545788917595049 X-GMAIL-MSGID: 1784545788917595049 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/record.c | 16 ++++++++++++++--  1 file changed, 14 insertions(+), 2 deletions(-)      used -= asize; diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 53629b1f65e9..7b6423584eae 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -535,8 +535,20 @@ bool mi_remove_attr(struct ntfs_inode *ni, struct mft_inode *mi,          return false;      if (ni && is_attr_indexed(attr)) { -        le16_add_cpu(&ni->mi.mrec->hard_links, -1); -        ni->mi.dirty = true; +        u16 links = le16_to_cpu(ni->mi.mrec->hard_links); +        struct ATTR_FILE_NAME *fname = +            attr->type != ATTR_NAME ? +                NULL : +                resident_data_ex(attr, +                         SIZEOF_ATTRIBUTE_FILENAME); +        if (fname && fname->type == FILE_NAME_DOS) { +            /* Do not decrease links count deleting DOS name. */ +        } else if (!links) { +            /* minor error. Not critical. */ +        } else { +            ni->mi.mrec->hard_links = cpu_to_le16(links - 1); +            ni->mi.dirty = true; +        }      } From patchwork Wed Dec 6 15:11:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174625 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4170061vqy; Wed, 6 Dec 2023 07:11:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTPn/PMv9o5aWLkHgnbVDQt+7l5fPvRaCCgCz9TaoxVeNS1MvG7ywJ7AGyCVTfDhhQI+/6 X-Received: by 2002:a17:902:6bc5:b0:1d0:afd5:1e93 with SMTP id m5-20020a1709026bc500b001d0afd51e93mr746682plt.8.1701875490468; Wed, 06 Dec 2023 07:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875490; cv=none; d=google.com; s=arc-20160816; b=ln77S49UglPyPYekcYo4cd5NZbunqyaGq+EoFKI7/zn+dMnQ+Zre7c6zNM76nlcY4z lFoB5ktwqbJhJ8kEiRISqW5M3Me4cxKpqhLdkPl2QCNtzscVpXgbZQ9FACVykrz9rDlm 5MKUdpHrAbavmVHeopV8oXB6AqoEyMu8W0TQKHyUcIc8uuLaJcwUBvP/o7JubTTsNRiE 0JJGlN8n+fEbdq4koAgFDN/T+BDVBvgqPmP+uHjPp/mK9FeABaM3to/qWFecs5frwkr4 A2oKAjvStDmNfpWV52t1uuec28BHlwf9K1Dd6CkLMoSL67W9Fc91YElLcKcRdDxJSZcf fV8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=2BFRYk4Moqh9lL8OQcoNVoZ0RV2c9czsoWnrNagsXik=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=ja4eD/QfhK5Z8bX3o1GVrVn+IbCWgMb8bp3g99jYLBORLNZiIkWZx/dvUUx08fyXGd w32IlkgmSpssa1MFMmUjw2mEHsq+8uZEnwixzQ5tbtyVIDtRd+MNIy0WsX/0qdCMYIWV YJBzf+9xPSTFM4fJOcHMb94HT2kWPEVK9csa7n0inEhGiK+WHwohqFbMxBtiCrK5NaLz qSLXuzcWmeUXyRDDKFzL02BO1d7+bHq7O492cgVsIjcHTLRvuAHkfEVPj9I/55AKRp3G UNbeP9bB7K/fMfk8I6J+VRjLgM08PSobtQLDb28aUG9MSL0N7G/TiiGOnJSW6eAqgYms hB+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=W9QM4y1P; dkim=pass header.i=@paragon-software.com header.s=mail header.b=LhPCq7kw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id jm1-20020a17090304c100b001d07d6916fesi6863337plb.88.2023.12.06.07.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:11:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=W9QM4y1P; dkim=pass header.i=@paragon-software.com header.s=mail header.b=LhPCq7kw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id AB2C081BFCCD; Wed, 6 Dec 2023 07:11:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379092AbjLFPLN (ORCPT + 99 others); Wed, 6 Dec 2023 10:11:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379096AbjLFPLJ (ORCPT ); Wed, 6 Dec 2023 10:11:09 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BC519A; Wed, 6 Dec 2023 07:11:15 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 4775E1E1A; Wed, 6 Dec 2023 15:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875089; bh=2BFRYk4Moqh9lL8OQcoNVoZ0RV2c9czsoWnrNagsXik=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=W9QM4y1PMOeSapyHHNSO54M7gNOc1aLuFNGjtTYjQSJV0htdC4x+VrQzupF0/j9I2 UQ/Qz+SxSN+tutElWa0RtsRilM5yspu+upzKbRQtGAS3NGzhFCZufJlfmJhGi0hO+U tyjNmuWSVtRiSUFQIzuDruoiwdUzHk7LPQA+M7rs= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 7F1272117; Wed, 6 Dec 2023 15:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875473; bh=2BFRYk4Moqh9lL8OQcoNVoZ0RV2c9czsoWnrNagsXik=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=LhPCq7kwV1lA63gtdTSLts0Uu8PS4YjNDVw1GJMjGvA42Ak90TZUseTrn1H2SP9cN sxA8xmWKrdoRbOZEcndzE9IUEt+a/pP//oH3NFdTK23dYF2ejGyECH6+V9PauMUPIH I7ouj8D/oTC4AJ8ES2dOWKSGaeBFkG1lESNnyQ7I= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:11:12 +0300 Message-ID: <44b1dd7e-f5fc-4908-84f1-8e631cdc23d9@paragon-software.com> Date: Wed, 6 Dec 2023 18:11:12 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 05/16] fs/ntfs3: Print warning while fixing hard links count Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:11:28 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545794366080576 X-GMAIL-MSGID: 1784545794366080576 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/inode.c | 2 +-  1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 5e3d71374918..fa6c7965473c 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -412,7 +412,6 @@ static struct inode *ntfs_read_mft(struct inode *inode,          goto out;      if (!is_match && name) { -        /* Reuse rec as buffer for ascii name. */          err = -ENOENT;          goto out;      } @@ -427,6 +426,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,      if (names != le16_to_cpu(rec->hard_links)) {          /* Correct minor error on the fly. Do not mark inode as dirty. */ +        ntfs_inode_warn(inode, "Correct links count -> %u.", names);          rec->hard_links = cpu_to_le16(names);          ni->mi.dirty = true;      } From patchwork Wed Dec 6 15:11:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174626 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4170368vqy; Wed, 6 Dec 2023 07:11:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5cuWRA0cpVsu1yBBPVt3LN/54Df6xTV6a2xOtO+jp5c2szXilE9vucypZTVAuVWKWRiLy X-Received: by 2002:a17:90a:3ea7:b0:286:6cc1:8676 with SMTP id k36-20020a17090a3ea700b002866cc18676mr728480pjc.91.1701875514649; Wed, 06 Dec 2023 07:11:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875514; cv=none; d=google.com; s=arc-20160816; b=V1nPB9E7C1WMy9h10H4qMfHJduEPp6JAgTzccT8KwQot7opEq2QgBmaCH/nrkJ0had JXvBp7zWc0JCcBZ4URTP5YxM207kbdLK/elAGpwAPfNlU6l6peQuXsVScBB44xa3AzHg 0iiVlNIzzE27Y7WpCpXuhu/ndWT2jgRQEp3e/TxTs2nl/8nl628WA1hJgOIFVvxf+1Zl jRnqQU9W9MvXykCPu2jz+FuMkI/218IJyuzWu9QlElzUL4VuiJ6sp86POr02SMYG+pxF ciT+Fjo77Woupw+Wb7HHYWcJHnOffwFcOC8gZDHcUnav64XxzeGnAKscrkswGukfnPW5 sZlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=RexGtu8XWQhs4tm8penzzSeBhtaDj8gNGca25jwrs2M=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=j4ss1QTk3shVAmkEAyDPeGygEJKo1eYG9giLxxQvR2zOLfBAFVzLV0YySSfVCC74JO DcKoQNoLKGwdgVTji3468M66FHcX7idB3X1clhL8Que3g+eOKjFdt/3TBOawh9i1cjiG nKX8gY9g48aOTtTU8ekdQa/H309vPYSgNSDVp7gCsrYfUZoKBMznJPcOC07FoCoH3T4m ixoS2DtnxtYs43plqI8XQMC2hTxLh0bs+FH2XqCSHZ6QTebkAOE+SmMFRay51gZUebpK 1oGVH2489pi78mK7lTKhs8DaFjHf8UbMGOoV2KdpqJhK/END/sS+7vMZqr+0X2wOZyEh u3tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=hXLqwnBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id w1-20020a17090aea0100b002865a495b84si9123387pjy.183.2023.12.06.07.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:11:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=hXLqwnBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 71E8481BFCD5; Wed, 6 Dec 2023 07:11:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379233AbjLFPLk (ORCPT + 99 others); Wed, 6 Dec 2023 10:11:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379090AbjLFPLi (ORCPT ); Wed, 6 Dec 2023 10:11:38 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1F6F112; Wed, 6 Dec 2023 07:11:42 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id C6A3D212D; Wed, 6 Dec 2023 15:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875116; bh=RexGtu8XWQhs4tm8penzzSeBhtaDj8gNGca25jwrs2M=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=hXLqwnBonYPKS90AP/XXpXvpg5+f5SWde19cling7MoZ4UnWwskiL/hAMPHubIxpw Of4FcC2fjOf/dQzXu8I2+vhD8p4R9EntgiXK60JCya/xpV8K9VtmMDipKLzh3QLjox JsiEpCgDcYrptLa+d6fhqSCIT7nICinhP97CaNZM= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:11:40 +0300 Message-ID: <17bac290-26bf-484d-bcf2-9a65e93add78@paragon-software.com> Date: Wed, 6 Dec 2023 18:11:40 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 06/16] fs/ntfs3: Reduce stack usage Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:11:49 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545819751664818 X-GMAIL-MSGID: 1784545819751664818 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/fslog.c | 218 +++++++++++++++++++++--------------------------  1 file changed, 98 insertions(+), 120 deletions(-)  #define NTFSLOG_WRAPPED 0x00000001 @@ -987,6 +997,7 @@ struct ntfs_log {      struct ntfs_inode *ni;      u32 l_size; +    u32 orig_file_size;      u32 sys_page_size;      u32 sys_page_mask;      u32 page_size; @@ -1040,6 +1051,8 @@ struct ntfs_log {      struct CLIENT_ID client_id;      u32 client_undo_commit; + +    struct restart_info rst_info, rst_info2;  };  static inline u32 lsn_to_vbo(struct ntfs_log *log, const u64 lsn) @@ -1105,16 +1118,6 @@ static inline bool verify_client_lsn(struct ntfs_log *log,             lsn <= le64_to_cpu(log->ra->current_lsn) && lsn;  } -struct restart_info { -    u64 last_lsn; -    struct RESTART_HDR *r_page; -    u32 vbo; -    bool chkdsk_was_run; -    bool valid_page; -    bool initialized; -    bool restart; -}; -  static int read_log_page(struct ntfs_log *log, u32 vbo,               struct RECORD_PAGE_HDR **buffer, bool *usa_error)  { @@ -1176,7 +1179,7 @@ static int read_log_page(struct ntfs_log *log, u32 vbo,   * restart page header. It will stop the first time we find a   * valid page header.   */ -static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first, +static int log_read_rst(struct ntfs_log *log, bool first,              struct restart_info *info)  {      u32 skip, vbo; @@ -1192,7 +1195,7 @@ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first,      }      /* Loop continuously until we succeed. */ -    for (; vbo < l_size; vbo = 2 * vbo + skip, skip = 0) { +    for (; vbo < log->l_size; vbo = 2 * vbo + skip, skip = 0) {          bool usa_error;          bool brst, bchk;          struct RESTART_AREA *ra; @@ -1285,22 +1288,17 @@ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first,  /*   * Ilog_init_pg_hdr - Init @log from restart page header.   */ -static void log_init_pg_hdr(struct ntfs_log *log, u32 sys_page_size, -                u32 page_size, u16 major_ver, u16 minor_ver) +static void log_init_pg_hdr(struct ntfs_log *log, u16 major_ver, u16 minor_ver)  { -    log->sys_page_size = sys_page_size; -    log->sys_page_mask = sys_page_size - 1; -    log->page_size = page_size; -    log->page_mask = page_size - 1; -    log->page_bits = blksize_bits(page_size); +    log->sys_page_size = log->page_size; +    log->sys_page_mask = log->page_mask;      log->clst_per_page = log->page_size >> log->ni->mi.sbi->cluster_bits;      if (!log->clst_per_page)          log->clst_per_page = 1; -    log->first_page = major_ver >= 2 ? -                  0x22 * page_size : -                  ((sys_page_size << 1) + (page_size << 1)); +    log->first_page = major_ver >= 2 ? 0x22 * log->page_size : +                       4 * log->page_size;      log->major_ver = major_ver;      log->minor_ver = minor_ver;  } @@ -1308,12 +1306,11 @@ static void log_init_pg_hdr(struct ntfs_log *log, u32 sys_page_size,  /*   * log_create - Init @log in cases when we don't have a restart area to use.   */ -static void log_create(struct ntfs_log *log, u32 l_size, const u64 last_lsn, +static void log_create(struct ntfs_log *log, const u64 last_lsn,                 u32 open_log_count, bool wrapped, bool use_multi_page)  { -    log->l_size = l_size;      /* All file offsets must be quadword aligned. */ -    log->file_data_bits = blksize_bits(l_size) - 3; +    log->file_data_bits = blksize_bits(log->l_size) - 3;      log->seq_num_mask = (8 << log->file_data_bits) - 1;      log->seq_num_bits = sizeof(u64) * 8 - log->file_data_bits;      log->seq_num = (last_lsn >> log->file_data_bits) + 2; @@ -3720,10 +3717,8 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      struct ntfs_sb_info *sbi = ni->mi.sbi;      struct ntfs_log *log; -    struct restart_info rst_info, rst_info2; -    u64 rec_lsn, ra_lsn, checkpt_lsn = 0, rlsn = 0; +    u64 rec_lsn, checkpt_lsn = 0, rlsn = 0;      struct ATTR_NAME_ENTRY *attr_names = NULL; -    struct ATTR_NAME_ENTRY *ane;      struct RESTART_TABLE *dptbl = NULL;      struct RESTART_TABLE *trtbl = NULL;      const struct RESTART_TABLE *rt; @@ -3741,9 +3736,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      struct TRANSACTION_ENTRY *tr;      struct DIR_PAGE_ENTRY *dp;      u32 i, bytes_per_attr_entry; -    u32 l_size = ni->vfs_inode.i_size; -    u32 orig_file_size = l_size; -    u32 page_size, vbo, tail, off, dlen; +    u32 vbo, tail, off, dlen;      u32 saved_len, rec_len, transact_id;      bool use_second_page;      struct RESTART_AREA *ra2, *ra = NULL; @@ -3758,52 +3751,50 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      u16 t16;      u32 t32; -    /* Get the size of page. NOTE: To replay we can use default page. */ -#if PAGE_SIZE >= DefaultLogPageSize && PAGE_SIZE <= DefaultLogPageSize * 2 -    page_size = norm_file_page(PAGE_SIZE, &l_size, true); -#else -    page_size = norm_file_page(PAGE_SIZE, &l_size, false); -#endif -    if (!page_size) -        return -EINVAL; -      log = kzalloc(sizeof(struct ntfs_log), GFP_NOFS);      if (!log)          return -ENOMEM;      log->ni = ni; -    log->l_size = l_size; -    log->one_page_buf = kmalloc(page_size, GFP_NOFS); +    log->l_size = log->orig_file_size = ni->vfs_inode.i_size; + +    /* Get the size of page. NOTE: To replay we can use default page. */ +#if PAGE_SIZE >= DefaultLogPageSize && PAGE_SIZE <= DefaultLogPageSize * 2 +    log->page_size = norm_file_page(PAGE_SIZE, &log->l_size, true); +#else +    log->page_size = norm_file_page(PAGE_SIZE, &log->l_size, false); +#endif +    if (!log->page_size) { +        err = -EINVAL; +        goto out; +    } +    log->one_page_buf = kmalloc(log->page_size, GFP_NOFS);      if (!log->one_page_buf) {          err = -ENOMEM;          goto out;      } -    log->page_size = page_size; -    log->page_mask = page_size - 1; -    log->page_bits = blksize_bits(page_size); +    log->page_mask = log->page_size - 1; +    log->page_bits = blksize_bits(log->page_size);      /* Look for a restart area on the disk. */ -    memset(&rst_info, 0, sizeof(struct restart_info)); -    err = log_read_rst(log, l_size, true, &rst_info); +    err = log_read_rst(log, true, &log->rst_info);      if (err)          goto out;      /* remember 'initialized' */ -    *initialized = rst_info.initialized; +    *initialized = log->rst_info.initialized; -    if (!rst_info.restart) { -        if (rst_info.initialized) { +    if (!log->rst_info.restart) { +        if (log->rst_info.initialized) {              /* No restart area but the file is not initialized. */              err = -EINVAL;              goto out;          } -        log_init_pg_hdr(log, page_size, page_size, 1, 1); -        log_create(log, l_size, 0, get_random_u32(), false, false); - -        log->ra = ra; +        log_init_pg_hdr(log, 1, 1); +        log_create(log, 0, get_random_u32(), false, false);          ra = log_create_ra(log);          if (!ra) { @@ -3820,25 +3811,26 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)       * If the restart offset above wasn't zero then we won't       * look for a second restart.       */ -    if (rst_info.vbo) +    if (log->rst_info.vbo)          goto check_restart_area; -    memset(&rst_info2, 0, sizeof(struct restart_info)); -    err = log_read_rst(log, l_size, false, &rst_info2); +    err = log_read_rst(log, false, &log->rst_info2);      if (err)          goto out;      /* Determine which restart area to use. */ -    if (!rst_info2.restart || rst_info2.last_lsn <= rst_info.last_lsn) +    if (!log->rst_info2.restart || +        log->rst_info2.last_lsn <= log->rst_info.last_lsn)          goto use_first_page;      use_second_page = true; -    if (rst_info.chkdsk_was_run && page_size != rst_info.vbo) { +    if (log->rst_info.chkdsk_was_run && +        log->page_size != log->rst_info.vbo) {          struct RECORD_PAGE_HDR *sp = NULL;          bool usa_error; -        if (!read_log_page(log, page_size, &sp, &usa_error) && +        if (!read_log_page(log, log->page_size, &sp, &usa_error) &&              sp->rhdr.sign == NTFS_CHKD_SIGNATURE) {              use_second_page = false;          } @@ -3846,52 +3838,43 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      }      if (use_second_page) { -        kfree(rst_info.r_page); -        memcpy(&rst_info, &rst_info2, sizeof(struct restart_info)); -        rst_info2.r_page = NULL; +        kfree(log->rst_info.r_page); +        memcpy(&log->rst_info, &log->rst_info2, +               sizeof(struct restart_info)); +        log->rst_info2.r_page = NULL;      }  use_first_page: -    kfree(rst_info2.r_page); +    kfree(log->rst_info2.r_page);  check_restart_area:      /*       * If the restart area is at offset 0, we want       * to write the second restart area first.       */ -    log->init_ra = !!rst_info.vbo; +    log->init_ra = !!log->rst_info.vbo;      /* If we have a valid page then grab a pointer to the restart area. */ -    ra2 = rst_info.valid_page ? -              Add2Ptr(rst_info.r_page, -                  le16_to_cpu(rst_info.r_page->ra_off)) : +    ra2 = log->rst_info.valid_page ? +              Add2Ptr(log->rst_info.r_page, +                  le16_to_cpu(log->rst_info.r_page->ra_off)) :                NULL; -    if (rst_info.chkdsk_was_run || +    if (log->rst_info.chkdsk_was_run ||          (ra2 && ra2->client_idx[1] == LFS_NO_CLIENT_LE)) {          bool wrapped = false;          bool use_multi_page = false;          u32 open_log_count;          /* Do some checks based on whether we have a valid log page. */ -        if (!rst_info.valid_page) { -            open_log_count = get_random_u32(); -            goto init_log_instance; -        } -        open_log_count = le32_to_cpu(ra2->open_log_count); - -        /* -         * If the restart page size isn't changing then we want to -         * check how much work we need to do. -         */ -        if (page_size != le32_to_cpu(rst_info.r_page->sys_page_size)) -            goto init_log_instance; +        open_log_count = log->rst_info.valid_page ? +                     le32_to_cpu(ra2->open_log_count) : +                     get_random_u32(); -init_log_instance: -        log_init_pg_hdr(log, page_size, page_size, 1, 1); +        log_init_pg_hdr(log, 1, 1); -        log_create(log, l_size, rst_info.last_lsn, open_log_count, -               wrapped, use_multi_page); +        log_create(log, log->rst_info.last_lsn, open_log_count, wrapped, +               use_multi_page);          ra = log_create_ra(log);          if (!ra) { @@ -3916,28 +3899,27 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)       * use the log file. We must use the system page size instead of the       * default size if there is not a clean shutdown.       */ -    t32 = le32_to_cpu(rst_info.r_page->sys_page_size); -    if (page_size != t32) { -        l_size = orig_file_size; -        page_size = -            norm_file_page(t32, &l_size, t32 == DefaultLogPageSize); +    t32 = le32_to_cpu(log->rst_info.r_page->sys_page_size); +    if (log->page_size != t32) { +        log->l_size = log->orig_file_size; +        log->page_size = norm_file_page(t32, &log->l_size, +                        t32 == DefaultLogPageSize);      } -    if (page_size != t32 || -        page_size != le32_to_cpu(rst_info.r_page->page_size)) { +    if (log->page_size != t32 || +        log->page_size != le32_to_cpu(log->rst_info.r_page->page_size)) {          err = -EINVAL;          goto out;      }      /* If the file size has shrunk then we won't mount it. */ -    if (l_size < le64_to_cpu(ra2->l_size)) { +    if (log->l_size < le64_to_cpu(ra2->l_size)) {          err = -EINVAL;          goto out;      } -    log_init_pg_hdr(log, page_size, page_size, -            le16_to_cpu(rst_info.r_page->major_ver), -            le16_to_cpu(rst_info.r_page->minor_ver)); +    log_init_pg_hdr(log, le16_to_cpu(log->rst_info.r_page->major_ver), +            le16_to_cpu(log->rst_info.r_page->minor_ver));      log->l_size = le64_to_cpu(ra2->l_size);      log->seq_num_bits = le32_to_cpu(ra2->seq_num_bits); @@ -3945,7 +3927,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      log->seq_num_mask = (8 << log->file_data_bits) - 1;      log->last_lsn = le64_to_cpu(ra2->current_lsn);      log->seq_num = log->last_lsn >> log->file_data_bits; -    log->ra_off = le16_to_cpu(rst_info.r_page->ra_off); +    log->ra_off = le16_to_cpu(log->rst_info.r_page->ra_off);      log->restart_size = log->sys_page_size - log->ra_off;      log->record_header_len = le16_to_cpu(ra2->rec_hdr_len);      log->ra_size = le16_to_cpu(ra2->ra_len); @@ -4045,7 +4027,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      log->current_avail = current_log_avail(log);      /* Remember which restart area to write first. */ -    log->init_ra = rst_info.vbo; +    log->init_ra = log->rst_info.vbo;  process_log:      /* 1.0, 1.1, 2.0 log->major_ver/minor_ver - short values. */ @@ -4105,7 +4087,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      log->client_id.seq_num = cr->seq_num;      log->client_id.client_idx = client; -    err = read_rst_area(log, &rst, &ra_lsn); +    err = read_rst_area(log, &rst, &checkpt_lsn);      if (err)          goto out; @@ -4114,9 +4096,8 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      bytes_per_attr_entry = !rst->major_ver ? 0x2C : 0x28; -    checkpt_lsn = le64_to_cpu(rst->check_point_start); -    if (!checkpt_lsn) -        checkpt_lsn = ra_lsn; +    if (rst->check_point_start) +        checkpt_lsn = le64_to_cpu(rst->check_point_start);      /* Allocate and Read the Transaction Table. */      if (!rst->transact_table_len) @@ -4330,23 +4311,20 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      lcb = NULL;  check_attribute_names2: -    if (!rst->attr_names_len) -        goto trace_attribute_table; - -    ane = attr_names; -    if (!oatbl) -        goto trace_attribute_table; -    while (ane->off) { -        /* TODO: Clear table on exit! */ -        oe = Add2Ptr(oatbl, le16_to_cpu(ane->off)); -        t16 = le16_to_cpu(ane->name_bytes); -        oe->name_len = t16 / sizeof(short); -        oe->ptr = ane->name; -        oe->is_attr_name = 2; -        ane = Add2Ptr(ane, sizeof(struct ATTR_NAME_ENTRY) + t16); -    } - -trace_attribute_table: +    if (rst->attr_names_len && oatbl) { +        struct ATTR_NAME_ENTRY *ane = attr_names; +        while (ane->off) { +            /* TODO: Clear table on exit! */ +            oe = Add2Ptr(oatbl, le16_to_cpu(ane->off)); +            t16 = le16_to_cpu(ane->name_bytes); +            oe->name_len = t16 / sizeof(short); +            oe->ptr = ane->name; +            oe->is_attr_name = 2; +            ane = Add2Ptr(ane, +                      sizeof(struct ATTR_NAME_ENTRY) + t16); +        } +    } +      /*       * If the checkpt_lsn is zero, then this is a freshly       * formatted disk and we have no work to do. @@ -5189,7 +5167,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)      kfree(oatbl);      kfree(dptbl);      kfree(attr_names); -    kfree(rst_info.r_page); +    kfree(log->rst_info.r_page);      kfree(ra);      kfree(log->one_page_buf); diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index 98ccb6650858..7dbb000fc691 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -974,6 +974,16 @@ static inline void *alloc_rsttbl_from_idx(struct RESTART_TABLE **tbl, u32 vbo)      return e;  } +struct restart_info { +    u64 last_lsn; +    struct RESTART_HDR *r_page; +    u32 vbo; +    bool chkdsk_was_run; +    bool valid_page; +    bool initialized; +    bool restart; +}; +  #define RESTART_SINGLE_PAGE_IO cpu_to_le16(0x0001) From patchwork Wed Dec 6 15:12:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174627 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4170657vqy; Wed, 6 Dec 2023 07:12:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMhLXOEBWf0rMmDh5xqJbmbT1+23/a/My9iNZD5h8xcGCXs3fLi1Vd65GKUZ0jeXoglXjm X-Received: by 2002:a05:6a20:8f07:b0:18f:ee27:aa59 with SMTP id b7-20020a056a208f0700b0018fee27aa59mr312098pzk.10.1701875536363; Wed, 06 Dec 2023 07:12:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875536; cv=none; d=google.com; s=arc-20160816; b=B/qEDd7kk4wqKfaRHVDsrjU4zurCfSDM0VEcEUX5i7tu310GWqNxHcl+c95/qraDMw QfJj81+ODAke6OrY5RN0FlXvQAdvCGoQxRliucWK09vVSNUzpFQ92+kij1loBXfNm/tY YyugY0JSLDro32suHQ0/3RWCPqTx+sxy4gQqCCxQxgYS/sGOdfqvU5Z1mWPns9lqNkxW OJpbWvVZVfvTV/z8KZI5E6Q59AiZwrprsUh02aZKbGb6z+cJI1/I7RAzUpmU52zYCgWO URaSdDl8dhA2NWbLK4pgPpPNeFuyVwWWcHchZG/R4Yq6uo3wv53JfoeTr8ISrC7M6uOg 0sRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=KEnz3KTE1Z9/osOlDauLKgWtI6LdwFBhWwhEahHqNQo=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=DChdTDPJoc63ohPEJ5VIOUKsWfJE5H6YEt7vX2w4dl5rnuIhyc4DnmwaPNmHQYHnsa vzhqP/YNAl8U5wpCTLKI200l4VyOEqXgPrI9LS9nTveGZHSv5gvLP7jSza9Eh+HAMvNF Fm4VV1q+iYq+FVW7owHvXu3fOUmZ4YRi/LEYp4GvuGKC+1Gpp9meJQF3zLdBPOgg/j75 JYAa9x/g5yfKCCz7p4s6OMbc2a4U3fIbfg5ZtcmeQskGJqUqxN+MrFZAS/KTLz6S5Zxo DOKvE/uC/CEDdWwMxOKjNeDtl3ZmnArL5pPaGUY41NQ9SMLcWvcSW8M4qHsFgmUgZoY7 G3Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=ml0RcwIB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id t32-20020a056a0013a000b006cd8db94631si79605pfg.365.2023.12.06.07.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:12:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=ml0RcwIB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2917581C0C08; Wed, 6 Dec 2023 07:12:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379228AbjLFPMB (ORCPT + 99 others); Wed, 6 Dec 2023 10:12:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379090AbjLFPMA (ORCPT ); Wed, 6 Dec 2023 10:12:00 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52FF1C6; Wed, 6 Dec 2023 07:12:06 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 2AAFC2120; Wed, 6 Dec 2023 15:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875140; bh=KEnz3KTE1Z9/osOlDauLKgWtI6LdwFBhWwhEahHqNQo=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=ml0RcwIB/jbk6KHc50rd9/kLCglaBQgfFiOHbhazURkapxReFpC4vxnpvlYMS8nrP 58adYEG0RnhgyeLDEMwND0AqrD9TZFlz6HTNiuDEmvzUmC5+PXmjU2b3YGybT7p0QH p4lAjZYfowSTC2GQFaBSEjxTjNgDlilQX4n/rSpU= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:12:03 +0300 Message-ID: <7ae15d02-7745-4241-8b28-197eebbb6b7b@paragon-software.com> Date: Wed, 6 Dec 2023 18:12:03 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 07/16] fs/ntfs3: Fix multithreaded stress test Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:12:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545841967640469 X-GMAIL-MSGID: 1784545841967640469 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/attrib.c | 21 ++++++++++++++-------  1 file changed, 14 insertions(+), 7 deletions(-)      CLST hint, svcn, to_alloc, evcn1, next_svcn, asize, end, vcn0, alen; @@ -904,12 +904,8 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,          *len = 0;      up_read(&ni->file.run_lock); -    if (*len) { -        if (*lcn != SPARSE_LCN || !new) -            return 0; /* Fast normal way without allocation. */ -        else if (clen > *len) -            clen = *len; -    } +    if (*len && (*lcn != SPARSE_LCN || !new)) +        return 0; /* Fast normal way without allocation. */      /* No cluster in cache or we need to allocate cluster in hole. */      sbi = ni->mi.sbi; @@ -918,6 +914,17 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,      ni_lock(ni);      down_write(&ni->file.run_lock); +    /* Repeat the code above (under write lock). */ +    if (!run_lookup_entry(run, vcn, lcn, len, NULL)) +        *len = 0; + +    if (*len) { +        if (*lcn != SPARSE_LCN || !new) +            goto out; /* normal way without allocation. */ +        if (clen > *len) +            clen = *len; +    } +      le_b = NULL;      attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, &mi_b);      if (!attr_b) { diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 63f70259edc0..4b78b669a3bd 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -886,7 +886,7 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,      struct runs_tree *run = &ni->file.run;      struct ntfs_sb_info *sbi;      u8 cluster_bits; -    struct ATTRIB *attr = NULL, *attr_b; +    struct ATTRIB *attr, *attr_b;      struct ATTR_LIST_ENTRY *le, *le_b;      struct mft_inode *mi, *mi_b; From patchwork Wed Dec 6 15:12:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4170979vqy; Wed, 6 Dec 2023 07:12:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdhvsa7NELXJGm9IAd5TOqtPvXRkL0asxxVT/FR5YHSp3+PitmmURqbYKSWtXMhoLT7i07 X-Received: by 2002:a05:6a20:840e:b0:18f:97c:8a29 with SMTP id c14-20020a056a20840e00b0018f097c8a29mr1396461pzd.84.1701875562116; Wed, 06 Dec 2023 07:12:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875562; cv=none; d=google.com; s=arc-20160816; b=NBLxdxJsUMi7y3vfjqPmlNu2kqyq2SSX8RR1w/irquTVMgytR0JaL0DJCYZSbg4pry N7l4DWaRpfOmY0R29hg4skHyBO2STRPaIZMegFUZY3HxDTSV/tl8VniDtt19SMXfC4Ac 0/EZe2VvKlcLol7IulIE2LeSxndTCmUKvzYhLaNfZQE66jRlTdAUrAukAbhDdhaAuCBv 2zeuO9bW9CpCsfhX8YS/IM0QwHBg0S20aFzt4FfTwawG5rxFJi2SsGn1RFMctiBs9v0S pZ9yx17yy6bccJH1jgPAfaAHwqWLkF9mfMLJnIBk/thccccV+hcdBd65nESU37WGURZj 8Abg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=oUVQuELufd+5uJnO89HaHyCbduYubrq21BOGdkAjVXA=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=Q/Tm0mGcrbSticf3wjMcFBylSJOZmWs20g/g095xY+oZpPsDaTlP6HIKPDMcbI4n8i gfpRCc7e0zB6tKW5uW14MmBcuyNrpIgfldbG0GisKbMkUZL94LZWlhBX+UmZd5qpmyxk ef8bhy2eQcYH9H2O1r5gWU0Xxr2l8R5vzGSSc9i9sZw5SranA/372BkgN3qcAu2HjrnP xsu1WCdCOSJUXHEg4n1cEqIlzyqQ3Ual75lP/bYe7KOi68e1Yz8qtYJb+2r+rkjjnrun A3KnQcms/0q0/vMbLfJdgljOQZsQzejrERF19oq9CJD28pN21wkElqMthgxGgL2w1ZOu kSow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=FOwzIfud; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bw10-20020a056a00408a00b006cb901a87c4si78796pfb.376.2023.12.06.07.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:12:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=FOwzIfud; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2B64181BFCFC; Wed, 6 Dec 2023 07:12:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379226AbjLFPM3 (ORCPT + 99 others); Wed, 6 Dec 2023 10:12:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379228AbjLFPM1 (ORCPT ); Wed, 6 Dec 2023 10:12:27 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AACBD7F; Wed, 6 Dec 2023 07:12:26 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 0ECBE1E1A; Wed, 6 Dec 2023 15:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875160; bh=oUVQuELufd+5uJnO89HaHyCbduYubrq21BOGdkAjVXA=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=FOwzIfudC9bkRwbf6E0CtzufD/ejcjuSxV7Z5x/uEjKnx7LMxtYMRpGMY3a0f+Xj1 VTN9Wid82R80TU43j6P6Id0vICyjWksAudOq7xKWIgihy04fyxDrpW81CcbUOoqSiM 4rGdNcNiGvt9vbbsKkj/CzhrpECl0PL2b3/cdjq8= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:12:23 +0300 Message-ID: <61494224-68a8-431b-ba76-46b4812c241c@paragon-software.com> Date: Wed, 6 Dec 2023 18:12:23 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 08/16] fs/ntfs3: Fix detected field-spanning write (size 8) of single field "le->name" Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:12:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545869817779142 X-GMAIL-MSGID: 1784545869817779142 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/ntfs.h | 2 +-  1 file changed, 1 insertion(+), 1 deletion(-)  }; // sizeof(0x20) diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 86aecbb01a92..13e96fc63dae 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -523,7 +523,7 @@ struct ATTR_LIST_ENTRY {      __le64 vcn;        // 0x08: Starting VCN of this attribute.      struct MFT_REF ref;    // 0x10: MFT record number with attribute.      __le16 id;        // 0x18: struct ATTRIB ID. -    __le16 name[3];        // 0x1A: Just to align. To get real name can use bNameOffset. +    __le16 name[];        // 0x1A: Just to align. To get real name can use name_off. From patchwork Wed Dec 6 15:12:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4171092vqy; Wed, 6 Dec 2023 07:12:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMYxooSIcm/EagOkzW+GFYmJQ9RtjAcLNjZVLPeFSDPteB0/FIf5M+uWFnUOJpa2dzkcjm X-Received: by 2002:a05:6a20:a303:b0:18b:cd15:b832 with SMTP id x3-20020a056a20a30300b0018bcd15b832mr651576pzk.42.1701875569578; Wed, 06 Dec 2023 07:12:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875569; cv=none; d=google.com; s=arc-20160816; b=fHNvR9P0kICCwu59VeKkH8HY+02TOPMy0f1Fm/iFiqjLAHvGI8xl6robpHQ2dzah9U oxp8PgDapF40Zdrq27t+foBUDwWpzBLm/BTws57o9aONEcaT41Ajl7kvM7UJEvrK952o PFbdXG+Blk7OdgJuSv/JygMj2jAdRi1bo5OBZkZpJqSuVFredKeHzTinT/2GODJYPz5v JTdg/v6q0k72gKWKlBPSae3TCwcqwNtAKzlggjCK1N6YFJ8RKpdpLewfR/PlRr0Z398C uA/iB2t4YYGJ+r+n29wqSYhvuunzCXrDBbh7LsiI7NKFXE0pWxvoixtH1POc5ssUN+4W 8ROQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=uNOivJvRpFbPgTjjVYSC1qoe7uSyIYuTw1rYbo9Hp0w=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=fxhQwBZD0qR7LNo/+0L9wO0TXpyIQz11qdSzm4RqrOSKzg2gmawG29tNLRPnfIgGsg SbJD6CVLF8WVYEJbhDE3Doi17g+3GgXBjfJ6F+q/Xi6m/SbR9zlr9MiCpaMo6xXkwrSN tDN+QlqKF5RG9lZGscRyz+B2ME3DuYLQxoXAAi8QHZB1KMWI6KJ8XP3MHHzJ+ts/YKhf LIOv/HSBCkp9NIfkPstESmx+S7TppfQytVag94DUdfUES62oPjVslH59Cdf7WEi5Hvbe VtxhQY7i433SR+f88o8wTSzVk+drRBd6DYrOHtbTmZf+lKz1zdEHXKg7ZLJgAY/TpDf7 4hVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="bj/RGX+6"; dkim=pass header.i=@paragon-software.com header.s=mail header.b=EDu7HbCK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id fd34-20020a056a002ea200b006be04b8c3basi91762pfb.178.2023.12.06.07.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:12:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="bj/RGX+6"; dkim=pass header.i=@paragon-software.com header.s=mail header.b=EDu7HbCK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8DE538030E7B; Wed, 6 Dec 2023 07:12:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442399AbjLFPMh (ORCPT + 99 others); Wed, 6 Dec 2023 10:12:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379090AbjLFPMg (ORCPT ); Wed, 6 Dec 2023 10:12:36 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92A799A; Wed, 6 Dec 2023 07:12:42 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 6CBA71E1A; Wed, 6 Dec 2023 15:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875176; bh=uNOivJvRpFbPgTjjVYSC1qoe7uSyIYuTw1rYbo9Hp0w=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=bj/RGX+6H/0ra5+wZHFHw7x8ZHxC4RWyNh6puOtIUKz5QvQUmsZ0xpgJCSi/3kgd8 CIsytNXKjsTuT5Mx61jzLyhwiQnJd83CIzQ/z1e9e85Gj6tRy0SUOh6XKrUueruEHx 18Yo98VSLGmUOGFrBa2t/w8+BTvfuN+wPVYQ0NHY= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id AF2152117; Wed, 6 Dec 2023 15:12:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875560; bh=uNOivJvRpFbPgTjjVYSC1qoe7uSyIYuTw1rYbo9Hp0w=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=EDu7HbCK/E19/EVWbQReaNUWjnJLDH4T6JYEPDGhrvSGr5wZUxVJQM4lhLYJD/t0W oR+i7ET+/BXRId+BZ8LmBGtxuI6ob1ldfPfm/VIOAwEHZKDQULAHXsEE6jT94qMOJ2 9BGkKHDpMtgzU6Cv1q/cZpWUFN0QVVDb06lPOESw= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:12:40 +0300 Message-ID: <29a1087c-c903-488c-993a-2e3c23c2d4d2@paragon-software.com> Date: Wed, 6 Dec 2023 18:12:40 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 09/16] fs/ntfs3: Correct use bh_read Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:12:46 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545876816059506 X-GMAIL-MSGID: 1784545876816059506 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/file.c  | 19 +++++++++----------  fs/ntfs3/inode.c |  7 +++----  2 files changed, 12 insertions(+), 14 deletions(-)      } diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index a5a30a24ce5d..5691f04e6751 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -188,6 +188,7 @@ static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vbo_to)      u32 bh_next, bh_off, to;      sector_t iblock;      struct folio *folio; +    bool dirty = false;      for (; idx < idx_end; idx += 1, from = 0) {          page_off = (loff_t)idx << PAGE_SHIFT; @@ -223,29 +224,27 @@ static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vbo_to)              /* Ok, it's mapped. Make sure it's up-to-date. */              if (folio_test_uptodate(folio))                  set_buffer_uptodate(bh); - -            if (!buffer_uptodate(bh)) { -                err = bh_read(bh, 0); -                if (err < 0) { -                    folio_unlock(folio); -                    folio_put(folio); -                    goto out; -                } +            else if (bh_read(bh, 0) < 0) { +                err = -EIO; +                folio_unlock(folio); +                folio_put(folio); +                goto out;              }              mark_buffer_dirty(bh); -          } while (bh_off = bh_next, iblock += 1,               head != (bh = bh->b_this_page));          folio_zero_segment(folio, from, to); +        dirty = true;          folio_unlock(folio);          folio_put(folio);          cond_resched();      }  out: -    mark_inode_dirty(inode); +    if (dirty) +        mark_inode_dirty(inode);      return err;  } diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index fa6c7965473c..bba0208c4afd 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -345,9 +345,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,              inode->i_size = le16_to_cpu(rp.SymbolicLinkReparseBuffer                                  .PrintNameLength) /                      sizeof(u16); -              ni->i_valid = inode->i_size; -              /* Clear directory bit. */              if (ni->ni_flags & NI_FLAG_DIR) {                  indx_clear(&ni->dir); @@ -653,9 +651,10 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo,              off = vbo & (PAGE_SIZE - 1);              folio_set_bh(bh, folio, off); -            err = bh_read(bh, 0); -            if (err < 0) +            if (bh_read(bh, 0) < 0) { +                err = -EIO;                  goto out; +            }              folio_zero_segment(folio, off + voff, off + block_size);          } From patchwork Wed Dec 6 15:12:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174630 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4171295vqy; Wed, 6 Dec 2023 07:13:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXv3buJTR7D6GTR56ya3shRa28GJI1pUKpVUIHKomo5aT0vGg82dHAmXgvSl814DrY60YR X-Received: by 2002:a05:6a00:23c1:b0:6ce:2731:e86b with SMTP id g1-20020a056a0023c100b006ce2731e86bmr1269516pfc.50.1701875586565; Wed, 06 Dec 2023 07:13:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875586; cv=none; d=google.com; s=arc-20160816; b=iRU3R/lN/8DbDeKBEPPp1aIdDATOfA051EVlUBwmKG3WmXYjfSna/r/mzfiuYTpH64 mPuFGwPqVS5gBBL0bA8BNJ4XsvVW7Hl5cqKdMa4PACZbGuQLtLpwXhEH7A93SoP4gEZ0 B80/Ra/sPF3nwUHlZp1KIA78PiLwZ/PdQ0RNid98LefOEzkJGWgSMSHV32gkbkOR7QsI fBasRQFqcMb/mGReL2sGVEO6XcrafmQfalVOwdcueeyo7Ly+hvxyFYFB7ZaZK2qFbny+ qTTyZXrCRYdwWmM5vA30iJ9NBikKz1iwGK8GM/4ZQ86pdVvAHwXAUBVNzokwqbEEwgag 9xSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=5WNxqIEiVf5xBesOyM4G/OuoGM3roOgonpEjUNzMoQc=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=bedM47Fs0FggHfNtGQXFxT6rHvq48svoJGZcujGWpIyb7/Aez787YJ5zZ5tmYc+sZB q/DIPFrsA14ffK8ItpzuQQ+Eb+qe6HpgpXZ9M140p5VCFGIDxrzDgXd0bYmTeFdxxTN0 S8DvW+xNMLoCv+MsgnsYbEi9U1thItbfhhzD+DUTF0hN1fBm6bw+jGJ1CvbSEJloxOtI PMWT9u9PTaL+fMhmlkd9EDyRkmbHCmvvGC+oLtO+7aJ40DuqgMJH2hmUYfTZ51Pqd+EQ PBO7mnRcuroptJjfTqsAJh7HdA3j/nJ9RjSTcR16UuakaRnqASCc6RYc5OIH+t9wpxhZ e8Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=SKOa+CHd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id fc12-20020a056a002e0c00b006ce56664fd5si87348pfb.157.2023.12.06.07.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:13:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=SKOa+CHd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 6D185826EEA0; Wed, 6 Dec 2023 07:13:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442399AbjLFPMz (ORCPT + 99 others); Wed, 6 Dec 2023 10:12:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379090AbjLFPMy (ORCPT ); Wed, 6 Dec 2023 10:12:54 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BAA0D44; Wed, 6 Dec 2023 07:13:00 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 346BF1E1A; Wed, 6 Dec 2023 15:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875194; bh=5WNxqIEiVf5xBesOyM4G/OuoGM3roOgonpEjUNzMoQc=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=SKOa+CHdhTDrT3JdA0I4GHvBuQyY1T0VvV9P7kGKydPxnb9m3t+8rtPN4g79s6Lwt nT3xoGGzTdH0XsfnMSCfZnc21q3dm8plyc7QvNSfcNOYeCRijRrabXr/Meqx8jTC9w xi4LFnvnnREfe4Bd80iBXzJ2WaMh/hFMKhNHYV+w= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:12:58 +0300 Message-ID: <3fbcb5a7-2b6f-44ae-8355-06461e7a1447@paragon-software.com> Date: Wed, 6 Dec 2023 18:12:58 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 10/16] fs/ntfs3: Add file_modified Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:13:04 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545894668524750 X-GMAIL-MSGID: 1784545894668524750 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/file.c | 13 +++++++++++++  1 file changed, 13 insertions(+)          filemap_invalidate_unlock(mapping); @@ -1040,6 +1046,7 @@ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)      struct address_space *mapping = file->f_mapping;      struct inode *inode = mapping->host;      ssize_t ret; +    int err;      struct ntfs_inode *ni = ntfs_i(inode);      if (is_encrypted(ni)) { @@ -1067,6 +1074,12 @@ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)      if (ret <= 0)          goto out; +    err = file_modified(iocb->ki_filp); +    if (err) { +        ret = err; +        goto out; +    } +      if (WARN_ON(ni->ni_flags & NI_FLAG_COMPRESSED_MASK)) {          /* Should never be here, see ntfs_file_open(). */          ret = -EOPNOTSUPP; diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 5691f04e6751..bb80ce2eec2f 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -632,11 +632,17 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)                          &ni->file.run, i_size, &ni->i_valid,                          true, NULL);              ni_unlock(ni); +            if (err) +                goto out;          } else if (new_size > i_size) {              inode->i_size = new_size;          }      } +    err = file_modified(file); +    if (err) +        goto out; +  out:      if (map_locked) From patchwork Wed Dec 6 15:13:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4171511vqy; Wed, 6 Dec 2023 07:13:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+fZFaB7LDG54mPgrBmVhzLFbTuzwPzsG1DMlfqABnQ1pktcwWU+YBQGessut8IwW8/a3m X-Received: by 2002:a17:90b:4a8f:b0:286:b6bf:e6d5 with SMTP id lp15-20020a17090b4a8f00b00286b6bfe6d5mr792282pjb.14.1701875604024; Wed, 06 Dec 2023 07:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875603; cv=none; d=google.com; s=arc-20160816; b=Ih7XbRzWic7iQCDO2cJoeSmsquF8JawRZ2PgKP7LNnzimrceLmWDz8x4evT2Q9Ig3c bZv4BujkT4w1lEsoSsa9qtiPNfQ9JfZHqD0abfN2FOXQLKcEUgb6kQXUWWc99a8j9mWA rmVhniBEhurGhtXOwhhnwblaBy52socBnQoWOtn1N4CC8zsoSZu2K6sGPI8vLSpb1Bqw uuRyLhCShr7Vvgeqkts6677dBtF1YI5ZRPz/dZo4wrjrJ9k5DLEyEmS0soeB78tqrDrJ qIblSxU4of2WdvQU3DPtboQ9MTGB5Ca/+gdjYBZ79N0SiHdzC41QstpqyRl5Yo+cJvSM Rv3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=F097v/jB8ZR21e/O3vd36dCK4gneA3BrFHtMeimQuV4=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=NfJaSY9kkPdpFSmN+lBSLaWaiQfsLIPBqEFnMiFnJ/LjW2IHuJ0+vOB3wHlD/RF2RO RewGFcPLhhBAnDOP3FjhrcF5VfbJqcH1T9xlmp9YHpDycNvrKvNhohROh6UrOQp2xCQw rMsbaG01o/+HYvlH+fh/Mga/L6gWoQcrI6w9s2ex/Qz+Ch6wUANSWBF6fL8kc0I6n8Lv MpZVw6SJJSITNqk0s1qeVzGFIDwwG2m0ek+je1n8C2E9MT2dRyleqGyYc/Rcfy1wj1fh TG6jqsH7UF3rIzUc4VbEupLFjdsL3p2DpBQ+E0usiU64tRr4K6g2ZUmynqjjZoAXJ7bW 4k3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="m3/oqph8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f8-20020a17090ace0800b00285864ca8a0si2924758pju.180.2023.12.06.07.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:13:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="m3/oqph8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 57BBE8030A19; Wed, 6 Dec 2023 07:13:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442399AbjLFPNN (ORCPT + 99 others); Wed, 6 Dec 2023 10:13:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379228AbjLFPNL (ORCPT ); Wed, 6 Dec 2023 10:13:11 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF039DE; Wed, 6 Dec 2023 07:13:17 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 903201E1A; Wed, 6 Dec 2023 15:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875211; bh=F097v/jB8ZR21e/O3vd36dCK4gneA3BrFHtMeimQuV4=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=m3/oqph84dOfSvsyEUrnjup2sI052twZlQVgqAS6UOH+jafuQ1FPCmz6Fu7lGEQQi 2/82ZDbxioT09DRo45akAqbUhutD4t5bbxSm44sL5MnKUhvjmAyx/0IIaHypmgn1vm OEh6DBzuauAM8FnZ1RUItM5m01Y3W9cCWxkOJYF0= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:13:15 +0300 Message-ID: <89861d9e-f3a4-483d-b88d-4085dc2e0a8b@paragon-software.com> Date: Wed, 6 Dec 2023 18:13:15 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 11/16] fs/ntfs3: Drop suid and sgid bits as a part of fpunch Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:13:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545913792543516 X-GMAIL-MSGID: 1784545913792543516 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/file.c | 9 +++++++++  1 file changed, 9 insertions(+)          end_a = end & ~mask; @@ -524,6 +528,8 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)              ni_lock(ni);              err = attr_punch_hole(ni, vbo_a, end_a - vbo_a, NULL);              ni_unlock(ni); +            if (err) +                goto out;          }      } else if (mode & FALLOC_FL_COLLAPSE_RANGE) {          /* @@ -563,6 +569,8 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)          ni_lock(ni);          err = attr_insert_range(ni, vbo, len);          ni_unlock(ni); +        if (err) +            goto out;      } else {          /* Check new size. */          u8 cluster_bits = sbi->cluster_bits; @@ -639,6 +647,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)          }      } +ok:      err = file_modified(file);      if (err)          goto out; diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index bb80ce2eec2f..0ff5d3af2889 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -498,10 +498,14 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)          ni_lock(ni);          err = attr_punch_hole(ni, vbo, len, &frame_size);          ni_unlock(ni); +        if (!err) +            goto ok; +          if (err != E_NTFS_NOTALIGNED)              goto out;          /* Process not aligned punch. */ +        err = 0;          mask = frame_size - 1;          vbo_a = (vbo + mask) & ~mask; From patchwork Wed Dec 6 15:13:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4171764vqy; Wed, 6 Dec 2023 07:13:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHETUcqpLEtsYa3qqKE3QibF81YV+8OmSZSihhyDXQtkeCT4JZDAjZvERksywAMdpnRyONw X-Received: by 2002:a17:90b:4002:b0:286:6cc0:b915 with SMTP id ie2-20020a17090b400200b002866cc0b915mr671578pjb.76.1701875623409; Wed, 06 Dec 2023 07:13:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875623; cv=none; d=google.com; s=arc-20160816; b=PO5YtNKVZzkaQEOF8lfWmt6qY/BH5UAAWIn4i4vAnOLacmfERwxfpjh/roqIYe/er0 /V3K/GSa4ZI8CutzpLZmP5HC2yFCOGmBWJM7VPmWiM+w5R976ud6GbbS2maFzKSFl0jD eTcWp85mSo49wkmL7N6788PTGVetjniksd7aBeouYa/MnH81ZXsoMhgvz84UK7K0qC5N xesJR6aVp/1ZSYmpkxLKzkFA5eWQn9Oxdti2sfIWMo1gHgygdwNzgehkLnK60NqHSsz0 oKy++n6JZNGM0THoW8hP2W/seHMadMW4jcsNvrr0oK1d2t75JfwurfoohUDf3KE7gV6v 0i2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=uJ8yXb35Y3nvlXGaUfbKb2hU6mLxvvg7KJ352HRIl1g=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=0VhGdIm7xdYoyv6PK/cwy5agYtpBmL6UKJDGIZUjH8q2cnxabWWdjmsWBitV6zxRWT TR9YImMz1mqze1YHOE6CFX0lXNKk+Oj7saoVLKgroVS3YZJrd8jkFx7xt7TVMBKwm5vY qZ+PfWXY2VfZrvdobuTYwsGrRU1bcavkFcfRo3kgNjF5kICSbIDyA6PJuyFxdsrFLuFF GAz1Bd9I/VVKwK0O6YNXZWFj+L3h46VlEQLcgTxutnfQFhweP1U0BK+mebAxNWpU48Oq /Leb3AD7o9oVsqntO7xKC4gXATFv++vs9nw4ilDrCZOCnn3LSHsA+MqUAzU92AsPWrx0 ohPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=eDwoUKNx; dkim=pass header.i=@paragon-software.com header.s=mail header.b="Ku8/Redg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id k18-20020a17090a911200b00285196ac998si7498843pjo.104.2023.12.06.07.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:13:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=eDwoUKNx; dkim=pass header.i=@paragon-software.com header.s=mail header.b="Ku8/Redg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BA78E802ACD1; Wed, 6 Dec 2023 07:13:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379238AbjLFPNb (ORCPT + 99 others); Wed, 6 Dec 2023 10:13:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379228AbjLFPN3 (ORCPT ); Wed, 6 Dec 2023 10:13:29 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B797FD5E; Wed, 6 Dec 2023 07:13:34 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 8507D1E1A; Wed, 6 Dec 2023 15:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875228; bh=uJ8yXb35Y3nvlXGaUfbKb2hU6mLxvvg7KJ352HRIl1g=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=eDwoUKNxnC3Mgo5YqMg62nEwQlIzs9ZN6vkl1Oj/N6/RT0nvXp72F+JN+rfgOMvXZ foAWQKxkFIIu8YklSD8zsvXh7Y6NfK7Y2fLZ8YkDkPMmdNYLJax5arNk3jQiZY1W5r cPNFAPUzgIEbNaip/DtL7zgWlJgjCSwWstIw/ml0= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id C75A42117; Wed, 6 Dec 2023 15:13:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875612; bh=uJ8yXb35Y3nvlXGaUfbKb2hU6mLxvvg7KJ352HRIl1g=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=Ku8/RedgSWDEvC1aHorRRbeFaxRRq9RroNtmTSCrs4SWXGRQM6g37ggHj/tEIDN7b 3EUjBCU0mnJo9y1wgCDSBcr/wdKVNjL3KM0gP50TDKsOV84HDSDA9jUQFNyBmpKVpy Qr3UwRwAkk39i6GpMLxR/4D3cv1L7zyyfGVMbXNM= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:13:32 +0300 Message-ID: <4f013a0c-9f3f-4a4a-88fa-17460abd702e@paragon-software.com> Date: Wed, 6 Dec 2023 18:13:32 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 12/16] fs/ntfs3: Implement super_operations::shutdown Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:13:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545933486567552 X-GMAIL-MSGID: 1784545933486567552 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/file.c    | 18 ++++++++++++++++++  fs/ntfs3/frecord.c |  3 +++  fs/ntfs3/inode.c   | 21 +++++++++++++++++++--  fs/ntfs3/namei.c   | 12 ++++++++++++  fs/ntfs3/ntfs_fs.h |  9 ++++++++-  fs/ntfs3/super.c   | 12 ++++++++++++  fs/ntfs3/xattr.c   |  3 +++  7 files changed, 75 insertions(+), 3 deletions(-)          /* system.dos_attrib */ diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 0ff5d3af2889..07ed3d946e7c 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -260,6 +260,9 @@ static int ntfs_file_mmap(struct file *file, struct vm_area_struct *vma)      bool rw = vma->vm_flags & VM_WRITE;      int err; +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; +      if (is_encrypted(ni)) {          ntfs_inode_warn(inode, "mmap encrypted not supported");          return -EOPNOTSUPP; @@ -677,6 +680,9 @@ int ntfs3_setattr(struct mnt_idmap *idmap, struct dentry *dentry,      umode_t mode = inode->i_mode;      int err; +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; +      err = setattr_prepare(idmap, dentry, attr);      if (err)          goto out; @@ -732,6 +738,9 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)      struct inode *inode = file->f_mapping->host;      struct ntfs_inode *ni = ntfs_i(inode); +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; +      if (is_encrypted(ni)) {          ntfs_inode_warn(inode, "encrypted i/o not supported");          return -EOPNOTSUPP; @@ -766,6 +775,9 @@ static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos,      struct inode *inode = in->f_mapping->host;      struct ntfs_inode *ni = ntfs_i(inode); +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; +      if (is_encrypted(ni)) {          ntfs_inode_warn(inode, "encrypted i/o not supported");          return -EOPNOTSUPP; @@ -1058,6 +1070,9 @@ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)      int err;      struct ntfs_inode *ni = ntfs_i(inode); +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; +      if (is_encrypted(ni)) {          ntfs_inode_warn(inode, "encrypted i/o not supported");          return -EOPNOTSUPP; @@ -1118,6 +1133,9 @@ int ntfs_file_open(struct inode *inode, struct file *file)  {      struct ntfs_inode *ni = ntfs_i(inode); +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; +      if (unlikely((is_compressed(ni) || is_encrypted(ni)) &&               (file->f_flags & O_DIRECT))) {          return -EOPNOTSUPP; diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 3df2d9e34b91..8744ba36d422 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -3259,6 +3259,9 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)      if (is_bad_inode(inode) || sb_rdonly(sb))          return 0; +    if (unlikely(ntfs3_forced_shutdown(sb))) +        return -EIO; +      if (!ni_trylock(ni)) {          /* 'ni' is under modification, skip for now. */          mark_inode_dirty_sync(inode); diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index bba0208c4afd..85452a6b1d40 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -852,9 +852,13 @@ static int ntfs_resident_writepage(struct folio *folio,                     struct writeback_control *wbc, void *data)  {      struct address_space *mapping = data; -    struct ntfs_inode *ni = ntfs_i(mapping->host); +    struct inode *inode = mapping->host; +    struct ntfs_inode *ni = ntfs_i(inode);      int ret; +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; +      ni_lock(ni);      ret = attr_data_write_resident(ni, &folio->page);      ni_unlock(ni); @@ -868,7 +872,12 @@ static int ntfs_resident_writepage(struct folio *folio,  static int ntfs_writepages(struct address_space *mapping,                 struct writeback_control *wbc)  { -    if (is_resident(ntfs_i(mapping->host))) +    struct inode *inode = mapping->host; + +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; + +    if (is_resident(ntfs_i(inode)))          return write_cache_pages(mapping, wbc, ntfs_resident_writepage,                       mapping);      return mpage_writepages(mapping, wbc, ntfs_get_block); @@ -888,6 +897,9 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping,      struct inode *inode = mapping->host;      struct ntfs_inode *ni = ntfs_i(inode); +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; +      *pagep = NULL;      if (is_resident(ni)) {          struct page *page = @@ -1305,6 +1317,11 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,          goto out1;      } +    if (unlikely(ntfs3_forced_shutdown(sb))) { +        err = -EIO; +        goto out2; +    } +      /* Mark rw ntfs as dirty. it will be cleared at umount. */      ntfs_set_state(sbi, NTFS_DIRTY_DIRTY); diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index ee3093be5170..cae41db0aaa7 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -181,6 +181,9 @@ static int ntfs_unlink(struct inode *dir, struct dentry *dentry)      struct ntfs_inode *ni = ntfs_i(dir);      int err; +    if (unlikely(ntfs3_forced_shutdown(dir->i_sb))) +        return -EIO; +      ni_lock_dir(ni);      err = ntfs_unlink_inode(dir, dentry); @@ -199,6 +202,9 @@ static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,      u32 size = strlen(symname);      struct inode *inode; +    if (unlikely(ntfs3_forced_shutdown(dir->i_sb))) +        return -EIO; +      inode = ntfs_create_inode(idmap, dir, dentry, NULL, S_IFLNK | 0777, 0,                    symname, size, NULL); @@ -227,6 +233,9 @@ static int ntfs_rmdir(struct inode *dir, struct dentry *dentry)      struct ntfs_inode *ni = ntfs_i(dir);      int err; +    if (unlikely(ntfs3_forced_shutdown(dir->i_sb))) +        return -EIO; +      ni_lock_dir(ni);      err = ntfs_unlink_inode(dir, dentry); @@ -264,6 +273,9 @@ static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,                1024);      static_assert(PATH_MAX >= 4 * 1024); +    if (unlikely(ntfs3_forced_shutdown(sb))) +        return -EIO; +      if (flags & ~RENAME_NOREPLACE)          return -EINVAL; diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index f6706143d14b..d40bc7669ae5 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -61,6 +61,8 @@ enum utf16_endian;  /* sbi->flags */  #define NTFS_FLAGS_NODISCARD        0x00000001 +/* ntfs in shutdown state. */ +#define NTFS_FLAGS_SHUTDOWN        0x00000002  /* Set when LogFile is replaying. */  #define NTFS_FLAGS_LOG_REPLAYING    0x00000008  /* Set when we changed first MFT's which copy must be updated in $MftMirr. */ @@ -226,7 +228,7 @@ struct ntfs_sb_info {      u64 maxbytes; // Maximum size for normal files.      u64 maxbytes_sparse; // Maximum size for sparse file. -    u32 flags; // See NTFS_FLAGS_XXX. +    unsigned long flags; // See NTFS_FLAGS_      CLST zone_max; // Maximum MFT zone length in clusters      CLST bad_clusters; // The count of marked bad clusters. @@ -999,6 +1001,11 @@ static inline struct ntfs_sb_info *ntfs_sb(struct super_block *sb)      return sb->s_fs_info;  } +static inline bool ntfs3_forced_shutdown(struct super_block *sb) +{ +    return test_bit(NTFS_FLAGS_SHUTDOWN, &ntfs_sb(sb)->flags); +} +  /*   * ntfs_up_cluster - Align up on cluster boundary.   */ diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 09d61c6c90aa..af8521a6ed95 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -714,6 +714,14 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)      return 0;  } +/* + * ntfs_shutdown - super_operations::shutdown + */ +static void ntfs_shutdown(struct super_block *sb) +{ +    set_bit(NTFS_FLAGS_SHUTDOWN, &ntfs_sb(sb)->flags); +} +  /*   * ntfs_sync_fs - super_operations::sync_fs   */ @@ -724,6 +732,9 @@ static int ntfs_sync_fs(struct super_block *sb, int wait)      struct ntfs_inode *ni;      struct inode *inode; +    if (unlikely(ntfs3_forced_shutdown(sb))) +        return -EIO; +      ni = sbi->security.ni;      if (ni) {          inode = &ni->vfs_inode; @@ -763,6 +774,7 @@ static const struct super_operations ntfs_sops = {      .put_super = ntfs_put_super,      .statfs = ntfs_statfs,      .show_options = ntfs_show_options, +    .shutdown = ntfs_shutdown,      .sync_fs = ntfs_sync_fs,      .write_inode = ntfs3_write_inode,  }; diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 4274b6f31cfa..071356d096d8 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -744,6 +744,9 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,      int err;      struct ntfs_inode *ni = ntfs_i(inode); +    if (unlikely(ntfs3_forced_shutdown(inode->i_sb))) +        return -EIO; +      /* Dispatch request. */      if (!strcmp(name, SYSTEM_DOS_ATTRIB)) { From patchwork Wed Dec 6 15:13:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174634 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4171929vqy; Wed, 6 Dec 2023 07:13:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5L46rKFCqaeazzrEkVoxnz2+wvxeRKXH91dOvxGcI2Yd0SvndZXFfOHD+ytDvZXoul5sx X-Received: by 2002:a17:90b:11cc:b0:286:da5e:a4fb with SMTP id gv12-20020a17090b11cc00b00286da5ea4fbmr808242pjb.90.1701875638099; Wed, 06 Dec 2023 07:13:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875638; cv=none; d=google.com; s=arc-20160816; b=gd4TOQKgWWGlMY/exwwHmjFOt+BHWUUNpvBVOrJymVMrDpDBZlxSvtstq2Kh+IwSiH pPeUvjt+njxat5aKWsvJew7DAR5XPIy51ljO1ildWqSK6RMYPWn/yE8uxnv8rO5KNlm0 Qw2ZzQbSkfF4U+pkEClnpKGqhpEfC7IKMVG/Td2A3NLD0mwe4k14PQu1+TV7ZAwQx7cZ sdk2HAFCFS6ChyFRwcq51lS+7VhZmPw72V1EEPQSztyBAsrP67D9gaIChycSydixKenb vjQkZNfBEf5QpMgHLHo2lBf15qnsUIyKJbUSZEtJmJKiW1238dkUwZKzTWxXvBoVo7Iw sjFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=CUZk88fabksVMQIwptkfOhP6XsgOcXbEpcc4odQSDSQ=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=dDNe0qfjHM8FCqy3d4LUmXa70FnZ8Au0umVYiqfxvwQ5oXJOgFbz9QkPrKrDO1gqJd OeEDJJbfra4cEfar4e1IclWju2pPP/BWr4L4eBBN4amKp52DDIVNdZg0cjDDfIMWqV7h EicT2WtH7BXzi/9UxPaB6D2PKMAy5ZyUft8EKY9gCBjjU37PTUyu+gSp1h2n0DuR8lEH CxIzl6DkRSW9+c9yQpnwyjg7a1WIrsn/SF9vZmBLNQ6yBU/BI3zndHyNOdzrnFTolid/ +Pj/49rvl4vNox5+i/Ui3oDt2JOMG4rFPqXuEztY+2mFewUMCvFE38G6PcSdSaq9DP5m JhCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=NCK6bfmA; dkim=pass header.i=@paragon-software.com header.s=mail header.b=cKTfILwv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id hb18-20020a17090b209200b00286edd97032si2469708pjb.134.2023.12.06.07.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:13:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=NCK6bfmA; dkim=pass header.i=@paragon-software.com header.s=mail header.b=cKTfILwv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E023080294A1; Wed, 6 Dec 2023 07:13:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442448AbjLFPNo (ORCPT + 99 others); Wed, 6 Dec 2023 10:13:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442472AbjLFPNn (ORCPT ); Wed, 6 Dec 2023 10:13:43 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FBC0B5; Wed, 6 Dec 2023 07:13:49 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 216141E1A; Wed, 6 Dec 2023 15:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875243; bh=CUZk88fabksVMQIwptkfOhP6XsgOcXbEpcc4odQSDSQ=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=NCK6bfmAVok0RLfrG2qNu60LQBlIyV8PnwhtGpjL8OHnbfVEi3NJ4VX370Q1e5hk3 HOzmdUxENLGFoCwvBzdk7CzHTnC0QkqbXH/Uig2v9kOtjc8kTdItbUuJFx9ZVhn1V6 awSW+hE0eS335PqIP4VtGv0WlMxfI8F7ZdrLM6YU= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 64E4B2117; Wed, 6 Dec 2023 15:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875627; bh=CUZk88fabksVMQIwptkfOhP6XsgOcXbEpcc4odQSDSQ=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=cKTfILwvtBLLE19pwq14wyqj1avYe8W/4CiDi8l/6aJTt4VI1IVYevoAo22826ksJ ROfjf2aOvncNloeosyx2+MUuiP2wVYUZC88epJYNhDB5WBuYiKNKTKnqQBeu/gg51w R0UbWXrBWjm1M6WFpRGa90JZRnpvbf+JG4wMctg4= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:13:46 +0300 Message-ID: <6e9cc7e7-b29c-4d63-a73c-9aadd1589f18@paragon-software.com> Date: Wed, 6 Dec 2023 18:13:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 13/16] fs/ntfs3: ntfs3_forced_shutdown use int instead of bool Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:13:54 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545949246694987 X-GMAIL-MSGID: 1784545949246694987 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/fsntfs.c  | 3 ++-  fs/ntfs3/ntfs_fs.h | 6 +++---  fs/ntfs3/super.c   | 2 +-  3 files changed, 6 insertions(+), 5 deletions(-)  /* diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index fbfe21dbb425..350461d8cece 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -853,7 +853,8 @@ void ntfs_update_mftmirr(struct ntfs_sb_info *sbi, int wait)      /*       * sb can be NULL here. In this case sbi->flags should be 0 too.       */ -    if (!sb || !(sbi->flags & NTFS_FLAGS_MFTMIRR)) +    if (!sb || !(sbi->flags & NTFS_FLAGS_MFTMIRR) || +        unlikely(ntfs3_forced_shutdown(sb)))          return;      blocksize = sb->s_blocksize; diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index d40bc7669ae5..7510875efef6 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -62,7 +62,7 @@ enum utf16_endian;  /* sbi->flags */  #define NTFS_FLAGS_NODISCARD        0x00000001  /* ntfs in shutdown state. */ -#define NTFS_FLAGS_SHUTDOWN        0x00000002 +#define NTFS_FLAGS_SHUTDOWN_BIT        0x00000002  /* == 4*/  /* Set when LogFile is replaying. */  #define NTFS_FLAGS_LOG_REPLAYING    0x00000008  /* Set when we changed first MFT's which copy must be updated in $MftMirr. */ @@ -1001,9 +1001,9 @@ static inline struct ntfs_sb_info *ntfs_sb(struct super_block *sb)      return sb->s_fs_info;  } -static inline bool ntfs3_forced_shutdown(struct super_block *sb) +static inline int ntfs3_forced_shutdown(struct super_block *sb)  { -    return test_bit(NTFS_FLAGS_SHUTDOWN, &ntfs_sb(sb)->flags); +    return test_bit(NTFS_FLAGS_SHUTDOWN_BIT, &ntfs_sb(sb)->flags);  }  /* diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index af8521a6ed95..65ef4b57411f 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -719,7 +719,7 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)   */  static void ntfs_shutdown(struct super_block *sb)  { -    set_bit(NTFS_FLAGS_SHUTDOWN, &ntfs_sb(sb)->flags); +    set_bit(NTFS_FLAGS_SHUTDOWN_BIT, &ntfs_sb(sb)->flags);  } From patchwork Wed Dec 6 15:14:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174637 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4176793vqy; Wed, 6 Dec 2023 07:20:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEtOoHVt8G5U9WBv7qfDheXyBugOUjLuORHfwlitRUm0+i7Q1nsHkrG0Y5PKB/c1/CG95s X-Received: by 2002:a17:903:44f:b0:1d0:8fad:f1a7 with SMTP id iw15-20020a170903044f00b001d08fadf1a7mr838559plb.54.1701876043877; Wed, 06 Dec 2023 07:20:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701876043; cv=none; d=google.com; s=arc-20160816; b=J7zwOqLdh9SO9Q7W//c2AKQd4Pu1vFpGC+Wq9NKgPtzuChJlxyERAsVzzo5YY2ZfIe luLRUgEzCjBMtQnYsElLlfDtE+YhqXQpWsSp+Q8yt4e10tbIydNV5jV+12Zz4jZ72TOj I+ym6AHZZz6vEL3C2VJycmNCyqFi5nFdYrnjFfhKro3klzzA0Wi9WTL/5j6Zj++H0qf0 o3hTJnhO22mgPagldEm69w9/1SevqnbxcPsNMVGg3xCvksi38OLNjJuBgHslxfDR3Y6b 73eRBylwzJLl51FGse8UDUCA2Q3kJwNlShhqL+2QqgwiYhqFC9gBoJal8lKsxLLbYv9m kLUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=/4I47So9TsCFHrAhRoQV8zzXSeAqCb/39siaVWL+gX0=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=wPWTCfGA1VTaDbw/t3TcoVr1NehrMe+1ZGLlieOPX0o1bezvQSbHhrCBUxRr2XaLHm KurnXwTjo7TWxTM/Rk52tBldAsy0naJwpecwtjs2iHWR3PnLBzLQWaqqSbkcQ6fneyLS AHf8X0VexBozq79Uy7fO2U08X3jh4uIrTP1PMPfKoJUNpTuc2R2WhLMR68HcbyBsPh1X sKuy1m9bv+huDNbUE4ssKtnQYoWEmfw1iCLZjCm1ErvqnaHb1s/UUjvcZFkTxpRBOYzp z2FW+kHo0ovo94tXzJjMKRcyN6VOqw3NLz7fL5hzca9DMax1HVj+5v7Zv4ulc0Xtk2De WPCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=kN9J13WY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id h9-20020a170902f7c900b001cffe1e01aesi6480681plw.603.2023.12.06.07.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:20:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=kN9J13WY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 566768078613; Wed, 6 Dec 2023 07:14:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442470AbjLFPOD (ORCPT + 99 others); Wed, 6 Dec 2023 10:14:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379228AbjLFPOC (ORCPT ); Wed, 6 Dec 2023 10:14:02 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31CCDD50; Wed, 6 Dec 2023 07:14:07 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 6E1C01E1A; Wed, 6 Dec 2023 15:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875261; bh=/4I47So9TsCFHrAhRoQV8zzXSeAqCb/39siaVWL+gX0=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=kN9J13WYKnTwM0/sOLGjGLDz5CC0z/k/AWpQjtIuyS78sqffL6F87LGiEKPYmwkL7 XsjaUGyF0vm3bNzJtlU1jEwm+8I+J8WbK9Qb1LZvwz2k8okN3eA6tNWNsW0vDDrybY zpr03m2YeMhs+FawFYMsmtMwLO398U/xikV1iWiY= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:14:05 +0300 Message-ID: <9cfeb726-0b6a-48bc-a640-435bcb6e359a@paragon-software.com> Date: Wed, 6 Dec 2023 18:14:05 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 14/16] fs/ntfs3: Add and fix comments Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:14:12 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784546374960797565 X-GMAIL-MSGID: 1784546374960797565 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/dir.c     | 4 +++-  fs/ntfs3/fsntfs.c  | 2 +-  fs/ntfs3/ntfs.h    | 2 +-  fs/ntfs3/ntfs_fs.h | 2 +-  4 files changed, 6 insertions(+), 4 deletions(-)  void ntfs_get_wsl_perm(struct inode *inode); diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index 726122ecd39b..9f6dd445eb04 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -536,8 +536,10 @@ static int ntfs_dir_count(struct inode *dir, bool *is_empty, size_t *dirs,              e = Add2Ptr(hdr, off);              e_size = le16_to_cpu(e->size);              if (e_size < sizeof(struct NTFS_DE) || -                off + e_size > end) +                off + e_size > end) { +                /* Looks like corruption. */                  break; +            }              if (de_is_last(e))                  break; diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 350461d8cece..321978019407 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -2129,8 +2129,8 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi,              if (le32_to_cpu(d_security->size) == new_sec_size &&                  d_security->key.hash == hash_key.hash &&                  !memcmp(d_security + 1, sd, size_sd)) { -                *security_id = d_security->key.sec_id;                  /* Such security already exists. */ +                *security_id = d_security->key.sec_id;                  err = 0;                  goto out;              } diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 13e96fc63dae..c8981429c721 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -523,7 +523,7 @@ struct ATTR_LIST_ENTRY {      __le64 vcn;        // 0x08: Starting VCN of this attribute.      struct MFT_REF ref;    // 0x10: MFT record number with attribute.      __le16 id;        // 0x18: struct ATTRIB ID. -    __le16 name[];        // 0x1A: Just to align. To get real name can use name_off. +    __le16 name[];        // 0x1A: To get real name use name_off.  }; // sizeof(0x20) diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 7510875efef6..abbc7182554a 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -874,7 +874,7 @@ int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,  int ntfs_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry);  ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size); -extern const struct xattr_handler * const ntfs_xattr_handlers[]; +extern const struct xattr_handler *const ntfs_xattr_handlers[];  int ntfs_save_wsl_perm(struct inode *inode, __le16 *ea_size); From patchwork Wed Dec 6 15:14:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4179803vqy; Wed, 6 Dec 2023 07:25:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqmPv/Y7vhD9Re/WQ/EOQ2J7J+AQdVdlwB5kJAQ68toSe2CTwe+NXFfd8HdTFRkfM5510U X-Received: by 2002:a17:90b:4f4e:b0:281:d84:a97e with SMTP id pj14-20020a17090b4f4e00b002810d84a97emr1374972pjb.2.1701876330355; Wed, 06 Dec 2023 07:25:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701876330; cv=none; d=google.com; s=arc-20160816; b=F1nFKw7w5BXu8WJxO89JTQBay+mhmIIjauQ1wJq3HHgUNZCcqOA4XTNR/FJoSjEzLT ONm9wNnS1WIEZmIaCtdfRscONggRKQVDp0pQvaDE3p1Kfds3Czt3geVEv8pqW3hJFyoH M6MiVYx0FhET0/sFyQTj8slVqTm+XciIKHClSOmGs7Ebl5eR5fUHpJe587BxWAGjYLLz /6WwW8lTe9rNDbulOKVOWVvjnR4M0a58BHwkMAqXz92KrIh4U2QsH74855Opyfu5jG6+ eIjpHXEqhIIkqSaZdOGTQv/gmf3qCkWMXQTn3wLrR0DHL6negwaUOSi23i5zE19519+5 6nuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=W/TNdgmKDqNDYIi7mUSo5ayyxeI6Wi55D54a4MJS5O8=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=CmzIGp1p0DOFX1nNW1YwZCpOPwHtvya8zKHphMumL5NvJNOABq468FlGF5QcPpOJ8T qUFQdHGgNtkLa3O2OUhUPg7LxYZaiEaJ7PAlSH8rMxRa6lfcks3yapZXX7WENozIDMCM 6UYTr3gbw+1XjAu+C7EIdnRfLkXvA+dyA/sVPneDOfZ7qjHQdQFiYCxyeVEXa+BymedQ 1oXMUmas44Mhq+yveJ3Rt+7XNvKQ9alUeZp3apOc3Ifc7cGlZ1q4fE+C/khUW8RjVHTb w8XGmAf0vH8geSh5tNXjdmUUFs382iniOsq/RlyjI3PFaXcCeIpK1tP8LGZZ5OWaUAdi oQnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=uB7SJ5ZV; dkim=pass header.i=@paragon-software.com header.s=mail header.b=HwerjDqS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id lp13-20020a17090b4a8d00b0028862f5a30dsi19567pjb.49.2023.12.06.07.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:25:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=uB7SJ5ZV; dkim=pass header.i=@paragon-software.com header.s=mail header.b=HwerjDqS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D2E2F81C19CD; Wed, 6 Dec 2023 07:14:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442537AbjLFPOW (ORCPT + 99 others); Wed, 6 Dec 2023 10:14:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442535AbjLFPOV (ORCPT ); Wed, 6 Dec 2023 10:14:21 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08B67112; Wed, 6 Dec 2023 07:14:26 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id E6D181D0B; Wed, 6 Dec 2023 15:08:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875280; bh=W/TNdgmKDqNDYIi7mUSo5ayyxeI6Wi55D54a4MJS5O8=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=uB7SJ5ZV34Sc6PLOrZBUBpCENFmPGqlFtRZvqJoH9vKlKM7YeJH4IMKAHPy9I9iEa ejo/mhQFbObUfY7QSS46h7IJ+xwplvgdoZFTxSFtWgAmYnNnVdXzTJPHQhaaWOBNo5 SWLDXhH3caMbQcpe06yX7DO97jt+0K3UDKKUucwE= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 32A922117; Wed, 6 Dec 2023 15:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875665; bh=W/TNdgmKDqNDYIi7mUSo5ayyxeI6Wi55D54a4MJS5O8=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=HwerjDqSLEHZuqFn+zzPuEhCBWA0uFcD4nADai1942YJ983cNo0j/pryidiex2rWP H0uuBaQ306w3AFnBoJcJRFcIIK8vQDQuWbmPIeusCe3s3FXdqFM+hDeHsYQD0L0g+x O29n04DNf2rqk9XpwAgCpKfKdguOdnw9nTpi3aCo= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:14:24 +0300 Message-ID: Date: Wed, 6 Dec 2023 18:14:24 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 15/16] fs/ntfs3: Add NULL ptr dereference checking at the end of attr_allocate_frame() Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:14:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784546674737446298 X-GMAIL-MSGID: 1784546674737446298 It is preferable to exit through the out: label because internal debugging functions are located there. Signed-off-by: Konstantin Komarov ---  fs/ntfs3/attrib.c | 20 ++++++++++++--------  1 file changed, 12 insertions(+), 8 deletions(-)              le = le_b; @@ -1825,13 +1827,15 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,  ok:      run_truncate_around(run, vcn);  out: -    if (new_valid > data_size) -        new_valid = data_size; +    if (attr_b) { +        if (new_valid > data_size) +            new_valid = data_size; -    valid_size = le64_to_cpu(attr_b->nres.valid_size); -    if (new_valid != valid_size) { -        attr_b->nres.valid_size = cpu_to_le64(valid_size); -        mi_b->dirty = true; +        valid_size = le64_to_cpu(attr_b->nres.valid_size); +        if (new_valid != valid_size) { +            attr_b->nres.valid_size = cpu_to_le64(valid_size); +            mi_b->dirty = true; +        }      }      return err; diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 4b78b669a3bd..646e2dad1b75 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -1743,8 +1743,10 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,              le_b = NULL;              attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL,                            0, NULL, &mi_b); -            if (!attr_b) -                return -ENOENT; +            if (!attr_b) { +                err = -ENOENT; +                goto out; +            }              attr = attr_b; From patchwork Wed Dec 6 15:14:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174639 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4179531vqy; Wed, 6 Dec 2023 07:25:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8xBaVTtoahPufIw/QdDuPnAFzFCruaUzGFWcNWIc8r2Fa6mFQBuUp445CCBxgR4I+YA/J X-Received: by 2002:a05:6a20:3c93:b0:18f:221b:52a8 with SMTP id b19-20020a056a203c9300b0018f221b52a8mr981549pzj.59.1701876306795; Wed, 06 Dec 2023 07:25:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701876306; cv=none; d=google.com; s=arc-20160816; b=ro4facCtDG/vDH6L/yYF5twaD31PbDmFSaaaTvP1XLd5IItCgItvnG8+zyletib+dC loL+PLXQFCSBEMlX3SluW2Ti3w8uwHasfH9nJ6cwMUPprREf2iyfik4cCi3qPSAOURBI gBIRbDTJYwLIRBnCAqPcKObbq/ZRzsSyh6EK8oplYlaabiWF2ZUe2ObEHLK7qPjNVGMc Mo8W/IS1OPLXMIXO0ViUefiRLTKU/T44Gcd/u0QPim90pjTCSMZpCP+/AjWTpCKMKix6 ydB9qLWvKPpMCLDWxmEXCZOdMgj1bVdWBhNbeZjqHzWgRcXNGVbeCtn1Dy6KjWf+Hgq2 qe8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=nuQ7oyEDVSuk9DOyuMG/cLB7BA1E7v6X/Af9iud7LTk=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=Pusd8jgVCno7yX0xu8vo41m13i9uGGnGLXrpO5PLWrQaRw+sn9jArZdbsMkZCfZTnV c1BTHVua9caArFeywkhT5R7vpfRXVCg9cCsxIyL1IPtbvWosinJwMp2J/H8KmJKh5sIV PrTYqlJ6M2kuuoR8LY9b9k76gen/gajkogfota3s5SAn16fGCQk90umd/XKw5xgz0XsS 6QjV+PN33sOL38WPgTP3CpHj8PkJ4xWPVhsoAMpqZJRp93Tl/ypiQ46x9EKwnJHEoGfC Gf5/BoUh/uetqfecTK846PVwdC9MsltC8e8tOFiMbHaTQxa2si47HTxAHzjTIY24gJpr RQXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=b9ns4krg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id jc15-20020a056a006c8f00b006c8d6276334si114631pfb.140.2023.12.06.07.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:25:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=b9ns4krg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id D150B80659B6; Wed, 6 Dec 2023 07:15:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379241AbjLFPOy (ORCPT + 99 others); Wed, 6 Dec 2023 10:14:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379260AbjLFPOw (ORCPT ); Wed, 6 Dec 2023 10:14:52 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07BE51707; Wed, 6 Dec 2023 07:14:48 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 860301D0B; Wed, 6 Dec 2023 15:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875302; bh=nuQ7oyEDVSuk9DOyuMG/cLB7BA1E7v6X/Af9iud7LTk=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=b9ns4krgsqsEKFEpkwSUxPt90w7J8llYZPi9MyON8+FjGR7kqRSI3r83ZLpiL8lua ljtibIPMsXBzU9i7KmTZE+TYjrZbhXEUlTTPX1RmZnUNPjnPkSSmcbBBJ+/dCgQp0e QeHhsteLuAYXMv33bEAa0QG5/Ze27T+lmW+bHQoM= Received: from [172.16.192.129] (192.168.211.144) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 18:14:46 +0300 Message-ID: <8babdfbc-5be7-428d-9c23-ca8ed66f7ec5@paragon-software.com> Date: Wed, 6 Dec 2023 18:14:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 16/16] fs/ntfs3: Fix c/mtime typo Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:15:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784546650274869510 X-GMAIL-MSGID: 1784546650274869510 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/frecord.c | 2 +-  1 file changed, 1 insertion(+), 1 deletion(-)              std->c_time = dup.c_time; diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 8744ba36d422..6ff4f70ba077 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -3291,7 +3291,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)              modified = true;          } -        ts = inode_get_mtime(inode); +        ts = inode_get_ctime(inode);          dup.c_time = kernel2nt(&ts);          if (std->c_time != dup.c_time) {