From nobody Mon Nov 10 01:36:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552458797471755.6977538133223; Tue, 12 Mar 2019 23:33:17 -0700 (PDT) Received: from localhost ([127.0.0.1]:39234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3xRt-0004cY-He for importer@patchew.org; Wed, 13 Mar 2019 02:33:09 -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) 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) 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-Google-Smtp-Source: APXvYqzQQ6BbY8F1BVAv4c479MBJ2bZu3F8gsPqiPl3bxkfVO64OsHnVUnaaDOBg0Mtv7c2bxK+nLw== X-Received: by 2002:a63:6605:: with SMTP id a5mr38836091pgc.372.1552458396294; Tue, 12 Mar 2019 23:26:36 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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" =20 #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -1883,12 +1884,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int = argc, int envc, } =20 /* - * 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 =3D 0; i < 16; i++) { - k_rand_bytes[i] =3D rand(); - } + qemu_getrandom(k_rand_bytes, sizeof(k_rand_bytes), false); if (STACK_GROWS_DOWN) { sp -=3D 16; u_rand_bytes =3D sp; --=20 2.17.1