Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp562915yba; Mon, 1 Apr 2019 11:55:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqz59deMvmUw26bAVaUqeKwM5EOesoufCQJTaWZja5A6nmnEjjM/XocJAnt4zvkqA1Q/s3Hy X-Received: by 2002:aa7:9193:: with SMTP id x19mr55450122pfa.108.1554144946053; Mon, 01 Apr 2019 11:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554144946; cv=none; d=google.com; s=arc-20160816; b=oK8SRWW9Kaic/rH7iq6M10qZsYcLJLcdtcHVKzi7lrA2i9BGvk+jeSDk0mhLZ+qiEr OzUq8fUD4UkG0I5Z49O7irZ6PDTmUbszfZOcbfK4pb36vOpCSkD/trIFDovJ0EZyAeCT rIliv3k4hVVXqB7cUPPJ4GZGmWd1+t6xDCiineUgbgy91I55s1Jj5Gu0rWhkxxG0/kQn RypYT7QmbRHkqrR8f8xy+Xv16HBIG4awkLKWlz+clqirFMVHKpcyPlYcAgliD81cLQi3 pYfGVgz5LJqs6sagEW/ETttZXSOZpPhAajL18H0LtzcfpbkjMz/sHWFRfDYSta3X0p7k UtLQ== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=p/Pvm4t+BK97mvOMvdIgxnMQbzo8J/I2Bcii76OapxE=; b=FGUbF9iLQkulfdz/Fis4PhJ6Bp+Dt76CT36i1+o6U3kuP6F0G8l8pl8gu6FLzy6VCY BaoqgFAU4suQPsjpPhJb6YW33kn+0W2j91RZFLV9SOGrDcc/8FoDsII8DY0/z/L1NALT 3QDGLfNUZ5tZXWXvS2cnwi8em8VxsiB+5wfrLBNgQW1obSfvd/k6jRg0L8qUlf+G4CdM S9AcAcLRLhIKScaEkGzOKY3/GqJNQp9pUSr4OA04FR7+gi7qnjfhb+N9HWg+Pi1nMw35 yLDNzc8o2eu7RoX0aew+EWkwA6VPFtQZGJpbKdHXCf8X9MNR+MzPXsd1MmayAF0DMWA6 e1Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=oKIcWEte; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7si2787711plq.31.2019.04.01.11.55.30; Mon, 01 Apr 2019 11:55:46 -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=fail header.i=@hansenpartnership.com header.s=20151216 header.b=oKIcWEte; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729054AbfDASyq (ORCPT + 99 others); Mon, 1 Apr 2019 14:54:46 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:34888 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728690AbfDASyq (ORCPT ); Mon, 1 Apr 2019 14:54:46 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 758698EE12C; Mon, 1 Apr 2019 11:54:45 -0700 (PDT) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xYMDqoXhVfSC; Mon, 1 Apr 2019 11:54:45 -0700 (PDT) Received: from [153.66.254.194] (unknown [50.35.68.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id A7DA18EE0CD; Mon, 1 Apr 2019 11:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1554144885; bh=jywvzMZ3T1LUMchw4h1QJoeQmzI1zyDJABogHdLRFlU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=oKIcWEteat8kFuHGz/OoCpFcFXbGgmU+H5SLdNaptS6WmpEHgBYqDpIIMlvxPEwz+ Yd3/loKr40Al//wRDsBvRVSNjzaxE0URHf9EZdQzn2OQpZSrxSFmdkQvU9Rj71EFxt dw+D+XuGiBShlCdQi2IKkXkHmM1eLDRXV8zo4C98= Message-ID: <1554144883.3029.20.camel@HansenPartnership.com> Subject: Re: [PATCH v2] tpm: Actually fail on TPM errors during "get random" From: James Bottomley To: Kees Cook , Jarkko Sakkinen Cc: Jason Gunthorpe , Phil Baker , Craig Robson , Laura Abbott , Tomas Winkler , Nayna Jain , linux-kernel@vger.kernel.org, Peter Huewe , Arnd Bergmann , linux-integrity@vger.kernel.org Date: Mon, 01 Apr 2019 11:54:43 -0700 In-Reply-To: <20190401185219.GA22215@beast> References: <20190401185219.GA22215@beast> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-04-01 at 11:52 -0700, Kees Cook wrote: > @@ -559,6 +559,9 @@ int tpm1_get_random(struct tpm_chip *chip, u8 > *dest, size_t max) > rc = total ? (int)total : -EIO; > out: > tpm_buf_destroy(&buf); > +fail: > + if (rc > 0) > + rc = -EIO; > return rc; > } No: same problem. If we're successful rc is set to total (a positive integer) so as it falls through to fail: it's converted to -EIO which means we never return success. James