Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4628926ybi; Tue, 30 Jul 2019 05:28:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqx58ws354TpLJfCkJi9cNZKUBtUHRWEWHoAb/FHN5KIhh+4DpNH3YEYG03MwMWSTf+WEZNp X-Received: by 2002:a62:e308:: with SMTP id g8mr43595066pfh.162.1564489733289; Tue, 30 Jul 2019 05:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564489733; cv=none; d=google.com; s=arc-20160816; b=sHqTgF5mTmaRovfOnIRvDRWvlrXl/J0xhxudE8LJ14ZOej1N8LdJVf0On5XZbLPlVR tAa7nQUFckw6jzRzz6fNcxlpwuNW6OCeeW++itslF2z71xW9u+vKubwfzgtWDNkqtq7I 4wvLp/Al+8a9Yv4VouDfgLx/P24r7S5EA60cloS0SVCmKnfULLSMnTqH14IMYV6FnWxK 4VlJ6//so9DjhBzR21iZmnZUimshTZT7zKmLevKtPxysQmykdKvjOVukUCTaI4EsmCFe JMzz2y/KkodEF32XPHgt14VhHJPbgKt0c2kByls/G2g5xQ8xxWgWwnTRw1wYbVInuOAw aZow== 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=E3OJFxf+mUWoz3h8BXrLdL53qyDG3CcJuYs/0iyxKF4=; b=bmqQX8bdXrRJYJI2qcjpQyEQK5VnMETflI1gceAUyG5e06985kuekkPpmTCqRBlL9I ar1uf+iAk/o850rbhBc8aKNV1ytJV9NMtrwkWYGTqJiYAyKf+0Io8w8P+rhuCRAdlVYx KpAF+X984jjAlU+dssvm3i/b3x/Z87EGlqGBkgGqhKZl3mjXelU59FPHzddkpiDcXffV VjrwKJrMMSIh2emw/5Jxi+K8kBIMIcWJg9KZ7OHHX4V63wi0aYlqD2GG36RgdeLvgwLS L8JSfN7qBZAurw2EIpdsxoF8yf01GDKblQf+Jqa0cV1DanQeIfhBdNey9LuVJCa4A8KX Lfsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lHZd4YOt; 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 s144si28983922pgs.232.2019.07.30.05.28.38; Tue, 30 Jul 2019 05:28:53 -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=lHZd4YOt; 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 S1729860AbfG3MYu (ORCPT + 99 others); Tue, 30 Jul 2019 08:24:50 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45757 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729661AbfG3MYu (ORCPT ); Tue, 30 Jul 2019 08:24:50 -0400 Received: by mail-pg1-f194.google.com with SMTP id o13so29969625pgp.12 for ; Tue, 30 Jul 2019 05:24:49 -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=E3OJFxf+mUWoz3h8BXrLdL53qyDG3CcJuYs/0iyxKF4=; b=lHZd4YOtFXL1Gwc2xUvnMZ7Or2UzfTKDyw87HagAQzlXqafH7TIxkdoiJQJhmsgk4P FycQZDE8Qu4bgy/7+a4uDb9S9UKbhoubw4F01cu1xYmfVZcQaREf2QEB/I0toxi4LgV4 /Mc5qRfpVdt9IGSYE+PYQWd1uaC515Ivb0mNPROtzmMX3fyeZicOL/5NY2SydG/NPcjK d5ThhCpIPGKBu8b6Wozgxk84LfNSFs/rNEEV0Es9qC5DSpJhEOcwlkDf9eGlwYHM0jVw INZyrebVn/ruh2+hKI2DdNFiOodeC0dZpYVQH8uuutCbtk35xar9PYrCyF2hfi7NebdX n+4Q== 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=E3OJFxf+mUWoz3h8BXrLdL53qyDG3CcJuYs/0iyxKF4=; b=q9FeyVhSMeSEM9/tvsBqYijCiAUEPwu4iEk0t42jkC87+8Xtj54fORkkV4vu1i27Nu bT0Xi6rOGjcjfZHb0wO+Qd2/ZJl17UMWjYfVgYpqo9aE0SDrlA6VHpjWS1CBAJY+ToJr Cux0Ay/es4uSLxoqz28Jz1RnVjBYQQbzqzz4S8d00iaIoecN03jFV5crnS2znXgCpxge zgKJVJkl4QpELrjGa4/3CqDqxzI6wEeKUxL46p5FEkZfGV8z6ffaW4HHC+FxmKWacugd F82k6SXzSclbBudXoqdyRdK68DsA/dxdCCaAY+nWksSk/P8CF9txlqzxkGs+xZXPJoHf kzNw== X-Gm-Message-State: APjAAAU4TZ5/SWadlGkRvqlOV8xfQgIWeKb6yhya4CuSFWPP40ziJcz0 x92I39NJhZGMYx1WIHBG4ITidw== X-Received: by 2002:a17:90a:3247:: with SMTP id k65mr73468902pjb.49.1564489489600; Tue, 30 Jul 2019 05:24:49 -0700 (PDT) Received: from localhost.localdomain ([45.114.72.197]) by smtp.gmail.com with ESMTPSA id v8sm54895462pgs.82.2019.07.30.05.24.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jul 2019 05:24:48 -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, casey@schaufler-ca.com, ard.biesheuvel@linaro.org, daniel.thompson@linaro.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tee-dev@lists.linaro.org, Sumit Garg Subject: [RFC v2 3/6] tee: add private login method for kernel clients Date: Tue, 30 Jul 2019 17:53:37 +0530 Message-Id: <1564489420-677-4-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564489420-677-1-git-send-email-sumit.garg@linaro.org> References: <1564489420-677-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 GP implementation defined login method range: (0x80000000 - 0xFFFFFFFF). Signed-off-by: Sumit Garg --- drivers/tee/tee_core.c | 6 ++++++ include/uapi/linux/tee.h | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c index 0f16d9f..2c2f646 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_MASK) { + pr_debug("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..a0a3d52 100644 --- a/include/uapi/linux/tee.h +++ b/include/uapi/linux/tee.h @@ -172,6 +172,14 @@ 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 +/* + * Disallow user-space to use GP implementation specific login + * method range (0x80000000 - 0xFFFFFFFF). This range is rather + * being reserved for REE kernel clients or TEE implementation. + */ +#define TEE_IOCTL_LOGIN_MASK 0x80000000 +/* Private login method for REE kernel clients */ +#define TEE_IOCTL_LOGIN_REE_KERNEL 0x80000000 /** * struct tee_ioctl_param - parameter -- 2.7.4