bugGNU GRUB - Bugs: bug #42466, GRUB cannot load symlinks of...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #42466: GRUB cannot load symlinks of length 60 on ext4

Submitter:  KOVACS Krisztian <hidden_balabit>
Submitted:  Fri 30 May 2014 01:24:13 PM UTC
   
 
Category:  Filesystem Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  None Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Open Release:  Git master
Release:  Reproducibility:  Every Time
Planned Release:  2.02

Mon 14 Nov 2016 04:37:40 PM UTC, comment #4: 

Well, that appears to work for Linux, and looks straightforward to me. See fs/ext4/inode.c:ext4_inode_is_fast_symlink().

Andrei Borzenkov <arvidjaar>
Group Member
Tue 11 Oct 2016 02:19:39 PM UTC, comment #3: 

So do you have any suggestion how a proper fix would work?

I've tried fixing the off-by-one so it works correctly with the most popular and widespread implementation of ext4.

A fix based on block counts seems less straightforward to me -- even though it seems that setting extended attributes on symbolic links is not supported (http://unix.stackexchange.com/questions/16537/extended-attribute-on-symbolic-link).

KOVACS Krisztian <hidden_balabit>
Wed 24 Aug 2016 08:10:08 AM UTC, comment #2: 

Yes, this is how Linux does it; but we need to take in account extended attributes which add to block count.

Andrei Borzenkov <arvidjaar>
Group Member
Sun 22 Jun 2014 01:35:06 AM UTC, comment #1: 

That's disturbing. The big problem is that different OS may have different behaviour (there are several ext* writers). Perhaps we should check blocks count instead.

Vladimir Serbinenko <phcoder>
Group administrator
Fri 30 May 2014 01:24:13 PM UTC, original submission:  

We have a setup where the kernel to be loaded is accessed through a path containing a symbolic link. The config is something like this:

- 8< -
search --set=root --label boot

linux '/boot/active/kernel'
initrd '/boot/active/initrd'
- 8< -

If '/boot/active' is a symbolic link to a directory whose name is exactly 60 characters long, loading the kernel fails and GRUB cannot boot. Directories whose name is less than 60 or more than 60 work perfectly.

It seems to be that there is a difference in how the Linux ext4 implementation handles in-inode symbolic links and what the GRUB implementation expects.

In the Linux implementation of ext4, symbolic links whose target is shorter than 60 bytes are stored directly in the inode. (See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/ext4/namei.c?id=455c6fdbd219161bd09b1165f11699d6d73de11c#n2831)

It's worth noting that the code performs the comparison '(l > 60)', where l equals strlen(symname)+1. That means in practice that if the lenth of the symlink target is 60, the comparison is true, meaning that it is stored as a non-fast symlink in a separate block.

In the GRUB implementation, however, the following comparison is made to check if the symlink target is stored in the inode structure: diro->inode.size <= 60. (sizeof(diro->inode.symlink) == 60) Unfortunately, if size is 60, this leads to GRUB looking for the symlink target in the inode, but the ext4 implementation has not stored that info there.

I've attached a patch that seems to fix the issue by making sure that GRUB handles symlink targets of length 60 as non-fast.

KOVACS Krisztian <hidden_balabit>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #31471:  grub-ext4-symlink-target-of-length-60.diff added by hidden_balabit (671B - text/x-patch - Patch fixing the issue with 60 char symlink targets.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arvidjaar (Posted a comment)
  • -email is unavailable- added by phcoder (Posted a comment)
  • -email is unavailable- added by hidden_balabit (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-02 phcoder Planned ReleaseNone 2.02
    2014-05-30 hidden_balabit Attached File- Added grub-ext4-symlink-target-of-length-60.diff, #31471

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code