From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A0EDC433F5 for ; Mon, 27 Dec 2021 11:22:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236333AbhL0LWE (ORCPT ); Mon, 27 Dec 2021 06:22:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233404AbhL0LWD (ORCPT ); Mon, 27 Dec 2021 06:22:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 911C6C06173E for ; Mon, 27 Dec 2021 03:22:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 50B0AB80E73 for ; Mon, 27 Dec 2021 11:22:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98DB5C36AEA; Mon, 27 Dec 2021 11:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1640604121; bh=z+H4X0NIYLqM6XxM2MDJ+wuBK6WufQT06DwhIFexAXg=; h=Subject:To:Cc:From:Date:From; b=w/1XsX03mPYRFmBUGUCpeQMT8xikyRZB94tSjOKPgTYx9syMLU7yLPsPlVq436jSO 7zuefO4o6b2yzqJwDdncUfp/Rq2uc2bn3oDxsh1r1bKZYh6AY/G03xOCksXcbSZYf2 zqAnrG64hyaqOaC6mRhKzQ0wDBypKLAxTnd8oPag= Subject: FAILED: patch "[PATCH] tee: optee: Fix incorrect page free bug" failed to apply to 5.10-stable tree To: sumit.garg@linaro.org, jens.wiklander@linaro.org, patrik.lantz@axis.com, tyhicks@linux.microsoft.com Cc: From: Date: Mon, 27 Dec 2021 12:21:50 +0100 Message-ID: <164060411019197@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 18549bf4b21c739a9def39f27dcac53e27286ab5 Mon Sep 17 00:00:00 2001 From: Sumit Garg Date: Thu, 16 Dec 2021 11:17:25 +0530 Subject: [PATCH] tee: optee: Fix incorrect page free bug Pointer to the allocated pages (struct page *page) has already progressed towards the end of allocation. It is incorrect to perform __free_pages(page, order) using this pointer as we would free any arbitrary pages. Fix this by stop modifying the page pointer. Fixes: ec185dd3ab25 ("optee: Fix memory leak when failing to register shm pages") Cc: stable@vger.kernel.org Reported-by: Patrik Lantz Signed-off-by: Sumit Garg Reviewed-by: Tyler Hicks Signed-off-by: Jens Wiklander diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index ab2edfcc6c70..2a66a5203d2f 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -48,10 +48,8 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool_mgr *poolm, goto err; } - for (i = 0; i < nr_pages; i++) { - pages[i] = page; - page++; - } + for (i = 0; i < nr_pages; i++) + pages[i] = page + i; shm->flags |= TEE_SHM_REGISTER; rc = shm_register(shm->ctx, shm, pages, nr_pages,