From patchwork Fri May 10 17:30:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163913 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2673283ilr; Fri, 10 May 2019 10:37:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6spiI6DuGv5TQQyP1Ux8GNvom3YSFDVCY90ob+ekc6YbnyG2vhy/MNJfBZeV92asKWyon X-Received: by 2002:a50:a5ed:: with SMTP id b42mr12222986edc.178.1557509874408; Fri, 10 May 2019 10:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557509874; cv=none; d=google.com; s=arc-20160816; b=pD5hy13v5B4coTLPC2jiVt5cNAWzSY9Yvz53HoCLpAaCKFW5uLKv+VFklcH8cGp4km uqqjGk0U6cJV+JmWkpOkuyR3FZK6AQF4ho15Sd43CCLdq25/RXHSzd+RN31YNtpmjVSR P/EZ8gLeBsUj20XFRJVgMV5Sa3BOljuJ/Wk7kyxJrPEiazBLRyNCyVtK2AEIpqXS2vNe phxy+N9+KSrfxTtnKlE2wvDzObNotrHBiQQr2Cv0BaPOAyp+AvlX+b3QS0daaEsuis42 hJ1UkX4R3Y7m08wc26UaoY9e6UpWxvBUhAeOQzf/M9TM53q+pEplQ0p1yD/k+jPaGcVi xsVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=LdhmXsWtKCIoVxpPYup4td/+S8+wQOPuaXnT2ZYWSOwOX+/1P6T/Xt3lsr3Fm7kAMK 0XTHnjh56WM71an3/x8P0m6+iWyaLgjgsWQn6yzkJABGVB4i3RXyBlBQ8XrTM2B5isXZ /xAVwbK5JeJFXw8oWcZzjKyb/lwKXhbSQ6W0KMSrgUiDt9RI0zrOIvOWFgycC0vGv/oz mOsIccNRyHqXccsX5hz/22jMGEvbfzCVObgqyIg/X094EApDNZ+Y5cpdZcqbgTVci1An GWsFJu1nA2F1SXgNUXPxQgAR3SUS7Hq+LYM+Gmo2SmKB60KXwOr0FeOUQFwSG5a+FWt5 csVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="LtT/LEiz"; 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 l4si3411341ejd.366.2019.05.10.10.37.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 10:37:54 -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="LtT/LEiz"; 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]:47564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP9Sz-00050p-A2 for patch@linaro.org; Fri, 10 May 2019 13:37:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP9MJ-0007Ka-Mh for qemu-devel@nongnu.org; Fri, 10 May 2019 13:31:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP9MI-000612-Tf for qemu-devel@nongnu.org; Fri, 10 May 2019 13:30:59 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:42221) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hP9MI-00060c-O2 for qemu-devel@nongnu.org; Fri, 10 May 2019 13:30:58 -0400 Received: by mail-pf1-x443.google.com with SMTP id 13so3575779pfw.9 for ; Fri, 10 May 2019 10:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=p/AR+QB1/uCfqQ+ytrGBnYCYqwPtnBM3b7CBgieQEw0=; b=LtT/LEiz8o8zZQG66+lyn31ggveLygkwoxdavL7ktPh1tyYPRmK1hIc4aZIyCEW9C+ OBowa7uPF2HK1lhsIX8q2WSzDubSznb+XQtAcgQbTVpYBLTrNBnwHYxbHuAMfLmYJ8+r 86vbw8svJwSbsugVfl2GoZm394SUdefVT084ocDxYGGdObxsAZPoTo6A7YDNf86UahwT JhHRb2jPTClkKuNQ7Ea+lM3+0L3NhEhNtdD0c5OR9GLx7yUXTQ3yXAkjaCbA7XY3sihS VQMlGvcDkev8Q+r7qPu8RgoHkAXVwhIEEWtvkbFNlMwJK5e9lYakLkJIBhHk08bVt0NX UYdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p/AR+QB1/uCfqQ+ytrGBnYCYqwPtnBM3b7CBgieQEw0=; b=NuZXZEzxPw/ZIlK3i+COtUyd9lLOHnHsAZcvNCWHUaLzcyHaYqUY6WXqSBG5Xrg9Ja w9yWNySyjVpLU/cqbSWuNvDoGEAAlPUNlc1idLQuIgL4yNl2zIzKSwUB/UB4IyW/dpi4 ebZJ2QbCTkkwlrcQa91U9BeNJj6dJTDNYK5vWJSuXst8gz/EFNU0hDqDO1otYH5Mnbhz 6wUyKdGzOqfLO4t3t40IeZ4U4d+8JS2wXTC1BEZuGkNlptTzhYPTZ103JrpZtIQBSl8n pf1V7L42lILEM8KHPW+wyorrrjFyVFHfIQoZfNJC0pYjC+6M1tRozOx1M9t56nDQAbnc KScA== X-Gm-Message-State: APjAAAWfCjXrBxHfR/Tk/jTiD+w6gsBEHzoE67JWMuz1KpoA4DCaE83g 4JAL8i75t6W9PD5KzrBTvEyPFjs85LE= X-Received: by 2002:aa7:8212:: with SMTP id k18mr15939374pfi.50.1557509457381; Fri, 10 May 2019 10:30:57 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id v64sm7936792pfv.106.2019.05.10.10.30.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 10:30:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 10:30:29 -0700 Message-Id: <20190510173049.28171-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510173049.28171-1-richard.henderson@linaro.org> References: <20190510173049.28171-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 v6 05/25] 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: , 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) {