Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp139637pxj; Wed, 16 Jun 2021 22:40:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdlo/gIWfm6hWn+oSmuygGoClu5AJwNczDsTM5waG8XpE4vfoubXtKYmDmmjYJFMVoY7Ec X-Received: by 2002:a17:906:6899:: with SMTP id n25mr3315002ejr.462.1623908431309; Wed, 16 Jun 2021 22:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623908431; cv=none; d=google.com; s=arc-20160816; b=jcXwcPw6EdU2j9/Ix6DKJA7i7zD+UfrhtO8uMOLeQ5Ki+Gps+rONmOSKoIAYQmOqJY 5K8/CS1dqLdy0dnSrLWDaJkSp5TDwDPseuck+divRbpyk1eqSmqiqPH1IYLXoK6ugy5/ rGIaRsgBh+RtoLaZ8XnTvScA5Hi5EUpBp0wt4smXXvj/edPSmnCxAdW/ypqzvJOXfYVf mTuEYtc67gOaANeOibiOjOEzZBFMFklbp7xiIz0swNz8OFKJEtVtGhdFql8BL32tICI5 JTQwxMbYnshlH1cqIH0kwfAtNQkrE2fDman+5nieFo93HzjfQ7ZqyOHwxPhG7ucx06eS GrKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=xk5lY+DviIEB+UeE2RSKHxcpgc9FMKqbw8HU2SouMqc=; b=c59I/4NLYsjjN5YamH3afM75JY6ygR1yW7O8fnfUit4ujfhvdIM8vybY1DboTZlNiF J2rfiZp0+jUl7XP58OiMI1Z9xP94K4CbCRB+jeEgHc/gi4KuuHlyfQCR6WxxUJlDOs5b vux7LX/WH7IvGxYcGFpfjTSSyU8qv31EfGU5WJJO1zEwDWj2ZGum51lgn8YsnEnJMq47 ++mFdc9I13WR1cunLPnsMtL2reR8Dh9bd8mELo8vHJHVT3Ye9118it2oJgosVWQltFSC LBGnOghUGNb+9GWz6Y2kWGnCaPPJqgdqkwvE9hhL1TwmEU6gPSp2MTJuJKEHg2PDQOHc 42wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=QRiK5c56; 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=axis.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si4722622edt.542.2021.06.16.22.40.09; Wed, 16 Jun 2021 22:40:31 -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 (test mode) header.i=@axis.com header.s=axis-central1 header.b=QRiK5c56; 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=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbhFQFkS (ORCPT + 99 others); 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/