Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751500AbdGYW4J (ORCPT ); Tue, 25 Jul 2017 18:56:09 -0400 Received: from imap0.codethink.co.uk ([185.43.218.159]:40604 "EHLO imap0.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751031AbdGYW4I (ORCPT ); Tue, 25 Jul 2017 18:56:08 -0400 Message-ID: <1501023361.12197.191.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 40/57] tpm: Provide strong locking for device removal From: Ben Hutchings To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Jason Gunthorpe , Stefan Berger , Jarkko Sakkinen Date: Tue, 25 Jul 2017 23:56:01 +0100 In-Reply-To: <20170719111251.592825675@linuxfoundation.org> References: <20170719111249.973558472@linuxfoundation.org> <20170719111251.592825675@linuxfoundation.org> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1070 Lines: 36 On Wed, 2017-07-19 at 13:12 +0200, Greg Kroah-Hartman wrote: > 4.4-stable review patch. If anyone has any objections, please let me know. > > ------------------ > > From: Jason Gunthorpe > > commit 4e26195f240d73150e8308ae42874702e3df8d2c upstream. > > Add a read/write semaphore around the ops function pointers so > ops can be set to null when the driver un-registers. [...] > @@ -49,10 +99,10 @@ struct tpm_chip *tpm_chip_find_get(int c > if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num) > continue; > > - if (try_module_get(pos->dev.parent->driver->owner)) { > + /* rcu prevents chip from being free'd */ > + if (!tpm_try_get_ops(pos)) [...] But an RCU read-side critical section is an atomic context, and semaphore operations can block! Fixed upstream by: commit 15516788e581eb32ec1c50e5f00aba3faf95d817 Author: Stefan Berger Date: Mon Feb 29 08:53:02 2016 -0500 tpm: Replace device number bitmap with IDR Ben. -- Ben Hutchings Software Developer, Codethink Ltd.