]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
logsave: fix fd leak which could cause logsave to hang
authorTheodore Ts'o <tytso@mit.edu>
Mon, 23 Jul 2012 22:45:23 +0000 (18:45 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 23 Jul 2012 22:45:23 +0000 (18:45 -0400)
The logsave program is leaking a file descriptor when it forks and
execs the program which forks a process which hangs around.  In the
case of /etc/init.d/checkroot, this would be fsck.  This file
descriptor never gets closed, so it's still present when fsck runs
e2fsck, and then if e2fsck has its own logging enabled using (in
/etc/e2fsck.conf):

[options]
    log_dir = /mnt
    log_filename = e2fsck-%N.%h.INFO.%D-%T
    log_dir_wait = true

then e2fsck will fork off a process waiting for /mnt to get remounted
read/write.  This causes logsave to never get an EOF from its pipe, so
it hangs waiting for the read to fail --- which won't happen due to
the file descriptor leak which is still being held open by e2fsck's
forked child process.  And so /etc/init.d/checkroot hangs, and the
root file system never gets remounted read/write, and we deadlock.

Fix the problem by closing the pipe fd so the logsave program doesn't
end up leaking it to its descendent processes.

Addresses-Debian-Bug: #682592

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/logsave.c

index c37473cbd358d1c0538895303e428ba4b36e0d3a..e783546d6c578d05124c9ca682a6bd92a7c27bff 100644 (file)
@@ -190,6 +190,7 @@ static int run_program(char **argv)
                dup2(fds[1],1);         /* fds[1] replaces stdout */
                dup2(fds[1],2);         /* fds[1] replaces stderr */
                close(fds[0]);  /* don't need this here */
+               close(fds[1]);
 
                execvp(argv[0], argv);
                perror(argv[0]);