[PATCH v1 0/3] FAT: fix mtime 0 breaking updates

2022-07-15 Thread Robbie Harwood
The first two commits are to make debugging grub-probe failures easier, while
the third is the actual fix.

A Fedora user reported a problem with grub2-mkconfig failing on their system.
This was caused by a grub2-probe failure probing the ESP.  It transpired that
some files on the ESP had mtime of 0, which was a fatal error for fs/fat.
While this is not the first time we have encountered 0 mtimes on the ESP, it's
not clear what causes it at this time.

Be well,
--Robbie

Robbie Harwood (3):
  grub-probe: document the behavior of multiple -v
  grub_fs_probe(): dprint errors from filesystems
  fs/fat: don't error when mtime is 0

 grub-core/fs/fat.c  | 3 ---
 grub-core/kern/fs.c | 1 +
 util/grub-probe.c   | 3 ++-
 3 files changed, 3 insertions(+), 4 deletions(-)

-- 
2.35.1


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH v1 1/3] grub-probe: document the behavior of multiple -v

2022-07-15 Thread Robbie Harwood
Signed-off-by: Robbie Harwood 
---
 util/grub-probe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util/grub-probe.c b/util/grub-probe.c
index 01d26bb87d..446bd25532 100644
--- a/util/grub-probe.c
+++ b/util/grub-probe.c
@@ -732,7 +732,8 @@ static struct argp_option options[] = {
   {"device-map",  'm', N_("FILE"), 0,
N_("use FILE as the device map [default=%s]"), 0},
   {"target",  't', N_("TARGET"), 0, 0, 0},
-  {"verbose", 'v', 0,  0, N_("print verbose messages."), 0},
+  {"verbose", 'v', 0,  0,
+   N_("print verbose messages (pass twice to enable debug printing)."), 0},
   {0, '0', 0, 0, N_("separate items in output using ASCII NUL characters"), 0},
   { 0, 0, 0, 0, 0, 0 }
 };
-- 
2.35.1


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH v1 3/3] fs/fat: don't error when mtime is 0

2022-07-15 Thread Robbie Harwood
In the wild, we occasionally see valid ESPs where some file modification times
are 0.  For instance:

├── [Dec 31  1979]  EFI
│   ├── [Dec 31  1979]  BOOT
│   │   ├── [Dec 31  1979]  BOOTX64.EFI
│   │   └── [Dec 31  1979]  fbx64.efi
│   └── [Jun 27 02:41]  fedora
│   ├── [Dec 31  1979]  BOOTX64.CSV
│   ├── [Dec 31  1979]  fonts
│   ├── [Mar 14 03:35]  fw
│   │   ├── [Mar 14 03:35]  
fwupd-359c1169-abd6-4a0d-8bce-e4d4713335c1.cap
│   │   ├── [Mar 14 03:34]  
fwupd-9d255c4b-2d88-4861-860d-7ee52ade9463.cap
│   │   └── [Mar 14 03:34]  
fwupd-b36438d8-9128-49d2-b280-487be02d948b.cap
│   ├── [Dec 31  1979]  fwupdx64.efi
│   ├── [May 10 10:47]  grub.cfg
│   ├── [Jun  3 12:38]  grub.cfg.new.new
│   ├── [May 10 10:41]  grub.cfg.old
│   ├── [Jun 27 02:41]  grubenv
│   ├── [Dec 31  1979]  grubx64.efi
│   ├── [Dec 31  1979]  mmx64.efi
│   ├── [Dec 31  1979]  shim.efi
│   ├── [Dec 31  1979]  shimx64.efi
│   └── [Dec 31  1979]  shimx64-fedora.efi
└── [Dec 31  1979]  FSCK.REC

5 directories, 17 files

This causes grub-probe failure, which in turn causes grub-mkconfig
failure.  They are valid filesystems that appear intact, and the Linux
FAT stack is able to mount and manipulate them without complaint.

