Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1382484ybh; Thu, 16 Jul 2020 10:31:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypkRElwAMp5TmwBbIrSIFv4A58XZvzLlujtygypkRC7TUdta1AgYccAdaXQJgRB6QpK4pg X-Received: by 2002:a50:fb95:: with SMTP id e21mr5669165edq.245.1594920664271; Thu, 16 Jul 2020 10:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594920664; cv=none; d=google.com; s=arc-20160816; b=YTZv3IsfbeuiBMKTc5OHqdDkqj8EDSQfSEqNH6dkbhC13DK2XEdUrMWeL/ccRky2sa sP8RewSsWbjgFF984SGkdDR5iwnJqpSvqWaQBWiNEO5rU9uc0CI2AbKtB+j6Dapd9S2U dt4D9SAKHbrdmqcmVhQAUtq7mfKoWvyS+HnqNEHIpATbvfnFbQ1sl+e73wt/VH+9HMEV SJZIoVLqMPGCiPr5hyMKDfuDdgf2KdQ0Hd0xv7Uqf9asktNSNfCC9TZxTzkfe5dj3NH5 7BzLaoiMpVVG+3Mo/JqaD0yrF2cst0JQzISXuMgRqthZY5tYeI5OZKl7IcKpZNcur2e4 d8WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=nALpE2DWpPc6tPvosGO87Oi7B/WryU7YTG0+IVR4maI=; b=1DErWTgyL2OgpHsetClbXgDZ6+jznyINjPTFVwyQaiI7i+an/f+r2kGFLQI8ubWTdz Hj7Uh1xXJS5sgI42xDGfUSDWoREBCJHlWGdfQP8pFn6W2KfKLdLc+1DaObdNXVy7BfgZ 06EKcwyUKV5dmUQhgHqW1spU5e6SxSh1ZhZ7q2wXJnnRHFe26R4My6gUMHXuz3IlzfJk nzmQk9h3ZHQzBDv59h0E5PxAVfqKLs1ON1Ds6K9on7iGD1gpHCBK+LrTHOiGAEFYNvYB RdA24y3r4zgBpluNFDAWmQa/ABQhtJWdiC39TdsZSsIei6/icBqRga2RZEWp88xjy5t/ veTw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si3250925edt.394.2020.07.16.10.30.40; Thu, 16 Jul 2020 10:31:04 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728949AbgGPR2a (ORCPT + 99 others); Thu, 16 Jul 2020 13:28:30 -0400 Received: from mga05.intel.com ([192.55.52.43]:43526 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbgGPR2a (ORCPT ); Thu, 16 Jul 2020 13:28:30 -0400 IronPort-SDR: MzJqVoL1VOyOjiind47ZVmhYJzlgUXn9XK2EYpX3xDhAdzd81nk4ftOT0cUSYTxqD6uRrML2Nq p2skPS7/SzcA== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="234304876" X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="234304876" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 10:28:16 -0700 IronPort-SDR: m6l+In8vox4es+mEgJ3YiEtcoyQ32y11TCHILjoKLi+6FWQ5SLHj8wHaSUphRUksGd+FQOj1rd SfPuP8TDs5VQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="325205940" Received: from unknown (HELO localhost) ([10.249.34.156]) by FMSMGA003.fm.intel.com with ESMTP; 16 Jul 2020 10:28:12 -0700 Date: Thu, 16 Jul 2020 20:28:11 +0300 From: Jarkko Sakkinen To: Guenter Roeck Cc: Andrey Pronin , Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org, LKML , Guenter Roeck Subject: Re: [PATCH] tpm: avoid accessing cleared ops during shutdown Message-ID: <20200716172811.GB14135@linux.intel.com> References: <20200710002209.6757-1-apronin@chromium.org> <20200710114000.GD2614@linux.intel.com> <20200714113205.GA1461506@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 14, 2020 at 08:48:38AM -0700, Guenter Roeck wrote: > On Tue, Jul 14, 2020 at 4:32 AM Jarkko Sakkinen > wrote: > > > > On Fri, Jul 10, 2020 at 11:25:44AM -0700, Andrey Pronin wrote: > > > > Why does not tpm_del_char_device need this? > > > > > > "Not" is a typo in the sentence above, right? tpm_del_char_device *does* > > > need the fix. When tpm_class_shutdown is called it sets chip->ops to > > > NULL. If tpm_del_char_device is called after that, it doesn't check if > > > chip->ops is NULL (normal kernel API and char device API calls go > > > through tpm_try_get_ops, but tpm_del_char_device doesn't) and proceeds to > > > call tpm2_shutdown(), which tries sending the command and dereferences > > > chip->ops. > > > > It's a typo, yes. Sorry about that. > > > > tpm_class_shutdown() is essentially tail of tpm_del_char_device(). > > > > To clean things up, I'd suggest dropping tpm_del_char_device() and > > call tpm_class_shutdown() in tpm_chip_unregisters() along, and open > > coding things that prepend it in tpm_del_char_device(). > > > > Personally I would have preferred two separate patches, one to fix the > immediate problem (with Cc: stable) and one for the cleanup, but I > guess merging both into one is ok as long as it is marked for stable. > > Thanks, > Guenter Not sure about stable as this issue does not afaik concern earlier kernel versions? /Jarkko