Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp893045imm; Wed, 4 Jul 2018 07:45:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpegWMuMCFVgrpYWPTPrOFEAgbOX+mx221V8pf3FqnuXuPSVXm2Bh7D38s0oZBfjz//iVsti X-Received: by 2002:a63:b505:: with SMTP id y5-v6mr2230618pge.213.1530715521813; Wed, 04 Jul 2018 07:45:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530715521; cv=none; d=google.com; s=arc-20160816; b=pjtSmYq8AVvXrhgmEhixwOo4hwCwkTIBVIQYRNlU0LPid493WEfHZJxjMxX8E92WBq pNO8rMke5DapzDL03NZCH+/G1j4WYfZERAdblL8eF4uuJHFr4fCxTeFhwI1upeJXUcJZ ZhN9/p+TVjXSrjqFis+speeU308WkJxfplY3ukdlwoVhipgarH8WtJjPlia4v3PpYRNi IYeLIUb9QHzMaTKDw20wxgbVAFQKtwFQxNfOlgafaMW0r3sQkOx8vUQqETG1Th5ckGHx zbxhmdc883MC11nFthaCXvhaQM++psBKk7XUSw0NZCGE/C7PIf6e1tp7LQuwbksHHEt0 4JPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=9cR5vFosKf4pOYy2kLbnrG5yXGupQHRfZtmrhhqsd9A=; b=pow788qtFcmtDHOtYn7KCqiHl6JZdOTScKN7keNPX2HD6nT5hj8hCvtUQLMf435rEO 5raRRsjnIAGLSFT+MFB9vk92FAIvEWzACE5+RttTEwyXDC35wxJtYUa2D1RcWKj3QdRe s/B2eTwpma1C9L5zgyDPbNghyFpMJuT47TShsxeATUew7dzCEW8j8az4RvjaZC3+V2aq PvIXNN6O61bwkjBUPI5wUngMfEcdA2vd0yGZYbrGrHmSvwyjYfL+HrvVJOgfIP+gMaak I9LswIOsIv1sNEYEwi7Z3UEdWMyEzOgQsgxmTi8XxOq8X9zWKE7oLoewYstunSyUtwhJ ne7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=RBlpq9hO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h69-v6si3818291pfc.206.2018.07.04.07.45.07; Wed, 04 Jul 2018 07:45:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=RBlpq9hO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752862AbeGDOn5 (ORCPT + 99 others); Wed, 4 Jul 2018 10:43:57 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36165 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752615AbeGDOnw (ORCPT ); Wed, 4 Jul 2018 10:43:52 -0400 Received: by mail-wm0-f66.google.com with SMTP id s14-v6so6110474wmc.1 for ; Wed, 04 Jul 2018 07:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9cR5vFosKf4pOYy2kLbnrG5yXGupQHRfZtmrhhqsd9A=; b=RBlpq9hOfSzNZvTMBVSfBUQhfc8ADKA+9DfrOXTxZxxqYvGzQ2J04tHLnSyRy2ej1c LAsqUUOG5x9npjPxQtXh9aUghef4aQ+stg9Zy1hDJksxjRj7qos2wlApHQCP+doPaPwA 0mCrozk4M64pCd9rpAByknUSOW7JIi6GM+w9X85mOnn51ndV9BNrSxbo2v4Yrs8aKehW 017J349Qkm7hJ1bxVio2Cl+m99vcJXyO+kBtXY9Dc+ETcYmqIEks+uJqW2oaTwlGKxjj oRag11INxpYd8zwT2rpRco7CckaMCtm7qIwGzkaiHK5VfTyVOhmD3nC/NVGhPRgrItsI L3vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9cR5vFosKf4pOYy2kLbnrG5yXGupQHRfZtmrhhqsd9A=; b=jXHcI7wc94KMH/cxTMNIO80wfCEFQGpaHyKIf+UMiU1sEw9sLokM9/DRdZpCe/BlN2 v0Q+AhSNPlji7p1xZlorOH3j8lAFU/z823sstJXRKclSCidKb8q9pwWcIR5PPeotH9D6 gpLYsfTCBxD4cO75b1mPJY727xaXYo1bDLWBHZTdNJYdU+7Cb9ACS7Or14V3jnSbLAYv ITET3Jsnq40oNAwgaLp8sS25RUloNLRXJtuG+R4De1gXHOcZyrWWM2B3tmr9ikw0I0SC pGIxKN6uCYyazVVOGbcTpZy/epB3yUwlFCIJXfWGMX8DP2B3MszaOoV/QictpZ2Wb95+ L9PQ== X-Gm-Message-State: APt69E29OThbVLBuRaPorGxjVkfgZB21IUgR+s9O1rLlLwz/UZPr+z0A no9nr2dUI8EQfs2SXouT+I4m2w== X-Received: by 2002:adf:a015:: with SMTP id k21-v6mr1819375wrk.202.1530715430239; Wed, 04 Jul 2018 07:43:50 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id 77-v6sm2350695wmq.22.2018.07.04.07.43.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 07:43:49 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1faj0S-0007qF-Vc; Wed, 04 Jul 2018 08:43:44 -0600 Date: Wed, 4 Jul 2018 08:43:44 -0600 From: Jason Gunthorpe To: Shirish S Cc: linux-integrity@vger.kernel.org, Peter Huewe , Jarkko Sakkinen , Arnd Bergmann , Greg Kroah-Hartman , open list Subject: Re: [PATCH] tpm: Fix NULL pointer dereference in tpm_transmit() Message-ID: <20180704144344.GA30037@ziepe.ca> References: <1530695020-21888-1-git-send-email-shirish.s@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1530695020-21888-1-git-send-email-shirish.s@amd.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 04, 2018 at 02:33:40PM +0530, Shirish S wrote: > During system shutdown, > tpm_class_shutdown() when called with TPM_CHIP_FLAG_TPM2 > flag set, makes chip->ops NULL. > > However tpm_chip_unregister() called later in shutdown > sequence tries to access chip->ops in tpm_try_transmit() > leading the NULL pointer dereference. > > This patch fixes this issue. > Below is the trace for reference: > > BUG: unable to handle kernel NULL pointer dereference at > 0000000000000048 > IP: tpm_transmit+0x267/0x565 > PGD 0 P4D 0 > Oops: 0000 [#1] PREEMPT SMP NOPTI > ... > task: ffff937c847fe580 task.stack: ffffa79f80b04000 > RIP: 0010:tpm_transmit+0x267/0x565 > RSP: 0018:ffffa79f80b07c08 EFLAGS: 00010286 > RAX: 0000000000000000 RBX: ffff937ca9bc8000 RCX: ffff937c847fe580 > RDX: 0000000000000000 RSI: 0000000000000002 RDI: ffffffff98e3cd40 > RBP: ffffa79f80b07c88 R08: 000000000001fff4 R09: 0000000000000000 > R10: 0000000000000000 R11: 0000000000000000 R12: ffffa79f80b07cd4 > R13: 000000000000008c R14: ffffffffffffffc3 R15: 0000000000000000 > FS: 00007ef31f747740(0000) GS:ffff937caed00000(0000) > knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 0000000000000048 CR3: 00000001243d2000 CR4: 00000000001406e0 > Call Trace: > tpm_transmit_cmd+0x25/0x70 > tpm2_shutdown+0x69/0xa3 > ? __radix_tree_replace+0xd9/0x120 > ? idr_replace_ext+0x92/0xb6 > tpm_chip_unregister+0xaa/0xdb > cr50_i2c_shutdown+0x1e/0x41 It makes no sense to call something like tpm_unregister from shutdown. Jason