--- linux-2.6.16-rc4/fs/super.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/super.c 2006-02-17 23:26:32 +0100 @@ -819,6 +827,13 @@ do_kern_mount(const char *fstype, int fl sb = type->get_sb(type, flags, name, data); if (IS_ERR(sb)) goto out_free_secdata; + + error = -EPERM; + if (!capable(CAP_SYS_ADMIN) && !sb->s_bdev && + (sb->s_magic != PROC_SUPER_MAGIC) && + (sb->s_magic != DEVPTS_SUPER_MAGIC)) + goto out_sb; + error = security_sb_kern_mount(sb, secdata); if (error) goto out_sb; --- linux-2.6.16-rc4/fs/sysfs/mount.c 2005-08-29 22:25:33 +0200 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/sysfs/mount.c 2006-02-17 23:26:32 +0100 @@ -11,8 +11,6 @@ #include "sysfs.h" -/* Random magic number */ -#define SYSFS_MAGIC 0x62656572 struct vfsmount *sysfs_mount; struct super_block * sysfs_sb = NULL; --- linux-2.6.16-rc4/fs/sysfs/mount.c 2005-08-29 22:25:33 +0200 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/sysfs/mount.c 2006-02-17 23:26:32 +0100 @@ -38,7 +36,7 @@ static int sysfs_fill_super(struct super sb->s_blocksize = PAGE_CACHE_SIZE; sb->s_blocksize_bits = PAGE_CACHE_SHIFT; - sb->s_magic = SYSFS_MAGIC; + sb->s_magic = SYSFS_SUPER_MAGIC; sb->s_op = &sysfs_ops; sb->s_time_gran = 1; sysfs_sb = sb; --- linux-2.6.16-rc4/include/linux/devpts_fs.h 2004-08-14 12:55:59 +0200 +++ linux-2.6.16-rc4-vs2.1.1-rc8/include/linux/devpts_fs.h 2006-02-17 23:26:32 +0100 @@ -30,5 +30,7 @@ static inline void devpts_pty_kill(int n #endif +#define DEVPTS_SUPER_MAGIC 0x00001cd1 + #endif /* _LINUX_DEVPTS_FS_H */ --- linux-2.6.16-rc4/include/linux/shmem_fs.h 2006-02-18 14:40:35 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/include/linux/shmem_fs.h 2006-02-17 23:26:33 +0100 @@ -8,6 +8,9 @@ #define SHMEM_NR_DIRECT 16 +#define TMPFS_SUPER_MAGIC 0x01021994 + + struct shmem_inode_info { spinlock_t lock; unsigned long flags; --- linux-2.6.16-rc4/include/linux/sysfs.h 2005-08-29 22:25:42 +0200 +++ linux-2.6.16-rc4-vs2.1.1-rc8/include/linux/sysfs.h 2006-02-17 23:26:33 +0100 @@ -12,6 +12,8 @@ #include +#define SYSFS_SUPER_MAGIC 0x62656572 + struct kobject; struct module; --- linux-2.6.16-rc4/mm/shmem.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/shmem.c 2006-02-17 23:26:33 +0100 @@ -50,7 +50,6 @@ #include /* This magic number is used in glibc for posix shared memory */ -#define TMPFS_MAGIC 0x01021994 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long)) #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE) --- linux-2.6.16-rc4/mm/shmem.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/shmem.c 2006-02-17 23:26:33 +0100 @@ -1605,7 +1604,7 @@ static int shmem_statfs(struct super_blo { struct shmem_sb_info *sbinfo = SHMEM_SB(sb); - buf->f_type = TMPFS_MAGIC; + buf->f_type = TMPFS_SUPER_MAGIC; buf->f_bsize = PAGE_CACHE_SIZE; buf->f_namelen = NAME_MAX; spin_lock(&sbinfo->stat_lock); --- linux-2.6.16-rc4/mm/shmem.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/mm/shmem.c 2006-02-17 23:26:33 +0100 @@ -2041,7 +2040,7 @@ static int shmem_fill_super(struct super sb->s_maxbytes = SHMEM_MAX_BYTES; sb->s_blocksize = PAGE_CACHE_SIZE; sb->s_blocksize_bits = PAGE_CACHE_SHIFT; - sb->s_magic = TMPFS_MAGIC; + sb->s_magic = TMPFS_SUPER_MAGIC; sb->s_op = &shmem_ops; inode = shmem_get_inode(sb, S_IFDIR | mode, 0); --- linux-2.6.16-rc4/fs/super.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/super.c 2006-02-17 23:26:32 +0100 @@ -790,7 +792,7 @@ struct vfsmount * do_kern_mount(const char *fstype, int flags, const char *name, void *data) { struct file_system_type *type = get_fs_type(fstype); - struct super_block *sb = ERR_PTR(-ENOMEM); + struct super_block *sb; struct vfsmount *mnt; int error; char *secdata = NULL; --- linux-2.6.16-rc4/fs/super.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/super.c 2006-02-17 23:26:32 +0100 @@ -798,6 +800,12 @@ do_kern_mount(const char *fstype, int fl if (!type) return ERR_PTR(-ENODEV); + sb = ERR_PTR(-EPERM); + if ((type->fs_flags & FS_BINARY_MOUNTDATA) && + !capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_BINARY_MOUNT)) + goto out; + + sb = ERR_PTR(-ENOMEM); mnt = alloc_vfsmnt(name); if (!mnt) goto out; --- linux-2.6.16-rc4/fs/ext2/super.c 2006-02-18 14:40:21 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext2/super.c 2006-02-17 23:26:32 +0100 @@ -289,7 +289,7 @@ enum { Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota, - Opt_usrquota, Opt_grpquota + Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid }; static match_table_t tokens = { --- linux-2.6.16-rc4/fs/ext2/super.c 2006-02-18 14:40:21 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext2/super.c 2006-02-17 23:26:32 +0100 @@ -317,6 +317,10 @@ static match_table_t tokens = { {Opt_acl, "acl"}, {Opt_noacl, "noacl"}, {Opt_xip, "xip"}, + {Opt_tag, "tag"}, + {Opt_notag, "notag"}, + {Opt_tagid, "tagid=%u"}, + {Opt_tag, "tagxid"}, {Opt_grpquota, "grpquota"}, {Opt_ignore, "noquota"}, {Opt_quota, "quota"}, --- linux-2.6.16-rc4/fs/ext2/super.c 2006-02-18 14:40:21 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext2/super.c 2006-02-17 23:26:32 +0100 @@ -380,6 +384,20 @@ static int parse_options (char * options case Opt_nouid32: set_opt (sbi->s_mount_opt, NO_UID32); break; +#ifndef CONFIG_TAGGING_NONE + case Opt_tag: + set_opt (sbi->s_mount_opt, TAGGED); + break; + case Opt_notag: + clear_opt (sbi->s_mount_opt, TAGGED); + break; +#endif +#ifdef CONFIG_PROPAGATE + case Opt_tagid: + /* use args[0] */ + set_opt (sbi->s_mount_opt, TAGGED); + break; +#endif case Opt_nocheck: clear_opt (sbi->s_mount_opt, CHECK); break; --- linux-2.6.16-rc4/fs/ext2/super.c 2006-02-18 14:40:21 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext2/super.c 2006-02-17 23:26:32 +0100 @@ -681,6 +699,8 @@ static int ext2_fill_super(struct super_ if (!parse_options ((char *) data, sbi)) goto failed_mount; + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED) + sb->s_flags |= MS_TAGGED; sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); --- linux-2.6.16-rc4/fs/ext2/super.c 2006-02-18 14:40:21 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext2/super.c 2006-02-17 23:26:32 +0100 @@ -990,6 +1010,13 @@ static int ext2_remount (struct super_bl goto restore_opts; } + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) && + !(sb->s_flags & MS_TAGGED)) { + printk("EXT2-fs: %s: tagging not permitted on remount.\n", + sb->s_id); + return -EINVAL; + } + sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); --- linux-2.6.16-rc4/fs/ext3/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext3/super.c 2006-02-17 23:26:32 +0100 @@ -634,7 +634,7 @@ enum { Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, - Opt_grpquota + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid }; static match_table_t tokens = { --- linux-2.6.16-rc4/fs/ext3/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext3/super.c 2006-02-17 23:26:32 +0100 @@ -683,6 +683,10 @@ static match_table_t tokens = { {Opt_quota, "quota"}, {Opt_usrquota, "usrquota"}, {Opt_barrier, "barrier=%u"}, + {Opt_tag, "tag"}, + {Opt_notag, "notag"}, + {Opt_tagid, "tagid=%u"}, + {Opt_tag, "tagxid"}, {Opt_err, NULL}, {Opt_resize, "resize"}, }; --- linux-2.6.16-rc4/fs/ext3/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext3/super.c 2006-02-17 23:26:32 +0100 @@ -775,6 +779,20 @@ static int parse_options (char *options, case Opt_nouid32: set_opt (sbi->s_mount_opt, NO_UID32); break; +#ifndef CONFIG_TAGGING_NONE + case Opt_tag: + set_opt (sbi->s_mount_opt, TAGGED); + break; + case Opt_notag: + clear_opt (sbi->s_mount_opt, TAGGED); + break; +#endif +#ifdef CONFIG_PROPAGATE + case Opt_tagid: + /* use args[0] */ + set_opt (sbi->s_mount_opt, TAGGED); + break; +#endif case Opt_nocheck: clear_opt (sbi->s_mount_opt, CHECK); break; --- linux-2.6.16-rc4/fs/ext3/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext3/super.c 2006-02-17 23:26:32 +0100 @@ -1429,6 +1447,9 @@ static int ext3_fill_super (struct super NULL, 0)) goto failed_mount; + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED) + sb->s_flags |= MS_TAGGED; + sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); --- linux-2.6.16-rc4/fs/ext3/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/ext3/super.c 2006-02-17 23:26:32 +0100 @@ -2238,6 +2259,12 @@ static int ext3_remount (struct super_bl if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) ext3_abort(sb, __FUNCTION__, "Abort forced by user"); + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) && + !(sb->s_flags & MS_TAGGED)) { + printk("EXT3-fs: %s: tagging not permitted on remount.\n", + sb->s_id); + return -EINVAL; + } sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); --- linux-2.6.16-rc4/fs/jfs/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/jfs/super.c 2006-02-17 23:26:32 +0100 @@ -195,7 +195,7 @@ static void jfs_put_super(struct super_b enum { Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize, Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota, - Opt_usrquota, Opt_grpquota + Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid }; static match_table_t tokens = { --- linux-2.6.16-rc4/fs/jfs/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/jfs/super.c 2006-02-17 23:26:32 +0100 @@ -205,6 +205,10 @@ static match_table_t tokens = { {Opt_resize, "resize=%u"}, {Opt_resize_nosize, "resize"}, {Opt_errors, "errors=%s"}, + {Opt_tag, "tag"}, + {Opt_notag, "notag"}, + {Opt_tagid, "tagid=%u"}, + {Opt_tag, "tagxid"}, {Opt_ignore, "noquota"}, {Opt_ignore, "quota"}, {Opt_usrquota, "usrquota"}, --- linux-2.6.16-rc4/fs/jfs/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/jfs/super.c 2006-02-17 23:26:32 +0100 @@ -313,6 +317,20 @@ static int parse_options(char *options, "JFS: quota operations not supported\n"); break; #endif +#ifndef CONFIG_TAGGING_NONE + case Opt_tag: + *flag |= JFS_TAGGED; + break; + case Opt_notag: + *flag &= JFS_TAGGED; + break; +#endif +#ifdef CONFIG_PROPAGATE + case Opt_tagid: + /* use args[0] */ + *flag |= JFS_TAGGED; + break; +#endif default: printk("jfs: Unrecognized mount option \"%s\" " --- linux-2.6.16-rc4/fs/jfs/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/jfs/super.c 2006-02-17 23:26:32 +0100 @@ -344,6 +362,13 @@ static int jfs_remount(struct super_bloc if (!parse_options(data, sb, &newLVSize, &flag)) { return -EINVAL; } + + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) { + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n", + sb->s_id); + return -EINVAL; + } + if (newLVSize) { if (sb->s_flags & MS_RDONLY) { printk(KERN_ERR --- linux-2.6.16-rc4/fs/jfs/super.c 2006-02-18 14:40:22 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/jfs/super.c 2006-02-17 23:26:32 +0100 @@ -415,6 +440,9 @@ static int jfs_fill_super(struct super_b #ifdef CONFIG_JFS_POSIX_ACL sb->s_flags |= MS_POSIXACL; #endif + /* map mount option tagxid */ + if (sbi->flag & JFS_TAGGED) + sb->s_flags |= MS_TAGGED; if (newLVSize) { printk(KERN_ERR "resize option for remount only\n"); --- linux-2.6.16-rc4/fs/reiserfs/super.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/reiserfs/super.c 2006-02-17 23:26:32 +0100 @@ -882,6 +882,14 @@ static int reiserfs_parse_options(struct {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT}, {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT}, #endif +#ifndef CONFIG_TAGGING_NONE + {"tagxid",.setmask = 1 << REISERFS_TAGGED}, + {"tag",.setmask = 1 << REISERFS_TAGGED}, + {"notag",.clrmask = 1 << REISERFS_TAGGED}, +#endif +#ifdef CONFIG_PROPAGATE + {"tag",.arg_required = 'T',.values = NULL}, +#endif #ifdef CONFIG_REISERFS_FS_POSIX_ACL {"acl",.setmask = 1 << REISERFS_POSIXACL}, {"noacl",.clrmask = 1 << REISERFS_POSIXACL}, --- linux-2.6.16-rc4/fs/reiserfs/super.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/reiserfs/super.c 2006-02-17 23:26:32 +0100 @@ -1154,6 +1162,12 @@ static int reiserfs_remount(struct super return -EINVAL; } + if ((mount_options & (1 << REISERFS_TAGGED)) && + !(s->s_flags & MS_TAGGED)) { + reiserfs_warning(s, "reiserfs: tagging not permitted on remount."); + return -EINVAL; + } + handle_attrs(s); /* Add options that are safe here */ --- linux-2.6.16-rc4/fs/reiserfs/super.c 2006-02-18 14:40:26 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/reiserfs/super.c 2006-02-17 23:26:32 +0100 @@ -1729,6 +1743,10 @@ static int reiserfs_fill_super(struct su goto error; } + /* map mount option tagxid */ + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED)) + s->s_flags |= MS_TAGGED; + rs = SB_DISK_SUPER_BLOCK(s); /* Let's do basic sanity check to verify that underlying device is not smaller than the filesystem. If the check fails then abort and scream, --- linux-2.6.16-rc4/fs/xfs/linux-2.6/xfs_super.c 2006-02-18 14:40:27 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/xfs/linux-2.6/xfs_super.c 2006-02-17 23:26:32 +0100 @@ -729,6 +738,12 @@ linvfs_remount( int error; VFS_PARSEARGS(vfsp, options, args, 1, error); + if ((args->flags2 & XFSMNT2_TAGGED) && + !(sb->s_flags & MS_TAGGED)) { + printk("XFS: %s: tagging not permitted on remount.\n", + sb->s_id); + error = EINVAL; + } if (!error) VFS_MNTUPDATE(vfsp, flags, args, error); kmem_free(args, sizeof(*args)); --- linux-2.6.16-rc4/fs/xfs/xfs_vfsops.c 2006-02-18 14:40:27 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/xfs/xfs_vfsops.c 2006-02-17 23:26:32 +0100 @@ -296,6 +296,8 @@ xfs_start_flags( if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE) mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; + if (ap->flags2 & XFSMNT2_TAGGED) + mp->m_flags |= XFS_MOUNT_TAGGED; /* * no recovery flag requires a read-only mount --- linux-2.6.16-rc4/fs/xfs/xfs_vfsops.c 2006-02-18 14:40:27 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/xfs/xfs_vfsops.c 2006-02-17 23:26:32 +0100 @@ -390,6 +392,8 @@ xfs_finish_flags( return XFS_ERROR(EINVAL); } + if (ap->flags2 & XFSMNT2_TAGGED) + vfs->vfs_super->s_flags |= MS_TAGGED; return 0; } --- linux-2.6.16-rc4/fs/xfs/xfs_vfsops.c 2006-02-18 14:40:27 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/xfs/xfs_vfsops.c 2006-02-17 23:26:32 +0100 @@ -1653,6 +1657,9 @@ xfs_vget( * in stat(). */ #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */ #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */ +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */ +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */ +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */ STATIC unsigned long suffix_strtoul(const char *cp, char **endp, unsigned int base) --- linux-2.6.16-rc4/fs/xfs/xfs_vfsops.c 2006-02-18 14:40:27 +0100 +++ linux-2.6.16-rc4-vs2.1.1-rc8/fs/xfs/xfs_vfsops.c 2006-02-17 23:26:32 +0100 @@ -1829,6 +1836,19 @@ xfs_parseargs( args->flags |= XFSMNT_ATTR2; } else if (!strcmp(this_char, MNTOPT_NOATTR2)) { args->flags &= ~XFSMNT_ATTR2; +#ifndef CONFIG_TAGGING_NONE + } else if (!strcmp(this_char, MNTOPT_TAGGED)) { + args->flags2 |= XFSMNT2_TAGGED; + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) { + args->flags2 &= ~XFSMNT2_TAGGED; + } else if (!strcmp(this_char, MNTOPT_TAGXID)) { + args->flags2 |= XFSMNT2_TAGGED; +#endif +#ifdef CONFIG_PROPAGATE + } else if (!strcmp(this_char, MNTOPT_TAGGED)) { + /* use value */ + args->flags2 |= XFSMNT2_TAGGED; +#endif } else if (!strcmp(this_char, "osyncisdsync")) { /* no-op, this is now the default */ printk("XFS: osyncisdsync is now the default, option is deprecated.\n");