Skip to contentSkip to conversation

grub2 claims grub.cfg is out of partition

DISCUSSION Svante Signell 3 participants 8 messages Jul 20, 2011 VFS

lore
Share & tools
lore
#0 lore raw

Have you seen this: Debian bug #634799. Seems to be a problem with Linux on kvm too.

#1 lore raw
Quoted 3 lines · Svante Signell

Have you seen this: Debian bug #634799. Seems to be a problem with Linux on kvm too.

Such bug forwarding requiring the potential bugfixer to search the actual description somewhere lese is automatically ignored

Quoted 5 lines

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

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#2 lore raw
Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Svante Signell

Have you seen this: Debian bug #634799. Seems to be a problem with Linux on kvm too.

Such bug forwarding requiring the potential bugfixer to search the actual description somewhere lese is automatically ignored

Sorry: Here is the link.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=634799

#3 lore raw

tags 634799 + upstream patch
thanks

Hello,

Digging a bit with the issue, it seems grub2 does not ignore entries with inode == 0 while it should. See linux' ext2_readdir() in fs/ext2/dir.c doing it:

		for ( ;(char*)de <= limit; de = ext2_next_entry(de)) {
			if (de->inode) {
			  ...
			}
		}

The attached patch fixes it. Shall I commit it to upstream grub2?

Samuel

=== modified file 'grub-core/fs/ext2.c'

fs/ext2.c +1 -1
@@ -689,7 +689,7 @@ grub_ext2_iterate_dir (grub_fshelp_node_
       if (dirent.direntlen == 0)
         return 0;
 
-      if (dirent.namelen != 0)
+      if (dirent.inode != 0 && dirent.namelen != 0)
 	{
 	  char filename[dirent.namelen + 1];
 	  struct grub_fshelp_node *fdiro;
#4 lore raw
Quoted 5 lines · Samuel Thibault

tags 634799 + upstream patch
thanks

Hello,

I've looked into it and arrived to the similar conclusion that the grub.cfg.new with inode = 0 is the problem. However I think no such entries should be there in the first place. In any case GRUB must be robust to such corruptions but I'd recommend to fix Hurd ext2 implementation as well.

Quoted 13 lines

Digging a bit with the issue, it seems grub2 does not ignore entries with inode == 0 while it should. See linux' ext2_readdir() in fs/ext2/dir.c doing it:

		for ( ;(char*)de <= limit; de = ext2_next_entry(de)) {
			if (de->inode) {
			  ...
			}
		}

The attached patch fixes it. Shall I commit it to upstream grub2?

Samuel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#7 lore raw
In reply to Samuel Thibault
Quoted 2 lines · Samuel Thibault

The attached patch fixes it. Shall I commit it to upstream grub2?

Go ahead

Quoted 17 lines

Samuel
patch

=== modified file 'grub-core/fs/ext2.c'

fs/ext2.c +1 -1
@@ -689,7 +689,7 @@ grub_ext2_iterate_dir (grub_fshelp_node_
       if (dirent.direntlen == 0)
         return 0;
 
-      if (dirent.namelen != 0)
+      if (dirent.inode != 0 && dirent.namelen != 0)
 	{
 	  char filename[dirent.namelen + 1];
 	  struct grub_fshelp_node *fdiro;
Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#5 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Vladimir 'φ-coder/phcoder' Serbinenko, le Thu 21 Jul 2011 00:31:51 +0200, a…
Quoted 5 lines · Samuel Thibault

tags 634799 + upstream patch
thanks

Hello,

I've looked into it and arrived to the similar conclusion that the grub.cfg.new with inode = 0 is the problem. However I think no such entries should be there in the first place.

Mmm, the following spec seems to say it is valid:

http://www.nongnu.org/ext2-doc/ext2.html#IFDIR-INODE

A value of 0 indicate that the entry is not used.

Samuel

#6 lore raw
Quoted 7 lines · Samuel Thibault
Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko, le Thu 21 Jul 2011 00:31:51 +0200, a…
Quoted 5 lines · Samuel Thibault

tags 634799 + upstream patch
thanks

Hello,

Quoted 9 lines
Quoted 3 lines

I've looked into it and arrived to the similar conclusion that the grub.cfg.new with inode = 0 is the problem. However I think no such entries should be there in the first place.

Mmm, the following spec seems to say it is valid:

http://www.nongnu.org/ext2-doc/ext2.html#IFDIR-INODE

A value of 0 indicate that the entry is not used.

Even in this case I'd recommend avoiding creating such entries since various third-party extN software (inclusive readers for other OS) is tailored for Linux flavour. Being nearer to this de-facto reference would facilitate interoperation. (but as I said GRUB implementation is to be fixed regardless)

Quoted 2 lines

Samuel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko