lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1f95ab55-ce05-4c11-8c14-8df260514208@paragon-software.com>
Date:   Tue, 26 Sep 2023 12:55:53 +0300
From:   Konstantin Komarovc <almaz.alexandrovich@...agon-software.com>
To:     <ntfs3@...ts.linux.dev>
CC:     <linux-kernel@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>
Subject: [PATCH 3/8] fs/ntfs3: Fix alternative boot searching


Signed-off-by: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>
---
  fs/ntfs3/super.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 71c80c578feb..d2951b23f52a 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -846,7 +846,7 @@ static int ntfs_init_from_boot(struct super_block 
*sb, u32 sector_size,
      struct ntfs_sb_info *sbi = sb->s_fs_info;
      int err;
      u32 mb, gb, boot_sector_size, sct_per_clst, record_size;
-    u64 sectors, clusters, mlcn, mlcn2;
+    u64 sectors, clusters, mlcn, mlcn2, dev_size0;
      struct NTFS_BOOT *boot;
      struct buffer_head *bh;
      struct MFT_REC *rec;
@@ -855,6 +855,9 @@ static int ntfs_init_from_boot(struct super_block 
*sb, u32 sector_size,
      u32 boot_off = 0;
      const char *hint = "Primary boot";

+    /* Save original dev_size. Used with alternative boot. */
+    dev_size0 = dev_size;
+
      sbi->volume.blocks = dev_size >> PAGE_SHIFT;

      bh = ntfs_bread(sb, 0);
@@ -1087,9 +1090,9 @@ static int ntfs_init_from_boot(struct super_block 
*sb, u32 sector_size,
      }

  out:
-    if (err == -EINVAL && !bh->b_blocknr && dev_size > PAGE_SHIFT) {
+    if (err == -EINVAL && !bh->b_blocknr && dev_size0 > PAGE_SHIFT) {
          u32 block_size = min_t(u32, sector_size, PAGE_SIZE);
-        u64 lbo = dev_size - sizeof(*boot);
+        u64 lbo = dev_size0 - sizeof(*boot);

          /*
            * Try alternative boot (last sector)
@@ -1103,6 +1106,7 @@ static int ntfs_init_from_boot(struct super_block 
*sb, u32 sector_size,

          boot_off = lbo & (block_size - 1);
          hint = "Alternative boot";
+        dev_size = dev_size0; /* restore original size. */
          goto check_boot;
      }
      brelse(bh);
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