linux-stable/tools/testing/selftests/proc
Alexey Dobriyan 5bc73bb345 proc: test how it holds up with mapping'less process
Create process without mappings and check

	/proc/*/maps
	/proc/*/numa_maps
	/proc/*/smaps
	/proc/*/smaps_rollup

They must be empty (excluding vsyscall page) or full of zeroes.

Retroactively this test should've caught embarassing /proc/*/smaps_rollup
oops:

[17752.703567] BUG: kernel NULL pointer dereference, address: 0000000000000000
[17752.703580] #PF: supervisor read access in kernel mode
[17752.703583] #PF: error_code(0x0000) - not-present page
[17752.703587] PGD 0 P4D 0
[17752.703593] Oops: 0000 [#1] PREEMPT SMP PTI
[17752.703598] CPU: 0 PID: 60649 Comm: cat Tainted: G        W         5.19.9-100.fc35.x86_64 #1
[17752.703603] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./X99 Extreme6/3.1, BIOS P3.30 08/05/2016
[17752.703607] RIP: 0010:show_smaps_rollup+0x159/0x2e0

Note 1:
	ProtectionKey field in /proc/*/smaps is optional,
	so check most of its contents, not everything.

Note 2:
	due to the nature of this test, child process hardly can signal
	its readiness (after unmapping everything!) to parent.
	I feel like "sleep(1)" is justified.
	If you know how to do it without sleep please tell me.

Note 3:
	/proc/*/statm is not tested but can be.

Link: https://lkml.kernel.org/r/Yz3liL6Dn+n2SD8Q@localhost.localdomain
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-10-11 18:51:11 -07:00
..
.gitignore proc: test how it holds up with mapping'less process 2022-10-11 18:51:11 -07:00
Makefile proc: test how it holds up with mapping'less process 2022-10-11 18:51:11 -07:00
config
fd-001-lookup.c selftests: fix warning: "_GNU_SOURCE" redefined 2018-10-24 14:49:37 -06:00
fd-002-posix-eq.c tools/testing/selftests/proc: test /proc/*/fd a bit (+ PF_KTHREAD is ABI!) 2018-06-07 17:34:38 -07:00
fd-003-kthread.c selftests: fix warning: "_GNU_SOURCE" redefined 2018-10-24 14:49:37 -06:00
proc-empty-vm.c proc: test how it holds up with mapping'less process 2022-10-11 18:51:11 -07:00
proc-fsconfig-hidepid.c proc: use human-readable values for hidepid 2020-04-22 10:51:22 -05:00
proc-loadavg-001.c selftests: proc: fix warning: _GNU_SOURCE redefined 2020-11-05 10:08:14 -07:00
proc-multiple-procfs.c proc: allow to mount many instances of proc in one pid namespace 2020-04-22 10:51:21 -05:00
proc-pid-vm.c proc: save LOC in vsyscall test 2022-09-11 21:55:06 -07:00
proc-self-map-files-001.c proc: fixup copyright sign 2018-04-12 20:52:25 -07:00
proc-self-map-files-002.c selftests: proc: Make va_max 1MB 2019-11-07 14:52:57 -07:00
proc-self-syscall.c selftests: proc: fix warning: _GNU_SOURCE redefined 2020-11-05 10:08:14 -07:00
proc-self-wchan.c proc: return exit code 4 for skipped tests 2019-03-05 21:07:21 -08:00
proc-subset-pid.c selftests: proc: test subset=pid 2021-05-06 19:24:11 -07:00
proc-tid0.c procfs: do not list TID 0 in /proc/<pid>/task 2021-11-09 10:02:48 -08:00
proc-uptime-001.c proc: fixup copyright sign 2018-04-12 20:52:25 -07:00
proc-uptime-002.c selftests: proc: fix warning: _GNU_SOURCE redefined 2020-11-05 10:08:14 -07:00
proc-uptime.h tools/testing/selftests/proc: test /proc/*/fd a bit (+ PF_KTHREAD is ABI!) 2018-06-07 17:34:38 -07:00
proc.h proc: test /proc/thread-self symlink 2018-08-22 10:52:45 -07:00
read.c proc: mandate ->proc_lseek in "struct proc_ops" 2021-05-06 19:24:11 -07:00
self.c proc: test /proc/self symlink 2018-08-22 10:52:45 -07:00
setns-dcache.c proc: fix /proc/net/* after setns(2) 2019-02-01 15:46:22 -08:00
setns-sysvipc.c proc: test /proc/sysvipc vs setns(CLONE_NEWIPC) 2019-07-16 19:23:21 -07:00
thread-self.c proc: test /proc/thread-self symlink 2018-08-22 10:52:45 -07:00