[Bug 249] New: findfs finds the wrong partition

bugzilla at busybox.net bugzilla at busybox.net
Tue Mar 31 01:48:12 UTC 2009


           Summary: findfs finds the wrong partition
           Product: Busybox
           Version: 1.13.x
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Other
        AssignedTo: unassigned at busybox.net
        ReportedBy: mrsam at courier-mta.com
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.0

A lengthy debugging session with kexec-tools identified what looks like a bug
in busybox's internal implementation of findfs.

See the 2-3 comments starting with

I'm looking at the following code in busybox:

char *get_devname_from_label(const char *spec)
        struct uuidCache_s *uc;
        int spec_len = strlen(spec);

        uc = uuidCache;
        while (uc) {
// FIXME: empty label ("LABEL=") matches anything??!
                if (uc->label[0] && strncmp(spec, uc->label, spec_len) == 0) {
                        return xstrdup(uc->device);
                uc = uc->next;
        return NULL;

My existing partitions have the following labels, "/", "/home", and "/boot" (I
use their mountpoints as labels, which is perfectly kosher).

The command "findfs LABEL=/" in busybox ends up returning the wrong partition
to me. It looks to me like that strncmp is the culprit. The loop iterates over
another partition first. strncmp("/", "/boot", 1) == 0, so this loop returns
the partition that carries the "/boot" label, instead of "/". Chaos ensues...

Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the busybox-cvs mailing list