Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1526022ybb; Thu, 26 Mar 2020 02:24:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsYiT5NlbZkCjRfUt7+9uz7iSnGDGjXXeIYUvuDFflU9hnFKAPjz4b+3hmmSZNKwsEOtTjB X-Received: by 2002:a54:448a:: with SMTP id v10mr1150624oiv.49.1585214676351; Thu, 26 Mar 2020 02:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585214676; cv=none; d=google.com; s=arc-20160816; b=f1E1ScIgZBTYMSS+majS7YyhXqaRz0RipIDu0PWY14xs63LpjsTHiRyhZ2ghhd/cIs kAqWqexcVDOyde7RTcqlZ5WpbuTo5+5q69WYheEOeeMJfry5rLreXnlg2c6FAwAvB32H hCtGXDJ3d8DwVAH3fdNfiVXWDJXKGdJYWz0ZSj/o8VmVvNz3q32I/Ip4j0MeaykyrRUA JT9AiGqAwVqSR0Ob3SxIRvRM5Q7H/MDhJZ3jgPgaFkr5l2kSBos6unaXMTC+j5ZcGOJa b6F0BBCO+yP6fIOjLuPwm8Zq1E1eHCU5jFD0dUDq8FZ7efd9P1G86DVZlviK12K1vec9 LHIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=NCq0cMZFL5YKjrRymewcPmfdY/+U3QFHvibyA/UA0EM=; b=I/878WGV8qcdSUt+RqSIk9S0J+ohVyXj5qi8ZB5+KHgahT0zmBMTTwX+f9gAODjV2V 8j6sl+drG1pg2IimK3hBajaXXv2wqN7wfxK/0UlRga27PZHsqiMO/mtyEwLUI73AhPgD FbPlaFL8de+rSgVAEZb5SELxEPvJw5jJbJhkQsF9+J0s/MADyRTMnLAc136hewesUqK/ runO5R86pbTqYUtjKUWiE9GMU53bT+ldLGHnmad6mESqbiNP8vq+b9z3WZVL5BtJ1VZu 7okjCbSVFpTuAKUayBgf85zrNoU2HVEIzORzWwrV6086ikR+XhIFmrshCeUqiks3dhBj GTNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@forissier-org.20150623.gappssmtp.com header.s=20150623 header.b=wdSfUa9f; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si784207oti.165.2020.03.26.02.24.23; Thu, 26 Mar 2020 02:24:36 -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=@forissier-org.20150623.gappssmtp.com header.s=20150623 header.b=wdSfUa9f; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbgCZJXi (ORCPT + 99 others); Thu, 26 Mar 2020 05:23:38 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38053 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727688AbgCZJXi (ORCPT ); Thu, 26 Mar 2020 05:23:38 -0400 Received: by mail-wr1-f65.google.com with SMTP id s1so6802815wrv.5 for ; Thu, 26 Mar 2020 02:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=forissier-org.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NCq0cMZFL5YKjrRymewcPmfdY/+U3QFHvibyA/UA0EM=; b=wdSfUa9fXkTxk6SAooj0EMqhEemdVCAWUYagyKUugjT86tKyyvSLhv2/FiUiyov4hj 89WD+pgTLUpbrkBkpZJ/0bKwhJcaYs3WznzozuSx0anb2PFHcy7AGNIu/VpLXY158ZoU yjgZpE+3CSeZ6vn8gXwkBjTvqO0VqsRYxIedSj0klcjx4P/6D7+CI56RoMQfXUQMZ8Ii LVIaMn5jvETT3zik+AVmi48zuFg97z2HGEBO+LQfoOnpdmThCA/SUbD3HPQN1SyvMQK+ HFnS09leWdTNU0v6ORvnW5LYWsMKag0syHH0AC36RD/fIHHJmajqty41YHeBypHjExs2 rD4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NCq0cMZFL5YKjrRymewcPmfdY/+U3QFHvibyA/UA0EM=; b=cFVimj7q2AFwOsY9wSTbOq8pUgAigUJIADn125AgaMmGICCuTNBiyy+2yJMuz5mSXr u1F0RJNIbQjoNAirN2GqJMUYUChNuFFVDfe9mIgJ/YwbMRmXjawvafte/0RPz0GFRmkT vqKHkodFmw01Z6PkcC3xWOtsouguFIXKkppuqB8ySkfalAYUQlkTMj38KvnkusTyqXFI WbHAmVOh/QYhnlw03Ge92NiIE9f2KVgERrxGrxDUg9lSZ0En2wfesVal+dHmBMExPvH+ OliOQ+Kq7aGyueUrmk9vin1S5W0NUhX7IZEPnQVk875VosSv48V/hE1/ogthSSYWKeCO MmkQ== X-Gm-Message-State: ANhLgQ0gCFXL3xtTLSRMkvoR1DiLPBIWAQlG+i4Y+VQeJpiAZm+fqMCn V5F1fYmXaCwaiGQgNseFNZ/xbaPWjmuySOo8 X-Received: by 2002:a5d:6847:: with SMTP id o7mr8066426wrw.274.1585214614992; Thu, 26 Mar 2020 02:23:34 -0700 (PDT) Received: from ?IPv6:2a01:e0a:3cb:7bb0:4468:e57e:609:75e5? ([2a01:e0a:3cb:7bb0:4468:e57e:609:75e5]) by smtp.gmail.com with ESMTPSA id h18sm2552278wmm.34.2020.03.26.02.23.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Mar 2020 02:23:34 -0700 (PDT) Subject: Re: [Tee-dev] [PATCH v5 2/2] tee: add private login method for kernel clients To: Sumit Garg Cc: Jens Wiklander , "tee-dev @ lists . linaro . org" , Daniel Thompson , Linux Kernel Mailing List References: <1585207429-10630-1-git-send-email-sumit.garg@linaro.org> <1585207429-10630-3-git-send-email-sumit.garg@linaro.org> From: Jerome Forissier Message-ID: Date: Thu, 26 Mar 2020 10:23:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/26/20 10:07 AM, Sumit Garg wrote: > On Thu, 26 Mar 2020 at 14:05, Jérôme Forissier wrote: >> >> On Thu, Mar 26, 2020 at 8:24 AM Sumit Garg wrote: >>> >>> 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 >> >> >> OK >> >>> and disallow user-space to open-session using GP implementation >>> defined login method range: (0x80000000 - 0xFFFFFFFF). >> >> >> I'm not sure this is correct, because it would prevent the client library or the TEE supplicant from using such values, although they are part of the TEE implementation; and further, nothing mandates that an implementation-defined method should not be used directly by client applications. >> > > Initial implementation of this patch only put restriction for single > implementation-defined login method (TEE_IOCTL_LOGIN_REE_KERNEL) only. > But after discussion with Jens here [1], I have changed that to > restrict complete implementation-defined range. If we think to further > partition this range considering API stability then I am open to that > too. > > [1] https://lore.kernel.org/patchwork/patch/1088062/ In the end he proposed to reserve half the range for user space and half for kernel space. (BTW sorry for my previous HTML reply) -- Jerome > > -Sumit > >> -- >> Jerome >> >>> >>> >>> 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 37d22e3..533e7a8 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 6596f3a..19172a2 100644 >>> --- a/include/uapi/linux/tee.h >>> +++ b/include/uapi/linux/tee.h >>> @@ -173,6 +173,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 >>> >>> _______________________________________________ >>> Tee-dev mailing list >>> Tee-dev@lists.linaro.org >>> https://lists.linaro.org/mailman/listinfo/tee-dev