From patchwork Wed May 22 18:42:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164859 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1223046ili; Wed, 22 May 2019 11:59:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUiMPtrIij3yUG7YJfos9+uFlnuqfvRV4wQ7WbXjQrO3fSS88PFWnIMOu2HGY3vrgBgI2w X-Received: by 2002:a17:906:31d4:: with SMTP id f20mr30384579ejf.275.1558551540457; Wed, 22 May 2019 11:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558551540; cv=none; d=google.com; s=arc-20160816; b=PCHrhqmCFQSqclZcpe+cIbqvn18IAL2kVtK+SZtysrJcUdjMxO2V8DyyNCflEbou9p KX0csjzp0QZ8E5F6haVqZyWE5ilp5+cPP0idc6bpVIUpg3u5MLuiY4oQvEIsMLky/Zf3 /5K3PKWvs1U0Ko8taH/f9dx3BSuzmsiJJsEd6GNEJQBKTfk/tl7ygQUofCXXGoUlo5iz dVQcVJGpdpy2hHH+GzlQp/VvVzxgoXs86nXXhRCYnShGQA9L1Vc+De4glvdBMFvClY4g iCj8Iumg7/srML06/mIT6uDrPWu2/mLpUDVUYYbH4IUlJmhisQARwQlqhNyFUMpOW2CX aqFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=LA1zmsYxmzBAEiSSaTbYsFeqnklh9uk6Ygv0EHqOLtQ=; b=D2pjtEv9BU9+/+t8K8oK+NYAtp4KmXnhaZIsuKeC6pa8rMjO3xMYAB5FY2m4FJDjL2 X99oJ/TzsDI5EmD+kZcQhKcRLOcc29o3YiIRwoRt+rzKWOsIu5piwfVNNaZjjpuY0XD5 W91Wko2J1Z0LpGvCHddjWO//IGR9YnAvaydlfDJC95XzWwqtpoVCEt650OTf9fxKqTw9 8o+GrOpqiMOl3aF28lT9BdOIzNHPYw297dRfNbZjo1ZyXIuiYJPrGsGfjWtB8FxIF4SD 4HwAEKAVdNiuOQYPLnIqizMi9qOrOLrizhJU0HZkrIa2P/BUiunl6avQAQlRglhpXIO8 fb8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wlPqZaOb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x22si15668051edx.1.2019.05.22.11.59.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 May 2019 11:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wlPqZaOb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:49667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWS3-0002z3-CH for patch@linaro.org; Wed, 22 May 2019 14:58:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWOo-0008Eq-TQ for qemu-devel@nongnu.org; Wed, 22 May 2019 14:55:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTWCL-00087x-Rv for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:47 -0400 Received: from mail-yb1-xb42.google.com ([2607:f8b0:4864:20::b42]:39835) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTWCK-000879-61 for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:45 -0400 Received: by mail-yb1-xb42.google.com with SMTP id a3so1256401ybr.6 for ; Wed, 22 May 2019 11:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LA1zmsYxmzBAEiSSaTbYsFeqnklh9uk6Ygv0EHqOLtQ=; b=wlPqZaOb4ijRuE3yZISM8x6gUnqRkZE2hXEFLBmosSPC4Sc6e8SlftA3Gxpay2eFzt 2ZHnDRIwfk+IgqhK2Q0Art2CCvn5AyryHoloPKjpOgkxNGEVNvwfiPyHUYI14k1l4zzM Iz1O3itt/XXnj863xOesyE+WxpmYGC7H1JiPOHQzxkVL+ZGJzGSl+Oiw0I/RyaziphQh c2qsAT0Ucd3mMkF3FaX869tLLn9q0Xw3v5N3QdEzwYz8oOPNX7jMGSZm2dP7npMMh+7G lSU2/BVLVYtjhET4vedF1/9SeO6P8JgtDqqsu/q0jm5y7bGZVWuZYs61YNqaCr+xX1jM i5Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LA1zmsYxmzBAEiSSaTbYsFeqnklh9uk6Ygv0EHqOLtQ=; b=e7q6aa3kV+v94R67+xfzI0GPEABQ7b0LFL9Xk9XJz3mCQ2IhOdpat6kN8fTOuj2sF7 RrkaBnlhxqVqkz3E2Xc/aO3jGbJPo2O5F8619t7EaXvVUt9Sq6jD/Tk6xnXaHCCHrZhT DfOABkplF1Zz1dWcXIr3rXP1WS5DN8da8VGcNDsJi0kPpLMSLAouRYzCuVrgIeMi5ca4 bWvOY9ADqpYSd59Q1yEj/mBLSxfovB2ekTQkYaJBQr9itQ/2HBHXt0HhlcCUaNQczzpS ydGTnnKJrdjtGvsgGH5HLvYGBtDDmtFwbrUsEGcPb82fTwNn2jZEMlarGwj56MYNH1pO RQ8A== X-Gm-Message-State: APjAAAWV9L/zQXMPB/6B5QQg7o/uAI+dR9fRTzxHscVM8TFn1C9riEhM EwTGFrKXWVQzLznUUJgaYftBjjdv/A8= X-Received: by 2002:a25:2d42:: with SMTP id s2mr16062056ybe.476.1558550563421; Wed, 22 May 2019 11:42:43 -0700 (PDT) Received: from localhost.localdomain ([71.46.56.17]) by smtp.gmail.com with ESMTPSA id 206sm1299445ywq.74.2019.05.22.11.42.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 11:42:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 14:42:15 -0400 Message-Id: <20190522184226.17871-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190522184226.17871-1-richard.henderson@linaro.org> References: <20190522184226.17871-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b42 Subject: [Qemu-devel] [PULL 14/25] linux-user: Use qemu_guest_getrandom_nofail for AT_RANDOM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use a better interface for random numbers than rand * 16. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/elfload.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ef42e02d82..1e06b908b7 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -7,6 +7,7 @@ #include "qemu.h" #include "disas/disas.h" #include "qemu/path.h" +#include "qemu/guest-random.h" #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -1883,12 +1884,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, } /* - * Generate 16 random bytes for userspace PRNG seeding (not - * cryptically secure but it's not the aim of QEMU). + * Generate 16 random bytes for userspace PRNG seeding. */ - for (i = 0; i < 16; i++) { - k_rand_bytes[i] = rand(); - } + qemu_guest_getrandom_nofail(k_rand_bytes, sizeof(k_rand_bytes)); if (STACK_GROWS_DOWN) { sp -= 16; u_rand_bytes = sp;