NetBSD Problem Report #55361
From kardel@Kardel.name Tue Jun 9 17:04:17 2020
Return-Path: <kardel@Kardel.name>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 5039E1A9219
for <gnats-bugs@gnats.NetBSD.org>; Tue, 9 Jun 2020 17:04:17 +0000 (UTC)
Message-Id: <20200609150855.019E544B33@Andromeda.Kardel.name>
Date: Tue, 9 Jun 2020 17:08:54 +0200 (CEST)
From: kardel@netbsd.org
Reply-To: kardel@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: realpath(3) does not resolve magic symlinks
X-Send-Pr-Version: 3.95
>Number: 55361
>Category: lib
>Synopsis: realpath(3) does not resolve magic symlinks
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jun 09 17:05:00 +0000 2020
>Last-Modified: Wed Jul 01 13:50:01 +0000 2020
>Originator: Frank Kardel
>Release: NetBSD 9.99.65
>Organization:
>Environment:
System: NetBSD test2 9.99.65 NetBSD 9.99.65 (GENERIC) #2: Tue Jun 9 01:58:38 CEST 2020 kardel@Andromeda:/src/NetBSD/cur/src/obj.amd64/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
realpath(3) does not replace the magic symlink variables when
magic symlinks are enabled (vfs.generic.magicsymlinks=1).
This leads to unexpected / hard to explain / hard to debug in build.sh runs as
some realpath resolved paths are embedded in built tools.
Example (part of running multiple userlands match the current kernel version)
# sysctl vfs.generic.magiclinks
vfs.generic.magiclinks = 1
# uname -r
9.99.65
# ls -ld /usr
lrwxr-xr-x 1 root wheel 14 May 13 11:50 /usr -> @osrelease/usr
# ls -l /@osrelease
lrwxr-xr-x 1 root wheel 7 May 13 11:56 /@osrelease -> 8.99.24
# realpath /usr
/8.99.24/usr <= unexpected for magiclinks=1
# ( cd /usr && pwd )
/9.99.65/usr <= kernel correctly resolves the path
Thus realpath(3) and kernel disagree on the final path.
>How-To-Repeat:
see above
>Fix:
- put a warning/bug into realpath(3) manual about not coping with magiclinks
- fix realpath(3) to pick up sysctl.generic.magiclinks and do
the respective replacements if needed.
>Audit-Trail:
From: Jukka Ruohonen <jruohonen@iki.fi>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: lib/55361: realpath(3) does not resolve magic symlinks
Date: Tue, 9 Jun 2020 20:55:38 +0300
On Tue, Jun 09, 2020 at 05:05:00PM +0000, kardel@netbsd.org wrote:
> >Fix:
> - put a warning/bug into realpath(3) manual about not coping with magiclinks
> - fix realpath(3) to pick up sysctl.generic.magiclinks and do
> the respective replacements if needed.
In addition, it would be worthwhile to add a unit/regression/consistency
test to ../tests/lib/libc/gen/t_realpath, i.e. to at least document it also
in terms of code.
- Jukka
From: "Jukka Ruohonen" <jruoho@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55361 CVS commit: src
Date: Wed, 1 Jul 2020 13:49:27 +0000
Module Name: src
Committed By: jruoho
Date: Wed Jul 1 13:49:26 UTC 2020
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/kernel: Makefile
Added Files:
src/tests/kernel: t_magic_symlinks.sh
Log Message:
Add basic checks for magic symlink(7)'s. These include a case for PR lib/55361,
although it seems that realpath(3) has bigger problems with these symlinks.
To generate a diff of this commit:
cvs rdiff -u -r1.869 -r1.870 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.67 -r1.68 src/tests/kernel/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/kernel/t_magic_symlinks.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.