From patchwork Fri Mar 15 03:26:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160381 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp16271349jad; Thu, 14 Mar 2019 20:46:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpwDzw8B2wlkYikfGMdIcnltXLy6JcuWvqBFPTz//vKWEiX1c1FiMKhFxUggdNsgvD6pU6 X-Received: by 2002:a1c:9684:: with SMTP id y126mr564639wmd.124.1552621603449; Thu, 14 Mar 2019 20:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552621603; cv=none; d=google.com; s=arc-20160816; b=LyGAIoYPYh1oTNu+aMdPubvSasBM6/iP9kOBrDnir+Va3qRPYWpgfQOyHGhmTC0tng NILEALK7U7oc36YXdJVFmURljp5otYMqyNamgZOUkW1T6NnPQLY2W2KgN62kX3tyRma4 Ls62rBcTUj3yWtWoHGbf69EWhqgLz9ph9rjzctyr7ZzQrXaSyKwrI6kri51w9eEXNcIC nWEM8frQuOA9a5N+T24a2yz/Uwk/TBAl7N5C7pwxGNF3RGuA5AaMqlVYcyjJQ5AJdyD7 CIMNVRozncpYaJZSh3+6p3voe0fR2VkFJUkNInVOwSgXBHhRDnmpLojzIuwhoNr7mQmx dT5w== 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=KlXWyx52cjVWhIiLC4AwAqaGQyW3OMCsC+sL4Pwitic=; b=zkeWlkY6T1zX66ERPuMYITECiZRnQa3D0n6frHenh355TyQp+PdF7Rcg5+J7UMpQcA ocCdSy3coYYQexQiQL4zZ9lhoGFpeIhqZmYN/zofTO/yMVZPZ4gho1YWK0U4gWCnCWlJ 2H8QIQYa2+SPcquFRU4jsTGwRk5uusMySPkN/7TE0K35eL7RZm52f/5FclF/s1UEKRXu A4pknOLQ0MFW6Ctmwi5iGVTMwveUxTw7PM50U46P8fCWLjS59pgQZP4CHfq6+JV/ce+p WH6SGqH/g1GKUphTNrc/OQdJ9JO9s8J6xsPCBlMDzNILM4gDGGYZ/P45mGkE8hVVXavS hk6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vYhjdfBP; 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 f1si397535wmj.114.2019.03.14.20.46.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 14 Mar 2019 20:46:43 -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=vYhjdfBP; 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]:48863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4dnu-0006p7-89 for patch@linaro.org; Thu, 14 Mar 2019 23:46:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4dcK-0005E9-Bp for qemu-devel@nongnu.org; Thu, 14 Mar 2019 23:34:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4dUg-0002xW-EJ for qemu-devel@nongnu.org; Thu, 14 Mar 2019 23:26:51 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:35643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h4dUg-0002wm-6B for qemu-devel@nongnu.org; Thu, 14 Mar 2019 23:26:50 -0400 Received: by mail-pg1-x544.google.com with SMTP id e17so5418189pgd.2 for ; Thu, 14 Mar 2019 20:26:50 -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=KlXWyx52cjVWhIiLC4AwAqaGQyW3OMCsC+sL4Pwitic=; b=vYhjdfBPoMTH70TRQosxuU9KQ4SzOV2sYgI1+iQaiulnzb7h//9UfIzncKDxIjvNqj mdw2wqz4PKstRWrt+sdDcErzkrsArKjPWstjHPmeqlZdS8gdcAwEyx56pR3lDjKUsILs u4fE6CXZIdmcoOjxkokIop0OPwdXr55XdlQdt6nG57qTGlnfRtEC+pT3RhCqOA7wjiDR acUJXZomhLvnt7Q8ZIAwXV5cbcN4yniDnwLkMCoizZQvbXf9NqtcT5ovL/hQQAoNeVfZ KBpPob+zuESVUT4XvWkHZ2LbpONlXTuUgtnC62pmI/lolBlANb4duyVN0aLEWsT2TjlO XY5Q== 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=KlXWyx52cjVWhIiLC4AwAqaGQyW3OMCsC+sL4Pwitic=; b=M4+Ma7ayfNxDGuk5nUUa+4tY07mlL/5Hi1ch2y5vAhWusD7J44AuCaxf5Lfchzcb5E 0cFrZ1IuwkaVAm7Eo0MTePAt7unbZL/rfer3rFS+ULm9Vs9yLjbnpkBtDs6tEahmhths PTNGgitMCuD3dBSEBfWXaTMmh4z+25UHYMh7mxR7ZFg/1IBcR4LkAABQjVELVmRJgsa3 hiKbrS0AidNNTCQMyjiTGdNQlMVXpLMNaiWGQtDbREiF8SqAUHbK2qP1x6jQfohqAA+a Xk0VAKUYOxuvfBF6pTMBo64FFzJp/xhPr+R660KNKgtVEZV00E3TAkJHT9GGxmPsmXgO QQVg== X-Gm-Message-State: APjAAAV5olzmVquL533wFFWlzJCXVibXiDoBssCC1UMxVSgFNuMQnsEd 6wvyPyC7ToAnaZY4E0mXY+Nf9nnmWfA= X-Received: by 2002:a62:18d8:: with SMTP id 207mr1735301pfy.57.1552620408948; Thu, 14 Mar 2019 20:26:48 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id d26sm690816pfn.86.2019.03.14.20.26.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Mar 2019 20:26:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 14 Mar 2019 20:26:19 -0700 Message-Id: <20190315032629.21234-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190315032629.21234-1-richard.henderson@linaro.org> References: <20190315032629.21234-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 v3 13/23] 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: 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/elfload.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.17.2 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;