Re: [2/2] e2fsck: remove unnecessary reserve_stdio_fds()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
Date:   Sat Aug 11 20:47:08 2018 -0400

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

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



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux