public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/rng-tools/, sys-apps/rng-tools/files/
Date: Mon,  5 Oct 2015 17:05:41 +0000 (UTC)	[thread overview]
Message-ID: <1443686986.2b90c55c6656d33d8a2dc6a679a85c6f8d29310d.mgorny@gentoo> (raw)

commit:     2b90c55c6656d33d8a2dc6a679a85c6f8d29310d
Author:     Gokturk Yuksek <gokturk <AT> binghamton <DOT> edu>
AuthorDate: Thu Oct  1 08:06:35 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Oct  1 08:09:46 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2b90c55c

sys-apps/rng-tools: open entropy src with O_NOCTTY flag #556456

This revision patches the source file 'rngd_entsource.c', adding 'O_NOCTTY'
flag to the open() call that opens the entropy source for rngd.

Gentoo-Bug: https://bugs.gentoo.org/556456

Package-Manager: portage-2.2.20.1

 .../rng-tools/files/rng-tools-5-fix-noctty.patch   | 45 ++++++++++++++++++++++
 sys-apps/rng-tools/rng-tools-5-r2.ebuild           |  1 +
 2 files changed, 46 insertions(+)

diff --git a/sys-apps/rng-tools/files/rng-tools-5-fix-noctty.patch b/sys-apps/rng-tools/files/rng-tools-5-fix-noctty.patch
new file mode 100644
index 0000000..a48b235
--- /dev/null
+++ b/sys-apps/rng-tools/files/rng-tools-5-fix-noctty.patch
@@ -0,0 +1,45 @@
+From: Gokturk Yuksek <gokturk@binghamton.edu>
+Subject: [PATCH] Fix rngd to open the entropy source with 'O_NOCTTY' flag
+
+When start-stop-daemon starts a rngd instance configured to use a tty
+device as its entropy source, the application crashes due to not being
+able to read from the entropy device. This is caused by
+start-stop-daemon calling setsid() before executing rngd, which
+disassociates the controlling terminal. When rngd attempts to open a
+hardware entropy source that's a tty device, per POSIX rules, the
+device becomes the controlling terminal for the process. Then rngd
+calls daemon(), which internally calls setsid(), and consequently
+disassociates the controlling terminal for the child. Meanwhile the
+parent rngd process exits. This results in tty device hanging up. By
+looking at the strace logs attached to the bug, it can be observed
+that although the parent rngd process is able to read() from the
+entropy source successfully, further attempts to read() by the child
+rngd process return 0. This complies with the POSIX, which states that
+read() calls on a hung up terminal shall return 0.
+
+Note that when rngd is started without start-stop-daemon, this problem
+does not happen because at the time of opening the entropy source rngd
+already has a controlling terminal.
+
+Prevent the entropy source from becoming the controlling terminal by
+passing 'O_NOCTTY' flag to open() when opening an entropy source. This
+flag prevents a tty device from becoming the controlling terminal for
+a process without a controlling terminal at the time of open().
+
+Thanks to John Bowler <jbowler@acm.org> for debugging the problem and
+pinpointing the issue as well as confirming the fix.
+
+Gentoo-Bug-URL: https://bugs.gentoo.org/556456
+Reported-By: John Bowler <jbowler@acm.org>
+
+--- rngd_entsource.c
++++ rngd_entsource.c
+@@ -175,7 +175,7 @@
+  */
+ int init_entropy_source(struct rng *ent_src)
+ {
+-	ent_src->rng_fd = open(ent_src->rng_name, O_RDONLY);
++	ent_src->rng_fd = open(ent_src->rng_name, O_RDONLY | O_NOCTTY);
+ 	if (ent_src->rng_fd == -1) {
+ 		return 1;
+ 	}

diff --git a/sys-apps/rng-tools/rng-tools-5-r2.ebuild b/sys-apps/rng-tools/rng-tools-5-r2.ebuild
index 61e60b0..a104f8b 100644
--- a/sys-apps/rng-tools/rng-tools-5-r2.ebuild
+++ b/sys-apps/rng-tools/rng-tools-5-r2.ebuild
@@ -26,6 +26,7 @@ src_prepare() {
 	epatch "${FILESDIR}"/${P}-fix-textrels-on-PIC-x86.patch #469962
 	epatch "${FILESDIR}"/${P}-man-fill-watermark.patch #555094
 	epatch "${FILESDIR}"/${P}-man-rng-device.patch #555106
+	epatch "${FILESDIR}"/${P}-fix-noctty.patch #556456
 	eautoreconf
 
 	sed -i '/^AR /d' Makefile.in || die


             reply	other threads:[~2015-10-05 17:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-05 17:05 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-09-26 17:50 [gentoo-commits] repo/gentoo:master commit in: sys-apps/rng-tools/, sys-apps/rng-tools/files/ Göktürk Yüksek
2018-12-29  2:12 Göktürk Yüksek
2019-03-13  0:42 Göktürk Yüksek
2019-06-05 18:17 Göktürk Yüksek
2021-03-06  6:04 Göktürk Yüksek
2021-05-13 22:11 David Seifert
2021-06-13  8:41 David Seifert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443686986.2b90c55c6656d33d8a2dc6a679a85c6f8d29310d.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox