Your message dated Sun, 10 Jul 2016 14:00:13 +0000
with message-id <[email protected]>
and subject line Bug#770215: fixed in procps 2:3.3.12-1
has caused the Debian Bug report #770215,
regarding [ps] needlessly stats files all over the VFS
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
770215: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770215
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: procps
Version: 1:3.3.3-3

When 'ps' tries to determine the tty of a process, it does it by first
finding out the major and minor device number, and then trying to
translate that back into a name. To do that translation, it falls back
through several methods, of which the first is to look up the major
number in /proc/tty/drivers, guess the probable pathname in /dev based
on that and the minor number, and then stat that pathname to see if it
does indeed have the right details.

For the common case of a pty device such as /dev/pts/0, this method
guesses wrong, and 'ps' therefore falls back to its second method,
which is to readlink the process's /proc/NNN/fd/2 and stat whatever it
finds to see if _that's_ a device file with the right numbers (based
on the empirical observation that processes often have fd 2 open on
their own terminal device).

When the process's fd 2 is not pointing at a terminal, this causes ps
to stat a potentially arbitrary node in the VFS. That's normally
harmless, but it can be irritating if one of those nodes is on an
unresponsive filesystem, e.g. an NFS mount whose server is
malfunctioning. And that situation is precisely one in which your
processes start to lock up and you start running 'ps' to find out
what's going on, so you'd quite like 'ps' not to hang as well for the
same reason.

So it would be desirable, if possible, for ps's original approach of
guessing the device name via /proc/tty/drivers to get the right answer
in the first place. And in fact this is very easy. Looking at what
happens with strace in a typical case, we see:

