From patchwork Mon May 6 17:33:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163436 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp266726ilm; Mon, 6 May 2019 10:48:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyj7QpvEkMHWtGzdlB0tZoRr5brnQzoEUQD+ETaRsEMdBFMTi/CwHWaSrLdpgyAsqOuKYP4 X-Received: by 2002:a5d:6ad2:: with SMTP id u18mr9050982wrw.199.1557164925315; Mon, 06 May 2019 10:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557164925; cv=none; d=google.com; s=arc-20160816; b=Ak2tYmg8tsczpjYRN2xsrTvL630lqIGE4igJf+8nGJIdZSJLG2fwwnB28I/x3hMiOM 7DeXGaIsGiBgR1DCE4CUv11JgXyFqdodw6+AGtSxIGKl8M8W7XiGWfk5jVlqoDYOnLr0 jNrVMGNbCK9XgMMZ6sKpqZ9beNBWrOM6/gS5O5h99MyGQnFj7iV0A+UMpq6dqRO178iE 1hNlblvZpkGHZj/ylwKBLKxJr33d0sp/HQhtrytVuydXUzzeywQ/g2VRQxXWTJWN+7hC bTn9xTNJ0eVvpsTvnszc9tBhoOLEsJ9+GxJlNK5OPTDzfITK1f42rnXpbx3JH+hSMTip KNMg== 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=6ZLSvDsE417cQFXtdznOdElqMvcAzRRA3vqOLnZRXkY=; b=QSQ6BkoA44VMI3hB9Vo8VUazupF4S9QrQ9KUBY2MiIEN2/SZxHKA6tIiq31Jp890XX H3IlClgr6btoDsA3WzG2efrjNlaJrL41E7ZZuP6v/NzkH95lEExqrX8XO2+xTpqFZe7Q KPH5jMfU+Y8JWBfZvMAGvHVUfg8uRun7XDvx5PO8qOes6xRLbMnJmw/23KeiARq9XRza avpAtcWJfu4hpfhJvivfU9wo54NInUN7jrKUN6iVUd1nddywPAW1A0lf344L4o1WyH8C dpuN+jHq2QIJM25eJXRdRi5C7t93V+wah3R4m0SfnH97rzYibIDEvkQqsit70JGOtUlC vxqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E32KfjgM; 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 n7si5384359wrs.10.2019.05.06.10.48.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 06 May 2019 10:48:45 -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=E32KfjgM; 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]:60090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNhjI-00065e-82 for patch@linaro.org; Mon, 06 May 2019 13:48:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNhVK-0001Cz-Gs for qemu-devel@nongnu.org; Mon, 06 May 2019 13:34:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNhVI-0001Qp-Lf for qemu-devel@nongnu.org; Mon, 06 May 2019 13:34:18 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:37276) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hNhVG-0001P9-Ol for qemu-devel@nongnu.org; Mon, 06 May 2019 13:34:15 -0400 Received: by mail-pg1-x544.google.com with SMTP id e6so6799970pgc.4 for ; Mon, 06 May 2019 10:34:13 -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=6ZLSvDsE417cQFXtdznOdElqMvcAzRRA3vqOLnZRXkY=; b=E32KfjgMlH1BNZqxvEe87rzW5aXT1ryTedZZsN1NoTPRj8Lo5MKTENOVYjBnYfpgQg vI74qDBQ6nv8qxXXDbvERkYtVaZ31P3Cl+Vt6tGex/nFUQ+UT6Po1dw5GesRWry95Jko ofBkUgbvbqwLTajEGDRqWgdm7ymFIk14MvdVu0+eL8V/oluZMMi+wDHw3c8/RUzCAfYX 8lwUbS1f42yaO7pdTL9RuljvwMIUuAYI7+aZco1eMucsi4JO9ixoowwuz7SctYK2frWy 3tIAOI8kS8r/4C6ZvmE/9DeGVwIkTOTM9mC+Pxe4xUPs5YBoEcixmRz6as2LTlM/95Zn wR5g== 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=6ZLSvDsE417cQFXtdznOdElqMvcAzRRA3vqOLnZRXkY=; b=CZ1Q8NW9hb6hL9Ri+DI6z4szHgEZTFRuqEI4X22qxudm8sbGY7XdVWeEeHkE1R4lvi hKoCISA7xjfjuHSSOE1jjeOuIYPpmUV5YcH8ZVJ+UkA+luDbPGFR1ugrB0AI3/WDDJzp nFUNuOX+obeQM6dDl92NEvboPb7eiqHS2SGndylMp4BWXF5xTscLqyKNZv8oNne/HDtc Bw0gfC6YNh/EcnMZMSJXTEbRm/lWALIpt0v36zWSytVmeklhPxNHKEDwsblutzZ6E2Ic z4hPSt4kFM0W15KjbRM3I4tLPYdKuXkoABoiqvQMQU+mBLfQu8+7YCZNgkhZhKjOUvxO 9wYQ== X-Gm-Message-State: APjAAAXuc/jZfwI9HNurogvIjpkdA1Pjiv+zhs0yrHdvvU0HM3r8xHXA HrCvCkjHmJAaWh6hTFPtH3AUhNiVAnM= X-Received: by 2002:a62:5a42:: with SMTP id o63mr36429284pfb.170.1557164052846; Mon, 06 May 2019 10:34:12 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id k9sm2268839pfa.180.2019.05.06.10.34.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 10:34:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 6 May 2019 10:33:43 -0700 Message-Id: <20190506173353.32206-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190506173353.32206-1-richard.henderson@linaro.org> References: <20190506173353.32206-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 v4 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: , 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.1 Reviewed-by: Laurent Vivier 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;