lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180812004743.GB11980@thunk.org>
Date:   Sat, 11 Aug 2018 20:47:43 -0400
From:   "Theodore Y. Ts'o" <tytso@....edu>
To:     Lukas Czerner <lczerner@...hat.com>
Cc:     linux-ext4@...r.kernel.org
Subject: Re: [2/2] e2fsck: remove unnecessary reserve_stdio_fds()

On Thu, Aug 09, 2018 at 10:35:46AM +0200, Lukas Czerner wrote:
> Standard stream are always open, we do not need to "check" it
> specifically. Remove reserve_stdio_fds().

I don't remember the exact circumstances, since it was twenty years
ago, but that's not *always* true.  Remember that e2fsck is run by
init or some other early boot sequence, and not all such programs
are.... sane.  In fact, this was added because some buggy init called
e2fsck with fd 2 closed, so the file system was opened using fd 2.
And then an error message ended up corrupting the file system....

This function was added in response to that failure, because
sometimes, the world *is* out to get you.  It is fair to fix the file
descriptor leak, so how about this?

					- Ted


commit 352701d9e2258299fe3bffb1d112566c0e4a7cdf
Author: Theodore Ts'o <tytso@....edu>
Date:   Sat Aug 11 20:47:08 2018 -0400

    e2fsck: fix fd leak in reserve_stdio_fds
    
    Signed-off-by: Theodore Ts'o <tytso@....edu>

diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 90065b395..2df22b171 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -617,9 +617,10 @@ static void reserve_stdio_fds(void)
 			fprintf(stderr, _("ERROR: Couldn't open "
 				"/dev/null (%s)\n"),
 				strerror(errno));
-			break;
+			return;
 		}
 	}
+	(void) close(fd);
 }
 
 #ifdef HAVE_SIGNAL_H

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