NetBSD Problem Report #40813

From dholland@eecs.harvard.edu  Sat Feb 28 22:24:45 2009
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 317E863C1DB
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 28 Feb 2009 22:24:45 +0000 (UTC)
Message-Id: <20090228222325.2E59CF897@tanaqui.eecs.harvard.edu>
Date: Sat, 28 Feb 2009 17:23:25 -0500 (EST)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: bad ps/ptyfs interaction
X-Send-Pr-Version: 3.95

>Number:         40813
>Category:       bin
>Synopsis:       bad ps/ptyfs interaction
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 28 22:25:00 +0000 2009
>Closed-Date:    Sun Jun 24 20:30:53 +0000 2012
>Last-Modified:  Sun Jun 24 20:30:53 +0000 2012
>Originator:     David A. Holland
>Release:        NetBSD 5.99.7 (20090209)
>Organization:
>Environment:
System: NetBSD tanaqui 5.99.7 NetBSD 5.99.7 (TANAQUI) #24: Mon Feb 9 11:19:51 EST 2009 root@tanaqui:/usr/src/sys/arch/i386/compile/TANAQUI i386
Architecture: i386
Machine: i386
>Description:

With ptyfs, ps can't -t on a pseudo-tty that isn't open.

>How-To-Repeat:

Leave some processes behind on a tty (in this case from -9'ing the
wrong process after hitting the recent ptrace problem) and then try to
check for whether they've gone away or not:

tanaqui% ps xtpts/31
ps: /dev/pts/31: No such file or directory
Exit 1
tanaqui% ps aux | grep pts/31
dholland 18313  0.0  0.0    96    308 pts/30  R+    5:19PM  0:00.00 grep pts/31
dholland 17941  0.0  0.1   552   1424 pts/31- IX    5:18PM  0:00.01 -bin/tcsh -
dholland 24349  0.0  0.0     0      0 pts/31- ZW         -  0:00.00 (tcsh)
dholland 25237  0.0  0.2  2800   3676 pts/31- I     5:18PM  0:00.04 gdb trace16
tanaqui% 

>Fix:

Dunno. Why should ps need to access the pty anyway? To get its device
number?

>Release-Note:

>Audit-Trail:
From: Julian Djamil Fagir <gnrp@komkon2.de>
To: gnats-bugs@gnats.netbsd.org
Cc: 
Subject: Re: bin/40813: bad ps/ptyfs interaction
Date: Sat, 3 Mar 2012 02:19:14 +0100

 Hi,

 > Dunno. Why should ps need to access the pty anyway? To get its device
 > number?
 yep, see src/bin/ps.c:
 305                 if (stat(ttypath, &sb) == -1)
 306                     err(1, "%s", ttypath);
 307                 if (!S_ISCHR(sb.st_mode))
 308                     errx(1, "%s: not a terminal", ttypath);
 309                 flag = sb.st_rdev;

 If you wouldn't fail now, you would fail later when you kvm_getproc2(3)
 without the device number.

 Regards, Julian

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/40813: bad ps/ptyfs interaction
Date: Sun, 18 Mar 2012 21:38:33 +0000

 On Sat, Mar 03, 2012 at 01:20:04AM +0000, Julian Djamil Fagir wrote:
  >  Hi,
  >  
  >  > Dunno. Why should ps need to access the pty anyway? To get its device
  >  > number?
  >  yep, see src/bin/ps.c:
  >  305                 if (stat(ttypath, &sb) == -1)
  >  306                     err(1, "%s", ttypath);
  >  307                 if (!S_ISCHR(sb.st_mode))
  >  308                     errx(1, "%s: not a terminal", ttypath);
  >  309                 flag = sb.st_rdev;
  >  
  >  If you wouldn't fail now, you would fail later when you kvm_getproc2(3)
  >  without the device number.

 Ok, but it needs to be able to do this without the tty available,
 because there can still be processes lying around even if the ptyfs
 entry has gone away.

 -- 
 David A. Holland
 dholland@netbsd.org

From: "Joerg Sonnenberger" <joerg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40813 CVS commit: src/bin/ps
Date: Mon, 7 May 2012 13:14:31 +0000

 Module Name:	src
 Committed By:	joerg
 Date:		Mon May  7 13:14:31 UTC 2012

 Modified Files:
 	src/bin/ps: ps.c

 Log Message:
 Push logic to convert a ttyname to a device number into its own
 function. Improve dealing with ptyfs by explicitly handling missing
 pts/%d entries, if the kernel supports the pts device (PR 40813).


 To generate a diff of this commit:
 cvs rdiff -u -r1.77 -r1.78 src/bin/ps/ps.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Tue, 19 Jun 2012 05:58:04 +0000
State-Changed-Why:
fixed, thanks joerg :-)


State-Changed-From-To: closed->pending-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Tue, 19 Jun 2012 06:16:59 +0000
State-Changed-Why:
On second thought: pullup-6 #355.


From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40813 CVS commit: [netbsd-6] src/bin/ps
Date: Sun, 24 Jun 2012 18:45:23 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Sun Jun 24 18:45:22 UTC 2012

 Modified Files:
 	src/bin/ps [netbsd-6]: ps.c

 Log Message:
 Pull up following revision(s) (requested by dholland in ticket #355):
 	bin/ps/ps.c: revision 1.78
 Push logic to convert a ttyname to a device number into its own
 function. Improve dealing with ptyfs by explicitly handling missing
 pts/%d entries, if the kernel supports the pts device (PR 40813).


 To generate a diff of this commit:
 cvs rdiff -u -r1.76 -r1.76.4.1 src/bin/ps/ps.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 24 Jun 2012 20:30:53 +0000
State-Changed-Why:
pulled up.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.