From nobody@FreeBSD.org  Sat May 21 11:18:00 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BA76E106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 21 May 2011 11:18:00 +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 A9D1A8FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 21 May 2011 11:18:00 +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 p4LBI0Yg037179
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 21 May 2011 11:18:00 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p4LBI08x037178;
	Sat, 21 May 2011 11:18:00 GMT
	(envelope-from nobody)
Message-Id: <201105211118.p4LBI08x037178@red.freebsd.org>
Date: Sat, 21 May 2011 11:18:00 GMT
From: Patrick Lamaiziere <patfbsd@davenulle.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: //proc/curproc/file returns "unknown" with a binary called via a nullfs mountpoint
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         157234
>Category:       docs
>Synopsis:       [patch] nullfs(5): //proc/curproc/file returns "unknown" with a binary called via a nullfs mountpoint
>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:   Sat May 21 11:20:08 UTC 2011
>Closed-Date:    
>Last-Modified:  Sun Sep 02 17:06:05 UTC 2012
>Originator:     Patrick Lamaiziere
>Release:        8.2-STABLE / i386
>Organization:
>Environment:
FreeBSD roxette.lamaiziere.net 8.2-STABLE FreeBSD 8.2-STABLE #0: Fri May 20 19:12:02 CEST 2011     root@roxette:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
Hello,

I use a nullfs mount /journal/usrlocal in /usr/local :

mount:
/dev/ada0s2e.journal on /journal (ufs, asynchronous, local, gjournal)
procfs on /proc (procfs, local)
/journal/usrlocal on /usr/local (nullfs, local)

/proc/curproc/file returns "unknown" with a binary called via a nullfs mountpoint, but not if called directly.

test program (test.c)
#include <stdio.h>
#include <unistd.h>
#include <errno.h>

main() {

  ssize_t n = 0;
  char link[1024];

  n = readlink("/proc/curproc/file", link, 1024);
  if (n == -1) {
    printf("error : %d\n", errno);
  } else {
    printf("file = %s\n", link);
  }
}

build and copy "test" binary into /usr/local/bin

$ /journal/usrlocal/bin/test
file = /journal/usrlocal/bin/test

$ /usr/local/bin/test
file = unknown

This prevents me to run java (it uses curproc file to find where are its libraries)

Thanks, regards.
>How-To-Repeat:
See above
>Fix:


>Release-Note:
>Audit-Trail:

From: Patrick Lamaiziere <patfbsd@davenulle.org>
To: bug-followup@FreeBSD.org <bug-followup@FreeBSD.org>
Cc:  
Subject: Re: kern/157234: //proc/curproc/file returns "unknown" with a
 binary called via a nullfs mountpoint
Date: Sat, 21 May 2011 15:34:18 +0200

 --MP_/VpgKIUX=tHLi5_qY/Vc1a2+
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 8bit
 Content-Disposition: inline
 
 Le Sat, 21 May 2011 11:18:00 GMT,
 Patrick Lamaiziere <patfbsd@davenulle.org> a crit :
 
 > /proc/curproc/file returns "unknown" with a binary called via a
 > nullfs mountpoint, but not if called directly.
 
 Well, i've looked a bit the procfs code and this behavior seems
 more or less intented by the function vn_fullpath(9).
 
 procstat(1) is affected too : procstat: sysctl: kern.proc.pathname:
 2265: No such file or directory
 
 So it looks to be a limitation instead of a bug.
 
 I would like to suggest to reclassify this PR into the doc section and
 the attached patch to document the nulls manual page (as usual feel
 free to change the text as english is not my natural language).
 
 Thanks, regards
 
 --MP_/VpgKIUX=tHLi5_qY/Vc1a2+
 Content-Type: text/x-patch
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=nullfs.5.patch
 
 --- nullfs.5.org	2011-05-21 14:37:23.000000000 +0200
 +++ nullfs.5	2011-05-21 15:00:38.000000000 +0200
 @@ -56,6 +56,16 @@
  file system:
  .Pp
  .Dl "mount_nullfs /usr/ports /home/devel/ports"
 +.Sh CAVEAT
 +The
 +.Nm
 +file system prevents to convert a vnode reference to a full pathname, given a
 +process context. This will prevent an application to retrieve its path
 +to process binary. For example, applications using the
 +.Xr procfs 5
 +file system /proc/curproc/file or the 
 +.Xr sysctl 8
 +kern.proc.pathname
  .Sh SEE ALSO
  .Xr fstab 5 ,
  .Xr mount_nullfs 8
 
 --MP_/VpgKIUX=tHLi5_qY/Vc1a2+--
Responsible-Changed-From-To: freebsd-bugs->freebsd-doc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat May 21 22:50:16 UTC 2011 
Responsible-Changed-Why:  
Reclassify at submitter request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=157234 
Responsible-Changed-From-To: freebsd-doc->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun May 6 20:18:33 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=157234 
Responsible-Changed-From-To: eadler->freebsd-bugs 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun Sep 2 17:06:02 UTC 2012 
Responsible-Changed-Why:  
I won't be looking at this PR for a while and I need to clear some out 
of my queue 

http://www.freebsd.org/cgi/query-pr.cgi?pr=157234 
>Unformatted:
