From patchwork Tue May 14 19:16:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164245 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3010863ili; Tue, 14 May 2019 12:29:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyggiMvHQ6Nm1eNeBG2TYqhZJWzEloPgTigWdQNq5zSzMyRYGnE8FZfRWg/Bvj+YqEyDzmF X-Received: by 2002:a17:906:164e:: with SMTP id n14mr29883083ejd.72.1557862191611; Tue, 14 May 2019 12:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557862191; cv=none; d=google.com; s=arc-20160816; b=hk9JhGeh0y8Ke8kThr4nJzAqAkJiXsR8m51LuSCslisdOCSuykFP3U/UWlZZziAM2S TFdUtkdzNs4Org3TmFHe9F2Yg7V5IyK6qsnsY92ScHxBwutEdF4VdCRwCyIMxo7YKc7S 2REkI9vD5A066JvSRGIiaaQ5bA8x5R6SEgv3FUmyufO5IMVgdzSGFmVkq2ID9msGgFpx r4beJ6T2TdezE4O2nmEyY9Q4LC+2vK2agv6EtbYfYagi3vUdhkienrg1/izc8G6w4XKc DDDGl3wa4HFMs0fP7dnrys5IShEMaCxS/vIQXrTLIw9uR9OXtcy3lMdrp444ACQzDGq2 RJDg== 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=LA1zmsYxmzBAEiSSaTbYsFeqnklh9uk6Ygv0EHqOLtQ=; b=SlrIxocf04jCIjkI53x0BlQja1oz8f4Lt2q/D23spATGZAUknyLkY+9bkjdseIaKBK OJFFzJr5IQJEF1/GfvFxkgjIOUzX0AtVqxWSVa/2C6XcsYytw4WGgULJwuXnOmscoKg+ 2ysK6EVqXzeScvHUyQa3Bk+B51pi4Pa9m1hl35M+sG2mcWtea6OzmSy6EuIbBAip5C85 AJKHwMOWfZ39Bik89SMv94Ck+okTi3i4JhJUsk/TeFpoz+MKzPv2UgKBwe4zzW+8PFMB 5dbYfidi7SZgbZf2ZaERUSaFu+ngrfVn9RIXpwnA1WAQpjqcsma+gCcP/Cs9jpqlczol +hFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qXAl+exE; 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 se27si5992705ejb.2.2019.05.14.12.29.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 14 May 2019 12:29:51 -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=qXAl+exE; 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]:53087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQd7W-0005DZ-Fc for patch@linaro.org; Tue, 14 May 2019 15:29:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQcvL-0002Yo-1y for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQcvJ-0006vB-UF for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:15 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:40108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQcvJ-0006ua-Ol for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:13 -0400 Received: by mail-pf1-x443.google.com with SMTP id u17so444pfn.7 for ; Tue, 14 May 2019 12:17: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=LA1zmsYxmzBAEiSSaTbYsFeqnklh9uk6Ygv0EHqOLtQ=; b=qXAl+exEkgjEqmClYfwO7vrFkayBfeQkBVu+IovbupV24zdHx8PFEg1hT2Eq5cGx2M sUcF4i1VsdHpd2MzpdaspluHu7CUuetHJXEiMafVf+Vr0qMcBT6aogQNhLqgpHSnKZab VG0F3d08mvQD+GhvQDyZ6rlMt9KQLCYrc+eDTGecT5badY3bA7ys0ksH+dxn/BOdTt0f nbb9yWAfSTIzcWJCwZC5o6MTkt4dbYCj2C/iFZqXp9JJugPvq9bgeeYoJxTKokDscs9O Q7YoSEn7UXpbVpaTpT9DY0WcUXrdUTAddAtNQkVRaVtcoVT3UWngoWeNb4FR+JCR//i3 QpcQ== 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=LA1zmsYxmzBAEiSSaTbYsFeqnklh9uk6Ygv0EHqOLtQ=; b=fw3UgFgw7W41UIa+c31Ms73RmZJN9j36pKcao10SgI2az9jxJhSA72XD847aM3ba6R ZT7a2MlrEzpuk9s7MTfBXZmLTPGMCwao2Rg8aOY/AO0XNzMmofhc4J96CglIY2H/G/wg qkNsp746aK7iYdqcE2cGUB6yGLyyqhjPg7pwOAdkY7r8yVovytv5y0QrrxaROKEd+q8K kuTSA2uVrPiiifSomVt6wUORGDWRHUpN3PAY4FlyCfKokeD2OqEoOFzp7g4LmbwSMntJ mcKWIsLsnQkeXSvBaNFhfWD8o/bR9qETGv4vfcOSEQ2xeQ9QHomQzF0aHdts4aopajSS KenQ== X-Gm-Message-State: APjAAAUCx4hqNBfKYO+Ge+zJeBo5JABHJVhyKQ+uAc1rghQwS1BQPdo+ VyCleKXCn5CwP6F2f8BBotEiyhKH3uo= X-Received: by 2002:a62:3605:: with SMTP id d5mr21638851pfa.28.1557861432600; Tue, 14 May 2019 12:17:12 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id o6sm18682982pfa.88.2019.05.14.12.17.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:17:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 12:16:42 -0700 Message-Id: <20190514191653.31488-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514191653.31488-1-richard.henderson@linaro.org> References: <20190514191653.31488-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::443 Subject: [Qemu-devel] [PATCH v7 13/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: lvivier@redhat.com, berrange@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use a better interface for random numbers than rand * 16. Reviewed-by: 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 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ef42e02d82..1e06b908b7 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;