1
0
Fork 0
alistair23-linux/tools
Alexey Dobriyan b2f5de0334 tools/testing/selftests/proc: test /proc/*/fd a bit (+ PF_KTHREAD is ABI!)
* Test lookup in /proc/self/fd.
  "map_files" lookup story showed that lookup is not that simple.

* Test that all those symlinks open the same file.
  Check with (st_dev, st_info).

* Test that kernel threads do not have anything in their /proc/*/fd/
  directory.

Now this is where things get interesting.

First, kernel threads aren't pinned by /proc/self or equivalent,
thus some "atomicity" is required.

Second, ->comm can contain whitespace and ')'.
No, they are not escaped.

Third, the only reliable way to check if process is kernel thread
appears to be field #9 in /proc/*/stat.

This field is struct task_struct::flags in decimal!
Check is done by testing PF_KTHREAD flags like we do in kernel.

	PF_KTREAD value is a part of userspace ABI !!!

Other methods for determining kernel threadness are not reliable:
* RSS can be 0 if everything is swapped, even while reading
  from /proc/self.

* ->total_vm CAN BE ZERO if process is finishing

	munmap(NULL, whole address space);

* /proc/*/maps and similar files can be empty because unmapping
  everything works. Read returning 0 can't distinguish between
  kernel thread and such suicide process.

Link: http://lkml.kernel.org/r/20180505000414.GA15090@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-06-07 17:34:38 -07:00
..
accounting License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
arch tools headers: Sync x86 cpufeatures.h with the kernel sources 2018-06-01 16:13:16 -03:00
bpf bpf: fix cbpf parser bug for octal numbers 2018-06-03 07:46:55 -07:00
build Kbuild: fix # escaping in .cmd files for future Make 2018-04-11 00:03:02 +09:00
cgroup tools: fix cross-compile var clobbering 2018-02-21 15:35:42 -08:00
firewire License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gpio Linux 4.16-rc5 2018-03-18 17:48:59 +01:00
hv tools: hv: include string.h in hv_fcopy_daemon 2018-03-06 09:57:16 -08:00
iio tools: fix cross-compile var clobbering 2018-02-21 15:35:42 -08:00
include Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-06-06 18:39:49 -07:00
kvm/kvm_stat tools/kvm_stat: Remove unused function 2018-03-28 22:47:06 +02:00
laptop tools: fix cross-compile var clobbering 2018-02-21 15:35:42 -08:00
leds tools: fix cross-compile var clobbering 2018-02-21 15:35:42 -08:00
lib Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-06-06 18:39:49 -07:00
memory-model tools/memory-model: Add reference for 'Simplifying ARM concurrency' 2018-05-15 08:11:19 +02:00
nfsd License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
objtool objtool: Detect RIP-relative switch table references, part 2 2018-05-19 08:10:04 +02:00
pci License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pcmcia License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
perf Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-06-04 17:14:22 -07:00
power Merge back earlier PM tools material for v4.18. 2018-06-03 10:12:30 +02:00
scripts Kbuild: fix # escaping in .cmd files for future Make 2018-04-11 00:03:02 +09:00
spi tools: fix cross-compile var clobbering 2018-02-21 15:35:42 -08:00
testing tools/testing/selftests/proc: test /proc/*/fd a bit (+ PF_KTHREAD is ABI!) 2018-06-07 17:34:38 -07:00
thermal/tmon tools/thermal: tmon: fix for segfault 2018-03-27 09:51:23 +02:00
time
usb usbip: usbip_detach: fix to check for invalid ports 2018-05-31 12:44:39 +02:00
virtio PCI: remove PCI_DMA_BUS_IS_PHYS 2018-05-07 07:15:41 +02:00
vm mm: mark pages in use for page tables 2018-06-07 17:34:37 -07:00
wmi tools: fix cross-compile var clobbering 2018-02-21 15:35:42 -08:00
Makefile platform-drivers-x86 for v4.15-1 2017-11-18 10:26:57 -08:00