From 882dbea3a22ad13da37f4d7279f096cc664f8786 Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Mon, 1 Feb 2021 11:53:05 +0900 Subject: [PATCH] tomoyo: recognize kernel threads correctly Commit 29a69a073f00f61f ("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 34ce4b51842c4ac2 ("Smack: Handle io_uring kernel thread privileges") does. Signed-off-by: Tetsuo Handa --- security/tomoyo/network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/tomoyo/network.c b/security/tomoyo/network.c index a89ed55d85d41..478f757ff8435 100644 --- a/security/tomoyo/network.c +++ b/security/tomoyo/network.c @@ -613,7 +613,7 @@ static int tomoyo_check_unix_address(struct sockaddr *addr, static bool tomoyo_kernel_service(void) { /* Nothing to do if I am a kernel service. */ - return uaccess_kernel(); + return (current->flags & (PF_KTHREAD | PF_IO_WORKER)) == PF_KTHREAD; } /** -- 2.39.5