From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Berger Subject: Re: [PATCH] tpm: vtpm_proxy: Do not run tpm2_shutdown Date: Thu, 25 May 2017 16:04:24 -0400 Message-ID: References: <1495717956-14252-1-git-send-email-stefanb@linux.vnet.ibm.com> <20170525155059.GA5151@obsidianresearch.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170525155059.GA5151@obsidianresearch.com> Sender: owner-linux-security-module@vger.kernel.org To: Jason Gunthorpe Cc: jarkko.sakkinen@linux.intel.com, tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: tpmdd-devel@lists.sourceforge.net On 05/25/2017 11:50 AM, Jason Gunthorpe wrote: > On Thu, May 25, 2017 at 09:12:36AM -0400, Stefan Berger wrote: >> The tpm2_shutdown does not work with the VTPM proxy driver since the >> function only gets called when the backend file descriptor is already >> closed and at this point no data can be sent anymore. A proper shutdown >> would have to be initated by a user space application, such as a container >> management stack, that sends the command via the character device before >> terminating the TPM emulator. >> >> To avoid the tpm2_shutdown we introduce a TPM_CHIP_FLAG_NO_SHUTDOWN flag >> that only the VTPM proxy driver sets. This also avoids misleading kernel >> log messages. > This seems strange to me.. > > Why isn't ops null if the fd has gone away? > > What is the call flow that hits this? In this function here. static void tpm_del_char_device(struct tpm_chip *chip) { cdev_device_del(&chip->cdev, &chip->dev); /* Make the chip unavailable. */ mutex_lock(&idr_lock); idr_replace(&dev_nums_idr, NULL, chip->dev_num); mutex_unlock(&idr_lock); /* Make the driver uncallable. */ down_write(&chip->ops_sem); if (chip->flags & TPM_CHIP_FLAG_TPM2) tpm2_shutdown(chip, TPM2_SU_CLEAR); chip->ops = NULL; up_write(&chip->ops_sem); } The request cannot be deliver because the anonymous fd has been closed already. Stefan