From a4f95ccad41f5befb6768ff58fe26b179237df6a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 12 Jan 2015 19:42:29 -0500 Subject: [PATCH 1/2] e2fsck: close the progress_fd in the logfile child process If e2fsck.conf's logging feature is enabled, and e2fsck is being run via systemd-fsck, there will be a deadlock since systemd-fsck is waiting for progress_fd pipe to be closed, instead of waiting for the fsck process to exit --- and so the logfile child process won't exit until it can write out the logfile, and systemd won't continue the boot process so that the file system can be remounted read-write. Oops. Addresses-Debian-Bug: #775234 Signed-off-by: Theodore Ts'o --- e2fsck/logfile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/e2fsck/logfile.c b/e2fsck/logfile.c index c48b8eb8..e004f31a 100644 --- a/e2fsck/logfile.c +++ b/e2fsck/logfile.c @@ -20,6 +20,8 @@ #include "e2fsck.h" #include +extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */ + struct string { char *s; int len; @@ -233,6 +235,8 @@ static FILE *save_output(const char *s0, const char *s1, const char *s2) } if (pid == 0) { + if (e2fsck_global_ctx && e2fsck_global_ctx->progress_fd) + close(e2fsck_global_ctx->progress_fd); if (daemon(0, 0) < 0) { perror("daemon"); exit(1); From c916e5248bab349f4375dcced9c8709fe4b1c8c2 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Mon, 19 Jan 2015 16:31:49 -0500 Subject: [PATCH 2/2] Fix clang warning and a resource leak Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- lib/ext2fs/symlink.c | 2 +- resize/resize2fs.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/symlink.c b/lib/ext2fs/symlink.c index ba8ed8ef..7c485a5f 100644 --- a/lib/ext2fs/symlink.c +++ b/lib/ext2fs/symlink.c @@ -88,7 +88,7 @@ errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino, } else { /* Slow symlinks, target stored in the first block */ memset(block_buf, 0, fs->blocksize); - strcpy(block_buf, target); + strncpy(block_buf, target, fs->blocksize); if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS) { /* diff --git a/resize/resize2fs.c b/resize/resize2fs.c index b3755f62..a2806b11 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -1852,8 +1852,10 @@ static errcode_t move_itables(ext2_resize_t rfs) ext2fs_inode_table_loc(fs, i)) to_move++; - if (to_move == 0) - return 0; + if (to_move == 0) { + retval = 0; + goto errout; + } if (rfs->progress) { retval = rfs->progress(rfs, E2_RSZ_MOVE_ITABLE_PASS,