Skip to contentSkip to conversation

How to test grub_iso9660_uuid from userland ?

DISCUSSION Thomas Schmitt via Grub-devel 2 participants 3 messages Jul 1, 2024

lore
Share & tools
lore
#0 lore raw

Hi,

i found a wrong word in an error message of grub-core/fs/iso9660.c function grub_iso9660_uuid():

         grub_error (GRUB_ERR_BAD_NUMBER, "no creation date in filesystem to generate UUID");

The missing entity would be the modification date
data->voldesc.modified
rather than the creation date
data->voldesc.created

The fix is obviously simple. But i have no idea how to get the code execution to this function for testing.
An ISO with 0 date would be easy to fake. A use case known to me is in GRUB configuration with command "search" and option "--fs-uuid". In grub-fstest.c i see no opportunity to perform "search".

Any idea how to test grub_iso9660_uuid() from userland of a running GNU/Linux ?

Have a nice day :)

Thomas

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

#1 lore raw
Quoted 13 lines · Thomas Schmitt via Grub-devel

Hi,

i found a wrong word in an error message of grub-core/fs/iso9660.c function grub_iso9660_uuid():

grub_error (GRUB_ERR_BAD_NUMBER, "no creation date in filesystem
to generate UUID");

The missing entity would be the modification date
data->voldesc.modified
rather than the creation date
data->voldesc.created

Quoted 9 lines

The fix is obviously simple. But i have no idea how to get the code execution to this function for testing.
An ISO with 0 date would be easy to fake. A use case known to me is in GRUB configuration with command "search" and option "--fs-uuid". In grub-fstest.c i see no opportunity to perform "search".

Any idea how to test grub_iso9660_uuid() from userland of a running GNU/Linux ?

grub-fstest IMAGE ls -- -l

Quoted 4 lines

Have a nice day :)

Quoted 8 lines

Thomas

_______________________________________________
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

#2 lore raw

Hi,

the question is now:

Is it worth to correct an error text which i cannot get to show up ?

Quoted 1 line · Vladimir 'phcoder' Serbinenko

grub-fstest IMAGE ls -- -l

  $ gunzip <tests/iso9660_early_ce.iso.gz >/tmp/iso9660_early_ce.iso
  $ ./grub-fstest /tmp/iso9660_early_ce.iso ls -- -l
  ...
  Device loop0: Filesystem type iso9660 - Label `ISOIMAGE' -
  Last modification time 2023-03-04 16:28:35 Saturday,
  UUID 2023-03-04-16-28-35-00 - Sector size 512B - Total size 68KiB
  ...

Now zeroizing the modification date (offset 830 in PVD at offset 32768):

  $ dd if=/dev/zero of=/tmp/iso9660_early_ce.iso conv=notrunc bs=1 count=17 seek=33598
  $ ./grub-fstest /tmp/iso9660_early_ce.iso ls -- -l
  ...
  Device loop0: Filesystem type iso9660 - Label `ISOIMAGE' -
  Sector size 512B - Total size 68KiB
  ...
  $

Well, it did not crash and there is no UUID. But i don't see the error message either.

Switching to the branch with my proposed error text improvements of grub-fstest ...
Still nothing to see. Obviously grub_errno is not set after function execute_command of grub-fstest.c.

I checked that a bad ISO still causes a visible error message

  $ /grub-fstest /tmp/iso9660_ce_loop2.iso ls / -- -l
  ls : GRUB error 9 with message 'suspecting endless CE loop'
  ./grub-fstest: error: encountered 1 error during command execution.
  $

I also zeroized creation date at offset 32768+813 of the original ISO and verified that grub-fstest still shows an UUID.
So the only thing i could prove by my test run is that indeed GRUB depends on ISO 9660 modification time for its UUID production.

I failed to hack the function grub_error in grub-core/kern/err.c so that it shows grub_errmsg to me. Neither fprintf(3) nor write(2) seem in reach. The attempt to #include /usr/include/stdio.h or /usr/include/unistd.h fails with not found sub-header files.

Have a nice day :)

Thomas

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