Hi.

I was looking at the code and it seems statbuf can be used without being
initialized in zpool_vdev.c:make_leaf_vdev().

We stat the given path only if it is not entire disk:

        if (arg[0] == '/') {
                /*
                 * Complete device or file path.  Exact type is
                 * determined by
                 * examining the file descriptor afterwards.
                 */
                wholedisk = is_whole_disk(arg);
                if (!wholedisk && (stat64(arg, &statbuf) != 0)) {
        [...]
        } else {
                /*
                 * This may be a short path for a device, or it could be
                 * total
                 * gibberish.  Check to see if it's a known device in
                 * /dev/dsk/.  As part of this check, see if we've been
                 * given a
                 * an entire disk (minus the slice number).
                 */
                (void) snprintf(path, sizeof (path), "%s/%s", DISK_ROOT,
                    arg);
                wholedisk = is_whole_disk(path);
                if (!wholedisk && (stat64(path, &statbuf) != 0)) {
        [...]

Although later on we use statbuf in the following check:

        /*
         * For a whole disk, defer getting its devid until after
         * labeling it.
         */
        if (S_ISBLK(statbuf.st_mode) && !wholedisk) {
        [...]

I think the best fix is to always stat the given file/device.
You can find the patch here:

        http://people.freebsd.org/~pjd/patches/zpool_vdev.c.patch

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
[email protected]                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!

Attachment: pgpTcWCrWGXEl.pgp
Description: PGP signature

_______________________________________________
zfs-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/zfs-code

Reply via email to