Re: 2.6.15 Bug? New security model?

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

 



On Sun, Feb 12, 2006 at 12:57:40PM -0500, Jeff Mahoney wrote:
> diff -ruNpX dontdiff linux-2.6.15/fs/reiserfs/inode.c linux-2.6.15-reiserfs/fs/reiserfs/inode.c
> --- linux-2.6.15/fs/reiserfs/inode.c	2006-02-06 19:54:10.000000000 -0500
> +++ linux-2.6.15-reiserfs/fs/reiserfs/inode.c	2006-02-12 12:43:00.000000000 -0500
> @@ -1195,6 +1195,7 @@ static void init_inode(struct inode *ino
>  		/* nopack is initially zero for v1 objects. For v2 objects,
>  		   nopack is initialised from sd_attrs */
>  		REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
> +		REISERFS_I(inode)->i_attrs = 0;

This part of the patch works fine for my test case - no more bogus
attributes, even when mounting with the "attrs" option.

>  	} else {
>  		// new stat data found, but object may have old items
>  		// (directories and symlinks)
> diff -ruNpX dontdiff linux-2.6.15/fs/reiserfs/super.c linux-2.6.15-reiserfs/fs/reiserfs/super.c
> --- linux-2.6.15/fs/reiserfs/super.c	2006-02-06 19:54:27.000000000 -0500
> +++ linux-2.6.15-reiserfs/fs/reiserfs/super.c	2006-02-12 12:48:41.000000000 -0500
> @@ -1121,7 +1121,9 @@ static void handle_attrs(struct super_bl
>  					 "reiserfs: cannot support attributes until flag is set in super-block");
>  			REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
>  		}
> -	} else if (le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared) {
> +	} else if (le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared &&
> +	           get_inode_item_key_version(s->s_root->d_inode) == KEY_FORMAT_3_6) {
> +		/* Enable attrs by default on v3.6-native file systems */
>  		REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ATTRS);
>  	}
>  }

This part, however, does not work - apparently the condition is never
true, even on a freshly created 3.6-format filesystem:

# mkreiserfs --format 3.6 -f tmp2.img
# mount -t reiserfs -o loop tmp2.img /mnt/disk/
# lsattr -d /mnt/disk/
lsattr: Inappropriate ioctl for device While reading flags on /mnt/disk/


Apparently directories always have old key format, even on new
filesystems:

	if (old_format_only(sb) || S_ISDIR(mode) || S_ISLNK(mode))
		set_inode_item_key_version(inode, KEY_FORMAT_3_5);
	else
		set_inode_item_key_version(inode, KEY_FORMAT_3_6);

However, checking the stat data format works:

diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index b33d67b..a2ea7ed 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1195,6 +1195,7 @@ static void init_inode(struct inode *ino
 		/* nopack is initially zero for v1 objects. For v2 objects,
 		   nopack is initialised from sd_attrs */
 		REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
+		REISERFS_I(inode)->i_attrs = 0;
 	} else {
 		// new stat data found, but object may have old items
 		// (directories and symlinks)
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index ef5e541..acafe32 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -1124,7 +1124,9 @@ static void handle_attrs(struct super_bl
 					 "reiserfs: cannot support attributes until flag is set in super-block");
 			REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
 		}
-	} else if (le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared) {
+	} else if ((le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared) &&
+		(get_inode_sd_version(s->s_root->d_inode) == STAT_DATA_V2)) {
+		/* Enable attrs by default on v3.6-native file systems */
 		REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ATTRS);
 	}
 }

But this patch has another problem - it forces the "attrs" option on
for such filesystems, leaving no way to turn it off - the "noattrs"
option is ignored.  This does not look good.

Attachment: pgpZtwprQDvrD.pgp
Description: PGP signature


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux