Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Oct 2017 19:03:45 +0200
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        Chagin Dmitry <dchagin@freebsd.org>, emulation@FreeBSD.org
Subject:   [patch] Fix linux readlink of dead link
Message-ID:  <20171014190345.2d6bcf68@kalimero.tijl.coosemans.org>

next in thread | raw e-mail | index | archive | help
--MP_/YPibB3Hkby4cOEmvRakG=rM
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

Can you review the attached patch?  Currently kern_alternate_path follows
symbolic links which means it fails to return the alternate path if it's
a dead link.  This means syscalls like readlink and lstat fail on a dead
link that exists under /compat/linux but not under /.  I also think it's
better to report an error to applications that try to open such a path
instead of ignoring the link and trying the path under /.
--MP_/YPibB3Hkby4cOEmvRakG=rM
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=linux.nofollow.patch

Index: sys/kern/vfs_lookup.c
===================================================================
--- sys/kern/vfs_lookup.c	(revision 324614)
+++ sys/kern/vfs_lookup.c	(working copy)
@@ -1390,13 +1390,13 @@ kern_alternate_path(struct thread *td, const char *pre
 		for (cp = &ptr[len] - 1; *cp != '/'; cp--);
 		*cp = '\0';
 
-		NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
+		NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf, td);
 		error = namei(&nd);
 		*cp = '/';
 		if (error != 0)
 			goto keeporig;
 	} else {
-		NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
+		NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf, td);
 
 		error = namei(&nd);
 		if (error != 0)

--MP_/YPibB3Hkby4cOEmvRakG=rM--



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