public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack()
@ 2026-03-29 11:17 tobgaertner
  2026-03-29 11:17 ` [PATCH 1/2] ntfs3: add buffer boundary checks to run_unpack() tobgaertner
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: tobgaertner @ 2026-03-29 11:17 UTC (permalink / raw)
  To: almaz.alexandrovich
  Cc: ntfs3, linux-kernel, stable, security, Tobias Gaertner

From: Tobias Gaertner <tob.gaertner@me.com>

Two bugs in run_unpack() found by fuzzing with a source-patched harness
(LibAFL + QEMU ARM64 system-mode):

Patch 1: run_unpack() checks `run_buf < run_last` at the loop top but
then reads size_size and offset_size bytes via run_unpack_s64() without
verifying they fit in the remaining buffer.  A crafted NTFS image with
truncated run data triggers a heap OOB read of up to 15 bytes on mount.

Patch 2: The volume boundary check `lcn + len > sbi->used.bitmap.nbits`
uses raw addition that can wrap for large values, bypassing the
validation.  CVE-2025-40068 added check_add_overflow() for adjacent
arithmetic but missed this instance.

Both bugs are present since NTFS3 was merged in 5.15.

Could CVE IDs be assigned for these two issues?

tobgaertner (2):
  ntfs3: add buffer boundary checks to run_unpack()
  ntfs3: fix integer overflow in run_unpack() volume boundary check

 fs/ntfs3/run.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] ntfs3: add buffer boundary checks to run_unpack()
  2026-03-29 11:17 [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() tobgaertner
@ 2026-03-29 11:17 ` tobgaertner
  2026-03-29 11:17 ` [PATCH 2/2] ntfs3: fix integer overflow in run_unpack() volume boundary check tobgaertner
  2026-04-07 17:19 ` [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() Konstantin Komarov
  2 siblings, 0 replies; 6+ messages in thread
From: tobgaertner @ 2026-03-29 11:17 UTC (permalink / raw)
  To: almaz.alexandrovich
  Cc: ntfs3, linux-kernel, stable, security, Tobias Gaertner

From: Tobias Gaertner <tob.gaertner@me.com>

run_unpack() checks `run_buf < run_last` at the top of the while loop
but then reads size_size and offset_size bytes via run_unpack_s64()
without verifying they fit within the remaining buffer.  A crafted NTFS
image with truncated run data in an MFT attribute triggers an OOB heap
read of up to 15 bytes when the filesystem is mounted.

Add boundary checks before each run_unpack_s64() call to ensure the
declared field size does not exceed the remaining buffer.

Found by fuzzing with a source-patched harness (LibAFL + QEMU).

Fixes: 82cae269cfa95 ("fs/ntfs3: Add initialization of super block")
Cc: stable@vger.kernel.org
Signed-off-by: Tobias Gaertner <tob.gaertner@me.com>
---
 fs/ntfs3/run.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c
index 395b20492..c3c6917fa 100644
--- a/fs/ntfs3/run.c
+++ b/fs/ntfs3/run.c
@@ -970,6 +970,9 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
 		if (size_size > sizeof(len))
 			return -EINVAL;
 
+		if (run_buf + size_size > run_last)
+			return -EINVAL;
+
 		len = run_unpack_s64(run_buf, size_size, 0);
 		/* Skip size_size. */
 		run_buf += size_size;
@@ -982,6 +985,9 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
 		else if (offset_size <= sizeof(s64)) {
 			s64 dlcn;
 
+			if (run_buf + offset_size > run_last)
+				return -EINVAL;
+
 			/* Initial value of dlcn is -1 or 0. */
 			dlcn = (run_buf[offset_size - 1] & 0x80) ? (s64)-1 : 0;
 			dlcn = run_unpack_s64(run_buf, offset_size, dlcn);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ntfs3: fix integer overflow in run_unpack() volume boundary check
  2026-03-29 11:17 [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() tobgaertner
  2026-03-29 11:17 ` [PATCH 1/2] ntfs3: add buffer boundary checks to run_unpack() tobgaertner
@ 2026-03-29 11:17 ` tobgaertner
  2026-04-07 17:19 ` [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() Konstantin Komarov
  2 siblings, 0 replies; 6+ messages in thread
From: tobgaertner @ 2026-03-29 11:17 UTC (permalink / raw)
  To: almaz.alexandrovich
  Cc: ntfs3, linux-kernel, stable, security, Tobias Gaertner

From: Tobias Gaertner <tob.gaertner@me.com>

The volume boundary check `lcn + len > sbi->used.bitmap.nbits` uses raw
addition which can wrap around for large lcn and len values, bypassing
the validation.  Use check_add_overflow() as is already done for the
adjacent prev_lcn + dlcn and vcn64 + len checks added by commit
3ac37e100385 ("ntfs3: Fix integer overflow in run_unpack()").

Found by fuzzing with a source-patched harness (LibAFL + QEMU).

Fixes: 82cae269cfa95 ("fs/ntfs3: Add initialization of super block")
Cc: stable@vger.kernel.org
Signed-off-by: Tobias Gaertner <tob.gaertner@me.com>
---
 fs/ntfs3/run.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c
index c3c6917fa..a68000bd4 100644
--- a/fs/ntfs3/run.c
+++ b/fs/ntfs3/run.c
@@ -1027,9 +1027,15 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
 			return -EOPNOTSUPP;
 		}
 #endif
-		if (lcn != SPARSE_LCN64 && lcn + len > sbi->used.bitmap.nbits) {
-			/* LCN range is out of volume. */
-			return -EINVAL;
+		if (lcn != SPARSE_LCN64) {
+			u64 lcn_end;
+
+			if (check_add_overflow(lcn, len, &lcn_end))
+				return -EINVAL;
+			if (lcn_end > sbi->used.bitmap.nbits) {
+				/* LCN range is out of volume. */
+				return -EINVAL;
+			}
 		}
 
 		if (!run)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack()
  2026-03-29 11:17 [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() tobgaertner
  2026-03-29 11:17 ` [PATCH 1/2] ntfs3: add buffer boundary checks to run_unpack() tobgaertner
  2026-03-29 11:17 ` [PATCH 2/2] ntfs3: fix integer overflow in run_unpack() volume boundary check tobgaertner
@ 2026-04-07 17:19 ` Konstantin Komarov
  2026-04-15  4:19   ` Tobias Gaertner
  2 siblings, 1 reply; 6+ messages in thread
From: Konstantin Komarov @ 2026-04-07 17:19 UTC (permalink / raw)
  To: tobgaertner; +Cc: ntfs3, linux-kernel, stable, security

On 3/29/26 13:17, tobgaertner wrote:

> [You don't often get email from tob.gaertner@me.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Tobias Gaertner <tob.gaertner@me.com>
>
> Two bugs in run_unpack() found by fuzzing with a source-patched harness
> (LibAFL + QEMU ARM64 system-mode):
>
> Patch 1: run_unpack() checks `run_buf < run_last` at the loop top but
> then reads size_size and offset_size bytes via run_unpack_s64() without
> verifying they fit in the remaining buffer.  A crafted NTFS image with
> truncated run data triggers a heap OOB read of up to 15 bytes on mount.
>
> Patch 2: The volume boundary check `lcn + len > sbi->used.bitmap.nbits`
> uses raw addition that can wrap for large values, bypassing the
> validation.  CVE-2025-40068 added check_add_overflow() for adjacent
> arithmetic but missed this instance.
>
> Both bugs are present since NTFS3 was merged in 5.15.
>
> Could CVE IDs be assigned for these two issues?
>
> tobgaertner (2):
>    ntfs3: add buffer boundary checks to run_unpack()
>    ntfs3: fix integer overflow in run_unpack() volume boundary check
>
>   fs/ntfs3/run.c | 18 +++++++++++++++---
>   1 file changed, 15 insertions(+), 3 deletions(-)
>
> --
> 2.43.0
>
Hello,

Patches are queued for the next merge window, thanks.

Regards,
Konstantin


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack()
  2026-04-07 17:19 ` [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() Konstantin Komarov
@ 2026-04-15  4:19   ` Tobias Gaertner
  2026-04-15  7:00     ` Willy Tarreau
  0 siblings, 1 reply; 6+ messages in thread
From: Tobias Gaertner @ 2026-04-15  4:19 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: ntfs3, linux-kernel, stable, security, info

Hi Konstantin,

Great news! 

Will I get a CVE for that memory leak? 

Can you credit the patch and CVE to “Tiefgang Security Labs”? 

info@tiefgangsecuritylabs.com

Cheers,

Tobias


> On Apr 7, 2026, at 10:19, Konstantin Komarov <almaz.alexandrovich@paragon-software.com> wrote:
> 
> On 3/29/26 13:17, tobgaertner wrote:
> 
>> [You don't often get email from tob.gaertner@me.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>> 
>> From: Tobias Gaertner <tob.gaertner@me.com>
>> 
>> Two bugs in run_unpack() found by fuzzing with a source-patched harness
>> (LibAFL + QEMU ARM64 system-mode):
>> 
>> Patch 1: run_unpack() checks `run_buf < run_last` at the loop top but
>> then reads size_size and offset_size bytes via run_unpack_s64() without
>> verifying they fit in the remaining buffer.  A crafted NTFS image with
>> truncated run data triggers a heap OOB read of up to 15 bytes on mount.
>> 
>> Patch 2: The volume boundary check `lcn + len > sbi->used.bitmap.nbits`
>> uses raw addition that can wrap for large values, bypassing the
>> validation.  CVE-2025-40068 added check_add_overflow() for adjacent
>> arithmetic but missed this instance.
>> 
>> Both bugs are present since NTFS3 was merged in 5.15.
>> 
>> Could CVE IDs be assigned for these two issues?
>> 
>> tobgaertner (2):
>>   ntfs3: add buffer boundary checks to run_unpack()
>>   ntfs3: fix integer overflow in run_unpack() volume boundary check
>> 
>>  fs/ntfs3/run.c | 18 +++++++++++++++---
>>  1 file changed, 15 insertions(+), 3 deletions(-)
>> 
>> --
>> 2.43.0
>> 
> Hello,
> 
> Patches are queued for the next merge window, thanks.
> 
> Regards,
> Konstantin
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack()
  2026-04-15  4:19   ` Tobias Gaertner
@ 2026-04-15  7:00     ` Willy Tarreau
  0 siblings, 0 replies; 6+ messages in thread
From: Willy Tarreau @ 2026-04-15  7:00 UTC (permalink / raw)
  To: Tobias Gaertner
  Cc: Konstantin Komarov, ntfs3, linux-kernel, stable, security, info

Hi,

On Tue, Apr 14, 2026 at 09:19:15PM -0700, Tobias Gaertner wrote:
> Hi Konstantin,
> 
> Great news! 
> 
> Will I get a CVE for that memory leak? 

CVEs are assigned by the CVE team once the patches are backported to
stable, according to the process described here:

   Documentation/process/cve.rst

regards,
Willy

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-15  7:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-29 11:17 [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() tobgaertner
2026-03-29 11:17 ` [PATCH 1/2] ntfs3: add buffer boundary checks to run_unpack() tobgaertner
2026-03-29 11:17 ` [PATCH 2/2] ntfs3: fix integer overflow in run_unpack() volume boundary check tobgaertner
2026-04-07 17:19 ` [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() Konstantin Komarov
2026-04-15  4:19   ` Tobias Gaertner
2026-04-15  7:00     ` Willy Tarreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox