Subject: kern/11757: emulations don't treat readlink(2) and similar symlink calls correctly
To: None <gnats-bugs@gnats.netbsd.org>
From: Jaromír <dolecek@ics.muni.cz>
List: netbsd-bugs
Date: 12/17/2000 15:06:15
>Number:         11757
>Category:       kern
>Synopsis:       emulations don't treat readlink(2) and similar symlink calls correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 17 15:06:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Jaromír Dolecek
>Release:        1.5N 2000-12-18
>Organization:
	
>Environment:
	
System: NetBSD saruman.ics.muni.cz 1.5N NetBSD 1.5N (SARUMAN) #168: Sun Dec 17 21:37:12 CET 2000 dolecek@saruman.ics.muni.cz:/usr/home/dolecek/soft/netbsd/sys/arch/i386/compile/SARUMAN i386
Architecture: i386
Machine: i386
>Description:
	readlink() might behave incorrectly if the symlink doesn't lead
	to real file. Emulations typically do CHECK_ALT_EXIST() check,
	but since the symlink does not lead to real file and namei() call
	is done with FOLLOW, it fails
	and path without /emul/FOO/ prefix is used for the syscall.

	This may affect also lchown() and similar syscalls which operate
	on symlinks. 

	This is non-critical, since the cases where it fails are pretty
	seldom (and for emulations only, it works ok for 'native' calls or
	if the accessed file exists under 'normal' tree)
>How-To-Repeat:
	ln -s U /emul/freebsd/etc/malloc.conf

	watch ktrace and find out the readlink(2) syscall fails even when
	the symlink exists.
>Fix:
	Probably introduce third form of CHECK_ALT_*, which makes emul_find()
	to use namei() with NOFOLLOW.
	No patch provided, this PR is mainly a reminder to handle this later.
>Release-Note:
>Audit-Trail:
>Unformatted: