From patchwork Thu Mar 14 04:55:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160286 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15073230jad; Wed, 13 Mar 2019 21:58:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwpfQ8ok5AhJ8wipuuRm0mfeVeGhhq5XkXHMhy7ojGNcEvPn4oI/sdxo58rtFCacZhC0Tb X-Received: by 2002:a81:3a05:: with SMTP id h5mr37502204ywa.282.1552539528202; Wed, 13 Mar 2019 21:58:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552539528; cv=none; d=google.com; s=arc-20160816; b=teN085ZYNYPS8cuBVhCSluRtj+svmVxePd/t7tQirEsGFftPZxGx/8C/VCSAv/4okI Yuu7jPAWpg0Gac6g1yGkPOC8tNqTFhMTe0kYIjdkGSIU1kw2SqX3d4E3I/x4MyIQOlsZ UEmUsaoJs67jVIy2C74Ed75XispaTXWRndyOKAIym1Y68MIuNWjUZuFAMDBFcvoana0t CimFLu5BLMHhBV7yvZ5k0EHyBQvwOwt0atNPARInZveRbn97M4llxOa1SWSOxl0noemL jYKWyxzcxDkICSwo1Jau0i2atx/kXb3FoUQ0ORyiTyaTsR2i89kdTCDQGXn7FIQN8tK7 ItqA== 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=7Mh6mMTXzeuIMplceTqZz4BZtZM4Cu0MqRNCaV8ItN4=; b=YUXHzIy4BAJpwlxSrg+GGH2hGnFJ9iUAW4Ag3ss4Bf/riAV0MmWn6g5hlccwsSzhzG EKVkiDi+aFFNsszPZicSjR/XFwnTJt1NIy9/JzZMcRAUXeeC5GaMsf1lko/QjPuA2FIl Gle1C4CdBTbmvMN52bWIEJhxfCO+7F4gNp9IX+JiMjPRndtZZlOoQYbJHu4kdQ4n9yOD hidTSiAy1XO3RBQKstxsRW+RxPZMwkhLmBBgiZFvHcigdYeCZVpspe/4Llkcze8vgP14 WvPRoTtioXjS1WFeXXVyVpLFZYNcLFASgb3QsiZmZKezxm5YZbudcuOkOGLdGzlXlDwd uVcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rj57aJww; 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 h40si8748882ywk.242.2019.03.13.21.58.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Mar 2019 21:58:48 -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=rj57aJww; 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]:56873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4IS7-0006to-LC for patch@linaro.org; Thu, 14 Mar 2019 00:58:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4IPA-0004Zt-NL for qemu-devel@nongnu.org; Thu, 14 Mar 2019 00:55:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4IP9-0007RL-KW for qemu-devel@nongnu.org; Thu, 14 Mar 2019 00:55:44 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:36581) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h4IP9-0007Ql-Ao for qemu-devel@nongnu.org; Thu, 14 Mar 2019 00:55:43 -0400 Received: by mail-pg1-x541.google.com with SMTP id r124so3161708pgr.3 for ; Wed, 13 Mar 2019 21:55:43 -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=7Mh6mMTXzeuIMplceTqZz4BZtZM4Cu0MqRNCaV8ItN4=; b=rj57aJwwtIkxSgELXPiehqfcI1fnaiXOaMjjBonNnXTHPJKJuIpZB5JIUMWAAJJYWB nLdCl/l5RDw5I2bNbmvi232YoTZQMhhbnsaOgXQotte8Mef+TRzRWW+bpJyRA3BR/++5 fjcui8J0B3eIljV/ZmeQC6xVAqh95SGTkaBxFfHFBPLclbpDZcujphNt0SvKcaM1cShs pqpPXIFDNujB1ffb3xy9g3v648LAWKogtQZd2icHvPLlu0uzOW37d+p3EE+hbFowYY3z GRqgQCOnOARy0ceFrpPzO33yDig80vmRUmdO44E25rlvAS63/M+JQIOauEvTbAk/Jszq 93Mw== 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=7Mh6mMTXzeuIMplceTqZz4BZtZM4Cu0MqRNCaV8ItN4=; b=rlqdqATCZycr1FdumsTWTvP51cwKn3JXqW6xwjWgIYIfvM38lRlWBGXQOSlfwHDwSx 90pAtx4oUe0CTRJRk030RszEYnHjCPSU9UAXjDG0Lxh2LF7+yAlqR59j9UTZcSVATar1 +25l1SSwUdEh2dw0V85ZXlpYd8y8PDfNlBoyJnmByap1KSL9R3cRSQbXg0gIRXmRjQoT AVFe0BKcYwOfVt7iG0Dj+/k6dnKz86Dq1ODSH7wCsKBERITpJtFPRhbICsm2P18aq3IS 2BvrjvsulWo6ASQPWiu34mTVrPoJ5eumfDwhSQ+s3IS/ILquqVAj6IhrS1nqS2jkAi5q PRyQ== X-Gm-Message-State: APjAAAU33eIDVBwe0r8j3JhOK9kL1nUzOMbMIuS2dz93m988HSclHphj FjY63VKDu83WvqS1krAtolonWwDgBBE= X-Received: by 2002:a17:902:6a4:: with SMTP id 33mr49539107plh.140.1552539341816; Wed, 13 Mar 2019 21:55:41 -0700 (PDT) Received: from localhost.localdomain (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id d9sm16185027pgq.6.2019.03.13.21.55.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 21:55:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 13 Mar 2019 21:55:23 -0700 Message-Id: <20190314045526.13342-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190314045526.13342-1-richard.henderson@linaro.org> References: <20190314045526.13342-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::541 Subject: [Qemu-devel] [PATCH v2 11/14] 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: Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use a better interface for random numbers than rand * 16. Cc: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/elfload.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé 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;