The check for mtime of 0 has been present since
20def1a3c3952982395cd7c3ea7e78638527962b ("fat: support file
modification times").

Signed-off-by: Robbie Harwood 
---
 grub-core/fs/fat.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c
index 0951b2e63f..c5efed7241 100644
--- a/grub-core/fs/fat.c
+++ b/grub-core/fs/fat.c
@@ -1027,9 +1027,6 @@ grub_fat_dir (grub_device_t device, const char *path, 
grub_fs_dir_hook_t hook,
  grub_le_to_cpu16 (ctxt.dir.w_date),
  &info.mtime);
 #endif
-  if (info.mtimeset == 0)
-   grub_error (GRUB_ERR_OUT_OF_RANGE,
-   "invalid modification timestamp for %s", path);
 
   if (hook (ctxt.filename, &info, hook_data))
break;
-- 
2.35.1


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH v1 2/3] grub_fs_probe(): dprint errors from filesystems

2022-07-15 Thread Robbie Harwood
When filesystem detection fails, all that's currently debug-logged is a
series of messages like:

grub-core/kern/fs.c:56:fs: Detecting ntfs...
grub-core/kern/fs.c:76:fs: ntfs detection failed.

repeated for each filesystem.  Any messages provided to grub_error() by
the filesystem are lost, and one has to break out gdb to figure out what
went wrong.

With this change, one instead sees:

grub-core/kern/fs.c:56:fs: Detecting fat...
grub-core/osdep/hostdisk.c:357:hostdisk: reusing open device
`/path/to/device'
grub-core/kern/fs.c:77:fs: error: invalid modification timestamp for /.
grub-core/kern/fs.c:79:fs: fat detection failed.

in the debug prints.

Signed-off-by: Robbie Harwood 
---
 grub-core/kern/fs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c
index e0d7e16a29..bb1d8cc9dd 100644
--- a/grub-core/kern/fs.c
+++ b/grub-core/kern/fs.c
@@ -74,6 +74,7 @@ grub_fs_probe (grub_device_t device)
  if (grub_errno == GRUB_ERR_NONE)
return p;
 
+ grub_dprintf ("fs", _("error: %s.\n"), grub_errmsg);
  grub_error_push ();
  grub_dprintf ("fs", "%s detection failed.\n", p->name);
  grub_error_pop ();
-- 
2.35.1


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Initialize local relocator subchunk struct to all zeros

2022-07-15 Thread Alec Brown
On Thu, Jul 14, 2022 at 03:38:04PM +0100, Darren Kenny wrote:
> Hi Ross,
> 
> This looks good to me.
> 
> On Thursday, 2022-07-14 at 09:41:28 -04, Ross Philipson wrote:
> > The way the code is written the tofree variable would never be
> > passed to the free_subchunk() function uninitialized. Coverity
> > cannot determine this and flags the situation as "Using uninitialized
> > value...". The fix is just to initialize the local struct.
> >
> > Fixes: CID 314016
> >
> > Signed-off-by: Ross Philipson 
> 
> Reviewed-by: Darren Kenny 

I ran this through a private Coverity scan which marked the bug as eliminated
and didn't have any issues running it on a VM.

Tested-by: Alec Brown 

Alec Brown

> 
> Thanks,
> 
> Darren.
> 
> > ---
> >  grub-core/lib/relocator.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
> > index 68ef128..bfcc70d 100644
> > --- a/grub-core/lib/relocator.c
> > +++ b/grub-core/lib/relocator.c
> > @@ -989,7 +989,7 @@ malloc_in_range (struct grub_relocator *rel,
> > if (j != 0 && events[j - 1].pos != events[j].pos)
> >   {
> > grub_addr_t alloc_start, alloc_end;
> > -   struct grub_relocator_subchunk tofree;
> > +   struct grub_relocator_subchunk tofree = {0};
> > struct grub_relocator_subchunk *curschu = &tofree;
> > if (!oom)
> >   curschu = &res->subchunks[cural];
> > -- 
> > 1.8.3.1

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel