From owner-freebsd-bugs@FreeBSD.ORG Sun Nov 13 14:50:08 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 186511065673 for ; Sun, 13 Nov 2011 14:50:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CB42F8FC1A for ; Sun, 13 Nov 2011 14:50:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id pADEo7VL010756 for ; Sun, 13 Nov 2011 14:50:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id pADEo7rk010755; Sun, 13 Nov 2011 14:50:07 GMT (envelope-from gnats) Resent-Date: Sun, 13 Nov 2011 14:50:07 GMT Resent-Message-Id: <201111131450.pADEo7rk010755@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Robert Millan Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92B381065672 for ; Sun, 13 Nov 2011 14:45:13 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 828948FC0A for ; Sun, 13 Nov 2011 14:45:13 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id pADEjDiY028781 for ; Sun, 13 Nov 2011 14:45:13 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id pADEjD41028754; Sun, 13 Nov 2011 14:45:13 GMT (envelope-from nobody) Message-Id: <201111131445.pADEjD41028754@red.freebsd.org> Date: Sun, 13 Nov 2011 14:45:13 GMT From: Robert Millan To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/162519: [zfs] "zpool import" relies on buggy realpath() behaviour X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Nov 2011 14:50:08 -0000 >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: