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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25B8FC4332F for ; Wed, 13 Oct 2021 07:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0593860E78 for ; Wed, 13 Oct 2021 07:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238301AbhJMHLT (ORCPT ); Wed, 13 Oct 2021 03:11:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232118AbhJMHLS (ORCPT ); Wed, 13 Oct 2021 03:11:18 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F627C061714 for ; Wed, 13 Oct 2021 00:09:14 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id j21so7697780lfe.0 for ; Wed, 13 Oct 2021 00:09:14 -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=ZMSfqssxjE37wIiOs10lPZQ3BHyZICBiMNu/viO9Wv8=; b=rZwwmSB0O6MunwUzqLxpVbT/59aCAtCIpWayoM9/SWKmDCW6I0WEpsajjGVvLWij2c ybOwVzD3dEoy6ZbDtAZpOKyLcG9zcVpSyrzLlSb4gyFIQX4myh3I2d6WFQJ0nHuTKmKF Kt/IYsB9C+xf8roofhcqu82qEr74K/v9oZukr1+4cw0Ir1uVKVNLYohfCpL9Sxp9KLHy 0MfLZEcn+jGWaRBoJ8idinvqrZ0d1GQ82MEo6IqIFTs4xLSFxKS7XAzlcSZSRIr1Cb4v kSXxY7XUQ4LeBMciHeuKduZ186E68TK6Vl9mdFsYuuw9LyiqMrLaPzlvqbLsKzCW3BUD WkJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZMSfqssxjE37wIiOs10lPZQ3BHyZICBiMNu/viO9Wv8=; b=YP7fvDzBjnnHttqAR0FnIXQFR5/p4Kj0sWYeKevIFmDmVDvTmVIUsqfO/py+s1FmKD l2m5JRZkHypEwSKydfMaL/YHrwdGMEri51WFh62hBPtZl3nIY4YM9vsXXYIHewHlOvYt b525VtkY3AUtYqG/5S4Bo5wlcO1S+e5AB0tVB5wDJLS3/bodKm0FKGTHUm2ya+d+FB2/ EFNgu2HGggIz8QdNHWefaDuMBO7S7+RzKiLppX5aVHhfp4Z5+k4Lak3NQ6QX/5+zJC+i LnduKVdi7dca1+S2R6SPt8mDKfTI10BmjdgYegdED3P0S5xxCqeER1G+UBnvtrrsAZNP qNuw== X-Gm-Message-State: AOAM53337Ms23APiOuIGYdo3JvH55vyvP5AGqrALilHn7u5LjFLP1XlQ w+BA/OkTQ1hiTrDXGWMBM9M2uAvgu4vIfIPvpqXtzA== X-Google-Smtp-Source: ABdhPJyR2s1TmAgABNpDg6esdyYm384WojAfLAKSbM0DVhqqaxhND78VpPMUiy5ZNLidqHGqJwrDL0N2dAW8NpM+cCs= X-Received: by 2002:a05:6512:3b94:: with SMTP id g20mr39470692lfv.119.1634108953052; Wed, 13 Oct 2021 00:09:13 -0700 (PDT) MIME-Version: 1.0 References: <20211006071546.2540920-1-jens.wiklander@linaro.org> <20211006071546.2540920-4-jens.wiklander@linaro.org> In-Reply-To: <20211006071546.2540920-4-jens.wiklander@linaro.org> From: Sumit Garg Date: Wed, 13 Oct 2021 12:39:02 +0530 Message-ID: Subject: Re: [PATCH v6 3/6] tee: fix put order in teedev_close_context() To: Jens Wiklander Cc: Linux Kernel Mailing List , linux-arm-kernel , OP-TEE TrustedFirmware , Devicetree List , Linux Doc Mailing List , Jerome Forissier , Etienne Carriere , Vincent Guittot , Rob Herring , Jonathan Corbet , Ard Biesheuvel , Marc Zyngier Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 6 Oct 2021 at 12:45, Jens Wiklander wrote: > > Prior to this patch was teedev_close_context() calling tee_device_put() > before teedev_ctx_put() leading to teedev_ctx_release() accessing > ctx->teedev just after the reference counter was decreased on the > teedev. Fix this by calling teedev_ctx_put() before tee_device_put(). > > Fixes: 217e0250cccb ("tee: use reference counting for tee_context") > Signed-off-by: Jens Wiklander > --- > drivers/tee/tee_core.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Reviewed-by: Sumit Garg -Sumit > diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c > index 2b37bc408fc3..85102d12d716 100644 > --- a/drivers/tee/tee_core.c > +++ b/drivers/tee/tee_core.c > @@ -98,8 +98,10 @@ void teedev_ctx_put(struct tee_context *ctx) > > static void teedev_close_context(struct tee_context *ctx) > { > - tee_device_put(ctx->teedev); > + struct tee_device *teedev = ctx->teedev; > + > teedev_ctx_put(ctx); > + tee_device_put(teedev); > } > > static int tee_open(struct inode *inode, struct file *filp) > -- > 2.31.1 > 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 233F3C433EF for ; Wed, 13 Oct 2021 08:39:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E078A60D43 for ; Wed, 13 Oct 2021 08:39:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E078A60D43 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=STgKLZJ9zm98S5pSIPwYDn/1CvfOJtbpAY45OBzj3PA=; b=xdKu3wnqyEJTrC U42sdbGzFd7J5ho5iaOQYJAJz8Ia0KWqm5HGhZsRmf/NkC8Kgtdd9/Wa45h1+sjN9sx34hcey3Pgs 6edJN9aIhpxFqabs/CY4Eu3OQj7yyaHNsaBxcV4L2mzE8Ho3OmP0jynoEgUJoJMtQYI2o8qn0hWRW CSYp1HFyPfZq76Jp3Rt5YRPzTX13oLtGxAVm4Sk1xu+5MvRHVbcK5QCttcg1PUkjO4HXWe0ed64Oc spVSCxlk8H4Lu95QF801vKIxxQ+SZftS1/Dfa22IJ5TM9LFcQOA/bbMeN5TYMDRTCSji1px5QLtdA k/XdnWgJC0T8oWuaiDtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maZju-00FbBz-IW; Wed, 13 Oct 2021 08:35:55 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maYO2-00FHLe-Na for linux-arm-kernel@lists.infradead.org; Wed, 13 Oct 2021 07:09:16 +0000 Received: by mail-lf1-x132.google.com with SMTP id t9so7537287lfd.1 for ; Wed, 13 Oct 2021 00:09:14 -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=ZMSfqssxjE37wIiOs10lPZQ3BHyZICBiMNu/viO9Wv8=; b=rZwwmSB0O6MunwUzqLxpVbT/59aCAtCIpWayoM9/SWKmDCW6I0WEpsajjGVvLWij2c ybOwVzD3dEoy6ZbDtAZpOKyLcG9zcVpSyrzLlSb4gyFIQX4myh3I2d6WFQJ0nHuTKmKF Kt/IYsB9C+xf8roofhcqu82qEr74K/v9oZukr1+4cw0Ir1uVKVNLYohfCpL9Sxp9KLHy 0MfLZEcn+jGWaRBoJ8idinvqrZ0d1GQ82MEo6IqIFTs4xLSFxKS7XAzlcSZSRIr1Cb4v kSXxY7XUQ4LeBMciHeuKduZ186E68TK6Vl9mdFsYuuw9LyiqMrLaPzlvqbLsKzCW3BUD WkJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZMSfqssxjE37wIiOs10lPZQ3BHyZICBiMNu/viO9Wv8=; b=dQt70z1MZCXr4UFOztzDzyKtk9l2wlF5wHv6dc0my1nZN4gu6Sz2fQLHNrxg2IHU2B bli9NELWNOS/5rMxyDLnDOhnGVNO/Fj+hcHeVg7S4wGRlzBabLCm3geUyGJyUO+vHXXv fH9q3iKwIK/KNuGkhZBOmK3f7FtWKxeWpVzL5jl0cq905vawsYv9jwL3hWSblr32lAqe 7EPmPfnTba3apYmv/thnphYdSHeMgSYB6Mr2Awf678kx3nq5uhbZdF7Gcy9mxbGZQGV+ xmzoCHEUpQWDgXwIOzgNVmOE9r5AlqiPAg6hA17Du6td+r7GzwEvEWz39CDTmitaOUZZ XSsw== X-Gm-Message-State: AOAM532dZKm3OZEqwNJuuopqlV1++ZSALj0zgSEUuVoLDL+MX+j67UtU tEoZQr1VJsRfrTIfz730iAc/mivjpDkrB/G2eVMpUw== X-Google-Smtp-Source: ABdhPJyR2s1TmAgABNpDg6esdyYm384WojAfLAKSbM0DVhqqaxhND78VpPMUiy5ZNLidqHGqJwrDL0N2dAW8NpM+cCs= X-Received: by 2002:a05:6512:3b94:: with SMTP id g20mr39470692lfv.119.1634108953052; Wed, 13 Oct 2021 00:09:13 -0700 (PDT) MIME-Version: 1.0 References: <20211006071546.2540920-1-jens.wiklander@linaro.org> <20211006071546.2540920-4-jens.wiklander@linaro.org> In-Reply-To: <20211006071546.2540920-4-jens.wiklander@linaro.org> From: Sumit Garg Date: Wed, 13 Oct 2021 12:39:02 +0530 Message-ID: Subject: Re: [PATCH v6 3/6] tee: fix put order in teedev_close_context() To: Jens Wiklander Cc: Linux Kernel Mailing List , linux-arm-kernel , OP-TEE TrustedFirmware , Devicetree List , Linux Doc Mailing List , Jerome Forissier , Etienne Carriere , Vincent Guittot , Rob Herring , Jonathan Corbet , Ard Biesheuvel , Marc Zyngier X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211013_000914_853224_B667A5D0 X-CRM114-Status: GOOD ( 19.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 6 Oct 2021 at 12:45, Jens Wiklander wrote: > > Prior to this patch was teedev_close_context() calling tee_device_put() > before teedev_ctx_put() leading to teedev_ctx_release() accessing > ctx->teedev just after the reference counter was decreased on the > teedev. Fix this by calling teedev_ctx_put() before tee_device_put(). > > Fixes: 217e0250cccb ("tee: use reference counting for tee_context") > Signed-off-by: Jens Wiklander > --- > drivers/tee/tee_core.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Reviewed-by: Sumit Garg -Sumit > diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c > index 2b37bc408fc3..85102d12d716 100644 > --- a/drivers/tee/tee_core.c > +++ b/drivers/tee/tee_core.c > @@ -98,8 +98,10 @@ void teedev_ctx_put(struct tee_context *ctx) > > static void teedev_close_context(struct tee_context *ctx) > { > - tee_device_put(ctx->teedev); > + struct tee_device *teedev = ctx->teedev; > + > teedev_ctx_put(ctx); > + tee_device_put(teedev); > } > > static int tee_open(struct inode *inode, struct file *filp) > -- > 2.31.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel