From patchwork Thu Jun 13 10:30:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 166694 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp908323ilk; Thu, 13 Jun 2019 08:34:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWi5Kyky55dL0Vmx0DohN3j7HwR2ErdBJ+0IvqFqw25s//z6BtcF0gcmeDDRy6IQ7pQRqI X-Received: by 2002:a17:902:778d:: with SMTP id o13mr37899496pll.82.1560440089940; Thu, 13 Jun 2019 08:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560440089; cv=none; d=google.com; s=arc-20160816; b=S6y4yqoM0ODnfuzytOegsApgt2JT6VzyBWhc233274vwIr3w2Rjj52YxSjdcZJ8h61 KfPgRg3OjdhIXZvpXyAckknA8HyeVd0rtpFSDsOGwyIRem6Yh0fcR9EfdV8PY+3cO+ID /wN8ilue25gXLGPKOvZqItdOs3JPxCtpr5PP8XGiuw4CJC38ksfjVdhRMJrn6RklOM6f nVfj6w50J/YicYQfjnWJTdprufUlvDiif51zev6sV5AnroxGuzSysZfrCHnzzsSKd+xf WSw6sKGVGZibm4fo0SHQFLExlS7JEgYJq5xO8fScD9osn45/dDcMPNOYKvHI/wrPLI23 iLDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=TYugXC8ytxOCfgDh3mg7Chcw/fQ6qx25pA1xGAB2wEo=; b=ldxKGVIqZc+cBeMTXhRiDy0rx/qBbWjVUcK3xYZW6VnR3xMgi+9CZGHs6rMWMTViOa HOmiXg9/UvXM2YQxHYKjXto8rznUdyYtiWuUpwLIVXDoo47F3Joku7CAFNwcy6/xKoK6 WdzVreXYxlBRacifaegeEiRz3J5/hmmZ+/XkFjg1F/qtIuvfVLOfpkW9o6IdSMVoO069 zO5G3BDlT3hcfTRqWptQh9O07qnAWESz2KLTgx9C3lTv6ES4bYXawsAd3/uK2y9xQCLd M903xpjT9OLkpFdssIYbRziR/YG1vFSeNYD8I8DHwRt1wZ/z9Tu313BaSt7smhr7sZ9g kppQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=om1b7q3q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1si97881pgi.278.2019.06.13.08.34.49; Thu, 13 Jun 2019 08:34:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=om1b7q3q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731981AbfFMPes (ORCPT + 25 others); Thu, 13 Jun 2019 11:34:48 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42255 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728083AbfFMKcB (ORCPT ); Thu, 13 Jun 2019 06:32:01 -0400 Received: by mail-pf1-f195.google.com with SMTP id q10so11556325pff.9 for ; Thu, 13 Jun 2019 03:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TYugXC8ytxOCfgDh3mg7Chcw/fQ6qx25pA1xGAB2wEo=; b=om1b7q3qqqL3hVwwom76w942uIQ0/B4EPiCLfCuWVjwAg29AoGLw6WXFFUHqXBibE+ 0j0OKdm3jdlxA1D/O0QRQOpLhNv5Ogrd9JNks1szszwbDlTE8sSL+SuHA47qdtkMVcBK fh0ruIWuUdE46y+O1g9vrHQwJ2XRu4UtkLoRcxKKBfjvZ+D+584zH7JEa39p/I12YLsd c4SCaI0zDdmJTRvb82Hyib1W7COcIB0wpLY7Sh0Zb0Rch/NfitptGgRpcVvVcY2jHp4N Dv9pfi9mVEfWv5k4TDh02gX+UvZQ5e9qjmJ5q90DuaaSymHzayeEBweOhsV/SAvK222W fDOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TYugXC8ytxOCfgDh3mg7Chcw/fQ6qx25pA1xGAB2wEo=; b=NUoNVUbTxLFtcn5x9GXgDHaNW9G3zz3r76Qs0P57Ohkf2tnQbc9YNG10mHKirNkrWX GFLUkO8R+jqnyLS2pEqc5l3kNgB4MSTtoKaqECcvAvTPdqQuej7MT15HNgbFa5Hytvcp X9S+6WUImQFl7LctFTM6buDre+rJfUxOQE/EIXi6H7Z+JzC2qwNyJIWOBGIJLQwEEk3S Em8hfZ7rqvNWXv6ZXOEKNMoCrtlE+MJXd5eJhAyoSjsD8CtnMTqGm//EdAZPko6joHiJ bqdyv1jURXyaTQ8ODrr2aZuKknGBWztAynoqLixBeNstSr3qPqRPXrxYvWuj/KF9uKMN z8ow== X-Gm-Message-State: APjAAAV7Xp4Tn/QLbRz4ZahPzatXpoJz0WIcFeb9j5VDG0XPy/gfsjK7 k9sNYo7FxyQV+oqBezrmaZsrIA== X-Received: by 2002:a62:1c92:: with SMTP id c140mr92232910pfc.258.1560421920566; Thu, 13 Jun 2019 03:32:00 -0700 (PDT) Received: from localhost.localdomain ([117.196.234.139]) by smtp.gmail.com with ESMTPSA id a12sm2265078pgq.0.2019.06.13.03.31.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Jun 2019 03:31:59 -0700 (PDT) From: Sumit Garg To: keyrings@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Cc: jens.wiklander@linaro.org, corbet@lwn.net, dhowells@redhat.com, jejb@linux.ibm.com, jarkko.sakkinen@linux.intel.com, zohar@linux.ibm.com, jmorris@namei.org, serge@hallyn.com, ard.biesheuvel@linaro.org, daniel.thompson@linaro.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, tee-dev@lists.linaro.org, Sumit Garg Subject: [RFC 3/7] tee: add private login method for kernel clients Date: Thu, 13 Jun 2019 16:00:29 +0530 Message-Id: <1560421833-27414-4-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560421833-27414-1-git-send-email-sumit.garg@linaro.org> References: <1560421833-27414-1-git-send-email-sumit.garg@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are use-cases where user-space shouldn't be allowed to communicate directly with a TEE device which is dedicated to provide a specific service for a kernel client. So add a private login method for kernel clients and disallow user-space to open-session using this login method. Signed-off-by: Sumit Garg --- drivers/tee/tee_core.c | 6 ++++++ include/uapi/linux/tee.h | 2 ++ 2 files changed, 8 insertions(+) -- 2.7.4 diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c index 0f16d9f..4581bd1 100644 --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -334,6 +334,12 @@ static int tee_ioctl_open_session(struct tee_context *ctx, goto out; } + if (arg.clnt_login == TEE_IOCTL_LOGIN_REE_KERNEL) { + pr_err("login method not allowed for user-space client\n"); + rc = -EPERM; + goto out; + } + rc = ctx->teedev->desc->ops->open_session(ctx, &arg, params); if (rc) goto out; diff --git a/include/uapi/linux/tee.h b/include/uapi/linux/tee.h index 4b9eb06..f33c69c 100644 --- a/include/uapi/linux/tee.h +++ b/include/uapi/linux/tee.h @@ -172,6 +172,8 @@ struct tee_ioctl_buf_data { #define TEE_IOCTL_LOGIN_APPLICATION 4 #define TEE_IOCTL_LOGIN_USER_APPLICATION 5 #define TEE_IOCTL_LOGIN_GROUP_APPLICATION 6 +/* Private login method for REE kernel clients */ +#define TEE_IOCTL_LOGIN_REE_KERNEL 0x80000000 /** * struct tee_ioctl_param - parameter