HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/share/selinux-basics/tests/10_test_kernel_processes.py
class TestNoKernelT(TestBase):
	"""
	Test for processes running in system_u:system_r:kernel_t
	This type should only be used by kernel processes, which are detected by
	not having any maps.
	"""
	# Not sure if this test actually helps when the init test succeeded.
	# But it doesn't harm either

	class ErrorBadKernelProcesses(ErrorBase):
		def __init__(self, badprocs):
			self.badprocs = badprocs
		def __str__(self):
			return "There were %d processes found running in the kernel domain." \
				% len(self.badprocs)

	@staticmethod
	def test():
		from subprocess import Popen, PIPE

		badprocs = []

		pipe = Popen("getfilecon /proc/[0-9]*", shell=True, stdin=PIPE, stdout=PIPE, close_fds=True, universal_newlines=True)
		pipe.stdin.close()
		for line in pipe.stdout.readlines():
			(dir, context) = line.split()
			components = dir.split("/")
			pid = components[-1]
			if context.find("system_r:kernel_t") >= 0:
				badproc = False
				file = open("/proc/%s/maps" % pid)
				if file.readlines():
					badproc = True
				file.close()
				if badproc:
					badprocs.append(pid)
		pipe.stdout.close()
		if len(badprocs) > 0:
			return [TestNoKernelT.ErrorBadKernelProcesses(badprocs)]
		return []
register_test(TestNoKernelT)