Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Nov 2011 14:45:13 GMT
From:      Robert Millan <rmh@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/162519: [zfs] "zpool import" relies on buggy realpath() behaviour
Message-ID:  <201111131445.pADEjD41028754@red.freebsd.org>
Resent-Message-ID: <201111131450.pADEo7rk010755@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         162519
>Category:       misc
>Synopsis:       [zfs] "zpool import" relies on buggy realpath() behaviour
>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:   Sun Nov 13 14:50:07 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Robert Millan
>Release:        Debian GNU/kFreeBSD "sid"
>Organization:
>Environment:
>Description:
zpool_find_import_impl() in cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c is relying on buggy realpath() behaviour.

FreeBSD realpath() does not currently conform to SUS specification (see PR 128933). It returns succesfully for invalid paths for which it should return ENOENT.

The code in zpool will stop working correctly when this bug is fixed:

  - By default zpool_find_import_impl() operates on "/dev/dsk/" directory, which on FreeBSD doesn't exist.

  - It begins by attempting to canonicalize this path using realpath(). This should fail with ENOENT and abort execution, but realpath() returns succesfully.

  - It then proceeds to replace "/dev/dsk/" with "/dev/".

  - Finally it opens devices from the (now correct) directory and imports them.

>How-To-Repeat:

>Fix:
The correct solution IMHO is to replace all instances of "/dev/dsk/" with "/dev/". However this could be undesirable wrt new code imports.

Other possibilities could be to move the 'rdsk = "/dev/";' correction up so that it happens before realpath() call, or to add "errno != ENOENT" requirement before aborting with error.


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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111131445.pADEjD41028754>