Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7489765ybi; Mon, 8 Jul 2019 23:01:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/J41XnFc3TNe6BEPLXeTqzscEBV16Jvxz6PcUFqbAs0pontegC2ttU7cGGy+sH5c4WZzx X-Received: by 2002:a17:902:54d:: with SMTP id 71mr29248374plf.140.1562652065291; Mon, 08 Jul 2019 23:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562652065; cv=none; d=google.com; s=arc-20160816; b=VdtFVUlAc1mXTQGf/Hh8g/N+4sFtW36DIniJd44zejDCDWS2EDAungDpirF3slWeab KI0Un6B781YomliCLq5C5hWXVM80LHPs2BEoYEPRBEjApkm3hzU5iZGsaeaPv9WhxfZE fLuIiM1BZkWPh1YHis/N6UIdnwxPaGUEg3kmRKtt22fVEDQgbkgz8h3y+lHJnf77F+nY 6hGsDRBNvby+Y1HAwXHsFlyOJzCUKx4uEDebQcb2zwS6xdnrDOTfINcXuKyNihPaHCaB uh/UkCCGWtvKZczhmAM7RJ8O1NgqDykvC04+QeHux1nJRJst6OXT30wb6rsEZUzvHoq+ HHMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=xli8Y1cqqEneErVoUF+bY1KzJjP8ZHOc6NmhgPLACKg=; b=OeSQjHwmL+EXe+rKShALpuzJhvOohjwWsR2RuiCSXbE3Agov2DHh5Ycy3CPjPQ0cgE aa91ffT0H1o7TOB27OYAabHJAua8bcUGdrtZYnfr2w1b9ujtgEwt/+LTd3cyjqp20gKu 4nyDDjSpr4pa0f3/gk2Jtt6gWJiRTVD4dslfF1wdijuKVy/2zNwiCiYOgFX7j2HIkL4P 3TayzB6jBm91Dy/Cd/e7izH+L3CDq9cF+giGSIGa7nbsW/O8p3k3Kxz2gMgfQqiyxFS4 dcD0pR3LFTOkusfGOw8B9lrz2vufQ1ojcoBZgfnOB8M0SdzUCmgJ9//Sf9dRgHYg92J6 aCuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IMCCarKQ; 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 e8si21676976plb.420.2019.07.08.23.00.49; Mon, 08 Jul 2019 23:01:05 -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=IMCCarKQ; 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 S1726025AbfGIF4c (ORCPT + 99 others); Tue, 9 Jul 2019 01:56:32 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:45766 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbfGIF4c (ORCPT ); Tue, 9 Jul 2019 01:56:32 -0400 Received: by mail-lj1-f196.google.com with SMTP id m23so18264796lje.12 for ; Mon, 08 Jul 2019 22:56:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xli8Y1cqqEneErVoUF+bY1KzJjP8ZHOc6NmhgPLACKg=; b=IMCCarKQ7otAoqPUCeGQC3vcXQb2Cyy+ZfbRDDkUApkZBYQD9XaWe8JxyQ2r2kqeNo iBJVq3IEy825J1ZWOrKaOxMAamH2f2vMKMoBJB3v9Pag6syG+IgeeABenXGICPBQqVRo TCM9fQapLUxDmgd5l/nMkqcnYtQpA18ueFn8Kf+B65KClSm2X8JmaYkufFfGd9PJ7M06 UnU5YQ6+xIMYq94vzkNzahudlTAkRFSRs7ooYuxhMyRpb6sFcPbMki9x9dlQKXVZvSxF OVDpetNx+Pr7CE/MltAUCeQcSuQw5PFb9k+56T+tdJXrd2q4ayYgA2XbDfZQj6MaXQC5 3KDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xli8Y1cqqEneErVoUF+bY1KzJjP8ZHOc6NmhgPLACKg=; b=PpmsZC3W4vAjJVQXGPQiK3C8gG8qzWFVF0Qzv8XhNgddgHzCd9Bqoqy+TFD5mGg1A1 UCxzuPwYzZYIXNXAWB4sWS1PIK4Db5lif/tMhOuz8sSDWNsXZSI33YZ2VffSOro9ZjoK ZxZOhklNfd60sDGbWozyqCbdXDc9ol+jHSXiA8ZeUQqytt2mk1BEpjQupc2vad91r3Nt yejF7/md/k8Q0NFMxmesyZ32lGqL+UsSFlJmw6jiOoae/XKYToQWZeVA3Q8gU+fSzeFs 5Sy9N8G7xdK2TYOsHILcUpcr88yIMnKpSmlO4//U/YEXG4Bwc3AjyK8HDghBeb0dhLan CDxg== X-Gm-Message-State: APjAAAU3rK8/5o8kd3k1nWNLWgNLRDH3/fHPTC/VAbq31R0KMSEFzhva N2L9MOr71ZQnkclNzC3gwbHVKtjvabqXNbYWR2S5ww== X-Received: by 2002:a2e:9b57:: with SMTP id o23mr7858753ljj.67.1562651790245; Mon, 08 Jul 2019 22:56:30 -0700 (PDT) MIME-Version: 1.0 References: <1560421833-27414-1-git-send-email-sumit.garg@linaro.org> <1560421833-27414-4-git-send-email-sumit.garg@linaro.org> <20190708153908.GA28253@jax> In-Reply-To: <20190708153908.GA28253@jax> From: Sumit Garg Date: Tue, 9 Jul 2019 11:26:19 +0530 Message-ID: Subject: Re: [RFC 3/7] tee: add private login method for kernel clients To: Jens Wiklander Cc: keyrings@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, corbet@lwn.net, dhowells@redhat.com, jejb@linux.ibm.com, Jarkko Sakkinen , Mimi Zohar , jmorris@namei.org, serge@hallyn.com, Ard Biesheuvel , Daniel Thompson , linux-doc@vger.kernel.org, Linux Kernel Mailing List , tee-dev@lists.linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks Jens for your comments. On Mon, 8 Jul 2019 at 21:09, Jens Wiklander wrote: > > Hi Sumit, > > On Thu, Jun 13, 2019 at 04:00:29PM +0530, 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 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(+) > > > > 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) { > TEE_IOCTL_LOGIN_REE_KERNEL is defined as 0x80000000 which is in the > range specified and implementation defined by the GP spec. I wonder if > we shouldn't filter the entire implementation defined range instead of > just this value. Agree. Will rather check for entire implementation defined range: 0x80000000 - 0xFFFFFFFF. > > > + pr_err("login method not allowed for user-space client\n"); > pr_debug(), if it's needed at all. > Ok will use pr_debug() instead. > > + 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 */ > It's worth noting that this is filtered by the TEE framework, compared > to everything else which is treated opaquely. > IIUC, you are referring to login filter in optee_os. Change to prevent filter for this login method is part of this PR [1]. [1] https://github.com/OP-TEE/optee_os/pull/3082 -Sumit > > +#define TEE_IOCTL_LOGIN_REE_KERNEL 0x80000000 > > > > /** > > * struct tee_ioctl_param - parameter > > -- > > 2.7.4 > > > > Thanks, > Jens