Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1538970ybb; Thu, 26 Mar 2020 02:41:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuJgWTvmAUIa1VQgwsdijTnNMRZlJVrCtCQP4e3GP7whtx/dwqHSZK6kh24qjAujHPDTgqM X-Received: by 2002:a4a:e211:: with SMTP id b17mr4481133oot.79.1585215688858; Thu, 26 Mar 2020 02:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585215688; cv=none; d=google.com; s=arc-20160816; b=AQwMbvoiY9o2vqeLf/iX2uOrpwdNA/57gTkIOseCSCSU8U2FZgzu3tfEjZZq9gM0JS XRy+O5R6Z3ORQdgHfCg7DuBXz72oCR5kLJgdQKEcyvMTSoYd2X7CCB1SgEfo2I1YDUrr J2eL/ZQxj/x2mWrv9CEoBkigVHA8UY60RQ8/vH8FHxCJ41rGTPfTCngNUd0k739jonVZ SsAH00JCA/ZWh6Z0UwevxVVf6jaEe0Y6/TvCi19wT1+xeuCS0g4sbrTFQyZi3+a8fYYX 2O9UCxI1YnYmhXGtZYUll9fBhF3QmTFsCUSSps0DQSWQmA+b2PSn9liDQTD5AWuoFgM7 WQeA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=eu3Uwa+VnU4xXATk5601RZo6ykANuBNgBtIg6vaHTbM=; b=GYkUwXY/INrS+NhdC2rR5PhitewGdOzxrj+TcEhTLfW6f/wxUO29BQSsugYG9YdZ+Q h7Vxrre/pG/kNqaz5/ROQfNdptIuBvbb6L2lxqeQolBobmje2VKK0iHLGaNez0Bavvp9 bsTrKWVW5c7if00cg3aLqKhxpUMK1UyX74YPDTryvTRnOVqj3K4zJ2znXYTZBJJU76D7 Hsi2Yo58jcw9V6xXZ1vAeHndpb7hU3cMEeQa9a+hqFwsKOPMt6QyvGOZuIDBF8YVQX7b FCix0y0JyaPu7rN53JOVUAxdc972SqrH1b+QVK3in13VBiQZROJa1CjyMfM+U4KsD+V9 zbSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=voMoECkc; 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 x2si888430otj.19.2020.03.26.02.41.16; Thu, 26 Mar 2020 02:41:28 -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=voMoECkc; 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 S1727846AbgCZJjY (ORCPT + 99 others); Thu, 26 Mar 2020 05:39:24 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:45448 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727780AbgCZJjY (ORCPT ); Thu, 26 Mar 2020 05:39:24 -0400 Received: by mail-lf1-f67.google.com with SMTP id v4so4192278lfo.12 for ; Thu, 26 Mar 2020 02:39:20 -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:content-transfer-encoding; bh=eu3Uwa+VnU4xXATk5601RZo6ykANuBNgBtIg6vaHTbM=; b=voMoECkcgMjOgY6psiBZX8ON1srXi4PYuJOK09VphgLrshwDqbkyFrPdo/BH+iBKzz XlOpbhoD+dVShpVol0jM1QH4u2PhjMFt73vjUm0d/qfnAgH6FkNyV5M5ZTOwt9E1HZzY IlY9wfIedRLfC5HoIBYY82hihSxChb1xtkKTa7qtHtNGXSc1fbcqAG2S0cIGb8NKs8Sg s+jJs7Kp1lb9HHyznoUHEN/RJ9S3A0G2WwcMSEIf/mXJAHczOlYXBl6KO8/gDU+0zcvo b1tVz1pGsh/NfUw30/zEZ9zZjItmmbcbXUSxkL2yCdVQfVXOT4fQnEObMCiEjHyW9Bzv XTgQ== 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:content-transfer-encoding; bh=eu3Uwa+VnU4xXATk5601RZo6ykANuBNgBtIg6vaHTbM=; b=U8zwyPg6hz9rrtxQrFQmPR4h2EhYhib6YZWmX3m0yw4+MWXNmmHSQW7fajBrQdeM7a eVasFMHOMq02o8tDFuAwhj4H13jsaIh7VpZsQD8Vr9dHGsdvYegiR3hoT5cVqBXBLmjm T4H0hRqYRcgQZzUM8pvK9QbZDOSyhBttnUJgxZwBGqM1tu/ZIsaFTU6Up6koLnuYuREE sk3tza1RHmsolLrAaKoOIbApGs06N/XCN3o1ujDlS0Ip2qjoSDTwWAhRJTh8F4Mi3zHd Jca6IIMcsF1C3lpDEax5/0BPK5AemsiIsnb6zraK1wJv59cJwCA10anYXRiuT5lITdC3 A3fw== X-Gm-Message-State: ANhLgQ3t/HjrDDTgniA2zARRy1o3NhWXvlqgutJTQOedPlx5Vdok1122 WMuqCbgUMmW1qS2jvA57QYpoT3H/Fl/kAnxMiOlbfQ== X-Received: by 2002:a19:3803:: with SMTP id f3mr5226139lfa.160.1585215559490; Thu, 26 Mar 2020 02:39:19 -0700 (PDT) MIME-Version: 1.0 References: <1585207429-10630-1-git-send-email-sumit.garg@linaro.org> <1585207429-10630-3-git-send-email-sumit.garg@linaro.org> In-Reply-To: From: Sumit Garg Date: Thu, 26 Mar 2020 15:09:08 +0530 Message-ID: Subject: Re: [Tee-dev] [PATCH v5 2/2] tee: add private login method for kernel clients To: Jerome Forissier Cc: Jens Wiklander , "tee-dev @ lists . linaro . org" , Daniel Thompson , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Mar 2020 at 14:53, Jerome Forissier wrote= : > > On 3/26/20 10:07 AM, Sumit Garg wrote: > > On Thu, 26 Mar 2020 at 14:05, J=C3=A9r=C3=B4me Forissier wrote: > >> > >> On Thu, Mar 26, 2020 at 8:24 AM Sumit Garg wro= te: > >>> > >>> There are use-cases where user-space shouldn't be allowed to communic= ate > >>> 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 libr= ary or the TEE supplicant from using such values, although they are part of= the TEE implementation; and further, nothing mandates that an implementati= on-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. It seems I probably misunderstood his proposal. So let me reserve (0x80000000 - 0xBFFFFFFF) range for kernel space. > > (BTW sorry for my previous HTML reply) > No worries. -Sumit > -- > 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_con= text *ctx, > >>> goto out; > >>> } > >>> > >>> + if (arg.clnt_login & TEE_IOCTL_LOGIN_MASK) { > >>> + pr_debug("login method not allowed for user-space cli= ent\n"); > >>> + rc =3D -EPERM; > >>> + goto out; > >>> + } > >>> + > >>> rc =3D 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