[klibc] latest fixes

maximilian attems max at stro.at
Sun Jun 15 17:20:02 PDT 2008


hello hpa,

nothing too exciting,
again syncing latest Debian upload and subsequent patch emails.
plus wanting to get the ext4dev in line for the Lenny release. :)

please review.

thanks

-- 
maks

please pull
git pull git://git.debian.org/~maks/klibc.git maks

for the changes:
Arthur Loiret (1):
      Makefile (ARCH): Support sh4 as sh.

David Härdeman (1):
      [klibc] mount: allow multiple fs on vfstype arg

maximilian attems (2):
      [klibc] run-init: drop executable stack
      [klibc] fstype: fix ext4dev detection


 Makefile                   |    2 +-
 usr/kinit/fstype/ext3_fs.h |   39 ++++++++++++++++++++++++++++++++++++---
 usr/kinit/fstype/fstype.c  |    8 ++++++--
 usr/kinit/run-init/Kbuild  |    4 ++++
 usr/utils/mount_main.c     |    4 +++-
 5 files changed, 50 insertions(+), 7 deletions(-)


commit c8428ceced1769a2cf9202390c68bbb4b8e32469
Author: maximilian attems <max at stro.at>
Date:   Mon Jun 16 02:03:03 2008 +0200

    [klibc] fstype: fix ext4dev detection
    
    ext4dev changed on disc format, cope with 2.6.26-rc6 ext4dev
    using e2fsprogs 1.40.8-2
    
     mke2fs -q -j /dev/mapper/dualvg0-foo -E test_fs
     mount /dev/mapper/dualvg0-foo  /mnt/ -t ext4dev
    
     EXT4 FS on dm-12, internal journal
     EXT4-fs: mounted filesystem with ordered data mode.
     EXT4-fs: file extents enabled
     EXT4-fs: mballoc enabled
    
    ./usr/kinit/fstype/shared/fstype /dev/mapper/dualvg0-foo
    FSTYPE=ext4dev
    FSSIZE=1073741824
    
    as bonus fix ext3_super_block to latest definition.
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/fstype/ext3_fs.h b/usr/kinit/fstype/ext3_fs.h
index 12d64fe..f958e5c 100644
--- a/usr/kinit/fstype/ext3_fs.h
+++ b/usr/kinit/fstype/ext3_fs.h
@@ -6,12 +6,31 @@
  */
 #define EXT3_SUPER_MAGIC        0xEF53
 
+#define EXT2_FLAGS_TEST_FILESYS                 0x0004
+#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     0x0001
+#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE       0x0002
+#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR        0x0004
+#define EXT2_FEATURE_INCOMPAT_FILETYPE          0x0002
+#define EXT2_FEATURE_INCOMPAT_META_BG           0x0010
 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL         0x0004
 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV       0x0008
+#define EXT3_FEATURE_INCOMPAT_RECOVER           0x0004
+
 #define EXT3_FEATURE_INCOMPAT_EXTENTS           0x0040
 #define EXT4_FEATURE_INCOMPAT_64BIT             0x0080
 #define EXT4_FEATURE_INCOMPAT_MMP               0x0100
 
+#define EXT3_FEATURE_RO_COMPAT_SUPP     (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
+					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
+					 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
+#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED      ~EXT3_FEATURE_RO_COMPAT_SUPP
+#define EXT3_FEATURE_INCOMPAT_SUPP      (EXT2_FEATURE_INCOMPAT_FILETYPE| \
+					 EXT3_FEATURE_INCOMPAT_RECOVER| \
+					 EXT2_FEATURE_INCOMPAT_META_BG)
+#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED       ~EXT3_FEATURE_INCOMPAT_SUPP
+
+
+
 /*
  * Structure of the super block
  */
@@ -93,9 +112,23 @@ struct ext3_super_block {
 	__u32 s_last_orphan;	/* start of list of inodes to delete */
 	__u32 s_hash_seed[4];	/* HTREE hash seed */
 	__u8 s_def_hash_version;	/* Default hash version to use */
-	__u8 s_reserved_char_pad;
-	__u16 s_reserved_word_pad;
-	__u32 s_reserved[192];	/* Padding to the end of the block */
+	__u8    s_jnl_backup_type;
+	__u16   s_reserved_word_pad;
+	__u32   s_default_mount_opts;
+	__u32   s_first_meta_bg;
+	__u32   s_mkfs_time;
+	__u32   s_jnl_blocks[17];
+	__u32   s_blocks_count_hi;
+	__u32   s_r_blocks_count_hi;
+	__u32   s_free_blocks_hi;
+	__u16   s_min_extra_isize;
+	__u16   s_want_extra_isize;
+	__u32   s_flags;
+	__u16   s_raid_stride;
+	__u16   s_mmp_interval;
+	__u64   s_mmp_block;
+	__u32   s_raid_stripe_width;
+	__u32   s_reserved[163];
 };
 
 #endif /* __EXT3_FS_H */
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index eee3431..6ff48e5 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -115,11 +115,15 @@ static int ext4_image(const void *buf, unsigned long long *bytes)
 	const struct ext3_super_block *sb =
 		(const struct ext3_super_block *)buf;
 
