From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27597FA3728 for ; Wed, 16 Oct 2019 10:43:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B09C20872 for ; Wed, 16 Oct 2019 10:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392515AbfJPKn1 (ORCPT ); Wed, 16 Oct 2019 06:43:27 -0400 Received: from mga07.intel.com ([134.134.136.100]:52408 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389345AbfJPKn1 (ORCPT ); Wed, 16 Oct 2019 06:43:27 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 03:43:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,303,1566889200"; d="scan'208";a="220736033" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.130]) by fmsmga004.fm.intel.com with ESMTP; 16 Oct 2019 03:43:23 -0700 Date: Wed, 16 Oct 2019 13:43:22 +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: <20191016104322.GC10184@linux.intel.com> References: <20191015124702.633-1-jarkko.sakkinen@linux.intel.com> <20191015170450.GB5444@ziepe.ca> <20191016103805.GA10184@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191016103805.GA10184@linux.intel.com> 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: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. /Jarkko