open("/proc/tty/drivers", O_RDONLY)     = 6
read(6, "/dev/tty             /dev/tty   "..., 9999) = 574
close(6)                                = 0
stat("/dev/pts3", 0x7fff3e4adaa0)       = -1 ENOENT (No such file or directory)
stat("/dev/pts", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
readlink("/proc/1555/fd/2", "/dev/pts/3", 127) = 10
stat("/dev/pts/3", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0

Having worked out from /proc/tty/drivers that the major number
corresponds to /dev/pts, we construct the filenames /dev/pts3 and
/dev/pts to test, neither of which works, and then you can see ps
falling back to looking at the process's fd 2. But if we'd tried
/dev/pts/3 as well, that would have been fine!

The attached file procps_driver_name_fix.diff is a small patch against
procps which fixes this for me, and causes the corresponding piece of
strace output to look like this:

open("/proc/tty/drivers", O_RDONLY)     = 7
read(7, "/dev/tty             /dev/tty   "..., 9999) = 574
close(7)                                = 0
stat("/dev/pts3", 0x7fff7c1b58e0)       = -1 ENOENT (No such file or directory)
stat("/dev/pts/3", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0

so that the right tty device is identified immediately and there's no
need to go via /proc at all.

Cheers,
Simon
-- 
for k in [pow(x,37,0x1a1298d262b49c895d47f) for x in [0x50deb914257022de7fff,
0x213558f2215127d5a2d1, 0x90c99e86d08b91218630, 0x109f3d0cfbf640c0beee7,
0xc83e01379a5fbec5fdd1, 0x19d3d70a8d567e388600e, 0x534e2f6e8a4a33155123]]:
 print "".join([chr(32+3*((k>>x)&1))for x in range(79)]) # <[email protected]>
diff --git a/proc/devname.c b/proc/devname.c
index 0066b46..a28bc1b 100644
--- a/proc/devname.c
+++ b/proc/devname.c
@@ -133,9 +133,12 @@ static int driver_name(char *restrict const buf, unsigned maj, unsigned min){
   }
   sprintf(buf, "/dev/%s%d", tmn->name, min);  /* like "/dev/ttyZZ255" */
   if(stat(buf, &sbuf) < 0){
-    if(tmn->devfs_type) return 0;
-    sprintf(buf, "/dev/%s", tmn->name);  /* like "/dev/ttyZZ255" */
-    if(stat(buf, &sbuf) < 0) return 0;
+    sprintf(buf, "/dev/%s/%d", tmn->name, min);  /* like "/dev/pts/255" */
+    if(stat(buf, &sbuf) < 0){
+      if(tmn->devfs_type) return 0;
+      sprintf(buf, "/dev/%s", tmn->name);  /* like "/dev/ttyZZ255" */
+      if(stat(buf, &sbuf) < 0) return 0;
+    }
   }
   if(min != MINOR_OF(sbuf.st_rdev)) return 0;
   if(maj != MAJOR_OF(sbuf.st_rdev)) return 0;

--- End Message ---
--- Begin Message ---
Source: procps
Source-Version: 2:3.3.12-1

We believe that the bug you reported is fixed in the latest version of
procps, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Craig Small <[email protected]> (supplier of updated procps package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Sun, 10 Jul 2016 17:39:28 +1000
Source: procps
Binary: procps libprocps6 libprocps-dev
Architecture: source amd64
Version: 2:3.3.12-1
Distribution: unstable
Urgency: medium
Maintainer: Craig Small <[email protected]>
Changed-By: Craig Small <[email protected]>
Description:
 libprocps-dev - library for accessing process information from /proc
 libprocps6 - library for accessing process information from /proc
 procps     - /proc file system utilities
Closes: 692113 692279 733172 755233 770215 786956 804966 812394 816237 823080 
827423 830313
Changes:
 procps (2:3.3.12-1) unstable; urgency=medium
 .
   [ Helmut Grohne <[email protected]> ]
   * Fix FTBFS pass --host to configure Closes: #812394
 .
   [ Craig Small ]
   * New upstream version
   - free: man document rewritten for shared Closes: #755233
   - free: interpret intervals in non-locale way Closes: #692113
   - library: find tty quicker Closes: #770215
   - kill: report error if cannot kill process Closes: #733172
   - ps: sort by cgroup Closes: #692279
   - ps: fallback to attr/current for context Closes: #786956
   - tests: conditionally add prctl Closes: #816237
   - watch: better handling ANSI including esc[m Closes: #830313
   - watch: use locale-independent float Closes: #692113
   * Fix FTBFS for hurd Closes: #816237
   * Dropped initscript dependency Closes: #804966
   * Don't start procps on install Closes: #827423
   * Fix LSB init script patch from Guillem Closes: #823080
   * Update to standards 3.9.8
Checksums-Sha1:
 17a8b0b8bb013eed8e60f7b5adc345d7665f31cb 2136 procps_3.3.12-1.dsc
 ff473ea8b3bc995b5caa4e68819e8a35cc565a16 840540 procps_3.3.12.orig.tar.xz
 fb18cb62b1f6c75a3e2e7bb6d8886ab400635fa4 26444 procps_3.3.12-1.debian.tar.xz
 3a38d87972479d715842c84f49ba957da7bc1719 69782 libprocps-dev_3.3.12-1_amd64.deb
 19ab820ea757ce8101ce681922ba774f60bbe638 71266 
libprocps6-dbgsym_3.3.12-1_amd64.deb
 a59140b45a3a800ddd54ccacf5699cd39bab47e4 57746 libprocps6_3.3.12-1_amd64.deb
 e83767bb20761167cc4da3906d0481323811b628 335884 
procps-dbgsym_3.3.12-1_amd64.deb
 f95d56c898c9cf36bd2677985c912279e6e35ce0 250030 procps_3.3.12-1_amd64.deb
Checksums-Sha256:
 2b7be33cca3a75e229f7cd8a4aeb6115fa62ad48907025f157abc575d9faf5b1 2136 
procps_3.3.12-1.dsc
 042fcc93e1850aee4c193c51c03f369293fb64fe47e37b38852be6693d12a3af 840540 
procps_3.3.12.orig.tar.xz
 42c33b97fb7ffbf5b16b71194c2a14acc44579723bb2b7a5fc7b0441aaeacf48 26444 
procps_3.3.12-1.debian.tar.xz
 2e0a045ac1a630a30576937b2f5c67de067b13345894b59134dcbf62abca04f1 69782 
libprocps-dev_3.3.12-1_amd64.deb
 6907bf51a5a32594cc6de18d74d83ea087af304f74c03d87824b03993dc2cfc6 71266 
libprocps6-dbgsym_3.3.12-1_amd64.deb
 f644ac219ccfbe6f2cf0d5598667d935ea351a4eca9a84fa186588cf9cd753e5 57746 
libprocps6_3.3.12-1_amd64.deb
 4f856f5d158d1fe682f252cf7bf81ca93ed67994e1e88ac9216247665cda72fd 335884 
procps-dbgsym_3.3.12-1_amd64.deb
 b5ddf2e1d1943c69dfd22d3b5289fe1afda193b5d55f3a6310c2da6d497ee9da 250030 
procps_3.3.12-1_amd64.deb
Files:
 3808bffa631d180fc6ba653e0c51eca3 2136 admin important procps_3.3.12-1.dsc
 8816d9cb9b860a2b5256cd6f48618ddb 840540 admin important 
procps_3.3.12.orig.tar.xz
 2d3517410cad0c745568cb03d1b98924 26444 admin important 
procps_3.3.12-1.debian.tar.xz
 2a58ac594c560233cfa8f13b6362dfaa 69782 libdevel optional 
libprocps-dev_3.3.12-1_amd64.deb
 6e7ff0a8882d09e7f8d82b8f22e87503 71266 debug extra 
libprocps6-dbgsym_3.3.12-1_amd64.deb
 0f67249b284fdbdb461971db11176fe7 57746 libs important 
libprocps6_3.3.12-1_amd64.deb
 949940f3b359dd07f20777df9d734d46 335884 debug extra 
procps-dbgsym_3.3.12-1_amd64.deb
 8effc15d357aa348e56bd5a0607e226e 250030 admin important 
procps_3.3.12-1_amd64.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJXgfyzAAoJEAIhZsD/PITjv04P/A17kF5OmEYo61zaNgHOiFdl
5IsmcRZqaHNdsIr78kvuPpoEf8MFayTqG4luWNAiNeisHq5fVfn7kzzvVZvZ71tr
2TkADtQ3QmMrlYlOVdnNOyhCVW3qiXvs83IzcQRwetMkZtgSw7/5cwxKTH63+tT/
2gcr2/vg8HM7QWKOoGA9CLQA5XQFnOjtG3mIikSQN9yoMCT63ZA5H7xcNsSjEtLn
bBNON6JchojR+9k4Z6NRgTFw3jxBUuRyIQ3EK/zvZWx94lSsQJjX0TtaZlAhdQsg
RTRAQ34g0usJE1r5/b5jy7GO0m/gsA7ACQvxFYvgCuuMkm8D4+4xh+yj9U1AhXRA
IOuMYS3O4V1qqPZZYT0HZ4F96JYcEIGL6gBcbUGOB4hTxHVZ3ubq3gQNkQVYVpOJ
782mpnGwm9slPYJX8wQPR5Jx2IYMJERH2UuyytSIX62Vv8b7MBlphXgaFrUN/Wjm
hUEsDIeXJXwtB5t6+n1iUn2hpH6mGf7lBK4lZQxRBtAwz6G+vTM2Z/2+xhkLcEzC
3GWC1yT0gvK0SLgFRPFMljrsvgf3E2lfKNBXIA54FplmonCH+a/9n5yd9SrZaQ12
7/392t4r7tExzk0hf6VPdSn/P+2JM41xE5uBji+zgB58ypy13AohTxr3C2yJLgAq
8mYxHOdk0HVfW9B8iecz
=f9Wn
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to