Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1847129ybh; Tue, 14 Jul 2020 08:49:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4hwlOav6wf589QqM8oNRvR/z2UQKKdIoWGRqfrJKmcmL34xWYiO7d679xkuBQ4jzHCld4 X-Received: by 2002:a05:6402:b23:: with SMTP id bo3mr5236019edb.331.1594741786773; Tue, 14 Jul 2020 08:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594741786; cv=none; d=google.com; s=arc-20160816; b=T+wbiPWc8MuAjwfNL1/3PiKh4CUEea5eCCTRfPoJilundCu/azUUSdI/xZPXRBRysD pO8YMclD3511IIHnVTHg6PswctB72PeSAah3FXfH6a/drUPG9GBU/6AMzHW6TjC5ndGf QXYaFF3BUhdJg2iHH9t6ap5VZcIRsgd1py3tbFbp7q052/zwWMYiHSbGtXdsR9x+2A/a Vp8JimfU8Sd7K2r7UHhYNZFkr7Morkqmj0h5nIakusx5Nnj8kmlkSv25qBTFMz6j6wgJ pf3DtQjpIlQLI1bKMMIIBF4GlZpwPWRakQwEUwnL9wq/4bkciwiCIwvmKW7Fjymu4Chq cKlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=geWoHm0dGyB50Rmo0gHBfcDLwCZECBkcejM8K8k30DQ=; b=k0PMW33qjRHIHD8pXNQPNKUOx+O6zoOZRBCIJ3MAwQ90UMtf6xi1m0YTTzcFvHBP0J OIjN1ZOc2UmXYbXKC3Su0yoHe3cCIh8mN48Qw0UI5q5kmRRtwKhW+CuzpHJi7qKqfklF KSkfLQKkKisHRClYtZn9H1ZXxTAF7838GcS2AC2ihZZ7dJKH/SL+OPFZbU537WW/Y5rt XVwrQ4Mw6GYkcEiKuGBzph93ScsiVvkf4w+hwI5PXCL1+Bppx5dgFgcyCwf40UrRiDj7 0IzVtq183LD2acg2mWRiKSwqlcRj8aIX4saKr8yUvasnafgs9mXwq5jNo78K3K+KtUX+ RCTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XxgHUC2I; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si10468077eja.703.2020.07.14.08.49.23; Tue, 14 Jul 2020 08:49:46 -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 header.i=@google.com header.s=20161025 header.b=XxgHUC2I; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725890AbgGNPsv (ORCPT + 99 others); Tue, 14 Jul 2020 11:48:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbgGNPsv (ORCPT ); Tue, 14 Jul 2020 11:48:51 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B455EC061755 for ; Tue, 14 Jul 2020 08:48:50 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id dm19so17702654edb.13 for ; Tue, 14 Jul 2020 08:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=geWoHm0dGyB50Rmo0gHBfcDLwCZECBkcejM8K8k30DQ=; b=XxgHUC2I3sDfRkOff33DVWFGlsDneOECTpImGtuyGsGtO0nGaNLhSMPKfl5P22aGeG TLVZGuaiHQwXMQb46pJmGUWWfzbMQb6vl0+JJBB2ZAWXonJOV180ui8YM9H54B9qO/v0 9jbY2VQ2cueS9HveKggZsF7i7NEJPQUfQgolZuaYVXlAqRdyW1JJrAwNi3MG/8CCn7cs 4KVww/VHimVN4gxPkQZYoYrnqLOOgDxzUTcktukP3c6IuQOShciXd+3JnsumWHJTakP1 d4Rw0zG5CUIvzggFksUfup3hfCKWDPDlRpJXgrCPxEzkhj5NHVOif4DHRBV3VF/3yL/q mz4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=geWoHm0dGyB50Rmo0gHBfcDLwCZECBkcejM8K8k30DQ=; b=fMFgkl8HkKahEQksRH6ISZnKZagbPe6t95YwW73LhUdQ318eqSqMGu/CMyUmN78xDj lRYeTk29N7z8ZgaF8TS1oUY2KJK7KeDcZCB6dCREQh5Ws2c6RJMyK8upvUUqG0pzqcId hBQBEFes8L6Z5c+CFB8Jk9/O6Cr7Xl/+Pgm6/CVNgDM5cZklspK7oSTKN1XrZTCeFbGv 8VRXLbAPBWgU/5H2QzlkKgefRG6t3s6nPh3+GWStg8MGXMes2q/7NrLoh6Kx1VyxMjOJ 1zy/pK25xJTIhcIeJlbQBvVxtN/tfUuYCkDJNCO9ujZtkj3HKnoH4bz87zmoq5Vwcg0O 52Eg== X-Gm-Message-State: AOAM531p2oHb6Xxx45Zfr4UBlhKLx5EwyvB89zQ8cidg51DGcxfz5Qsx N17LwrUY08ulgLmUT3KaXD7F6/SydGFMXyqNbdYbtA== X-Received: by 2002:a50:ed15:: with SMTP id j21mr5401524eds.246.1594741729082; Tue, 14 Jul 2020 08:48:49 -0700 (PDT) MIME-Version: 1.0 References: <20200710002209.6757-1-apronin@chromium.org> <20200710114000.GD2614@linux.intel.com> <20200714113205.GA1461506@linux.intel.com> In-Reply-To: <20200714113205.GA1461506@linux.intel.com> From: Guenter Roeck Date: Tue, 14 Jul 2020 08:48:38 -0700 Message-ID: Subject: Re: [PATCH] tpm: avoid accessing cleared ops during shutdown To: Jarkko Sakkinen Cc: Andrey Pronin , Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org, LKML , Guenter Roeck Content-Type: text/plain; charset="UTF-8" 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 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