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 X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A893C49361 for ; Thu, 17 Jun 2021 05:38:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E0A8613E7 for ; Thu, 17 Jun 2021 05:38:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbhFQFkS (ORCPT ); Thu, 17 Jun 2021 01:40:18 -0400 Received: from smtp2.axis.com ([195.60.68.18]:39023 "EHLO smtp2.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbhFQFkR (ORCPT ); Thu, 17 Jun 2021 01:40:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1623908290; x=1655444290; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=xk5lY+DviIEB+UeE2RSKHxcpgc9FMKqbw8HU2SouMqc=; b=QRiK5c56ooSAML0WkPR1ASFyoIY30BwI0yr+wHN9fSycdMQYhx9k9CdO wAOuIE/Qd74yNTnqsX5tdnbAVCATMVutTSL/QjTqjuW56rUvlxW8r7lb7 qBLJQvOPOiJ4cSHFP2AtrJhqPEqse+NazT61juHurRrASe7Oe1XFiiecH DLThqArLkyT3RKTl2su1PTT0HdciFc6E1G1U1/n5N6haQ5Le9xQx0BXJA YZFl8ZgaCvJZL76saslEtX99REeBYtArAF1X6FT1bNiF8IqK5DYBy3COQ u+u0DRfkvy5VAbokF1k+hrp1RiCiljieGtYH6Sm38iiaEJ/Uxzui9AORX w==; Date: Thu, 17 Jun 2021 07:38:09 +0200 From: Vincent Whitchurch To: Jason Gunthorpe CC: Peter Huewe , Jarkko Sakkinen , Stefan Berger , kernel , "linux-integrity@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Subject: Re: [PATCH 1/2] tpm: Fix tpmrm reference counting Message-ID: <20210617053809.GA4049@axis.com> References: <20210615091410.17007-1-vincent.whitchurch@axis.com> <20210616185301.GV1096940@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210616185301.GV1096940@ziepe.ca> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 16, 2021 at 08:53:01PM +0200, Jason Gunthorpe wrote: > On Tue, Jun 15, 2021 at 11:14:08AM +0200, Vincent Whitchurch wrote: > > The code added by commit 8979b02aaf1d6de8 ("tpm: Fix reference count to > > main device") tries to take an extra reference to the main device only > > for TPM2 by looking at the flags, but the flags are actually not set > > at the time when tpm_chip_alloc() is called, so no extra reference is > > ever taken, leading to a use-after-free if the TPM modules are removed > > when the tpmrm device is in use. > > Please read this > > https://lore.kernel.org/linux-integrity/20210205172528.GP4718@ziepe.ca/ Thank you for the pointer. I see that Lino already posted your proposal as a real patch as you requested so I will drop this. https://lore.kernel.org/linux-integrity/1613949567-1181-2-git-send-email-LinoSanfilippo@gmx.de/