From patchwork Tue May 14 19:16:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164238 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3006663ili; Tue, 14 May 2019 12:24:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNc614QDmowHVe7b/xfFor7k89Iw6v+hGCJoW9823wWLACtciED6QmqvWcV7AafT2iEGgV X-Received: by 2002:a17:906:660c:: with SMTP id b12mr29705329ejp.299.1557861869019; Tue, 14 May 2019 12:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557861869; cv=none; d=google.com; s=arc-20160816; b=e7BGeinZHhXpZ0DypSUQklVqAfGR0Sc4caNhGpftLnrEjC2PbCJTL/1vN+7+OTN1dw rwTgYUZmLejHOlYlG+0pQPSgdNtp6GQZ0FSlvYWyxSX3QIhm8Htd/q3BxN/ixQ78N3GX P+BiuEUikExuuP9AUTAQgFIFKRmeKCzZsA2yyYGMDyGJRxPt+orCXJnuLJn2fEu0hKsi m0TEfVgvqMoAbamXfAOpbkRxw8+/469OvJNYQ8ACqMZOMzdhavWykQOAtLTYAdZYAcfG kBaiNkBF1NMXxkuEU2zRPvpQ5jy16XxmB7tgelaxylTZzSHqChfZ6aLe4jzDW14t5mKQ CzXg== 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=p/AR+QB1/uCfqQ+ytrGBnYCYqwPtnBM3b7CBgieQEw0=; b=UVEZNnxxKSldodhV62UcTZQ3szFWSssfs8hwMeHA9r36SUqcrpEQR2x+YKumifKK+z vwZjFr4/pV+JmVwq4u0uocEmsGXPwj4X6P8w11XK4xFFPoZaP+9KgIGP7yladTaC2iFg Uy7C2/n9KJT+zPpujVhf3HMfQWTifyFKgMWUFWnX8EF624CReucwPywKA4xgXbO51MY3 9/hHrUYXjvOzuRKkqfvXkJZ2c2R5t1Hq+FflhO1WvUfPohCWaNerBHiCfAgNEtwBcoR7 8ZCai63nC3peHAPA52sqvYiyhQ/WvfmiLGvNMQmkh2M3TF0jVH/irnBATn0uqpXxH6EH jG1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=V27bejYP; 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 p49si8659097edc.249.2019.05.14.12.24.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 14 May 2019 12:24:29 -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=V27bejYP; 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]:53000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQd2J-0008Ic-US for patch@linaro.org; Tue, 14 May 2019 15:24:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQcv9-0002TJ-OJ for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQcv8-0006fl-Tl for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:03 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:38783) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQcv8-0006e9-OA for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:02 -0400 Received: by mail-pl1-x643.google.com with SMTP id f97so79423plb.5 for ; Tue, 14 May 2019 12:17:02 -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=p/AR+QB1/uCfqQ+ytrGBnYCYqwPtnBM3b7CBgieQEw0=; b=V27bejYPJ1d5Edg9q46vscEtm89bOnKxzU5r7sWIv8IilaDLnIMOP8AXYgW3Xxmbfw SpvIgUJF5QDDrzpY7eDH6SkqZHfgFRo9iC/F0BZP3p2SuyNGN0WYELh02fK8KNKPkzTV 77NabADkpyartaqjMMG1gZSrfKYsd2qg01kwjhEtfFSdYlr9J/Dv8/WmDvGOCe2Ug5nF SzFIAHLAqupumigka2FnjCWRAyN/Hci3xBBOR7CDqTrZcSyKpBeDLg9tY+Iw7WrijMhX CnsHMjfjs5b9A9yK1NJgABaM0qSjIHWVekLX6/8gBPa2a0RT+Lp01K+G3a3rAFwf9U3s YrmA== 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=p/AR+QB1/uCfqQ+ytrGBnYCYqwPtnBM3b7CBgieQEw0=; b=HnhEWc6H8lVna1qB9hEKz5J3KHrlVNHg7pG9QdtQnVRu/UNBogdHkJ89YktAHWd+0Z JCquR8OjsKWOk96vJdPv7uBzmQn9nK+M55VitaOOmKCeJiPXjxmjTyfk386LcQ3zgZig AHoj0SxDGmFZ57P4HmozaZzV9nx/7Soc3bXyuKcxKmrhg+9W7jpdMERij14CnYyjnNrg PdlA5j5LYdfjVWRg1/ARq+AlXw4PUCJfiRqXOe6C49GGQYNlDxutBnSPejXUCKnPuUj1 C1Blw0u1hJKALSJn715tfglOdBoYGUG2j7sypKsslILKOAlf4HLp6pj0BVp2m6Ia/xvv cufw== X-Gm-Message-State: APjAAAWX0724ZpCE2+ax3IAzk2mpppkut/WtguQirdiIWBJNHRGSEdPV dh5uP/8A/uSPm0rhJXufaIpP8tpT6fk= X-Received: by 2002:a17:902:8b8a:: with SMTP id ay10mr31193869plb.74.1557861421412; Tue, 14 May 2019 12:17:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:17:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 12:16:33 -0700 Message-Id: <20190514191653.31488-5-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::643 Subject: [Qemu-devel] [PATCH v7 04/24] crypto: Use O_CLOEXEC in qcrypto_random_init 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" Avoids leaking the /dev/urandom fd into any child processes. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé Signed-off-by: Richard Henderson --- crypto/random-platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/crypto/random-platform.c b/crypto/random-platform.c index 260b64564d..6df40744c7 100644 --- a/crypto/random-platform.c +++ b/crypto/random-platform.c @@ -42,9 +42,9 @@ int qcrypto_random_init(Error **errp) #else /* TBD perhaps also add support for BSD getentropy / Linux * getrandom syscalls directly */ - fd = open("/dev/urandom", O_RDONLY); + fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC); if (fd == -1 && errno == ENOENT) { - fd = open("/dev/random", O_RDONLY); + fd = open("/dev/random", O_RDONLY | O_CLOEXEC); } if (fd < 0) {