From patchwork Fri May 17 02:39:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 10947247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8C8876 for ; Fri, 17 May 2019 02:47:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A83E61FFFF for ; Fri, 17 May 2019 02:47:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B9BB20069; Fri, 17 May 2019 02:47:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 347751FFFF for ; Fri, 17 May 2019 02:47:14 +0000 (UTC) Received: from localhost ([127.0.0.1]:40204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRStt-0003a4-Bc for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 May 2019 22:47:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRSmi-0005ZD-9Q for qemu-devel@nongnu.org; Thu, 16 May 2019 22:39:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRSmh-00029Z-EV for qemu-devel@nongnu.org; Thu, 16 May 2019 22:39:48 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:44890) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRSmh-00028m-7N for qemu-devel@nongnu.org; Thu, 16 May 2019 22:39:47 -0400 Received: by mail-pg1-x542.google.com with SMTP id z16so2503362pgv.11 for ; Thu, 16 May 2019 19:39:45 -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=j1y8PrQG9icgmziWvlfkG0Hzbs7kfCM8gvSVz7sdaacnDrJye7Z9Ewf5f9mCZgthd+ x5ywYzed9i4+nd3eYjZCwXw9csSJCbDrNf+pWfYMn9X0QiZ1DjdJLARvWwPBPFfBaa+O xgllAvachONSuAorQ8TD0gSh5CUKlgEirrop23dECNJzfItQhm5DApCu9Oi6aE5Fi/2n vErB4/PEY9SI/Me1c7hPHkAlea/9xMg6ilGshOgUxABAysF3RsQYiEPfz+oB9JgMaZtN mPW2L8nEL2ABo/UDEhqFdPSBbRvl/LM50eP8DfyRhDk4EOGFWeKlwOrxbNdRB1DWqRm0 ZR/Q== 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=KAabcyTz7/bWTbjg8cwbhqlAaRaBfzCxxeYBkvszX9553U2xd7htkjrhTVCi/xHNPO lpvyyBUG8xthX3Nn6J2zY6gR8BP2w+/RNyJglZFnag+9V2QPXkCkq/twv5Pj9iYsCk1D uyRFEwAioJf+eyZdZe2krc9Six4xvUxhb6z/YOwUKA6WyJuT1NC8CTFgaYgLDDj2oo4A +4wIM/9sUVKoF+DFjd7Xe2+lCmN1V7H5HggDE+aFqc8DwIhkc9NbL4QP3KesCUWmNjtI qkxAy50fkdgFe6sVb09/Zdv/T85i4Y7ocSJvklwCY/ilP6TIdFKPe5kTVW2wJN5blfzV Ruiw== X-Gm-Message-State: APjAAAXQP7ngqrTDuGJ6Dn7QRmMU2LHeKXOwK+HW6NaeYBRIV90sbCvp APKuoJ8M58xVxCHiLehYEfzcBnWC5Hw= X-Google-Smtp-Source: APXvYqwL2KGvkvWPz+y9wUXtOT3P783hmTES/qQleOQ5Cse1WO6/ao7TrbLTuxvxnCsPA6bBZY8zpw== X-Received: by 2002:a63:7b1e:: with SMTP id w30mr48535344pgc.406.1558060784225; Thu, 16 May 2019 19:39:44 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id w6sm6984152pge.30.2019.05.16.19.39.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 19:39:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 16 May 2019 19:39:13 -0700 Message-Id: <20190517023924.1686-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190517023924.1686-1-richard.henderson@linaro.org> References: <20190517023924.1686-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::542 Subject: [Qemu-devel] [PATCH v8 14/25] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;