misc/150207: zpool import -d /dev tries to open weird devices

Aurelien Jarno aurelien at aurel32.net
Wed Sep 1 23:00:10 UTC 2010


>Number:         150207
>Category:       misc
>Synopsis:       zpool import -d /dev tries to open weird devices
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 01 23:00:09 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Aurelien Jarno
>Release:        8.1
>Organization:
>Environment:
FreeBSD freebsd.aurel32.net 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010     root at almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
When running "zpool import -d /dev", this command should loop on all devices in /dev and try to open them to look for a zpool. Unfortunately there is a small programming error in the way the name of the device is computed, as shown with ktrace:

 16061 zpool    CALL  open(0xbfbfa724,O_RDONLY,<unused>0x280cdaef)
 16061 zpool    NAMI  "/dev//geom.ctl"
 16061 zpool    CALL  open(0xbfbfa724,O_RDONLY,<unused>0x280cdaef)
 16061 zpool    NAMI  "/dev//geom.ctl/console"
 16061 zpool    RET   open -1 errno 20 Not a directory
 16061 zpool    CALL  open(0xbfbfa724,O_RDONLY,<unused>0x280cdaef)
 16061 zpool    NAMI  "/dev//geom.ctl/console/devctl"

[...]

 16061 zpool    CALL  open(0xbfbfa724,O_RDONLY,<unused>0x280cdaef)
 16061 zpool    NAMI  "/dev//geom.ctl/console/devctl/null/zero/klog/pci/ptmx/ctty/random/urandom/bpf/bpf0/sysmouse/dcons/dgdb/fido/nfslock/audit/fd/stdin/stdout/stderr/io/kbdmux0/kbd1/mem/kmem/ata/acpi/led/atkbd0/kbd0/psm0/bpsm0/lpt0/lpt0.ctl/ppi0/ttyu0/ttyu0.init/ttyu0.lock/cuau0/cuau0.init/cuau0.lock/ttyv0/ttyv1/ttyv2/ttyv3/ttyv4/ttyv5/ttyv6/ttyv7/ttyv8/ttyv9/ttyva/ttyvb/ttyvc/ttyvd/ttyve/ttyvf/consolectl/usbctl/mdctl/devstat/xpt0/ad0/ad0s1/acd0/ad0s1a/ad0s1b/ufsid/log/pts/zfs"

>How-To-Repeat:
Just run zpool import -d /dev
>Fix:
The problem comes from cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c 

The file name is computed using:

  (void) snprintf(path, sizeof (path), "%s/%s", rdsk,
                  dp->d_name);

However, a few lines upper, rpath is assigned to rdev:

  if (strcmp(path, "/dev/dsk/") == 0)
          rdsk = "/dev/rdsk/";
  else
          rdsk = path;

Thes best way to fix that is probably to avoid reusing variables.

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list