From patchwork Wed Mar 13 06:26:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160202 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp13954802jad; Tue, 12 Mar 2019 23:32:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTbce7OKO5a2EuD5bULC25XOWjupI4vp2PajnKLlfR5vGt8hn99+LoA0ifSD3gELbEH2Ln X-Received: by 2002:a81:a342:: with SMTP id a63mr33725733ywh.362.1552458737187; Tue, 12 Mar 2019 23:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552458737; cv=none; d=google.com; s=arc-20160816; b=jDSVy/BmOyTSdd92kzucqY5mT0bzxEIMGgFWEux4iJ13ckFFO4lcLnidKgflaes2cj igbNEDpQSAEbyFvFkxyAENABem/2Qzp94VlN656KJVOQxkCcgULBK83fdcPpPcizxRT1 XVkjg0YFB+ogTyn+OBRGEiKOqBE0j36DL9/3UHQ2KEYY38W5p7eTr+Ypzf/MPQgY0x4V pjvLxYGpp5h9uwRjG/GtrVMzWIKnPxO8pSRV867Qrn60yHlvnVk799DX+IwT70WJBEy2 LIzWIbhq0OTBSK41pjAoB9dOSQXxDffuYGHPOE07HAm0NcAhJvVbuBpkuyFo2APQPRl2 +KtA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=CRrzqIjVEmnH35vuK6IV8EUSMF7zJvww1HBvBe97Ku4=; b=dCLFAOLJjjbsccHFBBCf3cn0viY6lk56v06kCZ1O+nCnBfju+az4PSM5Nkj0tAEsa/ mnRy8pfr3+nXKKgWZ+N6f6XLdsJMLxuBfrv2OefYgcBm2npjqkaACkBpcCf4UFnSHGfX 5Bet4Tx+Tlui3Dyepovo219RIq69aHip0jqywzG34j6RXmf5+URD678xK22skaIIcFME SqD0OE3sGqPHCwIpNd/EvI0RZYL2UD+dZjaK8gipjMYXu2Euzt2x5ksGmupNjHlnGtRN UmxdHVmMVu5uvAqbJyD8wJnaJErcpnss2cF0kefO/z1yayricQUBHMltlYlhtznrPRK7 M8lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rcLdNjoV; 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 i1si6071267ybk.389.2019.03.12.23.32.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 12 Mar 2019 23:32:17 -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=rcLdNjoV; 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]:39230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3xR2-00047s-O2 for patch@linaro.org; Wed, 13 Mar 2019 02:32:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3xLi-0000fi-2b for qemu-devel@nongnu.org; Wed, 13 Mar 2019 02:26:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3xLg-000211-UR for qemu-devel@nongnu.org; Wed, 13 Mar 2019 02:26:45 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:41148) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3xLd-0001zV-Qk for qemu-devel@nongnu.org; Wed, 13 Mar 2019 02:26:42 -0400 Received: by mail-pf1-x442.google.com with SMTP id d25so655910pfn.8 for ; Tue, 12 Mar 2019 23:26:37 -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; bh=CRrzqIjVEmnH35vuK6IV8EUSMF7zJvww1HBvBe97Ku4=; b=rcLdNjoVIFH1g8WiIkvbj+zNp7Ux9iXWfNyq8aL69cL517Jr/hTLmCz3e9GEbxQps9 a/V9dDc2mMt5Mw727KPVM8ZUcgKcFG3vr4Ng3VrsOyaqZcky6Vqt9yS7bgpuPFrgX6hn Jweauj+3uY4V3Aa28hp8yEW6WsKXSRBllCskxIDmg9tSEprXKBwj26rgbzpYKiJjFjSB xZy2JI4pfCWIxp3j4hNqXhtxCM7S8RFQW3bd08buctR3zxO6iP8ftaPHSDMMSpelTKd/ Kan4nOMwszEbNtXePbliuHECm+iaEryKGa5BoAGTJQIOtoLY2OZwlyVq8pgn87I5DySc DRfA== 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; bh=CRrzqIjVEmnH35vuK6IV8EUSMF7zJvww1HBvBe97Ku4=; b=RG7l3IsLoHtlPL+huEijJ6PoXA1P/NmpFaUGhTloS3Jvg55U30H3sXfR7Lz1mrwfkA y7WE5f+n3W8D9qRNsFHPsTKC2YIiLHnLoTY0oE0GxgX07XKXvSK/0TFpBxxOsVPqai54 DnlpC4x/SrXHIbJX5DXh4i1eWrQMDRVqBAkRmTMuk9DJOKnHsnUlNvBcp7zNoperUog4 WamMfM9uPTmmuhjeMEddU7H3QVCP7Ls43n/oO9kdBfp9vKg/ksA+u/4KanefVIxmb9Ye 1QkOr+2LLA5EW7rLfEBq8ueg3V/nn2fVlsITO8wNW9uStOyPm1OpinDAzhy3d3pyv4zP gkVg== X-Gm-Message-State: APjAAAXULbYuSOVsY+XWzcno+dyoemhcIahfGdtQu+PiLriaaGyZN/j5 b1j5QSQRA97T3c+KVKJ6Tf+1eJYuGto= X-Received: by 2002:a63:6605:: with SMTP id a5mr38836091pgc.372.1552458396294; Tue, 12 Mar 2019 23:26:36 -0700 (PDT) Received: from localhost.localdomain (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id m64sm25593889pfi.149.2019.03.12.23.26.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Mar 2019 23:26:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 23:26:26 -0700 Message-Id: <20190313062630.30568-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190313062630.30568-1-richard.henderson@linaro.org> References: <20190313062630.30568-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH for-4.1 3/7] linux-user: Use qemu_getrandom 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, david@redhat.com, laurent@vivier.eu, armbru@redhat.com, kraxel@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use a better interface for random numbers than rand * 16. 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..f33bf4fb85 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/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_getrandom(k_rand_bytes, sizeof(k_rand_bytes), false); if (STACK_GROWS_DOWN) { sp -= 16; u_rand_bytes = sp;