Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp340292img; Thu, 21 Mar 2019 22:19:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH+E6KVHhdUBFYl7iJPis079CDL4DMoIyDcL9rgH6pO6Mf5JDhO80VxKJCdpFt4U8A9Loj X-Received: by 2002:a63:6ec5:: with SMTP id j188mr7045039pgc.191.1553231940242; Thu, 21 Mar 2019 22:19:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553231940; cv=none; d=google.com; s=arc-20160816; b=rhwJ3BtvbyYZ7thZ+24fSuWzxIiCyQ5W8+aTHNOrpS8RxqksWARE2z+j9zy0ow25Qr b30bTxsFpxebuMgb4SYXYB0Y7SQ6suAfB2XMLoMYQOFPxqJRGnDZaOtSSgVCKD1rtpts Kd/lzriCnmKEIIsi2BO5eXcW+ZIn/YVMbnI5WSgE90diYWDEBX1tiusWtD97QGB9iweU O6OFEtpjY4oMfxJh1Cdn4hIakk36+RCBoqdLgDKGFlPLlyylA84YSiQKPBHEldAP6y71 Rt+EPCVglL0Ar8dd0xv8kaQvSi/Z4qYx4iNXskE7tZN66zwd5wsCEpwwOqL9+eQklC5X z5IQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iOZlxKFH0WQAoxYfc8HOup2uw3KC77CsrAv1v2qGiNk=; b=h27i7HfVGf+tJtmuJ7AwtQU0zTvx9WZrReH9+V9PXhZAcvuK4wRIgHdFz9EFCme3JU s7qbqQ5LL7CFeuEaCsuyhl14/iFuBNVAh8RXWj/jKIOsQWtoI6JYKSVrPxi+GVedrpfA /Qo+7mbU8Gz+w08HnfRpbIsYqJ/XwGpP0Hcdbs47q+Yqs0n6OIQTs1IOS/I8mqYAwulL WW/968YN3rXj5ytFo3vbZ0pOCgjSxN0NDDIA5XtSSPSw71qgZ4J3K6J5BbKwJXFw20Tr vL9sZpUzt5/Y2wECHnHddlDnrklL1evYaexu78x2CB9w+eFBsIg9O728k+NHAoEN9Opk /V3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wdzDZdwx; 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 d16si5671999pgv.70.2019.03.21.22.18.43; Thu, 21 Mar 2019 22:19:00 -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=@kernel.org header.s=default header.b=wdzDZdwx; 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 S1726063AbfCVFSF (ORCPT + 99 others); Fri, 22 Mar 2019 01:18:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:39378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbfCVFSF (ORCPT ); Fri, 22 Mar 2019 01:18:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 07010218E2; Fri, 22 Mar 2019 05:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553231884; bh=1RwfR4wZGg5wvqtXX5QnuvT9FxKwsePFHu69Ic59dXc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wdzDZdwxoelcU7q4dhtHFGdZ0QImu3PCZ+B0W1Er/URXWudT3sVnfc631JbRefTEX 3eYyuv29Mht1SAkKxYNJo0mFlwonP/GL6eem5Ss/B6ulIQtvGVN3uxNMJkQLmohRV5 yNUgNGiT6pURCn8Xvew4AOTD7kbl8yeE65LMxvvY= Date: Fri, 22 Mar 2019 06:18:02 +0100 From: Greg KH To: Tadeusz Struk Cc: jarkko.sakkinen@linux.intel.com, grawity@gmail.com, James.Bottomley@hansenpartnership.com, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v3] tpm: fix an invalid condition in tpm_common_poll Message-ID: <20190322051802.GA17257@kroah.com> References: <155320933278.5015.1752135965699928631.stgit@tstruk-mobl1.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <155320933278.5015.1752135965699928631.stgit@tstruk-mobl1.jf.intel.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 21, 2019 at 04:02:12PM -0700, Tadeusz Struk wrote: > The poll condition should only check response_length, > because reads should only be issued if there is data to read. > The response_read flag only prevents double writes. > The problem was that the write set the response_read to false, > enqued a tpm job, and returned. Then application called poll > which checked the response_read flag and returned EPOLLIN. > Then the application called read, but got nothing. > After all that the async_work kicked in. > Added also mutex_lock around the poll check to prevent > other possible race conditions. > > Fixes: 9488585b21bef0df12 ("tpm: add support for partial reads") > Reported-by: Mantas Mikulėnas > Tested-by: Mantas Mikulėnas > Signed-off-by: Tadeusz Struk > --- > drivers/char/tpm/tpm-dev-common.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.