e2fsprogs/e2fsprogs-1.39-save-backup-sbs.patch
Eric Sandeen 66fd3626d0 * Fri Jun 22 2007 Eric Sandeen <esandeen@redhat.com> 1.39-14
- Many coverity-found potential leaks, segfaults, etc (#239354)
- Fix debugfs segfaults when no fs open (#208416, #209330)
- Avoid recursive loops in logdump due to symlinks in /dev (#210371)
- Don't write changes to the backup superblocks by default (#229561)
- Correct byteswapping for fast symlinks with xattrs (#232663)
- e2fsck: added sanity check for xattr validation (#230193)
2007-06-22 17:04:55 +00:00

174 lines
6.4 KiB
Diff

# HG changeset patch
# User tytso@mit.edu
# Date 1182205610 14400
# Node ID 5c00c21991974cc750efa2474fab484b0a1f1522
# Parent 449d075befe0e4be32cce9d34ca1f03575e292d2
Don't write changes to the backup superblocks by default
This patch changes ext2fs_open() to set EXT2_FLAG_MASTER_SB_ONLY by
default. This avoids some problems in e2fsck (reported by Jim Garlick)
where a corrupt journal can end up writing the bad superblock to the
backups. In general, only e2fsck (after the filesystem is clean),
tune2fs, and resize2fs should change the backup superblocks by default.
Most callers of ext2fs_open() should not be touching anything where the
backups should be touched. So let's change the defaults to avoid
potential problems.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Index: e2fsprogs-1.39-RHEL5/e2fsck/ChangeLog
===================================================================
--- e2fsprogs-1.39-RHEL5.orig/e2fsck/ChangeLog
+++ e2fsprogs-1.39-RHEL5/e2fsck/ChangeLog
@@ -1,3 +1,10 @@
+2007-06-18 Theodore Tso <tytso@mit.edu>
+
+ * journal.c (e2fsck_run_ext3_journal), unix.c (main): Explicitly
+ add the EXT2_FLAG_MASTER_SB_ONLY flag to make sure we
+ won't write out the backup superblocks until we're sure
+ that we want write them out.
+
2007-03-28 Theodore Tso <tytso@mit.edu>
* pass1.c (e2fsck_pass1, check_ext_attr),
Index: e2fsprogs-1.39-RHEL5/e2fsck/journal.c
===================================================================
--- e2fsprogs-1.39-RHEL5.orig/e2fsck/journal.c
+++ e2fsprogs-1.39-RHEL5/e2fsck/journal.c
@@ -832,6 +832,7 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx
}
ctx->fs->priv_data = ctx;
ctx->fs->now = ctx->now;
+ ctx->fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
/* Set the superblock flags */
e2fsck_clear_recover(ctx, recover_retval);
Index: e2fsprogs-1.39-RHEL5/e2fsck/unix.c
===================================================================
--- e2fsprogs-1.39-RHEL5.orig/e2fsck/unix.c
+++ e2fsprogs-1.39-RHEL5/e2fsck/unix.c
@@ -978,6 +978,19 @@ restart:
fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
fatal_error(ctx, 0);
}
+ /*
+ * We only update the master superblock because (a) paranoia;
+ * we don't want to corrupt the backup superblocks, and (b) we
+ * don't need to update the mount count and last checked
+ * fields in the backup superblock (the kernel doesn't update
+ * the backup superblocks anyway). With newer versions of the
+ * library this flag is set by ext2fs_open2(), but we set this
+ * here just to be sure. (No, we don't support e2fsck running
+ * with some other libext2fs than the one that it was shipped
+ * with, but just in case....)
+ */
+ fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
+
ctx->fs = fs;
fs->priv_data = ctx;
fs->now = ctx->now;
@@ -989,7 +1002,6 @@ restart:
get_newer:
fatal_error(ctx, _("Get a newer version of e2fsck!"));
}
-
/*
* Set the device name, which is used whenever we print error
* or informational messages to the user.
@@ -1088,15 +1100,6 @@ restart:
!(ctx->options & E2F_OPT_READONLY))
ext2fs_mark_super_dirty(fs);
- /*
- * We only update the master superblock because (a) paranoia;
- * we don't want to corrupt the backup superblocks, and (b) we
- * don't need to update the mount count and last checked
- * fields in the backup superblock (the kernel doesn't
- * update the backup superblocks anyway).
- */
- fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
-
ehandler_init(fs->io);
if (ctx->superblock)
Index: e2fsprogs-1.39-RHEL5/lib/ext2fs/ChangeLog
===================================================================
--- e2fsprogs-1.39-RHEL5.orig/lib/ext2fs/ChangeLog
+++ e2fsprogs-1.39-RHEL5/lib/ext2fs/ChangeLog
@@ -1,3 +1,10 @@
+2007-06-12 Theodore Tso <tytso@mit.edu>
+
+ * openfs.c (ext2fs_open2): We now set EXT2_FLAG_MASTER_SB_ONLY
+ when we open a filesystem. Applications that want to
+ write changes to the backup superblocks need to explicitly
+ clear this flag.
+
2007-03-21 Theodore Tso <tytso@mit.edu>
* imager.c (ext2fs_image_inode_write), inode.c
Index: e2fsprogs-1.39-RHEL5/lib/ext2fs/openfs.c
===================================================================
--- e2fsprogs-1.39-RHEL5.orig/lib/ext2fs/openfs.c
+++ e2fsprogs-1.39-RHEL5/lib/ext2fs/openfs.c
@@ -100,6 +100,8 @@ errcode_t ext2fs_open2(const char *name,
memset(fs, 0, sizeof(struct struct_ext2_filsys));
fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
fs->flags = flags;
+ /* don't overwrite sb backups unless flag is explicitly cleared */
+ fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
fs->umask = 022;
retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
if (retval)
Index: e2fsprogs-1.39-RHEL5/misc/ChangeLog
===================================================================
--- e2fsprogs-1.39-RHEL5.orig/misc/ChangeLog
+++ e2fsprogs-1.39-RHEL5/misc/ChangeLog
@@ -1,3 +1,9 @@
+2007-06-12 Theodore Tso <tytso@mit.edu>
+
+ * tune2fs.c (main): Clear the EXT2_FLAG_MASTER_SB_ONLY flag
+ because we want tune2fs changes to get written to the
+ backup blocks.
+
2007-05-31 Theodore Tso <tytso@mit.edu>
* mke2fs.c (parse_extended_opts): Free allocated buf on return
Index: e2fsprogs-1.39-RHEL5/misc/tune2fs.c
===================================================================
--- e2fsprogs-1.39-RHEL5.orig/misc/tune2fs.c
+++ e2fsprogs-1.39-RHEL5/misc/tune2fs.c
@@ -781,6 +781,7 @@ int main (int argc, char ** argv)
exit(1);
}
sb = fs->super;
+ fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
if (print_label) {
/* For e2label emulation */
printf("%.*s\n", (int) sizeof(sb->s_volume_name),
Index: e2fsprogs-1.39-RHEL5/resize/ChangeLog
===================================================================
--- e2fsprogs-1.39-RHEL5.orig/resize/ChangeLog
+++ e2fsprogs-1.39-RHEL5/resize/ChangeLog
@@ -1,3 +1,9 @@
+2007-06-12 Theodore Tso <tytso@mit.edu>
+
+ * resize2fs.c (resize_fs): Clear the EXT2_FLAG_MASTER_SB_ONLY flag
+ to make sure the superblock changes are written out to the
+ backup superblocks.
+
2007-03-18 Theodore Tso <tytso@mit.edu>
* resize2fs.c (check_and_change_inodes): Check to make sure the
Index: e2fsprogs-1.39-RHEL5/resize/resize2fs.c
===================================================================
--- e2fsprogs-1.39-RHEL5.orig/resize/resize2fs.c
+++ e2fsprogs-1.39-RHEL5/resize/resize2fs.c
@@ -138,6 +138,7 @@ errcode_t resize_fs(ext2_filsys fs, blk_
if (retval)
goto errout;
+ rfs->new_fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
retval = ext2fs_close(rfs->new_fs);
if (retval)
goto errout;