Bug 162519 - [zfs] "zpool import" relies on buggy realpath() behaviour
Summary: [zfs] "zpool import" relies on buggy realpath() behaviour
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Bugmeister
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-13 14:50 UTC by Robert Millan
Modified: 2025-01-19 06:18 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Millan freebsd_committer freebsd_triage 2011-11-13 14:50:07 UTC
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.

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.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-11-13 20:28:39 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:58:47 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2025-01-19 06:18:53 UTC
^Triage: I'm sorry that this PR did not get addressed in a timely fashion.

By now, the version that it was created against is long out of support.
As well, many newer versions of ZFS have been imported.

Please re-open if it is still a problem on a supported version.