Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1709681pxb; Mon, 8 Mar 2021 04:37:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzG+m8jeG1soyKFSjH8I/0u2nzktMeUXw4UUJG9pB3E19w4cWUoir39xdcJbv1EI/f/uHgl X-Received: by 2002:a17:906:260a:: with SMTP id h10mr14991580ejc.392.1615207029677; Mon, 08 Mar 2021 04:37:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615207029; cv=none; d=google.com; s=arc-20160816; b=xDTK+CGbpoFcyHZ2lX7zw5ZxuwuBrI7FuY8SoPiddByc7rIJ3dqhdO2iemO+HVC77Z KYsfOsjq/2hN2Go/0rHe1RSEzzlFDM14vCWJiKsRbp6H4F0nrDGicDpZD695YoXYX96R +RYS1VkWC4cG2IWOkS3F+iOz56yGKnwd/91ruleH0aWTG9SBEDgZHnCNA6vijK3z7YUt +x0teO3ll5m8whsal+fTVcUbaszyKsSSZcOl+SzZ+nY7pei8x1deUERKM7Lz8hWlQYOj Qr/bY9ARHlTwKw4N5tqPNzfOX+OAtkwrQIPH38NEn4VVk2ksRtTkTbOrrBAP9anrUSFo Bwrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Sdn7JNQ9MsHTk5cyEmxX2gq/UaDLC4MPpR8RBLorres=; b=YMnmokbsDBcrpuWCHxXnee+cX/g9eLF0K4j243L0HvM1SfJNeH5/kg2TlKKYE1iYBJ wYlzM9U4D8yXDzXtgtwcqnwkpR4qJJ27tT5Fzc9Azb9uKMRcwyXxotO3DW3Or55znRXT zCDaCqAV+uhqyGlb/fA9WC+yvf/MkVrXPr8p/4nNpH385LYyEZ4gBZg7NsHi78N6Omxf PaU8h83lw5Mm8X4XkwAqZujTTF6kcNIlOKEeaTvww6mWVIydstYIGd4mQ6i4kzpdtwNX DqGYaykmu5PzUNFYUy4PqD1TXwWem8IbCSOx/XJwjiwN9PibtMA8vlFXhXFz+yYk65JI NI2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=amxX52nN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 1si6709484ejo.651.2021.03.08.04.36.46; Mon, 08 Mar 2021 04:37:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=amxX52nN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231921AbhCHMfU (ORCPT + 99 others); Mon, 8 Mar 2021 07:35:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:43946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231377AbhCHMeu (ORCPT ); Mon, 8 Mar 2021 07:34:50 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8D5D651C3; Mon, 8 Mar 2021 12:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615206890; bh=qPx5HoDeIJd5nqO3DGiogsWAn9wZ84K1xBXP1XmXZ6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=amxX52nNkt2CkEtXsfFlofUH36XiU18kYxXIhK55kPTkOWU6sjppGyL5toXrm8TS8 M40B9fKfVF91uaUyqlOLkBAYsTCUsOlNHTzEZdDcTjC6gNgAqew+4Jfcc50FsbuzyT 1dTBxb66mG15qT7v8WF4GaI5ayCQLDdyBO9NOghk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa Subject: [PATCH 5.10 41/42] tomoyo: recognize kernel threads correctly Date: Mon, 8 Mar 2021 13:31:07 +0100 Message-Id: <20210308122720.101768274@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308122718.120213856@linuxfoundation.org> References: <20210308122718.120213856@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tetsuo Handa 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 Signed-off-by: Greg Kroah-Hartman --- security/tomoyo/network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/security/tomoyo/network.c +++ b/security/tomoyo/network.c @@ -613,7 +613,7 @@ static int tomoyo_check_unix_address(str 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; } /**