tomoyo: recognize kernel threads correctly
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Mon, 1 Feb 2021 02:53:05 +0000 (11:53 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Mar 2021 10:11:15 +0000 (11:11 +0100)
commitaa40f5e33ce337a037ec06cc11aae49be64c306c
tree4a42961a4fa195f50389efc913dfc324cc32a1b4
parent4645271c32b440d1e0031e979a39dad46f396401
tomoyo: recognize kernel threads correctly

commit 9c83465f3245c2faa82ffeb7016f40f02bfaa0ad upstream.

Commit db68ce10c4f0a27c ("new helper: uaccess_kernel()") replaced
segment_eq(get_fs(), KERNEL_DS) with uaccess_kernel(). But the correct
method for tomoyo to check whether current is a kernel thread in order
to assume that kernel threads are privileged for socket operations was
(current->flags & PF_KTHREAD). Now that uaccess_kernel() became 0 on x86,
tomoyo has to fix this problem. Do like commit 942cb357ae7d9249 ("Smack:
Handle io_uring kernel thread privileges") does.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/tomoyo/network.c