+	/* ext4dev needs ext2 + journal + test_fs flag + one !ext3 feature */
 	if (sb->s_magic == __cpu_to_le16(EXT2_SUPER_MAGIC)
+		&& (sb->s_feature_compat
+		& __cpu_to_le32(EXT3_FEATURE_COMPAT_HAS_JOURNAL))
+		&& (sb->s_flags & __cpu_to_le32(EXT2_FLAGS_TEST_FILESYS)) 
 		&& (sb->s_feature_incompat
-		& __cpu_to_le32(EXT3_FEATURE_INCOMPAT_EXTENTS)
+		& __cpu_to_le32(EXT3_FEATURE_RO_COMPAT_SUPP)
 		|| sb->s_feature_incompat
-		& __cpu_to_le32(EXT4_FEATURE_INCOMPAT_64BIT)
+		& __cpu_to_le32(EXT3_FEATURE_INCOMPAT_UNSUPPORTED)
 		|| sb->s_feature_incompat
 		& __cpu_to_le32(EXT4_FEATURE_INCOMPAT_MMP))) {
 		*bytes = (unsigned long long)__le32_to_cpu(sb->s_blocks_count)

commit 34a10f9b28a011e2cf42226ef260ad0d73ddc5b3
Author: David Härdeman <david at hardeman.nu>
Date:   Sun Jun 8 23:43:28 2008 +0200

    [klibc] mount: allow multiple fs on vfstype arg
    
    Basically it fixes the argument parsing when running something like
    "mount -t ext3,ext2...".
    
    I've already submitted the attached patch to the Debian BTS:
    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=480994
    
    It is not yet the real fix for "-t auto", that could be faked by
    replacing auto with a long list of fs types or running "fstype".
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/utils/mount_main.c b/usr/utils/mount_main.c
index cf5db69..b5993cc 100644
--- a/usr/utils/mount_main.c
+++ b/usr/utils/mount_main.c
@@ -42,8 +42,10 @@ retry:
 				rwflag |= MS_RDONLY;
 				goto retry;
 			}
-			break;
+		} else {
+			error = 0;
 		}
+		break;
 	}
 
 	if (error) {

commit 8ab60fca13b186a6c14cbd7fe6f63f5c5e6a773a
Author: Arthur Loiret <arthur.loiret at u-psud.fr>
Date:   Sun Jun 15 12:24:06 2008 +0200

    Makefile (ARCH): Support sh4 as sh.
    
    Signed-off-by: Arthur Loiret <arthur.loiret at u-psud.fr>
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/Makefile b/Makefile
index b507668..136d4e8 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ export OBJDUMP  := $(KLIBCROSS)objdump
 
 NOSTDINC_FLAGS := -nostdlib -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 
-ARCH	          := $(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
+ARCH	          := $(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh4/sh/)
 export KLIBCARCH  ?= $(ARCH)
 export KLIBCARCHDIR := $(shell echo $(KLIBCARCH) | sed -e s/s390x/s390/)
 

commit 812e2ff7e74e8c495c936981ba0a0372e50b7244
Author: maximilian attems <maks at debian.org>
Date:   Wed Apr 30 15:48:31 2008 +0200

    [klibc] run-init: drop executable stack
    
    sledgehammer run-init instead of the entire klibc suite,
    since PAE+nx and signal handlers could end up failing in rare cases.
    so the READ_IMPLIES_EXEC does not get set for children.
    
    based on a patch by Kees Cook <kees at ubuntu.com>,
    simplified to use the provided EXTRA_KLIBCLDFLAGS.
    
    Cc: Kees Cook <kees at ubuntu.com>
    Signed-off-by: maximilian attems <maks at debian.org>

diff --git a/usr/kinit/run-init/Kbuild b/usr/kinit/run-init/Kbuild
index 61a9d0b..bf6e140 100644
--- a/usr/kinit/run-init/Kbuild
+++ b/usr/kinit/run-init/Kbuild
@@ -14,6 +14,10 @@ objs := run-init.o runinitlib.o
 # Create built-in.o with all object files (used by kinit)
 lib-y := $(objs)
 
+# force run-init to not have an executable stack (to keep READ_IMPLIES_EXEC
+# personality(2) flag from getting set and passed to init).
+EXTRA_KLIBCLDFLAGS += -z noexecstack
+
 # .o files used to built executables
 static/run-init-y := $(objs)
 shared/run-init-y := $(objs)



More information about the klibc mailing list