Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp137435ybm; Tue, 26 May 2020 12:42:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc1fEfOF1NRG5zTaFIq29c1Vf+OK0BaTvNxlkAx2Y3KW7o9bi7Ww69QkECnRKzL74qOz92 X-Received: by 2002:a05:6402:1a29:: with SMTP id be9mr20939968edb.70.1590522158488; Tue, 26 May 2020 12:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590522158; cv=none; d=google.com; s=arc-20160816; b=zL9j9fs4Kn6TsLX6d6AQXewBOUVMHemLPwxiqaFcf9UvGe/X2jutWX4PEzmn6R1Ww7 NDj1y9VtuTuEcOEHQrSJUKCBFTLV3s0fwCQsKwCxTBd8F7gFP4sEWWJUsabGCbOzyTT1 Ak1k7BgEt56Jq1ykqpY+kDBXoM6FlenPmcCyCddmqzKNfOYuBxZYGj6j5hStPzlE6kBc q1FZ0fSLFUkO21gKR/UCvMkOvUfkzYwZ96dLjnTm5EK784NthJIIVpgJLRThUVOfVoT2 jGkEVzQTPPjNJ/fNyUqkZJQI0dtiKZO7k8EuADpovhWugsX4uAnPnlNznFtgaGxdrY9k jY2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=P1S/jJWjfuAnrLOcm+BjO/Ac53iAJs4aKRGes1JuJOQ=; b=ohRMQZ1V5MPrKABpGa18RP4dSIaYndd05r/iIhQ2Cx8e+m5proDfQLUt345v/DLQFJ hHyoEUXOb9pbIHFWC14p5BirlEaS+f1h5X3lCHQbOSeQLs89yjiD4ZF9WFG50Mss1Pvi PcrIP7wOiHD2Hi0YWgwJCnXxGk/buEoOb1vubHhOSchaoOtMb2SqUT59AZswabYAioyL s1dy8GwdBANJSvEnZmQE7kFRx4c0PLUlEqaG3irley9idg0ASyBo8rGO0KlyvLBv1ura 7rHUHB+ydxA+lADgVsjRQ2Pai/ohwkrJG+2Lh3SZabfc93vlbNCW21zq091q0DKZQyg9 sYLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bdChZ6x5; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s14si455480ejq.37.2020.05.26.12.42.14; Tue, 26 May 2020 12:42:38 -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=@gmail.com header.s=20161025 header.b=bdChZ6x5; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389703AbgEZTjk (ORCPT + 99 others); Tue, 26 May 2020 15:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389382AbgEZTjk (ORCPT ); Tue, 26 May 2020 15:39:40 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 706DAC03E96D; Tue, 26 May 2020 12:39:39 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id s10so10555085pgm.0; Tue, 26 May 2020 12:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=P1S/jJWjfuAnrLOcm+BjO/Ac53iAJs4aKRGes1JuJOQ=; b=bdChZ6x5vP4WGqb/pLthvuv4yhSeP3uHUJoeY8eZchxnVrHzFKs1XM9otGP3DrUXt7 gIgFsfZ/fZMYAYpSerFf4Y5HN3EpwAyNm4GDN5vUpsU7UOILV0bAB4k5tLNKRW/6ZUsp F4CFwRI1uMome8fNI9Mzx5Swqnly3HpOVBXJu6zknAKuJzaRvBE+CxsIEywzfkKdPBRD z5mhvn0b3PTeMPFldXQw3Oy/nbAhixN11mSqMMetv6oxPjzzg4bxfkA/EMuxYqegEnUa hsTyteUmmFvLqwMYhNyar66RSfYmVeiGT9QsfPTDnffO/yROVUByeiJsDZeMtt29ucHe 56pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=P1S/jJWjfuAnrLOcm+BjO/Ac53iAJs4aKRGes1JuJOQ=; b=R4ZnqoLgBAxtCSL9wcvdIPVq/Z1tMk1YA8R0uEaF0haTIpj4McvEPzL88lEZQVpzJ2 OEAhMfghovQizAnbkfGrBchlSVMUmM3mlbxdDa9kX5IIkmiwI+WBiYrWqQjZ9OigAVQ/ gbFr4PGv3tntcqLTODA2wdzl2dAEeTkys5yAwoGnV7ncbElPv/UXUVvWiKexc0gv7RF/ 3vFpOGhHh/oZUs2WLdGGDC7LiabmNJ4LqJlVCKR3LA7Xjl1cr6HX6tAcGlOTYNAHDBfq CD7C/rwr6YRxh5VB/KyhbzFxxydibdPspdq5F+DzzXA9NO8BKskyydMPEtCz4B8bj4On Ft6g== X-Gm-Message-State: AOAM531t3SmUsEJZRcAxW+5tXOzwbb7xJ2n52P013O/RYvdRHMSsb5LV OR1eB/1PT0XsylGv1ll8tQs= X-Received: by 2002:a65:67d3:: with SMTP id b19mr430032pgs.431.1590521978781; Tue, 26 May 2020 12:39:38 -0700 (PDT) Received: from [192.168.1.5] ([75.164.7.205]) by smtp.gmail.com with ESMTPSA id gv4sm245687pjb.6.2020.05.26.12.39.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 May 2020 12:39:38 -0700 (PDT) Subject: Re: [PATCH] tpm: Revert "tpm: fix invalid locking in NONBLOCKING mode" To: James Bottomley , Mario Limonciello , Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Jeffrin Jose T , Alex Guzman References: <20200526183213.20720-1-mario.limonciello@dell.com> <1590520454.11810.40.camel@HansenPartnership.com> From: Tadeusz Struk Message-ID: Date: Tue, 26 May 2020 12:39:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <1590520454.11810.40.camel@HansenPartnership.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/26/20 12:14 PM, James Bottomley wrote: > + /* atomic tpm command send and result receive. We only hold the ops > + * lock during this period so that the tpm can be unregistered even if > + * the char dev is held open. > + */ > + if (tpm_try_get_ops(priv->chip)) { > + ret = -EPIPE; > + goto out; > + } > + Hi James, This won't help if the message is read by an async tcti. If the problem lies in the chip get locality code, perhaps this could help to debug the root-cause instead of masking it out in the upper layer code: diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 2435216bd10a..da5ecd0376bf 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -202,20 +202,22 @@ static int request_locality(struct tpm_chip *chip, int l) return rc; stop = jiffies + chip->timeout_a; + timeout = stop - jiffies; if (chip->flags & TPM_CHIP_FLAG_IRQ) { again: timeout = stop - jiffies; if ((long)timeout <= 0) - return -1; + goto out; + rc = wait_event_interruptible_timeout(priv->int_queue, - (check_locality - (chip, l)), + check_locality(chip, l), timeout); if (rc > 0) return l; if (rc == -ERESTARTSYS && freezing(current)) { clear_thread_flag(TIF_SIGPENDING); + timeout = stop - jiffies; goto again; } } else { @@ -226,6 +228,10 @@ static int request_locality(struct tpm_chip *chip, int l) tpm_msleep(TPM_TIMEOUT); } while (time_before(jiffies, stop)); } +out: + dev_warn(&chip->dev, "%s: failed to request locality %d after %lu ms\n", + __func__, l, timeout * HZ / 1000); + return -1; }