From patchwork Fri May 10 01:24:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163799 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp1726653ilr; Thu, 9 May 2019 18:34:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/sWyjMQ4klOFF83YfVLPlx02vOB2G1MjtNYSLr29W+53gbUDPCw991yo7Flg3MyJ4jFj/ X-Received: by 2002:adf:fb4a:: with SMTP id c10mr5273284wrs.309.1557452045361; Thu, 09 May 2019 18:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557452045; cv=none; d=google.com; s=arc-20160816; b=LLsVanQCIKqCRICXE2zsfdUMyrvNXHbUuI/wZ4es92TgW9ho+Hf3nUWphbvalJIeR/ 9uxjjRrhi6DnkHLmO1ibUSNMH0iSZA3ESI55o9wvMrZF41KeGg6/WyYM1gyyVQwgI7mq hPHLWF+JjIv3n7vN5SmxwrB7hcY9D3ZRF72a0jnLwKTrp3eCU6r1ApCd3bjcJUwH2Dzz 1FxUjAt+77T8m27XFz3nwZxhwrzVHeLAvKn9IJqr+pREpWCgiZaFuZIptARkg3ERofiZ rqsRc2akqU1XGhu6VAiqXolNEmY5X4G7eNNOBWhrT3tuPlOlIdnxee0o9uFwW+z129ch yoYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=Rw5R34uV/AA62KXp+YUGZEBrbetteys0TOZc4Uvv8RM=; b=A93kMaxqtDnTC/YaH3Jt56+PbZ3zGO5KfhMUtj/2uXv4OZROgxsHUmFemcyb3Onh0C mcBQgJyntK7bvd6ixouzMxSaOKj2U4AzC5C0m0ocOyhV06aHL6XtbGkdGDpTs6IboEbV LqsiyVLJ7KnaQjicYOMb74LH9y3O/UkB99Byz7pdzZ0jAmSao8Z3Vne3I72QGeH/+W2Q CnHobJZR/sTIG0lsbTbBkNxay8/3IqZbFs/UIc9chP+HTFhIIrT12nQCJnVtlY6u5P40 mWX+we4wVJmWus2DmQPaencGXSZckhlJ0eDgSgwC27OqNkck4RpvucLAnXueq/WNKqsR wqrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aB2fPoOW; 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 f3si2657134wme.155.2019.05.09.18.34.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 May 2019 18:34:05 -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=aB2fPoOW; 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]:35102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOuQG-0006Br-91 for patch@linaro.org; Thu, 09 May 2019 21:34:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOuHn-0006Jy-Ro for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOuHm-0001D8-Sx for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:19 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:43033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOuHm-0001B5-MD for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:18 -0400 Received: by mail-pg1-x544.google.com with SMTP id t22so2116689pgi.10 for ; Thu, 09 May 2019 18:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Rw5R34uV/AA62KXp+YUGZEBrbetteys0TOZc4Uvv8RM=; b=aB2fPoOWuQCw5NIc5+gb078QFH6muv4uHr2aYtDjwlaZsJIRmcfCOBCCm8ftdQNCMK 7CPbCGUK200HhSjdkNMtg5Cj3nN+5fKAInsKpNXiWqsUD3Fp8DS6YzQlcnZ/WzeMRnHF 6LHPBaPbCBawvZWV62E0HO+C+METlFtxLegUmrrFboVAyY+H5tUd9JVhNQyzzZaaXkDQ Xq0dWc9lPVfDhx34Ai9YGpHNWbRUJwseEkV2JseS7zj1m/Kuk47rOADXWQSOdm2wJjHS yFKBEA6YDBOhgfShvmvk1I7ABQXEkPcbfz/0L9ozLmsbaBk+gNQsOk+NI5ElSkXUABBr 3kJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rw5R34uV/AA62KXp+YUGZEBrbetteys0TOZc4Uvv8RM=; b=qX7lUplvLpmtTWQC53bYxpSt9f5bETMGNM2+vYAe0cX4KS/9IHAhJcMtCzqUAU1PE3 ou2uHaCmWjrMTFvZO0vpKCw8fAePd2FJyxVLoavbCpGIwEtTLNzhXYCsNJFXXYk3AvGH 0myV1dRjB5gyqefE1jx6AfORh/dllgOvnSRb1PKQSpIqYhJC2xXDSy938LNQlxottfu9 sKZNoqQlrpxcYwAep6cL5u8QPKkn5bs0U6jml88JKc0GI427sBaqlVNNBgN5WPBMoIo3 lZRikg4HwXR8EHsGtWU3NbZ/slFbLIz/JeTQ7ceyOte0o+EIc23r1wA5hPaR6zphpV5s LNQA== X-Gm-Message-State: APjAAAV3LHrwZ+hgS0OKrK2QasfCFE0/qiehPNWCfe9TpYan4VpSFYO0 McPJueiDHpA9F2ikApqmAPyp6fNuMts= X-Received: by 2002:a62:b40a:: with SMTP id h10mr2261748pfn.216.1557451517305; Thu, 09 May 2019 18:25:17 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id n18sm8252700pfi.48.2019.05.09.18.25.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 18:25:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 18:24:48 -0700 Message-Id: <20190510012458.22706-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510012458.22706-1-richard.henderson@linaro.org> References: <20190510012458.22706-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::544 Subject: [Qemu-devel] [PATCH v5 14/24] 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: , 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 c1a26021f8..e673f7ea55 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;