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]
Date: Mon, 29 Jan 2024 11:08:41 +0300
From: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>
To: <ntfs3@...ts.linux.dev>
CC: <linux-kernel@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>
Subject: [PATCH 3/5] fs/ntfs3: Correct function is_rst_area_valid


Reported-by: Robert Morris <rtm@...il.mit.edu>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>
---
  fs/ntfs3/fslog.c | 14 ++++++++------
  1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
index 7dbb000fc691..855519713bf7 100644
--- a/fs/ntfs3/fslog.c
+++ b/fs/ntfs3/fslog.c
@@ -465,7 +465,7 @@ static inline bool is_rst_area_valid(const struct 
RESTART_HDR *rhdr)
  {
      const struct RESTART_AREA *ra;
      u16 cl, fl, ul;
-    u32 off, l_size, file_dat_bits, file_size_round;
+    u32 off, l_size, seq_bits;
      u16 ro = le16_to_cpu(rhdr->ra_off);
      u32 sys_page = le32_to_cpu(rhdr->sys_page_size);

@@ -511,13 +511,15 @@ static inline bool is_rst_area_valid(const struct 
RESTART_HDR *rhdr)
      /* Make sure the sequence number bits match the log file size. */
      l_size = le64_to_cpu(ra->l_size);

-    file_dat_bits = sizeof(u64) * 8 - le32_to_cpu(ra->seq_num_bits);
-    file_size_round = 1u << (file_dat_bits + 3);
-    if (file_size_round != l_size &&
-        (file_size_round < l_size || (file_size_round / 2) > l_size)) {
-        return false;
+    seq_bits = sizeof(u64) * 8 + 3;
+    while (l_size) {
+        l_size >>= 1;
+        seq_bits -= 1;
      }

+    if (seq_bits != ra->seq_num_bits)
+        return false;
+
      /* The log page data offset and record header length must be 
quad-aligned. */
      if (!IS_ALIGNED(le16_to_cpu(ra->data_off), 8) ||
          !IS_ALIGNED(le16_to_cpu(ra->rec_hdr_len), 8))
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