Subject: kern/35395: procfs broken?
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Andreas Wiese <andreas.wiese@instandbesetzt.net>
List: netbsd-bugs
Date: 01/10/2007 12:45:00
>Number:         35395
>Category:       kern
>Synopsis:       /proc/N/exe points to /
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 10 12:45:00 +0000 2007
>Originator:     Andreas Wiese
>Release:        NetBSD 4.99.7
>Organization:
	BSD-Crew Dresden
>Environment:
System: NetBSD schroeder.lan.instandbesetzt.net 4.99.7 NetBSD 4.99.7 (SCHROEDER) #0: Mon Jan 8 22:11:15 CET 2007 root@schroeder.lan.instandbesetzt.net:/sys/arch/i386/compile/SCHROEDER i386
Architecture: i386
Machine: i386
>Description:
I noticed the following weird behaviour in /proc with NetBSD 4.99.7 and
also NetBSD 4.0_BETA2:

#v+
aw@schroeder:~> ls -l /proc/self/exe
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:25 /proc/self/exe -> /
aw@schroeder:~> ls -l /proc/*/exe
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/10228/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/11546/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/1599/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/1642/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/16816/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/16979/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/17372/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/27251/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/27936/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/292/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/298/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/29891/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/303/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/482/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/485/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/817/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/887/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/9620/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/curproc/exe -> /
lr-xr-xr-x  1 root  wheel  1 Jan 10 13:26 /proc/self/exe -> /
aw@schroeder:~> ls -l /proc/self/
total 206
-r--r--r--  1 aw    users      0 Jan 10 13:26 cmdline
--w-------  1 aw    users      0 Jan 10 13:26 ctl
lr-xr-xr-x  1 root  wheel     11 Jan 10 13:26 cwd -> /home/aw
-r--r--r--  1 aw    users      6 Jan 10 13:26 emul
lr-xr-xr-x  1 root  wheel      1 Jan 10 13:26 exe -> /
dr-x------  2 aw    users    512 Jan 10 13:26 fd
-r-xr-xr-x  1 root  wheel  25645 Dec  7 05:16 file
-rw-------  1 aw    users    108 Jan 10 13:26 fpregs
-r--r--r--  1 aw    users      0 Jan 10 13:26 map
-r--r--r--  1 aw    users      0 Jan 10 13:26 maps
-rw-------  1 aw    users  77824 Jan 10 13:26 mem
--w-------  1 aw    users      0 Jan 10 13:26 note
--w-------  1 aw    users      0 Jan 10 13:26 notepg
-rw-------  1 aw    users     64 Jan 10 13:26 regs
lr-xr-xr-x  1 root  wheel      1 Jan 10 13:26 root -> /
-r--r--r--  1 aw    users      0 Jan 10 13:26 status
-rw-------  1 aw    users    512 Jan 10 13:26 xmmregs
aw@schroeder:~>
#v-

I noticed this when touching sun-jdk15 after a looong time and since
java* tries to find itself and its libs via readlink(2)'ing
/proc/self/exe, this completely breaks.

First I thought I optimized my kernel to death, but with an standard
optimized GENERIC kernel this also happens (my toolchain isn't
optimized, so it shouldn't be responsible here).

With a 4.99.5 GENERIC kernel everything works fine, 4.0_BETA2 also seems
to be broken.

Then I wanted to blame security.curtain=1, but setting it to 0 doesn't
change anything (and having it 1 in 4.99.5 also works).

>How-To-Repeat:
n/a
>Fix:
n/a

HAND & LG -- aw
np: Silly (Paradies) -- 11. Flieg
-- 
This signature is intentionally left blank.