From patchwork Thu Mar 14 04:55:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160291 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15077508jad; Wed, 13 Mar 2019 22:04:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMEL0YGNzg/TC1xDy1Y1VlXpZ1TLvvfCdGyfdGT9Mnrlp0QTDAohxexYrfgaZGDQ7EEC+R X-Received: by 2002:a81:4bce:: with SMTP id y197mr13867632ywa.204.1552539863583; Wed, 13 Mar 2019 22:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552539863; cv=none; d=google.com; s=arc-20160816; b=wAtp7lEVqkT+iCyEj/OQt7s+sOZD59U1eFRWXqxVE8doGwSKzvIJ1zybXvjIsZW44y 9IAbI5alMXoFLNHtTatqfTLRSxOdgOsX4xF6XYGOvqoNCrnFoqM7cdf1DbVN5rwQgn37 s7PjzWoZ0SwfoNeXKXjNxqqoDeUhGJtly527iB1gioHN3aGaY6S5QrBndRKZTGcswsH7 n4lpABTT504pFBq8JgO4Ee9gXFy0uInn/vAjeTfMLAdMZdynEgrr5Ba+XQPd9d6WwEo8 nMyp51gt8NOnjSsQ/IycEh5cdgrov09hhJSUwAywCuKyEgr/gj0bIPYJM9VxhSLMEPgF +x1Q== 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=NWEt74dwLia08E5ia2X/lyc1UBZ3BVl9ogK5yim+NNU=; b=m4MjD7hKtvey4ZukA8cvfI5amlPztSswdlXhBjnbHwQyoBXo7eJluIlp+R4kAKdkdr j93ZGTu2WOqnLMUkxlFtvnK9Wgffa2tnePTJa7PPC8F9gPFM+s5l1eLLHRf9OjwzcjDq /IMIjVRSw9NfP/sJif5+Fhf6rXaAr7qsyGJZkHgsizmHgnLiixFZcyWdgcVWt/jAd1dO w+B/0ylNqrAOrgJXmWCE/kZGzm8hp6TE5HigMMzdHwfs825SLsgrL2yqS+OJBVl4p5wi vwrC8zWbzDiAPD/V8hhccJ7Kp0jwhLFBSZElyFbdpKe+Ddq5hjtu4O7U/EEpMOcYQWfB qtRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ubpItWhA; 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 x14si8373955ywj.463.2019.03.13.22.04.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Mar 2019 22:04:23 -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=ubpItWhA; 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]:56944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4IXX-0002dC-3N for patch@linaro.org; Thu, 14 Mar 2019 01:04:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4IP2-0004UI-2T for qemu-devel@nongnu.org; Thu, 14 Mar 2019 00:55:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4IP1-0007NB-CE for qemu-devel@nongnu.org; Thu, 14 Mar 2019 00:55:36 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h4IP1-0007Mn-48 for qemu-devel@nongnu.org; Thu, 14 Mar 2019 00:55:35 -0400 Received: by mail-pg1-x542.google.com with SMTP id h11so3168713pgl.0 for ; Wed, 13 Mar 2019 21:55:35 -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=NWEt74dwLia08E5ia2X/lyc1UBZ3BVl9ogK5yim+NNU=; b=ubpItWhA6lntjTUhGvP0EaDAhbCkORRernTV0grnO8NABPGSYaPzqJEIhTJWroQT5b Y2qXKPP4CkjNubOtgLHvJtbFE4cAfWKeCoan87M3TmObJ504bSKI1ozZHTGvx2QbGswJ 7vNFr4T7DzkRCP0VAJfXZB+xGCdIm9j4CMDEpgQRjC60T6o27o+Yb23J6C99mvFMkOo8 ufztjVvIjdVRZKzcOGdsn72hxaK2jQ+H5D5eG1BtZAd6Qq4S1MwOcbHWtzBiHQjap9fN 79Dz6MFVxbnKqEXZ+4m0YFZTVFUPaBi+NUT0oCA+X1xZtpzcLTKKGVA18ZWp79rFXPYO Siww== 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=NWEt74dwLia08E5ia2X/lyc1UBZ3BVl9ogK5yim+NNU=; b=r8h7QcyFrzo8GCLc1vm4zvSO9S7azM0uVhDZoQPIXHswoKl+h6x36l0THzATifexr7 dXybKKSX/hvL7YvF805fN6udot5QxDd4Y79HVveghfpEUh3reH+WtO8ZmfO5RLlz7N+m OmQbqZBhvz5K5g1hx8SPUu5XCMlq43Vu/vs1bBMcQEksjANrmW1+6xSRD5YsZZ75dTLh 5DQ9FWGsZ12gwkXEbsT9PV+iZcLrdT/VwPcRbrc3mnHDg7YH50AxAOcRuZruARvSF3N1 862RCDOcQ4zvvcuDIugkUzdGfSJqWcviX82bNh8C8Uw0ypC3ULqHe4/0I60BC5bAYSQE qNmA== X-Gm-Message-State: APjAAAUJswwrd+eoanRlD6DZcMtZSlLC1ngsMg9ezZd4OSx/sWh8m85k YV4h4SYXXGyEzRd+XscmPVPPJRcjvaQ= X-Received: by 2002:a17:902:765:: with SMTP id 92mr48236470pli.95.1552539333922; Wed, 13 Mar 2019 21:55:33 -0700 (PDT) Received: from localhost.localdomain (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id d9sm16185027pgq.6.2019.03.13.21.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 21:55:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 13 Mar 2019 21:55:16 -0700 Message-Id: <20190314045526.13342-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190314045526.13342-1-richard.henderson@linaro.org> References: <20190314045526.13342-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 v2 04/14] 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. Cc: Daniel P. Berrangé Signed-off-by: Richard Henderson --- crypto/random-platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Daniel P. Berrangé diff --git a/crypto/random-platform.c b/crypto/random-platform.c index 0866f216dc..8bfce99a65 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) {