From patchwork Wed May 22 18:42:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164867 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1237499ili; Wed, 22 May 2019 12:12:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzGM0pt1E9znVWeWAUR+jeGdrGe5s6nLqXTWYdJnDgx0cpojDa3tvKkWR4DRacrVOkTlf9 X-Received: by 2002:a17:906:7e57:: with SMTP id z23mr41653224ejr.62.1558552320608; Wed, 22 May 2019 12:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558552320; cv=none; d=google.com; s=arc-20160816; b=qm5yCxOfGViWCjSKGG53UUJUAZR9z4iAUOjuQlf2klKsdFzvk5W/3LZPSHs2vW+Jky pjMsvAvzl8mmZYqNoPLnDm6jaBoZTMszyfq648+uF6qAl7qn6KWsxxW8M1TPy7SXP8AG tRkK2aOKvz4PGRxHEtiCYReZjawMrhsA9USSVQOQRJLs17evpOgTdXBzKXvaGuuCc8xV hT91ZhA+ZaA1dUkHu+A8zIgog921+JUwjErZcROsXVy38FC1Lo5jeON4MC7LydLNgJxp gfB9U2+IM54/CvX6Fws0n4NT9QdeP7jTMQi9h8fyTSxesWKcPgjkKbL5BSPBkenqrzgf 5NgQ== 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=dx8gNNmuMIEpFhNjiJQdPAyGQ6XRJB7vnXhxdjovM6bwLuquibU6B5U5FiIIEXwxf0 NJsPe/pECw42aS5y0D9VtGz4lrL3AMKHJGe/FWdyxcjrcs4dCQ80Ym4QjupW/gTh95df ac/zaURcxoNWjRqSRDNoyyekPpetulNq5r1bF7UmMrGtjwihbxwH0Mgh3tVXU9W7cAHO rQzdJYk5We4+mGR8Qw2Yb4yzr1cLVDMcWWl6rY9Ns6H8vQFqXTo7DrzLbfuuIeRb5HSP KCNEEATORvN94a3dr1n3bNZKtv+zYuFO1aDClvvzsWZKCnJnbMhXyxFeoj3xGbkbK1Ld ERjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OBFpmPi9; 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 a47si5251135edd.409.2019.05.22.12.12.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 May 2019 12:12:00 -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=OBFpmPi9; 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]:49865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWed-0006VO-I3 for patch@linaro.org; Wed, 22 May 2019 15:11:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWOr-0008Lh-Ag for qemu-devel@nongnu.org; Wed, 22 May 2019 14:55:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTWCA-00082m-GE for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:35 -0400 Received: from mail-yb1-xb41.google.com ([2607:f8b0:4864:20::b41]:44893) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTWCA-00082T-9q for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:34 -0400 Received: by mail-yb1-xb41.google.com with SMTP id x187so1239402ybc.11 for ; Wed, 22 May 2019 11:42:34 -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=OBFpmPi9AWbdbtlYgTZidrE4QnXMu+xB9Qsjq6MUEiJotntcRpE6196p4t87OpGn+w tivMWHcZP1f/68eWfkTp0LXDzPcZJUyc09KvuhoG9+nyYzBW56wpJTlM6FJO9T2+0r4p FD+8m5+R4gaVVJ30i0UBAu1RGbdbEUErxX3b6QEPzX72VuARHtLrucetpKP3LpnXXOfj lZMnOJtEv17bB5VqpFK40bp9zNs7XONIKYOQKXB6NsMZM+6MJGC7Y+j8SC4vk6Yogrws zyRgs6+gEBExms0b+JgU5qHT1hV5Fx5HhS3j0Af+MhWUH8Xtp3tPv6Kx2CkdjK1tsQ/s RDKQ== 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=MnajBEt6gqhu4Fzxl5kO5YSoiNOzN4S4rmEZMqDOXkLwLs52CKFH8+SA8FQ1Un97y+ LsO9XpSzN2fCrLmPvKKcjM/YvEVqnn16nGSpYdwVXoTZiLspfNmz7fH8EcLgsVcsEwOD SIuzwa0cuZbSTw3qfxPGZ8Kixk4H3FNgR1PoKRUNm+IZjNkoQhDmrM/WtMzkxISDfvDo BqKFaDN2UnikFPE+RDqQ+8LjkXHVrNGf6MxdgwJI5SrL8l4U7c7plBCKWm0zspShYEOQ 2higDRMHC/Za5NHRmd2/8Bz31yaD1hVoDjOIcLW19iTTWDyuxGVtdR1O77hWMNcrUwyX Kwvg== X-Gm-Message-State: APjAAAVuYIqPWBjG59/+EWfRxaAfwlrSaZ8Qc0oKE/wjSM4oykWvW01+ Y4OzJMYQXSlfFy8Kg6KofCb+mLi+FSk= X-Received: by 2002:a25:abf3:: with SMTP id v106mr10653436ybi.123.1558550553422; Wed, 22 May 2019 11:42:33 -0700 (PDT) Received: from localhost.localdomain ([71.46.56.17]) by smtp.gmail.com with ESMTPSA id 206sm1299445ywq.74.2019.05.22.11.42.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 11:42:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 14:42:06 -0400 Message-Id: <20190522184226.17871-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190522184226.17871-1-richard.henderson@linaro.org> References: <20190522184226.17871-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::b41 Subject: [Qemu-devel] [PULL 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: , Cc: peter.maydell@linaro.org 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) {