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
Created attachment 9680 [details] Code fix
Thanks a lo for this patch.