Received: by 10.192.165.156 with SMTP id m28csp2066610imm; Sat, 14 Apr 2018 13:00:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/au9x4R4iaO9+7i88/UzOXHVU+Z+Kuju9pV47IEX3lU0QWqZ4vOmwSU9HIwffbxRMJddxv X-Received: by 2002:a17:902:a50d:: with SMTP id s13-v6mr9667597plq.228.1523736056930; Sat, 14 Apr 2018 13:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523736056; cv=none; d=google.com; s=arc-20160816; b=t85clk/cObd+2I3TcC3lQd+GmUARD2o4E7F+eUSSfzkl6JT41chSwHegxBQde3HUeL IAcBSTxLm89pVyamRZu4JZBPVKtNSfDNXLrUwf7KVveI72qWMCca2oUbR8spoQAlGh0y BbZMZDvUniBcZLRQaXPpTzDXluNCApb4c6WBPMI1MqlDkQm0r+Xea1gfpcaomUB0WhLU to5ezD12j3CsZ81eJRCV44hVeChB2LllGUTKN0XhgGMVxaImrDJb8hDyWfTEWOjSW87C XluL1wGHhkWeasLZVPFlw3gUgixh89gaMVfVAMQ4CNZbxDHfkj6lQvGJRmlC9uuQRjW6 jGxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=SQlzpE/mjZ9NzyyJq1tHa9K9p5+hKgDUPKFPaaGcxHQ=; b=k0ZvIZPwWeDSFoj7hByAfdRKEuc1h/Mur7Cbz4JjWqGqQf//r+CDaVId/Ayam7N7j8 uaPIUZkb/FYwHdjDLDJssG+3mod4DEwr2AWlip6n6y3ibSIsz2jNhG76D5LuJmgaPALV Z+AamINFZ2dc3urCw4Im4EImRYQcZexilCKyz+a8WDtF7YFuOPBE//lC/bE4spbyHQ9+ JcBReBUqJduCcpMRNryvFY6WXyrd+j6iKI5xb/SnhZ73/hmiyjBn6bRSfn2QyBzUi/0J oYRcemOTJSdYqXpH2egUSVwiS2Yl4Cjngl/IwZqzMoI2Rl/raPhXLnrjpBjPwdCw6olW wuTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TT8X3DWh; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t16-v6si7663015plo.485.2018.04.14.13.00.41; Sat, 14 Apr 2018 13:00:56 -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=@gmail.com header.s=20161025 header.b=TT8X3DWh; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751890AbeDNT72 (ORCPT + 99 others); Sat, 14 Apr 2018 15:59:28 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:37162 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751600AbeDNT70 (ORCPT ); Sat, 14 Apr 2018 15:59:26 -0400 Received: by mail-wr0-f181.google.com with SMTP id l49so15955627wrl.4; Sat, 14 Apr 2018 12:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=SQlzpE/mjZ9NzyyJq1tHa9K9p5+hKgDUPKFPaaGcxHQ=; b=TT8X3DWhdvnliignsWlHsgyEPb+szIOguVHcjv7d+kj7cdM92GAkQ8Nn/l60s+cbFo l9CltVjyTDgG+3o5LIjemUZSab1B1CHkiFBv/uW2YQjVlCvWtGR7N8REQ2baKTcLTcNq 9YJZEu65juHpctKMcZM8e6cTb2ujdesesbbDXgwTunJyRZrPs6op4ojekdfZYHNmkKcH 5cLscqUycUVdo8egnMBKBR4GcrS9BHja/ZLIhRaL0lGvWx5HUjwPavdXm8VUEGGQUcM1 PFS4859sk5/YLNHFUcPC0YQsHSCbsc0ULybV9+R815Ju0uj/H97MBtzJn+mjBhNqO8x6 d7Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=SQlzpE/mjZ9NzyyJq1tHa9K9p5+hKgDUPKFPaaGcxHQ=; b=rNtiFEItQNVaE5vNdS6SMl1UZ75IlS1ecoaX3Dx1dNZqZb926GtcxrI1/V3mZ96qCk Up40FiIzoCfiGp7TeTE0QUH/Fnz29Y7oYaaso+dUPoKl/w6hxO2nqaf0dWzIbO3APZrf wJ0/ywBwPF8hZ/wtnTCjkE5XHCOH8ajEBX/vMZUd9fOjHbNXWuGespRgOjnz3wEyYKpM Vww21fM6phbCNq8DFxDHTa0w5X3yfvPQ7pyaFWEB/l0YQ+ZDXfW7DlXjh4wLR1rUqHL8 YHIERI67XVqAFEUYBmsVFmI/sF4pK/UxjuZ3Z5pHdfNoXeeoAvYRA1ZORdCZfFmTnjPN jtTA== X-Gm-Message-State: ALQs6tA2y02+ncPRqQrmioVCE1ZlLKSVQUCiTTr32M8y2SAgaQQIZySf U+9dE7w1d+mlz9JzbQ7wxZZF X-Received: by 10.223.160.241 with SMTP id n46mr6570956wrn.280.1523735965260; Sat, 14 Apr 2018 12:59:25 -0700 (PDT) Received: from avx2 (nat4-minsk-pool-46-53-177-92.telecom.by. [46.53.177.92]) by smtp.gmail.com with ESMTPSA id k11sm4945818wmi.35.2018.04.14.12.59.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Apr 2018 12:59:24 -0700 (PDT) Date: Sat, 14 Apr 2018 22:59:21 +0300 From: Alexey Dobriyan To: linux-kernel@vger.kernel.org, tytso@mit.edu, kvm@vger.kernel.org Cc: security@kernel.org Subject: repeatable boot randomness inside KVM guest Message-ID: <20180414195921.GA10437@avx2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SLAB allocators got CONFIG_SLAB_FREELIST_RANDOM option which randomizes allocation pattern inside a slab: #ifdef CONFIG_SLAB_FREELIST_RANDOM /* Pre-initialize the random sequence cache */ static int init_cache_random_seq(struct kmem_cache *s) { ... Then I printed actual random sequences for each kmem cache. Turned out they were all the same for most of the caches and they didn't vary across guest reboots. int cache_random_seq_create(struct kmem_cache *cachep, unsigned int count, gfp_t gfp) { ... /* Get best entropy at this stage of boot */ prandom_seed_state(&state, get_random_long()); Then I searched internet and turned out KVM can pass randomness via virtio-rng or something. So I linked /dev/urandom. And it didn't help! The only way to get randomness for SLAB is to enable RDRAND inside guest. Is it KVM bug? For the record I'm using qemu 2.11.1-r2 and whatever F27 ships now.