Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1213728ybg; Fri, 18 Oct 2019 13:57:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyiakjLVLEhtYLqLucjf3bI1GpgiT3Jjv8Q54bPDmIMAlGOuLv/yqsxVrTd9pealyknysb X-Received: by 2002:a17:906:6094:: with SMTP id t20mr10784627ejj.316.1571432224569; Fri, 18 Oct 2019 13:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571432224; cv=none; d=google.com; s=arc-20160816; b=iLsX2v0DyT0pjtCZksVZJQBIuwCER66p0bH4acerKqu/K9SlKiOU3Rb2Pj/MbsA+k9 Ay2YR3+MsGWh0id8s42FHyMdYyMkNJ8Rgn+Ur77B20rygWX/DMtfijpKnSuOF8XBBuND u+JZMWdk1wJtgfKtAVvdhQFF5oxpRqRTQO60gs0NORYwZgpPA2+alhw924spJNnh2vpB JqbnU4UYGH3iOv/wAKBfbEtSYdclMSSQdZ0Sgq9CwxQ2g3RzSqJ4Q53cTbA9yB4n3MJs R2FFXjTU1wWS1CIxiUFmBZV6kV23y4sWfZecx/zOlgqCKsvWu4HXkdBBw6ItvWsMVidP UBgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IzfLLu0q60GD9CC4TicALNjRXKbS1VTSotP9HmwgOy0=; b=CZlFeAeQnZcDYN0xO2QxT+zaZBg66WKV42Fw8m02P1ejYucUBnoMAPM0/rS3IT+Z3G uiB7krOlQkzfhoKmthduRGnBqkIqQs8+DwQ4Gl0eeYUJATfuLP9jeJatspaIYczfuWoN o82qMt5TV/QEsg23PJAPIvFXi+0e7UPl+GheCwdhkp9a+1f8x1s/Reia7cpWwXYHllSi Ty4DYZh5nFRVR05ElrxpSuJsqR116OewXqQho/d9wP0WYoJglXOVQbpPVRZJhwZC4k29 E0GdYwREoVXgaEuBwpL90JhOips2lwZMoqiuZSydY/FdzVstJIw4cQSQ8ZD5dSc/S73+ ptYg== ARC-Authentication-Results: i=1; mx.google.com; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 96si4783081edq.24.2019.10.18.13.56.41; Fri, 18 Oct 2019 13:57:04 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440447AbfJQQVs (ORCPT + 99 others); Thu, 17 Oct 2019 12:21:48 -0400 Received: from mga11.intel.com ([192.55.52.93]:33920 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391091AbfJQQVs (ORCPT ); Thu, 17 Oct 2019 12:21:48 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2019 09:21:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,308,1566889200"; d="scan'208";a="347809155" Received: from eshoguli-mobl1.ccr.corp.intel.com (HELO localhost) ([10.252.19.56]) by orsmga004.jf.intel.com with ESMTP; 17 Oct 2019 09:21:42 -0700 Date: Thu, 17 Oct 2019 19:21:41 +0300 From: Jarkko Sakkinen To: Jason Gunthorpe Cc: linux-integrity@vger.kernel.org, David Safford , Pascal Van Leeuwen , James Bottomley , Peter Huewe , Arnd Bergmann , Greg Kroah-Hartman , open list Subject: Re: [PATCH] tpm: Salt tpm_get_random() result with get_random_bytes() Message-ID: <20191017162141.GA6667@linux.intel.com> References: <20191015124702.633-1-jarkko.sakkinen@linux.intel.com> <20191015170450.GB5444@ziepe.ca> <20191016103805.GA10184@linux.intel.com> <20191016104322.GC10184@linux.intel.com> <20191016160908.GA3637@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191016160908.GA3637@ziepe.ca> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 16, 2019 at 01:09:08PM -0300, Jason Gunthorpe wrote: > On Wed, Oct 16, 2019 at 01:43:22PM +0300, Jarkko Sakkinen wrote: > > On Wed, Oct 16, 2019 at 01:38:05PM +0300, Jarkko Sakkinen wrote: > > > On Tue, Oct 15, 2019 at 02:04:50PM -0300, Jason Gunthorpe wrote: > > > > On Tue, Oct 15, 2019 at 03:47:02PM +0300, Jarkko Sakkinen wrote: > > > > > Salt the result that comes from the TPM RNG with random bytes from the > > > > > kernel RNG. This will allow to use tpm_get_random() as a substitute for > > > > > get_random_bytes(). TPM could have a bug (making results predicatable), > > > > > backdoor or even an inteposer in the bus. Salting gives protections > > > > > against these concerns. > > > > > > > > Seems like a dangerous use case, why would any kernel user that cared > > > > about quality of randomness ever call a tpm_* API to get quality > > > > random data? > > > > > > This is related to this discussion: > > > > > > https://lore.kernel.org/linux-integrity/CAE=NcrY3BTvD-L2XP6bsO=9oAJLtSD0wYpUymVkAGAnYObsPzQ@mail.gmail.com/T/#t > > > > > > I could also move this to the call site. > > > > But I hear you anyway. > > > > I think for trusted keys the best strategy would be to do > > exactly this: > > > > 1. Generate one random value with get_random_bytes_arch() > > 2. Generate another with backend specific technology (we > > have now two TPM and TEE) if an RNG available. > > 3. Xor the values together. > > Feels like something the random core should handle - maybe some way to > say 'my trust model requires trust in this RNG' and then the random > core can more heavily weight data from that RNG Yeah, I think. I'll study these emails threads and RNG implementation a bit when I have more time. Now I think I lack some knowledge to say anything educated so better to take a step back and go back to the drawing board. Thank you for the suggestion. /Jarkko