Bug 27071 - fsck can't find filesystems with 16 character labels
fsck can't find filesystems with 16 character labels
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: e2fsprogs (Show other bugs)
7.1
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Florian La Roche
Aaron Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-02-11 13:56 EST by Mike Fleetwood
Modified: 2007-04-18 12:31 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-02-11 14:06:26 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Code fix (578 bytes, patch)
2001-02-11 14:06 EST, Mike Fleetwood
no flags Details | Diff

  None (edit)
Description Mike Fleetwood 2001-02-11 13:56:30 EST
Fsck fails to find a filesystem which uses a 16 character volume label.  15
character (and less) labels work.  The error message reported when root
tries to fsck a filesystem is:

    [root]# fsck LABEL=opt1_67890123456
    Couldn't find matching filesystem: LABEL=opt1_67890123456

and for non-root users the error is:

    [mike]$ /sbin/fsck LABEL=opt1_67890123456
    Must be root to scan for matching filesystems: LABEL=opt1_67890123456

The problem is caused by using strdup() to copy the volume label from the
e2fs superblock structure in memory.  The volume label is a 16 character
fixed sized array, not a NUL terminated C string.  It works with labels
less than 16 characters because the array is NUL byte padded up to 16
characters.  When a 16 character label is used strdup() includes random
data from the stack until a 0 byte is found.  (Fsck uses a cut down version
of the e2fs superblock structure which ends with s_last_mounted, hence
random data from the stack and not data from the "Last mounted on" field,
s_last_mounted, is appended).

The faulty code is in:
e2fsprogs-1.19/misc/get_device_by_label.c:get_label_uuid().

Mount does not have the same fault.  Its code correctly handles a non-NUL
terminated character array.  See:
util-linux-2.10p/mount/mount_by_label.c:get_label_uuid().

Find fix for this problem in the attached file:
e2fsprogs-1.19-16clabel.patch.
    
NOTES:
1) Rawhide also uses the same e2fprogs RPM so is also effected.

2) All platforms are probably effected, but it has only been verified on
i386.

3) The fix also adds inclusion of stdlib.h for the required malloc()
function prototype, but half the source files in e2fsprogs-1.19/misc just
use:

    #include <stdio.h>

and the other half use:

    #ifdef HAVE_STDLIB_H
    #include <stdlib.h>
    #endif
Comment 1 Mike Fleetwood 2001-02-11 14:06:23 EST
Created attachment 9680 [details]
Code fix
Comment 2 Florian La Roche 2001-02-12 09:39:37 EST
Thanks a lo for this patch.

Note You need to log in before you can comment on or make changes to this bug.