Skip to contentSkip to conversation

ntfs: Fix attribute validation check

PATCH In review Vladimir Serbinenko 4 participants 5 messages May 3, 2025 – May 17, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ntfs: Fix attribute validation check

Without this fix GRUB doesn't see most of the files on NTFS partition.

---
 grub-core/fs/ntfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/fs/ntfs.c +1 -1
index b3117bf92..393a763ee 100644
@@ -175,7 +175,7 @@ validate_attribute (grub_uint8_t *attr, void *end)
 	   * the minimum size.
 	   */
 	  min_size += (attr[curr] & 0x7) + ((attr[curr] >> 4) & 0x7);
-	  curr += min_size;
+	  curr = min_size;
 	  min_size++;
 	  if (min_size > attr_size)
 	    goto fail;
Signature · 7 lines
2.49.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Tested-by on v1 1/1
#1 lore raw
Quoted 2 lines · On Sat, 3 May 2025 08:02:07 +0000 Vladimir Serbinenko <[email protected]>…

Without this fix GRUB doesn't see most of the files on NTFS partition.

I can confirm that this fixes the testing issue I mentioned in another thread. The ntfs filesystem tests now fail with HARDLINK FAIL, but I presume that's a separate issue.

Glenn

Quoted 11 lines
---
 grub-core/fs/ntfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/fs/ntfs.c +0 -0
index b3117bf92..393a763ee 100644

grub-core/fs/ntfs.c validate_attribute (grub_uint8_t *attr, void *end) · line 181

Quoted 8 lines
grub-core/fs/ntfs.c +1 -1
@@ -175,7 +175,7 @@ validate_attribute (grub_uint8_t *attr, void *end)
 	   * the minimum size.
 	   */
 	  min_size += (attr[curr] & 0x7) + ((attr[curr] >> 4) & 0x7);
-	  curr += min_size;
+	  curr = min_size;
 	  min_size++;
 	  if (min_size > attr_size)
 	    goto fail;

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw

Yes this matches with the first layer of the onion I also found.

The hard link fail issue seems to stem from attempting to use validate_attribute on attribute lists instead of attributes, I’m working on a fix for that but it’s taking some time as it creates new fuzzer identified flaws once changed.

Thanks
Andrew

Quoted 20 lines · Glenn Washburn
Quoted 2 lines · On Sat, 3 May 2025 08:02:07 +0000 Vladimir Serbinenko <[email protected]>…

Without this fix GRUB doesn't see most of the files on NTFS partition.

I can confirm that this fixes the testing issue I mentioned in another thread. The ntfs filesystem tests now fail with HARDLINK FAIL, but I presume that's a separate issue.

Glenn

Quoted 6 lines
---
 grub-core/fs/ntfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

grub-core/fs/ntfs.c validate_attribute (grub_uint8_t *attr, void *end) · line 181

Quoted 13 lines
grub-core/fs/ntfs.c +1 -1
index b3117bf92..393a763ee 100644
@@ -175,7 +175,7 @@ validate_attribute (grub_uint8_t *attr, void *end)
         * the minimum size.
         */
        min_size += (attr[curr] & 0x7) + ((attr[curr] >> 4) & 0x7);
-       curr += min_size;
+       curr = min_size;
        min_size++;
        if (min_size > attr_size)
          goto fail;

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw

I just sent a patch series that happens to attempt to address the same issue being addressed here, but in a slightly different way. It should have title:
[PATCH 1/3] fs/ntfs: Correct some NTFS regressions

Thanks,
Andrew

Quoted 7 lines · Daniel Kiper
Quoted 2 lines · Vladimir Serbinenko

Without this fix GRUB doesn't see most of the files on NTFS partition.

It would be perfect if it is explained why current code is broken and why the fix is correct...

Quoted 7 lines

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel