Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2507339pxj; Mon, 10 May 2021 04:48:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoiTRjK9kbU6v7L+4p6Z0h1mSojYzX45NYaM+zS4V3BPUX1OFFr7or1tgxRaWNyZvPr+Gd X-Received: by 2002:a5d:9b86:: with SMTP id r6mr3360253iom.43.1620647283689; Mon, 10 May 2021 04:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620647283; cv=none; d=google.com; s=arc-20160816; b=ov+F+7bVcC0iIkueVishsvgG071loQm1NL5pjqwRzi3q/APqNOnyw6azcosMN0MOwf nBCu5kyWYva/Jg3I7/qla2eVuGr4gv0AkGJTqcH103ikhrAxtx+XnyxIFhQME2RsY4/s RURYQLMyiDspttyQQ5d062a5NKjPZs0eHVzNQecoA3/eIa7y0no57GDMDkW2BZX/UBg/ k3e3j1j/5EsQoPjPok1OH3AHlEv3ni44UTTvw5sUTQvHg7b4Om2YFw6ubDoMNL6DU3Y/ gtXY5NXWngY/Tcan3rBWs8krerm5onSOlp2Eua+1QO0sJ66IpxA+va3zFqLsKbv4B59U 1eNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QF7u0soi5VgURQT2kshFvH2tmkhRNIjnygj58CtPADY=; b=X/hIBGHWIDJdqC7a79C+GwPsSEPMslJn5UNEuQyBJ5VxvwxFvd5nPKlz+mpBwkQawF ToxcTKJAlmyjCnZYnQf/fy0m52TeRK/YpEP2tuDtIuZq0siisk+FDmP++z+x+81nNzrp UEnMi5ik5O1vd+WH59dcZcZQVq5h3pVZSPni1pWLT713lRT+Gi55yk5gweIvePlG9vKI F5i/QSZ/Shv5JgGXDYa8bHxgrxptEFA/fNQVio8wv6zy6th8p54M9B9ZsJXqGdu4tcVx 5Wko91OL0AM65GdIQ5tNTDHxA9d8U79TRnOLlrBALOXrAf6rmUZwuyod/nUQobflUts4 oBrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WLwtiviK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si15037643jas.102.2021.05.10.04.47.36; Mon, 10 May 2021 04:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WLwtiviK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241857AbhEJLi6 (ORCPT + 99 others); Mon, 10 May 2021 07:38:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:53006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234565AbhEJK4j (ORCPT ); Mon, 10 May 2021 06:56:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0BBBD61931; Mon, 10 May 2021 10:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643628; bh=0B3ppj/Z+oUjmrvE4pPZDD4gi3C+apA+BcViiJEhQUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WLwtiviKzGnU209CdTlLHE8zgZs5Puqp3ZtvI6+XJVdl5TU51Tz0w4AS0lKWKO+2l +no8s2Wvn+cz+66be6v5alipCFqmBQ1vRhrsVzjSjbaPp7LtqvTHDlxUlXn+iLeBYj T7HAvynWHCkWRj356ctgP4nvhN78LWbVx12FgWvc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumit Garg , Jens Wiklander , Jerome Forissier , Sasha Levin Subject: [PATCH 5.11 091/342] tee: optee: do not check memref size on return from Secure World Date: Mon, 10 May 2021 12:18:01 +0200 Message-Id: <20210510102013.112041891@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jerome Forissier [ Upstream commit c650b8dc7a7910eb25af0aac1720f778b29e679d ] When Secure World returns, it may have changed the size attribute of the memory references passed as [in/out] parameters. The GlobalPlatform TEE Internal Core API specification does not restrict the values that this size can take. In particular, Secure World may increase the value to be larger than the size of the input buffer to indicate that it needs more. Therefore, the size check in optee_from_msg_param() is incorrect and needs to be removed. This fixes a number of failed test cases in the GlobalPlatform TEE Initial Configuratiom Test Suite v2_0_0_0-2017_06_09 when OP-TEE is compiled without dynamic shared memory support (CFG_CORE_DYN_SHM=n). Reviewed-by: Sumit Garg Suggested-by: Jens Wiklander Signed-off-by: Jerome Forissier Signed-off-by: Jens Wiklander Signed-off-by: Sasha Levin --- drivers/tee/optee/core.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index cf4718c6d35d..63542c1cc291 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -79,16 +79,6 @@ int optee_from_msg_param(struct tee_param *params, size_t num_params, return rc; p->u.memref.shm_offs = mp->u.tmem.buf_ptr - pa; p->u.memref.shm = shm; - - /* Check that the memref is covered by the shm object */ - if (p->u.memref.size) { - size_t o = p->u.memref.shm_offs + - p->u.memref.size - 1; - - rc = tee_shm_get_pa(shm, o, NULL); - if (rc) - return rc; - } break; case OPTEE_MSG_ATTR_TYPE_RMEM_INPUT: case OPTEE_MSG_ATTR_TYPE_RMEM_OUTPUT: -- 2.30.2