>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:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to