Completing the user namespace
Subsystems (36)
PATCH 43/43 userns: Convert the move_pages, and migrate_pages permission checks to use uid_eq
In reply to a message not in the archiveFrom: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
--- mm/mempolicy.c | 4 ++-- mm/migrate.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
mm/mempolicy.c +2 -2
@@ -1334,8 +1334,8 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,* userid as the target process. */ tcred =__task_cred (task); -if (cred->euid != tcred->suid && cred->euid != tcred->uid && - cred->uid != tcred->suid && cred->uid != tcred->uid && +if (!uid_eq (cred->euid, tcred->suid) && !uid_eq (cred->euid, tcred->uid) && + !uid_eq (cred->uid, tcred->suid) && !uid_eq (cred->uid, tcred->uid) && !capable (CAP_SYS_NICE )) {rcu_read_unlock (); err = -EPERM ;
mm/migrate.c +2 -2
@@ -1371,8 +1371,8 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,* userid as the target process. */ tcred =__task_cred (task); -if (cred->euid != tcred->suid && cred->euid != tcred->uid && - cred->uid != tcred->suid && cred->uid != tcred->uid && +if (!uid_eq (cred->euid, tcred->suid) && !uid_eq (cred->euid, tcred->uid) && + !uid_eq (cred->uid, tcred->suid) && !uid_eq (cred->uid, tcred->uid) && !capable (CAP_SYS_NICE )) {rcu_read_unlock (); err = -EPERM ;
Signature · 1 line
1.7.2.5
Thanks, Eric.
While this approach has limitations and administrative overhead which I'd prefer it didn't, it also has huge benefits, especially faster id comparisons and, most importantly, type safety enforcing that the right kinds of uids are compared.
So I endorse this approach.
I've reviewed and acked many of the patches, some I still had questions on, but the approach as a whole gets an ack from me.
thanks,
-serge
Quoted 3 lines · Eric W. Biederman
- Capabilities are localized to the current user namespace making it safe to give the initial user in a user namespace all capabilities.
So, this makes LXC and friends ready for hostile environments? IOW a root user (with all capabilities) sitting in his own namespace can no longer ham the host?
Signature · 2 lines
Thanks, //richard
PATCH 35/43 userns: Convert ext2 to use kuid/kgid where appropriate.
In reply to Eric W. BiedermanFrom: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
--- fs/ext2/balloc.c | 5 +++-- fs/ext2/ext2.h | 8 ++++---- fs/ext2/inode.c | 20 ++++++++++++-------- fs/ext2/super.c | 31 +++++++++++++++++++++++-------- 4 files changed, 42 insertions(+), 22 deletions(-)
fs/ext2/balloc.c +3 -2
@@ -1193,8 +1193,9 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi) free_blocks =percpu_counter_read_positive (&sbi->s_freeblocks_counter); root_blocks =le32_to_cpu (sbi->s_es->s_r_blocks_count);if (free_blocks < root_blocks +1 && !capable (CAP_SYS_RESOURCE ) && - sbi->s_resuid !=current_fsuid () && - (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) { + !uid_eq (sbi->s_resuid,current_fsuid ()) && + (gid_eq (sbi->s_resgid,GLOBAL_ROOT_GID ) || + !in_group_p (sbi->s_resgid))) {return 0 ; }return 1 ;
fs/ext2/ext2.h +4 -4
@@ -82,8 +82,8 @@ struct ext2_sb_info {struct buffer_head ** s_group_desc;unsigned long s_mount_opt;unsigned long s_sb_block; -uid_t s_resuid; -gid_t s_resgid; +kuid_t s_resuid; +kgid_t s_resgid;unsigned short s_mount_state;unsigned short s_pad;int s_addr_per_block_bits;
@@ -637,8 +637,8 @@ static inline void verify_offsets(void)*/ struct ext2_mount_options {unsigned long s_mount_opt; -uid_t s_resuid; -gid_t s_resgid; +kuid_t s_resuid; +kgid_t s_resgid; };/*
fs/ext2/inode.c +12 -8
@@ -1293,6 +1293,8 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)struct inode *inode;long ret = -EIO ;int n; +uid_t i_uid; +gid_t i_gid; inode =iget_locked (sb, ino);if (!inode)
@@ -1310,12 +1312,14 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino) } inode->i_mode =le16_to_cpu (raw_inode->i_mode); - inode->i_uid = (uid_t )le16_to_cpu (raw_inode->i_uid_low); - inode->i_gid = (gid_t )le16_to_cpu (raw_inode->i_gid_low); + i_uid = (uid_t )le16_to_cpu (raw_inode->i_uid_low); + i_gid = (gid_t )le16_to_cpu (raw_inode->i_gid_low);if (!(test_opt (inode->i_sb,NO_UID32 ))) { - inode->i_uid |=le16_to_cpu (raw_inode->i_uid_high) <<16 ; - inode->i_gid |=le16_to_cpu (raw_inode->i_gid_high) <<16 ; + i_uid |=le16_to_cpu (raw_inode->i_uid_high) <<16 ; + i_gid |=le16_to_cpu (raw_inode->i_gid_high) <<16 ; } +i_uid_write (inode, i_uid); +i_gid_write (inode, i_gid);set_nlink (inode,le16_to_cpu (raw_inode->i_links_count)); inode->i_size =le32_to_cpu (raw_inode->i_size); inode->i_atime.tv_sec = (signed )le32_to_cpu (raw_inode->i_atime);
@@ -1413,8 +1417,8 @@ static int __ext2_write_inode(struct inode *inode, int do_sync)struct ext2_inode_info *ei =EXT2_I (inode);struct super_block *sb = inode->i_sb;ino_t ino = inode->i_ino; -uid_t uid = inode->i_uid; -gid_t gid = inode->i_gid; +uid_t uid =i_uid_read (inode); +gid_t gid =i_gid_read (inode);struct buffer_head * bh;struct ext2_inode * raw_inode =ext2_get_inode (sb, ino, &bh);int n;
@@ -1529,8 +1533,8 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)if (is_quota_modification (inode, iattr))dquot_initialize (inode); -if ((iattr->ia_valid &ATTR_UID && iattr->ia_uid != inode->i_uid) || - (iattr->ia_valid &ATTR_GID && iattr->ia_gid != inode->i_gid)) { +if ((iattr->ia_valid &ATTR_UID && !uid_eq (iattr->ia_uid, inode->i_uid)) || + (iattr->ia_valid &ATTR_GID && !gid_eq (iattr->ia_gid, inode->i_gid))) { error =dquot_transfer (inode, iattr);if (error)return error;
fs/ext2/super.c +23 -8
@@ -228,13 +228,15 @@ static int ext2_show_options(struct seq_file *seq, struct dentry *root)seq_puts (seq,",grpid" );if (!test_opt (sb,GRPID ) && (def_mount_opts &EXT2_DEFM_BSDGROUPS ))seq_puts (seq,",nogrpid" ); -if (sbi->s_resuid !=EXT2_DEF_RESUID || +if (!uid_eq (sbi->s_resuid,make_kuid (&init_user_ns,EXT2_DEF_RESUID )) ||le16_to_cpu (es->s_def_resuid) !=EXT2_DEF_RESUID ) { -seq_printf (seq,",resuid=%u" , sbi->s_resuid); +seq_printf (seq,",resuid=%u" , +from_kuid_munged (&init_user_ns, sbi->s_resuid)); } -if (sbi->s_resgid !=EXT2_DEF_RESGID || +if (!gid_eq (sbi->s_resgid,make_kgid (&init_user_ns,EXT2_DEF_RESGID )) ||le16_to_cpu (es->s_def_resgid) !=EXT2_DEF_RESGID ) { -seq_printf (seq,",resgid=%u" , sbi->s_resgid); +seq_printf (seq,",resgid=%u" , +from_kgid_munged (&init_user_ns, sbi->s_resgid)); }if (test_opt (sb,ERRORS_RO )) {int def_errors =le16_to_cpu (es->s_errors);
@@ -436,6 +438,8 @@ static int parse_options(char *options, struct super_block *sb)struct ext2_sb_info *sbi =EXT2_SB (sb);substring_t args[MAX_OPT_ARGS ];int option; +kuid_t uid; +kgid_t gid;if (!options)return 1 ;
@@ -462,12 +466,23 @@ static int parse_options(char *options, struct super_block *sb)case Opt_resuid:if (match_int (&args[0 ], &option))return 0 ; - sbi->s_resuid = option; + uid =make_kuid (current_user_ns (), option); +if (!uid_valid (uid)) { +ext2_msg (sb,KERN_ERR ,"Invalid uid value %d" , option); +return -1 ; + + } + sbi->s_resuid = uid;break ;case Opt_resgid:if (match_int (&args[0 ], &option))return 0 ; - sbi->s_resgid = option; + gid =make_kgid (current_user_ns (), option); +if (!gid_valid (gid)) { +ext2_msg (sb,KERN_ERR ,"Invalid gid value %d" , option); +return -1 ; + } + sbi->s_resgid = gid;break ;case Opt_sb:/* handled by get_sb_block() instead of here */
@@ -841,8 +856,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)else set_opt (sbi->s_mount_opt,ERRORS_RO ); - sbi->s_resuid =le16_to_cpu (es->s_def_resuid); - sbi->s_resgid =le16_to_cpu (es->s_def_resgid); + sbi->s_resuid =make_kuid (&init_user_ns,le16_to_cpu (es->s_def_resuid)); + sbi->s_resgid =make_kgid (&init_user_ns,le16_to_cpu (es->s_def_resgid));set_opt (sbi->s_mount_opt,RESERVATION );
Signature · 1 line
1.7.2.5
PATCH 36/43 userns: Convert ext3 to use kuid/kgid where appropriate
In reply to Eric W. BiedermanFrom: Eric W. Biederman <[email protected]>
--- fs/ext3/balloc.c | 5 +++-- fs/ext3/ext3.h | 8 ++++---- fs/ext3/inode.c | 32 ++++++++++++++++++++------------ fs/ext3/super.c | 35 +++++++++++++++++++++++++---------- include/trace/events/ext3.h | 4 ++-- 5 files changed, 54 insertions(+), 30 deletions(-)
fs/ext3/balloc.c +3 -2
@@ -1439,8 +1439,9 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation) free_blocks =percpu_counter_read_positive (&sbi->s_freeblocks_counter); root_blocks =le32_to_cpu (sbi->s_es->s_r_blocks_count);if (free_blocks < root_blocks +1 && !capable (CAP_SYS_RESOURCE ) && - !use_reservation && sbi->s_resuid !=current_fsuid () && - (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) { + !use_reservation && !uid_eq (sbi->s_resuid,current_fsuid ()) && + (gid_eq (sbi->s_resgid,GLOBAL_ROOT_GID ) || + !in_group_p (sbi->s_resgid))) {return 0 ; }return 1 ;
fs/ext3/ext3.h +4 -4
@@ -243,8 +243,8 @@ struct ext3_new_group_data {*/ struct ext3_mount_options {unsigned long s_mount_opt; -uid_t s_resuid; -gid_t s_resgid; +kuid_t s_resuid; +kgid_t s_resgid;unsigned long s_commit_interval;#ifdef CONFIG_QUOTA int s_jquota_fmt;
@@ -637,8 +637,8 @@ struct ext3_sb_info {struct buffer_head ** s_group_desc;unsigned long s_mount_opt;ext3_fsblk_t s_sb_block; -uid_t s_resuid; -gid_t s_resgid; +kuid_t s_resuid; +kgid_t s_resgid;unsigned short s_mount_state;unsigned short s_pad;int s_addr_per_block_bits;
fs/ext3/inode.c +20 -12
@@ -2891,6 +2891,8 @@ struct inode *ext3_iget(struct super_block *sb, unsigned long ino)transaction_t *transaction;long ret;int block; +uid_t i_uid; +gid_t i_gid; inode =iget_locked (sb, ino);if (!inode)
@@ -2907,12 +2909,14 @@ struct inode *ext3_iget(struct super_block *sb, unsigned long ino) bh = iloc.bh; raw_inode =ext3_raw_inode (&iloc); inode->i_mode =le16_to_cpu (raw_inode->i_mode); - inode->i_uid = (uid_t )le16_to_cpu (raw_inode->i_uid_low); - inode->i_gid = (gid_t )le16_to_cpu (raw_inode->i_gid_low); + i_uid = (uid_t )le16_to_cpu (raw_inode->i_uid_low); + i_gid = (gid_t )le16_to_cpu (raw_inode->i_gid_low);if (!(test_opt (inode->i_sb,NO_UID32 ))) { - inode->i_uid |=le16_to_cpu (raw_inode->i_uid_high) <<16 ; - inode->i_gid |=le16_to_cpu (raw_inode->i_gid_high) <<16 ; + i_uid |=le16_to_cpu (raw_inode->i_uid_high) <<16 ; + i_gid |=le16_to_cpu (raw_inode->i_gid_high) <<16 ; } +i_uid_write (inode, i_uid); +i_gid_write (inode, i_gid);set_nlink (inode,le16_to_cpu (raw_inode->i_links_count)); inode->i_size =le32_to_cpu (raw_inode->i_size); inode->i_atime.tv_sec = (signed )le32_to_cpu (raw_inode->i_atime);
@@ -3068,6 +3072,8 @@ static int ext3_do_update_inode(handle_t *handle,struct ext3_inode_info *ei =EXT3_I (inode);struct buffer_head *bh = iloc->bh;int err =0 , rc, block; +uid_t i_uid; +gid_t i_gid; again:/* we can't allow multiple procs in here at once, its a bit racey */
@@ -3080,27 +3086,29 @@ again:ext3_get_inode_flags (ei); raw_inode->i_mode =cpu_to_le16 (inode->i_mode); + i_uid =i_uid_read (inode); + i_gid =i_gid_read (inode);if (!(test_opt (inode->i_sb,NO_UID32 ))) { - raw_inode->i_uid_low =cpu_to_le16 (low_16_bits (inode->i_uid)); - raw_inode->i_gid_low =cpu_to_le16 (low_16_bits (inode->i_gid)); + raw_inode->i_uid_low =cpu_to_le16 (low_16_bits (i_uid)); + raw_inode->i_gid_low =cpu_to_le16 (low_16_bits (i_gid));/* * Fix up interoperability with old kernels. Otherwise, old inodes get * re-used with the upper 16 bits of the uid/gid intact */ if (!ei->i_dtime) { raw_inode->i_uid_high = -cpu_to_le16 (high_16_bits (inode->i_uid)); +cpu_to_le16 (high_16_bits (i_uid)); raw_inode->i_gid_high = -cpu_to_le16 (high_16_bits (inode->i_gid)); +cpu_to_le16 (high_16_bits (i_gid)); }else { raw_inode->i_uid_high =0 ; raw_inode->i_gid_high =0 ; } }else { raw_inode->i_uid_low = -cpu_to_le16 (fs_high2lowuid (inode->i_uid)); +cpu_to_le16 (fs_high2lowuid (i_uid)); raw_inode->i_gid_low = -cpu_to_le16 (fs_high2lowgid (inode->i_gid)); +cpu_to_le16 (fs_high2lowgid (i_gid)); raw_inode->i_uid_high =0 ; raw_inode->i_gid_high =0 ; }
@@ -3262,8 +3270,8 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)if (is_quota_modification (inode, attr))dquot_initialize (inode); -if ((ia_valid &ATTR_UID && attr->ia_uid != inode->i_uid) || - (ia_valid &ATTR_GID && attr->ia_gid != inode->i_gid)) { +if ((ia_valid &ATTR_UID && !uid_eq (attr->ia_uid, inode->i_uid)) || + (ia_valid &ATTR_GID && !gid_eq (attr->ia_gid, inode->i_gid))) {handle_t *handle;/* (user+group)*(old+new) structure, inode write (sb,
fs/ext3/super.c +25 -10
@@ -617,13 +617,15 @@ static int ext3_show_options(struct seq_file *seq, struct dentry *root)seq_puts (seq,",grpid" );if (!test_opt (sb,GRPID ) && (def_mount_opts &EXT3_DEFM_BSDGROUPS ))seq_puts (seq,",nogrpid" ); -if (sbi->s_resuid !=EXT3_DEF_RESUID || +if (!uid_eq (sbi->s_resuid,make_kuid (&init_user_ns,EXT3_DEF_RESUID )) ||le16_to_cpu (es->s_def_resuid) !=EXT3_DEF_RESUID ) { -seq_printf (seq,",resuid=%u" , sbi->s_resuid); +seq_printf (seq,",resuid=%u" , +from_kuid_munged (&init_user_ns, sbi->s_resuid)); } -if (sbi->s_resgid !=EXT3_DEF_RESGID || +if (!gid_eq (sbi->s_resgid,make_kgid (&init_user_ns,EXT3_DEF_RESGID )) ||le16_to_cpu (es->s_def_resgid) !=EXT3_DEF_RESGID ) { -seq_printf (seq,",resgid=%u" , sbi->s_resgid); +seq_printf (seq,",resgid=%u" , +from_kgid_munged (&init_user_ns, sbi->s_resgid)); }if (test_opt (sb,ERRORS_RO )) {int def_errors =le16_to_cpu (es->s_errors);
@@ -967,6 +969,8 @@ static int parse_options (char *options, struct super_block *sb,substring_t args[MAX_OPT_ARGS ];int data_opt =0 ;int option; +kuid_t uid; +kgid_t gid;#ifdef CONFIG_QUOTA int qfmt;#endif
@@ -1000,12 +1004,23 @@ static int parse_options (char *options, struct super_block *sb,case Opt_resuid:if (match_int (&args[0 ], &option))return 0 ; - sbi->s_resuid = option; + uid =make_kuid (current_user_ns (), option); +if (!uid_valid (uid)) { +ext3_msg (sb,KERN_ERR ,"Invalid uid value %d" , option); +return -1 ; + + } + sbi->s_resuid = uid;break ;case Opt_resgid:if (match_int (&args[0 ], &option))return 0 ; - sbi->s_resgid = option; + gid =make_kgid (current_user_ns (), option); +if (!gid_valid (gid)) { +ext3_msg (sb,KERN_ERR ,"Invalid gid value %d" , option); +return -1 ; + } + sbi->s_resgid = gid;break ;case Opt_sb:/* handled by get_sb_block() instead of here */
@@ -1651,8 +1666,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) } sb->s_fs_info = sbi; sbi->s_mount_opt =0 ; - sbi->s_resuid =EXT3_DEF_RESUID ; - sbi->s_resgid =EXT3_DEF_RESGID ; + sbi->s_resuid =make_kuid (&init_user_ns,EXT3_DEF_RESUID ); + sbi->s_resgid =make_kgid (&init_user_ns,EXT3_DEF_RESGID ); sbi->s_sb_block = sb_block; blocksize =sb_min_blocksize (sb,EXT3_MIN_BLOCK_SIZE );
@@ -1716,8 +1731,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)else set_opt (sbi->s_mount_opt,ERRORS_RO ); - sbi->s_resuid =le16_to_cpu (es->s_def_resuid); - sbi->s_resgid =le16_to_cpu (es->s_def_resgid); + sbi->s_resuid =make_kuid (&init_user_ns,le16_to_cpu (es->s_def_resuid)); + sbi->s_resgid =make_kgid (&init_user_ns,le16_to_cpu (es->s_def_resgid));/* enable barriers by default */ set_opt (sbi->s_mount_opt,BARRIER );
include/trace/events/ext3.h +2 -2
@@ -24,8 +24,8 @@ TRACE_EVENT(ext3_free_inode, __entry->dev = inode->i_sb->s_dev; __entry->ino = inode->i_ino; __entry->mode = inode->i_mode; - __entry->uid = inode->i_uid; - __entry->gid = inode->i_gid; + __entry->uid =i_uid_read (inode); + __entry->gid =i_gid_read (inode); __entry->blocks = inode->i_blocks; ),
Signature · 1 line
1.7.2.5
PATCH 37/43 userns: Convert ext4 to user kuid/kgid where appropriate
In reply to Eric W. BiedermanFrom: Eric W. Biederman <[email protected]>
--- fs/ext4/balloc.c | 4 ++-- fs/ext4/ext4.h | 4 ++-- fs/ext4/ialloc.c | 4 ++-- fs/ext4/inode.c | 34 ++++++++++++++++++++-------------- fs/ext4/migrate.c | 4 ++-- fs/ext4/super.c | 38 ++++++++++++++++++++++++++------------ include/trace/events/ext4.h | 4 ++-- 7 files changed, 56 insertions(+), 36 deletions(-)
fs/ext4/balloc.c +2 -2
@@ -461,8 +461,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,return 1 ;/* Hm, nope. Are (enough) root reserved clusters available? */ -if (sbi->s_resuid ==current_fsuid () || - ((sbi->s_resgid !=0 ) &&in_group_p (sbi->s_resgid)) || +if (uid_eq (sbi->s_resuid,current_fsuid ()) || + (!gid_eq (sbi->s_resgid,GLOBAL_ROOT_GID ) &&in_group_p (sbi->s_resgid)) ||capable (CAP_SYS_RESOURCE ) || (flags &EXT4_MB_USE_ROOT_BLOCKS )) {
fs/ext4/ext4.h +2 -2
@@ -1153,8 +1153,8 @@ struct ext4_sb_info {unsigned int s_mount_flags;unsigned int s_def_mount_opt;ext4_fsblk_t s_sb_block; -uid_t s_resuid; -gid_t s_resgid; +kuid_t s_resuid; +kgid_t s_resgid;unsigned short s_mount_state;unsigned short s_pad;int s_addr_per_block_bits;
fs/ext4/ialloc.c +2 -2
@@ -808,8 +808,8 @@ got: }if (owner) { inode->i_mode = mode; - inode->i_uid = owner[0 ]; - inode->i_gid = owner[1 ]; +i_uid_write (inode, owner[0 ]); +i_gid_write (inode, owner[1 ]); }else if (test_opt (sb,GRPID )) { inode->i_mode = mode; inode->i_uid =current_fsuid ();
fs/ext4/inode.c +20 -14
@@ -3630,6 +3630,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)journal_t *journal =EXT4_SB (sb)->s_journal;long ret;int block; +uid_t i_uid; +gid_t i_gid; inode =iget_locked (sb, ino);if (!inode)
@@ -3645,12 +3647,14 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) goto bad_inode; raw_inode =ext4_raw_inode (&iloc); inode->i_mode =le16_to_cpu (raw_inode->i_mode); - inode->i_uid = (uid_t )le16_to_cpu (raw_inode->i_uid_low); - inode->i_gid = (gid_t )le16_to_cpu (raw_inode->i_gid_low); + i_uid = (uid_t )le16_to_cpu (raw_inode->i_uid_low); + i_gid = (gid_t )le16_to_cpu (raw_inode->i_gid_low);if (!(test_opt (inode->i_sb,NO_UID32 ))) { - inode->i_uid |=le16_to_cpu (raw_inode->i_uid_high) <<16 ; - inode->i_gid |=le16_to_cpu (raw_inode->i_gid_high) <<16 ; + i_uid |=le16_to_cpu (raw_inode->i_uid_high) <<16 ; + i_gid |=le16_to_cpu (raw_inode->i_gid_high) <<16 ; } +i_uid_write (inode, i_uid); +i_gid_write (inode, i_gid);set_nlink (inode,le16_to_cpu (raw_inode->i_links_count));ext4_clear_state_flags (ei);/* Only relevant on 32-bit archs */
@@ -3870,6 +3874,8 @@ static int ext4_do_update_inode(handle_t *handle,struct ext4_inode_info *ei =EXT4_I (inode);struct buffer_head *bh = iloc->bh;int err =0 , rc, block; +uid_t i_uid; +gid_t i_gid;/* For fields not not tracking in the in-memory inode, * initialise them to zero for new inodes. */
@@ -3878,27 +3884,27 @@ static int ext4_do_update_inode(handle_t *handle,ext4_get_inode_flags (ei); raw_inode->i_mode =cpu_to_le16 (inode->i_mode); + i_uid =i_uid_read (inode); + i_gid =i_gid_read (inode);if (!(test_opt (inode->i_sb,NO_UID32 ))) { - raw_inode->i_uid_low =cpu_to_le16 (low_16_bits (inode->i_uid)); - raw_inode->i_gid_low =cpu_to_le16 (low_16_bits (inode->i_gid)); + raw_inode->i_uid_low =cpu_to_le16 (low_16_bits (i_uid)); + raw_inode->i_gid_low =cpu_to_le16 (low_16_bits (i_gid));/* * Fix up interoperability with old kernels. Otherwise, old inodes get * re-used with the upper 16 bits of the uid/gid intact */ if (!ei->i_dtime) { raw_inode->i_uid_high = -cpu_to_le16 (high_16_bits (inode->i_uid)); +cpu_to_le16 (high_16_bits (i_uid)); raw_inode->i_gid_high = -cpu_to_le16 (high_16_bits (inode->i_gid)); +cpu_to_le16 (high_16_bits (i_gid)); }else { raw_inode->i_uid_high =0 ; raw_inode->i_gid_high =0 ; } }else { - raw_inode->i_uid_low = -cpu_to_le16 (fs_high2lowuid (inode->i_uid)); - raw_inode->i_gid_low = -cpu_to_le16 (fs_high2lowgid (inode->i_gid)); + raw_inode->i_uid_low =cpu_to_le16 (fs_high2lowuid (i_uid)); + raw_inode->i_gid_low =cpu_to_le16 (fs_high2lowgid (i_gid)); raw_inode->i_uid_high =0 ; raw_inode->i_gid_high =0 ; }
@@ -4084,8 +4090,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)if (is_quota_modification (inode, attr))dquot_initialize (inode); -if ((ia_valid &ATTR_UID && attr->ia_uid != inode->i_uid) || - (ia_valid &ATTR_GID && attr->ia_gid != inode->i_gid)) { +if ((ia_valid &ATTR_UID && !uid_eq (attr->ia_uid, inode->i_uid)) || + (ia_valid &ATTR_GID && !gid_eq (attr->ia_gid, inode->i_gid))) {handle_t *handle;/* (user+group)*(old+new) structure, inode write (sb,
fs/ext4/migrate.c +2 -2
@@ -466,8 +466,8 @@ int ext4_ext_migrate(struct inode *inode) } goal = (((inode->i_ino -1 ) /EXT4_INODES_PER_GROUP (inode->i_sb)) *EXT4_INODES_PER_GROUP (inode->i_sb)) +1 ; - owner[0 ] = inode->i_uid; - owner[1 ] = inode->i_gid; + owner[0 ] =i_uid_read (inode); + owner[1 ] =i_gid_read (inode); tmp_inode =ext4_new_inode (handle, inode->i_sb->s_root->d_inode,S_IFREG ,NULL , goal, owner);if (IS_ERR (tmp_inode)) {
fs/ext4/super.c +26 -12
@@ -1448,6 +1448,8 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, {struct ext4_sb_info *sbi =EXT4_SB (sb);const struct mount_opts *m; +kuid_t uid; +kgid_t gid;int arg =0 ;if (args->from &&match_int (args, &arg))
@@ -1464,10 +1466,20 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, "Ignoring removed %s option", opt);return 1 ;case Opt_resuid: - sbi->s_resuid = arg; + uid =make_kuid (current_user_ns (), arg); +if (!uid_valid (uid)) { +ext4_msg (sb,KERN_ERR ,"Invalid uid value %d" , arg); +return -1 ; + } + sbi->s_resuid = uid;return 1 ;case Opt_resgid: - sbi->s_resgid = arg; + gid =make_kgid (current_user_ns (), arg); +if (!gid_valid (gid)) { +ext4_msg (sb,KERN_ERR ,"Invalid gid value %d" , arg); +return -1 ; + } + sbi->s_resgid = gid;return 1 ;case Opt_abort: sbi->s_mount_flags |=EXT4_MF_FS_ABORTED ;
@@ -1732,12 +1744,14 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,SEQ_OPTS_PRINT ("%s" ,token2str (m->token)); } -if (nodefs || sbi->s_resuid !=EXT4_DEF_RESUID || +if (nodefs || !uid_eq (sbi->s_resuid,make_kuid (&init_user_ns,EXT4_DEF_RESUID )) ||le16_to_cpu (es->s_def_resuid) !=EXT4_DEF_RESUID ) -SEQ_OPTS_PRINT ("resuid=%u" , sbi->s_resuid); -if (nodefs || sbi->s_resgid !=EXT4_DEF_RESGID || +SEQ_OPTS_PRINT ("resuid=%u" , +from_kuid_munged (&init_user_ns, sbi->s_resuid)); +if (nodefs || !gid_eq (sbi->s_resgid,make_kgid (&init_user_ns,EXT4_DEF_RESGID )) ||le16_to_cpu (es->s_def_resgid) !=EXT4_DEF_RESGID ) -SEQ_OPTS_PRINT ("resgid=%u" , sbi->s_resgid); +SEQ_OPTS_PRINT ("resgid=%u" , +from_kgid_munged (&init_user_ns, sbi->s_resgid)); def_errors = nodefs ?-1 :le16_to_cpu (es->s_errors);if (test_opt (sb,ERRORS_RO ) && def_errors !=EXT4_ERRORS_RO )SEQ_OPTS_PUTS ("errors=remount-ro" );
@@ -2996,8 +3010,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) } sb->s_fs_info = sbi; sbi->s_mount_opt =0 ; - sbi->s_resuid =EXT4_DEF_RESUID ; - sbi->s_resgid =EXT4_DEF_RESGID ; + sbi->s_resuid =make_kuid (&init_user_ns,EXT4_DEF_RESUID ); + sbi->s_resgid =make_kgid (&init_user_ns,EXT4_DEF_RESGID ); sbi->s_inode_readahead_blks =EXT4_DEF_INODE_READAHEAD_BLKS ; sbi->s_sb_block = sb_block;if (sb->s_bdev->bd_part)
@@ -3076,8 +3090,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)if (def_mount_opts &EXT4_DEFM_DISCARD )set_opt (sb,DISCARD ); - sbi->s_resuid =le16_to_cpu (es->s_def_resuid); - sbi->s_resgid =le16_to_cpu (es->s_def_resgid); + sbi->s_resuid =make_kuid (&init_user_ns,le16_to_cpu (es->s_def_resuid)); + sbi->s_resgid =make_kgid (&init_user_ns,le16_to_cpu (es->s_def_resgid)); sbi->s_commit_interval =JBD2_DEFAULT_MAX_COMMIT_AGE *HZ ; sbi->s_min_batch_time =EXT4_DEF_MIN_BATCH_TIME ; sbi->s_max_batch_time =EXT4_DEF_MAX_BATCH_TIME ;
@@ -4229,8 +4243,8 @@ static int ext4_unfreeze(struct super_block *sb)struct ext4_mount_options {unsigned long s_mount_opt;unsigned long s_mount_opt2; -uid_t s_resuid; -gid_t s_resgid; +kuid_t s_resuid; +kgid_t s_resgid;unsigned long s_commit_interval;u32 s_min_batch_time, s_max_batch_time;#ifdef CONFIG_QUOTA
include/trace/events/ext4.h +2 -2
@@ -36,8 +36,8 @@ TRACE_EVENT(ext4_free_inode, __entry->dev = inode->i_sb->s_dev; __entry->ino = inode->i_ino; __entry->mode = inode->i_mode; - __entry->uid = inode->i_uid; - __entry->gid = inode->i_gid; + __entry->uid =i_uid_read (inode); + __entry->gid =i_gid_read (inode); __entry->blocks = inode->i_blocks; ),
Signature · 1 line
1.7.2.5
PATCH 38/43 userns: Convert proc to use kuid/kgid where appropriate
In reply to Eric W. BiedermanFrom: Eric W. Biederman <[email protected]>
--- fs/proc/array.c | 10 ++++++++-- fs/proc/base.c | 16 ++++++++-------- fs/proc/inode.c | 4 ++-- fs/proc/root.c | 2 +- include/linux/pid_namespace.h | 2 +- include/linux/proc_fs.h | 4 ++-- 6 files changed, 22 insertions(+), 16 deletions(-)
fs/proc/array.c +8 -2
@@ -191,8 +191,14 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,task_tgid_nr_ns (p, ns),pid_nr_ns (pid, ns), ppid, tpid, - cred->uid, cred->euid, cred->suid, cred->fsuid, - cred->gid, cred->egid, cred->sgid, cred->fsgid); +from_kuid_munged (user_ns, cred->uid), +from_kuid_munged (user_ns, cred->euid), +from_kuid_munged (user_ns, cred->suid), +from_kuid_munged (user_ns, cred->fsuid), +from_kgid_munged (user_ns, cred->gid), +from_kgid_munged (user_ns, cred->egid), +from_kgid_munged (user_ns, cred->sgid), + from_kgid_munged(user_ns, cred->fsgid));task_lock (p);if (p->files)
fs/proc/base.c +8 -8
@@ -1562,8 +1562,8 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)generic_fillattr (inode, stat);rcu_read_lock (); - stat->uid =0 ; - stat->gid =0 ; + stat->uid =GLOBAL_ROOT_UID ; + stat->gid =GLOBAL_ROOT_GID ; task =pid_task (proc_pid (inode),PIDTYPE_PID );if (task) {if (!has_pid_permissions (pid, task,2 )) {
@@ -1623,8 +1623,8 @@ int pid_revalidate(struct dentry *dentry, struct nameidata *nd) inode->i_gid = cred->egid;rcu_read_unlock (); }else { - inode->i_uid =0 ; - inode->i_gid =0 ; + inode->i_uid =GLOBAL_ROOT_UID ; + inode->i_gid =GLOBAL_ROOT_GID ; } inode->i_mode &= ~(S_ISUID |S_ISGID );security_task_to_inode (task, inode);
@@ -1811,8 +1811,8 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) inode->i_gid = cred->egid;rcu_read_unlock (); }else { - inode->i_uid =0 ; - inode->i_gid =0 ; + inode->i_uid =GLOBAL_ROOT_UID ; + inode->i_gid =GLOBAL_ROOT_GID ; } inode->i_mode &= ~(S_ISUID |S_ISGID );security_task_to_inode (task, inode);
@@ -2061,8 +2061,8 @@ static int map_files_d_revalidate(struct dentry *dentry, struct nameidata *nd) inode->i_gid = cred->egid;rcu_read_unlock (); }else { - inode->i_uid =0 ; - inode->i_gid =0 ; + inode->i_uid =GLOBAL_ROOT_UID ; + inode->i_gid =GLOBAL_ROOT_GID ; }security_task_to_inode (task, inode); status =1 ;
fs/proc/inode.c +2 -2
@@ -108,8 +108,8 @@ static int proc_show_options(struct seq_file *seq, struct dentry *root)struct super_block *sb = root->d_sb;struct pid_namespace *pid = sb->s_fs_info; -if (pid->pid_gid) -seq_printf (seq,",gid=%lu" , (unsigned long )pid->pid_gid); +if (!gid_eq (pid->pid_gid,GLOBAL_ROOT_GID )) +seq_printf (seq,",gid=%u" ,from_kgid_munged (&init_user_ns, pid->pid_gid));if (pid->hide_pid !=0 )seq_printf (seq,",hidepid=%u" , pid->hide_pid);
fs/proc/root.c +1 -1
@@ -67,7 +67,7 @@ static int proc_parse_options(char *options, struct pid_namespace *pid)case Opt_gid:if (match_int (&args[0 ], &option))return 0 ; - pid->pid_gid = option; + pid->pid_gid =make_kgid (current_user_ns (), option);break ;case Opt_hidepid:if (match_int (&args[0 ], &option))
include/linux/pid_namespace.h +1 -1
@@ -31,7 +31,7 @@ struct pid_namespace {#ifdef CONFIG_BSD_PROCESS_ACCT struct bsd_acct_struct *bacct;#endif -gid_t pid_gid; +kgid_t pid_gid;int hide_pid;int reboot;/* group exit code if this pidns was rebooted */ };
include/linux/proc_fs.h +2 -2
@@ -52,8 +52,8 @@ struct proc_dir_entry {unsigned int low_ino;umode_t mode;nlink_t nlink; -uid_t uid; -gid_t gid; +kuid_t uid; +kgid_t gid;loff_t size;const struct inode_operations *proc_iops;/*
Signature · 1 line
1.7.2.5
PATCH 39/43 userns: Convert sysctl permission checks to use kuid and kgids.
In reply to Eric W. BiedermanFrom: Eric W. Biederman <[email protected]>
--- fs/proc/proc_sysctl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/proc/proc_sysctl.c +2 -2
@@ -371,9 +371,9 @@ void register_sysctl_root(struct ctl_table_root *root)static int test_perm (int mode,int op) { -if (!current_euid ()) +if (uid_eq (current_euid (),GLOBAL_ROOT_UID )) mode >>=6 ; -else if (in_egroup_p (0 )) +else if (in_egroup_p (GLOBAL_ROOT_GID )) mode >>=3 ;if ((op & ~mode & (MAY_READ |MAY_WRITE |MAY_EXEC )) ==0 )return 0 ;
Signature · 1 line
1.7.2.5
PATCH 40/43 userns: Convert sysfs to use kgid/kuid where appropriate
In reply to Eric W. BiedermanFrom: Eric W. Biederman <[email protected]>
--- fs/sysfs/inode.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/sysfs/inode.c +2 -2
@@ -62,8 +62,8 @@ static struct sysfs_inode_attrs *sysfs_init_inode_attrs(struct sysfs_dirent *sd)/* assign default attributes */ iattrs->ia_mode = sd->s_mode; - iattrs->ia_uid =0 ; - iattrs->ia_gid =0 ; + iattrs->ia_uid =GLOBAL_ROOT_UID ; + iattrs->ia_gid =GLOBAL_ROOT_GID ; iattrs->ia_atime = iattrs->ia_mtime = iattrs->ia_ctime =CURRENT_TIME ;return attrs;
Signature · 1 line
1.7.2.5
PATCH 41/43 userns: Convert tmpfs to use kuid and kgid where appropriate
In reply to Eric W. BiedermanFrom: Eric W. Biederman <[email protected]>
--- include/linux/shmem_fs.h | 4 ++-- mm/shmem.c | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-)
include/linux/shmem_fs.h +2 -2
@@ -28,8 +28,8 @@ struct shmem_sb_info {unsigned long max_inodes;/* How many inodes are allowed */ unsigned long free_inodes;/* How many are left for allocation */ spinlock_t stat_lock;/* Serialize shmem_sb_info changes */ -uid_t uid;/* Mount uid for root directory */ -gid_t gid;/* Mount gid for root directory */ +kuid_t uid;/* Mount uid for root directory */ +kgid_t gid;/* Mount gid for root directory */ umode_t mode;/* Mount mode for root directory */ struct mempolicy *mpol;/* default memory policy for mappings */ };
mm/shmem.c +16 -6
@@ -2075,6 +2075,8 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo, bool remount) {char *this_char, *value, *rest; +uid_t uid; +gid_t gid;while (options !=NULL ) { this_char = options;
@@ -2134,15 +2136,21 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo, }else if (!strcmp (this_char,"uid" )) {if (remount)continue ; - sbinfo->uid =simple_strtoul (value, &rest,0 ); + uid =simple_strtoul (value, &rest,0 );if (*rest) goto bad_val; + sbinfo->uid =make_kuid (current_user_ns (), uid); +if (!uid_valid (sbinfo->uid)) + goto bad_val; }else if (!strcmp (this_char,"gid" )) {if (remount)continue ; - sbinfo->gid =simple_strtoul (value, &rest,0 ); + gid =simple_strtoul (value, &rest,0 );if (*rest) goto bad_val; + sbinfo->gid =make_kgid (current_user_ns (), gid); +if (!gid_valid (sbinfo->gid)) + goto bad_val; }else if (!strcmp (this_char,"mpol" )) {if (mpol_parse_str (value, &sbinfo->mpol,1 )) goto bad_val;
@@ -2210,10 +2218,12 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root)seq_printf (seq,",nr_inodes=%lu" , sbinfo->max_inodes);if (sbinfo->mode != (S_IRWXUGO |S_ISVTX ))seq_printf (seq,",mode=%03ho" , sbinfo->mode); -if (sbinfo->uid !=0 ) -seq_printf (seq,",uid=%u" , sbinfo->uid); -if (sbinfo->gid !=0 ) -seq_printf (seq,",gid=%u" , sbinfo->gid); +if (!uid_eq (sbinfo->uid,GLOBAL_ROOT_UID )) +seq_printf (seq,",uid=%u" , +from_kuid_munged (&init_user_ns, sbinfo->uid)); +if (!gid_eq (sbinfo->gid,GLOBAL_ROOT_GID )) +seq_printf (seq,",gid=%u" , +from_kgid_munged (&init_user_ns, sbinfo->gid));shmem_show_mpol (seq, sbinfo->mpol);return 0 ; }
Signature · 1 line
1.7.2.5
PATCH 42/43 userns: Convert cgroup permission checks to use uid_eq
In reply to Eric W. BiedermanFrom: Eric W. Biederman <[email protected]>
--- kernel/cgroup.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
kernel/cgroup.c +3 -3
@@ -2160,9 +2160,9 @@ retry_find_task:* only need to check permissions on one of them. */ tcred =__task_cred (tsk); -if (cred->euid && - cred->euid != tcred->uid && - cred->euid != tcred->suid) { +if (!uid_eq (cred->euid,GLOBAL_ROOT_UID ) && + !uid_eq (cred->euid, tcred->uid) && + !uid_eq (cred->euid, tcred->suid)) {rcu_read_unlock (); ret = -EACCES ; goto out_unlock_cgroup;
Signature · 1 line
1.7.2.5
PATCH 43/43 userns: Convert the move_pages, and migrate_pages permission checks to use uid_eq
In reply to Eric W. BiedermanFrom: Eric W. Biederman <[email protected]>
--- mm/mempolicy.c | 4 ++-- mm/migrate.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
mm/mempolicy.c +2 -2
@@ -1334,8 +1334,8 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,* userid as the target process. */ tcred =__task_cred (task); -if (cred->euid != tcred->suid && cred->euid != tcred->uid && - cred->uid != tcred->suid && cred->uid != tcred->uid && +if (!uid_eq (cred->euid, tcred->suid) && !uid_eq (cred->euid, tcred->uid) && + !uid_eq (cred->uid, tcred->suid) && !uid_eq (cred->uid, tcred->uid) && !capable (CAP_SYS_NICE )) {rcu_read_unlock (); err = -EPERM ;
mm/migrate.c +2 -2
@@ -1371,8 +1371,8 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,* userid as the target process. */ tcred =__task_cred (task); -if (cred->euid != tcred->suid && cred->euid != tcred->uid && - cred->uid != tcred->suid && cred->uid != tcred->uid && +if (!uid_eq (cred->euid, tcred->suid) && !uid_eq (cred->euid, tcred->uid) && + !uid_eq (cred->uid, tcred->suid) && !uid_eq (cred->uid, tcred->uid) && !capable (CAP_SYS_NICE )) {rcu_read_unlock (); err = -EPERM ;
Signature · 1 line
1.7.2.5
Thanks, Eric.
While this approach has limitations and administrative overhead which I'd prefer it didn't, it also has huge benefits, especially faster id comparisons and, most importantly, type safety enforcing that the right kinds of uids are compared.
So I endorse this approach.
I've reviewed and acked many of the patches, some I still had questions on, but the approach as a whole gets an ack from me.
thanks,
-serge
Quoted 3 lines · Eric W. Biederman
- Capabilities are localized to the current user namespace making it safe to give the initial user in a user namespace all capabilities.
So, this makes LXC and friends ready for hostile environments? IOW a root user (with all capabilities) sitting in his own namespace can no longer ham the host?
Signature · 6 lines
Thanks, //richard -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · richard -rw- weinberger
Quoted 3 lines · Eric W. Biederman
- Capabilities are localized to the current user namespace making it safe to give the initial user in a user namespace all capabilities.
So, this makes LXC and friends ready for hostile environments? IOW a root user (with all capabilities) sitting in his own namespace can no longer ham the host?
The user namespace now restricts the root user in a container to being able to do no more harm than any other user can do. Additionally suid executables can no longer lead to having all power on the system. Which means that the only privilege escalation attacks available from a container require kernel bugs.
With my version of user namespaces you no longer have to worry about the container root writing to files in /proc or /sys and changing the behavior of the system. Nor do you have to worry about messages passed across unix domain sockets to d-bus having a trusted uid and being allowed to do something nasty.
It allows for applications with no capabilities to use multiple uids and to implement privilege separation.
I certainly see user namespaces like this as having the potential to make linux systems more secure.
You will have to make your own threat assessment to decide if that is enough of an improvement to start deploying containers in what you consider hostile environments.
For me the big potential I see is that it makes possible the creation of a container without privilege (today the uid mapping setup still requires privilege), and it allows a lot of things that the existence of suid root executables has prevented us from making unprivileged before.
After the core is settled we can start looking at patches to allow unprivileged creation of other namespaces. Unprivileged mounts. Unprivileged use of the networking stack. Bringing many of the improvements that linux has seen over the years to unprivileged users.
I also see great potential for April fools day jokes. You log in and try to fix something and discover you are not the root you thought you were. Does that count as a hostile environment?
Eric
Quoted 46 lines · Eric W. Biederman
Quoted 8 lines · richard -rw- weinberger
Quoted 3 lines · Eric W. Biederman
- Capabilities are localized to the current user namespace making it safe to give the initial user in a user namespace all capabilities.
So, this makes LXC and friends ready for hostile environments? IOW a root user (with all capabilities) sitting in his own namespace can no longer ham the host?
The user namespace now restricts the root user in a container to being able to do no more harm than any other user can do. Additionally suid executables can no longer lead to having all power on the system. Which means that the only privilege escalation attacks available from a container require kernel bugs.
With my version of user namespaces you no longer have to worry about the container root writing to files in /proc or /sys and changing the behavior of the system. Nor do you have to worry about messages passed across unix domain sockets to d-bus having a trusted uid and being allowed to do something nasty.
It allows for applications with no capabilities to use multiple uids and to implement privilege separation.
I certainly see user namespaces like this as having the potential to make linux systems more secure.
You will have to make your own threat assessment to decide if that is enough of an improvement to start deploying containers in what you consider hostile environments.
For me the big potential I see is that it makes possible the creation of a container without privilege (today the uid mapping setup still requires privilege), and it allows a lot of things that the existence of suid root executables has prevented us from making unprivileged before.
After the core is settled we can start looking at patches to allow unprivileged creation of other namespaces. Unprivileged mounts. Unprivileged use of the networking stack. Bringing many of the improvements that linux has seen over the years to unprivileged users.
Quoted 4 lines
I also see great potential for April fools day jokes. You log in and try to fix something and discover you are not the root you thought you were. Does that count as a hostile environment?
Yep. Sounds great!
I'll give your patch set a try within the next few days on my LXC testbed. :-)
Signature · 2 lines
Thanks, //richard
Quoted 7 lines · richard -rw- weinberger
Quoted 1 line · Eric W. Biederman
richard -rw- weinberger <[email protected]> writes:
Yep. Sounds great!
I'll give your patch set a try within the next few days on my LXC testbed. :-)
Sounds good.
The big practical detail to work out is all of the userspace bits for the uid and gid mappings. Assigning multiple uids per each user and things like that. Which I expect ultimately means updating the shadow package to set it up so that we reserve a bunch of uids and gids for each user when their accounts are added.
Eric
A message that is not in the archive (sent off-list or not yet received): CAFLxGvwHtA028V2XudM-5HXmXCPw5ENL5E_nHKZh_gbrsRV69g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 7 lines · richard -rw- weinberger
Quoted 1 line · Eric W. Biederman
richard -rw- weinberger <[email protected]> writes:
Yep. Sounds great!
I'll give your patch set a try within the next few days on my LXC testbed. :-)
Sounds good.
The big practical detail to work out is all of the userspace bits for the uid and gid mappings. Assigning multiple uids per each user and things like that. Which I expect ultimately means updating the shadow package to set it up so that we reserve a bunch of uids and gids for each user when their accounts are added.
Eric
Quoted 16 lines · Eric W. Biederman
This is a course correction for the user namespace, so that we can reach an inexpensive, maintainable, and reasonably complete implementation.
If anyone can think of a reason why the user namespace should not evolve in the direction taken in this patchset please let me know.
There is not an obvious maintainer for the scope of what this patchset covers so I intend to host this tree myself and to place it in linux-next after this round of review.
Highlights.
- The kernel will now fail to build if you attempt to compile in code whose permission checks have not been updated to be user namespace safe.
Quoted 4 lines
- All uids from child user namespaces are mapped into the initial user namespace before they are processed. Removing the need to add an additional check to see if the user namespace of the compared uids remains the same.
[...]
I haven't read enough of the details to figure out how the uid mapping works (do all the child namespace uids map to the same parent uid?), so I may be missing some details here.
As a bit of background, the no_new_privs mode introduced in the big seccomp patchset will add a flag that any task can set to prevent it or any of its children from gaining privileges by using execve.
How should this interact with pid namespaces? As a first pass, I imagine that the main PR_SET_NO_NEW_PRIVS(1) mode will prevent setuid from working inside uid namespaces as well, but there may be interest in weaker variants that allow setuid inside namespaces.
Any thoughts?
--Andy
Quoted 22 lines · Andy Lutomirski
Quoted 16 lines · Eric W. Biederman
This is a course correction for the user namespace, so that we can reach an inexpensive, maintainable, and reasonably complete implementation.
If anyone can think of a reason why the user namespace should not evolve in the direction taken in this patchset please let me know.
There is not an obvious maintainer for the scope of what this patchset covers so I intend to host this tree myself and to place it in linux-next after this round of review.
Highlights.
- The kernel will now fail to build if you attempt to compile in code whose permission checks have not been updated to be user namespace safe.Quoted 4 lines
- All uids from child user namespaces are mapped into the initial user namespace before they are processed. Removing the need to add an additional check to see if the user namespace of the compared uids remains the same.
Quoted 5 lines
[...]
I haven't read enough of the details to figure out how the uid mapping works (do all the child namespace uids map to the same parent uid?), so I may be missing some details here.
You seem to be missing a detail or two.
What you want to look at are the functions make_kuid and from_kuid in kernel/user_namespace.c You might look at the patches that talk about uidgid.h and introducing a mapping layer.
The implementation creates an incomplete but 1-1 mapping to the uids in the initial user namespace. Which means except for the change in datatype (sigh) the existing permission checks don't need to be changed.
I change the data type from uid_t to kuid_t for everything internal and make them assignment incompatible to force the use of make_kuid and from_kuid at the boundaries of user space, and of the filesystems and unfortunately that means uid comparisons themselves must change a little. aka uid_eq. instead of == . That grand search and replace is probably the scariest bit of this patchset.
Quoted 5 lines
As a bit of background, the
no_new_privsmode introduced in the big seccomp patchset will add a flag that any task can set to prevent it or any of its children from gaining privileges by using execve.How should this interact with pid namespaces?
I assume you mean uid namespaces? I don't expect pid namespaces will have any effect.
Quoted 6 lines
As a first pass, I
imagine that the mainPR_SET_NO_NEW_PRIVS(1)mode will prevent setuid from working inside uid namespaces as well, but there may be interest in weaker variants that allow setuid inside namespaces.Any thoughts?
It looks like a big strength of seccomp is reducing the attack surface of the kernel. The user namespace will actually increase that attack surface by making much more of the functionality available. So on that level they are very different mechanisms.
My understanding of no_new_privs is that current_cred() including the user, the user namespace and the security label will never change, with the goal of making the security analysis simple.
I don't recall how seccomp filters are dealt with if you don't have no_new_privs enabled. If seccomp filters installed by root are dropped when we change privilege levels it might be worth looking at how to keep a seccomp filter installed as long as you stay in a user namespace.
There are essentially two modes you can use the user namespace in:
with mappings setup (a privileged operation) and with no mappings.
With no mappings you can not create a new user namespace or change or uid or gids, and suid exec fails (or possibly ignores the uid/gid change but I am starting with suid exec fails). Making user namespaces similar to no_new_privs.
The emphasis is a bit different from new_new_privs as the user_namespace does not need to guarantee that the lsm will not change security labels, etc.
At a basic level of interaction I expect no_new_privs will need to fail any change of the user namespace. As changing the user namespace changes current_cred(), and fundamentally allows more things to happen.
Overall I think the two mechanisms are complementary. I actually don't expect any fundamental conflicts in the code between user namespaces and no_new_privs I do expect conflicts in the patches, because some of the same code paths will be touched. Both approaches change exec and the user namespace implementation lightly touches every every permission check in the kernel.
Where seccomp focuses on making things secure the user namespace focuses on making things possible that were not before. In particular the user namespace makes it easily possible and generally safe to allow suid exec, creation of namespaces and allowing capable calls with respect to namespaces we have created.
With both mechanisms in play I would expect the implementation of no_new_privs to be able focus on limiting the attack surface and not have to worry about allowing more kernel functionality to be used. While the user namespaces can then focus on increasing the functionality exported to unprivileged users.
Eric
Quoted 32 lines · Eric W. Biederman
Quoted 22 lines · Andy Lutomirski
Quoted 16 lines · Eric W. Biederman
This is a course correction for the user namespace, so that we can reach an inexpensive, maintainable, and reasonably complete implementation.
If anyone can think of a reason why the user namespace should not evolve in the direction taken in this patchset please let me know.
There is not an obvious maintainer for the scope of what this patchset covers so I intend to host this tree myself and to place it in linux-next after this round of review.
Highlights.
- The kernel will now fail to build if you attempt to compile in code whose permission checks have not been updated to be user namespace safe.Quoted 4 lines
- All uids from child user namespaces are mapped into the initial user namespace before they are processed. Removing the need to add an additional check to see if the user namespace of the compared uids remains the same.
Quoted 5 lines
[...]
I haven't read enough of the details to figure out how the uid mapping works (do all the child namespace uids map to the same parent uid?), so I may be missing some details here.
You seem to be missing a detail or two.
Quoted 7 lines
What you want to look at are the functions
make_kuidandfrom_kuidinkernel/user_namespace.cYou might look at the patches that talk aboutuidgid.hand introducing a mapping layer.The implementation creates an incomplete but 1-1 mapping to the uids in the initial user namespace. Which means except for the change in datatype (sigh) the existing permission checks don't need to be changed.
I'll do my homework at the same time that I write up docs for no_new_privs (i.e. maybe today).
Quoted 4 lines
My understanding of
no_new_privsis thatcurrent_cred()including the user, the user namespace and the security label will never change, with the goal of making the security analysis simple.
They can change but only if you already have the privilege to change them yourself and then you do so. For example, PR_SET_NO_NEW_PRIVS, setuid, then drop caps is allowed and useful -- it's a race-free way to make sure that a given uid never executes without no_new_privs set.
I've implemented this as a pam module.
This still simplifies security analysis: the guarantee is that, if no_new_privs is set, then a task's children cannot do anything that the task could do on it's own. Therefore it's safe for the task to manipulate its own environment in whatever strange ways it wants, because even if that gives it the ability to subvert its children, there is no privilege gained.
Quoted 7 lines
I don't recall how seccomp filters are dealt with if you don't have
no_new_privsenabled. If seccomp filters installed by root are dropped when we change privilege levels it might be worth looking at how to keep a seccomp filter installed as long as you stay in a user namespace.
They're not dropped. I think in the current implementation they can't be dropped at all.
Quoted 5 lines
There are essentially two modes you can use the user namespace in:
with mappings setup (a privileged operation) and with no mappings.
Quoted 8 lines
With no mappings you can not create a new user namespace or change or uid or gids, and suid exec fails (or possibly ignores the uid/gid change but I am starting with suid exec fails). Making user namespaces similar to
no_new_privs.The emphasis is a bit different from
new_new_privsas theuser_namespacedoes not need to guarantee that the lsm will not change security labels, etc.
Hmm. Is this safe? For example, if there's a program that LSM policy grants extra privileges that malfunctions when run inside a user namespace, can that be used to break out of LSM restrictions?
Quoted 4 lines
At a basic level of interaction I expect
no_new_privswill need to fail any change of the user namespace. As changing the user namespace changescurrent_cred(), and fundamentally allows more things to happen.
If a user namespace has no visible effect on processes that aren't descendents of whoever created it, then creating one in no_new_privs mode should be safe. On the other hand, it could be somewhat useless.
--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Andrew Lutomirski
Quoted 4 lines · Eric W. Biederman
With no mappings you can not create a new user namespace or change or uid or gids, and suid exec fails (or possibly ignores the uid/gid change but I am starting with suid exec fails). Making user namespaces similar to
no_new_privs.Hmm. Is this safe? For example, if there's a program that LSM policy grants extra privileges that malfunctions when run inside a user namespace, can that be used to break out of LSM restrictions?
Is creation without a mapping similar to some of the other CLONE_XXX flags that essentially give you a new anonymous and ephemeral namespace? Or does it just give you a 1:1 mapping to the parent's namespace?
The former would conceivably be useful for sandboxing purposes. Every so often, it is desirable to run a process as a user id that is distinct from any other user id in the system. But this usually requires the explicit creation of a new entry in /etc/passwd; and of course it also takes a privileged user to switch to this new user id. So, unprivileged processes can usually not switch to a dedicated user id. I could see the benefit in being able to create an ephemeral anonymous user id.
Of course, if the kernel provided for anonymous user ids, this would have interesting semantics throughout the system. E.g. what happens if the process attempts to create a new file in /tmp. Would that be allowed? If so, who would be the owner of the file. Presumably, file systems don't have any way to represent the fact the user id is emphemeral. So, an application should be denied file system accesses unless they obtained a file descriptor that was opened outside of the namespace.
What happens if credentials are passed with SCM_CREDENTIALS? Do they get translated? Does this work in both directions (i.e. passing in and out of the namespace)?
What happens to permissions on files in /proc?
Can the creator of a namespace send signals to processes in the namespace? How about the reverse?
But maybe, this is just too complicated and anonymous ephemeral user is are not really doable.
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Markus Gutschke
Quoted 6 lines · Andrew Lutomirski
Quoted 4 lines · Eric W. Biederman
With no mappings you can not create a new user namespace or change or uid or gids, and suid exec fails (or possibly ignores the uid/gid change but I am starting with suid exec fails). Making user namespaces similar to
no_new_privs.
Quoted 7 lines
Quoted 3 lines
Hmm. Is this safe? For example, if there's a program that LSM policy grants extra privileges that malfunctions when run inside a user namespace, can that be used to break out of LSM restrictions?
Is creation without a mapping similar to some of the other
CLONE_XXXflags that essentially give you a new anonymous and ephemeral namespace?
Close. The primary purpose is to make it simpler to setup the mapping. Strictly speaking you are still running with your original user id, which just doesn't happen to map in a way that is useful for getuid(), or stat, but still works for the permission checks.
Quoted 1 line
Or does it just give you a 1:1 mapping to the parent's namespace?
There is no mapping setup. In the parent user namespace you see an unchanged uid. In the new user namespace you see your uid as overflowuid aka 65534 aka nobody.
Quoted 8 lines
The former would conceivably be useful for sandboxing purposes. Every so often, it is desirable to run a process as a user id that is distinct from any other user id in the system. But this usually requires the explicit creation of a new entry in
/etc/passwd; and of course it also takes a privileged user to switch to this new user id. So, unprivileged processes can usually not switch to a dedicated user id. I could see the benefit in being able to create an ephemeral anonymous user id.
You don't get an ephemeral/anonymous user id, but you do get sandboxed into the user namespace. Which ultimately will make other namespaces usable.
Quoted 8 lines
Of course, if the kernel provided for anonymous user ids, this would have interesting semantics throughout the system. E.g. what happens if the process attempts to create a new file in /tmp. Would that be allowed? If so, who would be the owner of the file. Presumably, file systems don't have any way to represent the fact the user id is emphemeral. So, an application should be denied file system accesses unless they obtained a file descriptor that was opened outside of the namespace.
Which is why I skipped that. The entire purpose of this patchset is to make it so that you always, always, always have a uid that maps into the initial user namespace. So as to avoid creating strange cases to consider in the permission checks or the rest of the logic throughout the kernel.
Quoted 8 lines
What happens if credentials are passed with
SCM_CREDENTIALS? Do they get translated? Does this work in both directions (i.e. passing in and out of the namespace)?What happens to permissions on files in /proc?
Can the creator of a namespace send signals to processes in the namespace? How about the reverse?
The logic is the uid in the initial user namespace is translated into whatever user namespaces you are in.
If the uid maps you get the mapped uid. If the uid does not map (the initial state) you get overflowuid.
Quoted 2 lines
But maybe, this is just too complicated and anonymous ephemeral user is are not really doable.
Which is why the user namespace needs this course correction I am putting it on. Too much pain for too little gain in dealing with uids that don't map in a useful way for the permission checks.
Adding the one extra constraint that uids always map to the initial user namespace makes the code fast and simple, at very little cost in flexibility.
Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 28 lines · Andrew Lutomirski
Quoted 10 lines · Eric W. Biederman
Quoted 6 lines · Andy Lutomirski
[...]
I haven't read enough of the details to figure out how the uid mapping works (do all the child namespace uids map to the same parent uid?), so I may be missing some details here.
You seem to be missing a detail or two.
Quoted 7 lines
What you want to look at are the functions
make_kuidandfrom_kuidinkernel/user_namespace.cYou might look at the patches that talk aboutuidgid.hand introducing a mapping layer.The implementation creates an incomplete but 1-1 mapping to the uids in the initial user namespace. Which means except for the change in datatype (sigh) the existing permission checks don't need to be changed.
I'll do my homework at the same time that I write up docs for
no_new_privs(i.e. maybe today).Quoted 4 lines
My understanding of
no_new_privsis thatcurrent_cred()including the user, the user namespace and the security label will never change, with the goal of making the security analysis simple.
Quoted 5 lines
They can change but only if you already have the privilege to change them yourself and then you do so. For example,
PR_SET_NO_NEW_PRIVS, setuid, then drop caps is allowed and useful -- it's a race-free way to make sure that a given uid never executes withoutno_new_privsset.
I've implemented this as a pam module.
Careful. There is the security_task_fix_setuid call that will raise your capabilities from cap->effective to cap->permitted if you call setuid(0). Which in the general case means you can regain all of the root privileges if you only have CAP_SETUID.
Quoted 14 lines
This still simplifies security analysis: the guarantee is that, if
no_new_privsis set, then a task's children cannot do anything that the task could do on it's own. Therefore it's safe for the task to manipulate its own environment in whatever strange ways it wants, because even if that gives it the ability to subvert its children, there is no privilege gained.Quoted 6 lines
I don't recall how seccomp filters are dealt with if you don't have
no_new_privsenabled. If seccomp filters installed by root are dropped when we change privilege levels it might be worth looking at how to keep a seccomp filter installed as long as you stay in a user namespace.
Quoted 2 lines
They're not dropped. I think in the current implementation they can't be dropped at all.
Which makes sense. Is this why you need no_new_privs? So you can't run
seccomp on higher privileged executables and confusing them into keeping privileges when they should not?
Quoted 9 lines
Quoted 9 lines
There are essentially two modes you can use the user namespace in:
with mappings setup (a privileged operation) and with no mappings.With no mappings you can not create a new user namespace or change or uid or gids, and suid exec fails (or possibly ignores the uid/gid change but I am starting with suid exec fails). Making user namespaces similar to
no_new_privs.
Quoted 7 lines
Quoted 3 lines
The emphasis is a bit different from
new_new_privsas theuser_namespacedoes not need to guarantee that the lsm will not change security labels, etc.Hmm. Is this safe? For example, if there's a program that LSM policy grants extra privileges that malfunctions when run inside a user namespace, can that be used to break out of LSM restrictions?
I can't see how it would not be safe.
Except for the user namespace pointer the state the LSM and the rest of the kernel sees is the same state the kernel sees. Aka userspace sees uid 0, the LSM does not. So I don't know why a LSM would get confused.
Beyond that it is a bug for an LSM to grant permissions beyond the core DAC model. So the worst I can see is an LSM not grokking user namespaces and getting confused and not restricting a process as much as the designer of the LSM would like.
Quoted 7 lines
Quoted 3 lines
At a basic level of interaction I expect
no_new_privswill need to fail any change of the user namespace. As changing the user namespace changescurrent_cred(), and fundamentally allows more things to happen.If a user namespace has no visible effect on processes that aren't descendents of whoever created it, then creating one in
no_new_privsmode should be safe. On the other hand, it could be somewhat useless.
Creating a user namespace will allowing a process access to more kernel facilities. Aka you can (or at least will be able to) create network namespaces and mount namespaces and the like. That increases the surface of the kernel an attacker can hit.
So in a perfect kernel there are no affects on others. In a scenario where you are limiting how much of the kernel a user can use I think you would want that.
Still given that you aren't doing the very restrictive current_cred() must not change I don't know how it matters, and a bpf based seccomp can pretty easily filter out new user namespace creation. Shrug.
Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 16 lines · Eric W. Biederman
Quoted 8 lines · Andrew Lutomirski
Quoted 5 lines · Eric W. Biederman
Andy Lutomirski <[email protected]> writes:
My understanding of
no_new_privsis thatcurrent_cred()including the user, the user namespace and the security label will never change, with the goal of making the security analysis simple.Quoted 5 lines
They can change but only if you already have the privilege to change them yourself and then you do so. For example,
PR_SET_NO_NEW_PRIVS, setuid, then drop caps is allowed and useful -- it's a race-free way to make sure that a given uid never executes withoutno_new_privsset. I've implemented this as a pam module.
Quoted 5 lines
Careful. There is the
security_task_fix_setuidcall that will raise your capabilities fromcap->effectivetocap->permittedif you call setuid(0). Which in the general case means you can regain all of the root privileges if you only haveCAP_SETUID.
That's fine. If you're running with CAP_SETUID and default securebits, then you effectively have all capabilities already and don't need to exploit setuid binaries to gain them. no_new_privs doesn't change that. If you don't want to be able to gain all privs, change securebits or drop CAP_SETUID. seccomp reduces the kernel attack surface; no_new_privs reduces the userspace attack surface. But see below...
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I don't recall how seccomp filters are dealt with if you don't have
no_new_privsenabled. If seccomp filters installed by root are dropped when we change privilege levels it might be worth looking at how to keep a seccomp filter installed as long as you stay in a user namespace.
Quoted 6 lines
Quoted 2 lines
They're not dropped. I think in the current implementation they can't be dropped at all.
Which makes sense. Is this why you need
no_new_privs? So you can't run seccomp on higher privileged executables and confusing them into keeping privileges when they should not?
Exactly. seccomp is flexible enough that it's probably possible to confuse many setuid executables with it.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
The emphasis is a bit different from
new_new_privsas theuser_namespacedoes not need to guarantee that the lsm will not change security labels, etc.Hmm. Is this safe? For example, if there's a program that LSM policy grants extra privileges that malfunctions when run inside a user namespace, can that be used to break out of LSM restrictions?
I can't see how it would not be safe.
Quoted 8 lines
Except for the user namespace pointer the state the LSM and the rest of the kernel sees is the same state the kernel sees. Aka userspace sees uid 0, the LSM does not. So I don't know why a LSM would get confused.
Beyond that it is a bug for an LSM to grant permissions beyond the core DAC model. So the worst I can see is an LSM not grokking user namespaces and getting confused and not restricting a process as much as the designer of the LSM would like.
Right. Suppose you have some program that has extra restrictions applied by an LSM. It executes a helper (e.g. Apache's suidexec thing, but I bet there are more examples) which is supposed to be very careful not to leak privileges. The LSM is set to restrict that helper less than the parent process. But that program was written before user namespaces existed, and it has a bug (or missing feature) that allows its parent to exploit it when run inside an unmapped user namespace. The parent can now escape from the LSM restrictions.
no_new_privs is designed to prevent exactly this issue.
Quoted 10 lines
Quoted 4 lines
If a user namespace has no visible effect on processes that aren't descendents of whoever created it, then creating one in
no_new_privsmode should be safe. On the other hand, it could be somewhat useless.Creating a user namespace will allowing a process access to more kernel facilities. Aka you can (or at least will be able to) create network namespaces and mount namespaces and the like. That increases the surface of the kernel an attacker can hit.
Quoted 7 lines
So in a perfect kernel there are no affects on others. In a scenario where you are limiting how much of the kernel a user can use I think you would want that.
Still given that you aren't doing the very restrictive
current_cred()must not change I don't know how it matters, and a bpf based seccomp can pretty easily filter out new user namespace creation. Shrug.
I'm not worried about that. I'm more interested in whether unprivileged user namespace creation should require nnp and/or whether someone might want a mode in which a task is has nnp set but can create a user namespace that allows setuid execution inside the namespace in spite of the nnp setting. The latter is probably rather complicated to get right and depends on nonexistent filesystem features.
--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 80 lines · Andrew Lutomirski
Quoted 16 lines · Eric W. Biederman
Quoted 8 lines · Andrew Lutomirski
Quoted 5 lines · Eric W. Biederman
Andy Lutomirski <[email protected]> writes:
My understanding of
no_new_privsis thatcurrent_cred()including the user, the user namespace and the security label will never change, with the goal of making the security analysis simple.Quoted 5 lines
They can change but only if you already have the privilege to change them yourself and then you do so. For example,
PR_SET_NO_NEW_PRIVS, setuid, then drop caps is allowed and useful -- it's a race-free way to make sure that a given uid never executes withoutno_new_privsset. I've implemented this as a pam module.Quoted 5 lines
Careful. There is the
security_task_fix_setuidcall that will raise your capabilities fromcap->effectivetocap->permittedif you call setuid(0). Which in the general case means you can regain all of the root privileges if you only haveCAP_SETUID.That's fine. If you're running with
CAP_SETUIDand default securebits, then you effectively have all capabilities already and don't need to exploit setuid binaries to gain them.no_new_privsdoesn't change that. If you don't want to be able to gain all privs, change securebits or dropCAP_SETUID. seccomp reduces the kernel attack surface;no_new_privsreduces the userspace attack surface. But see below...Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I don't recall how seccomp filters are dealt with if you don't have
no_new_privsenabled. If seccomp filters installed by root are dropped when we change privilege levels it might be worth looking at how to keep a seccomp filter installed as long as you stay in a user namespace.Quoted 6 lines
Quoted 2 lines
They're not dropped. I think in the current implementation they can't be dropped at all.
Which makes sense. Is this why you need
no_new_privs? So you can't run seccomp on higher privileged executables and confusing them into keeping privileges when they should not?Exactly. seccomp is flexible enough that it's probably possible to confuse many setuid executables with it.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
The emphasis is a bit different from
new_new_privsas theuser_namespacedoes not need to guarantee that the lsm will not change security labels, etc.Hmm. Is this safe? For example, if there's a program that LSM policy grants extra privileges that malfunctions when run inside a user namespace, can that be used to break out of LSM restrictions?
I can't see how it would not be safe.
Quoted 8 lines
Except for the user namespace pointer the state the LSM and the rest of the kernel sees is the same state the kernel sees. Aka userspace sees uid 0, the LSM does not. So I don't know why a LSM would get confused.
Beyond that it is a bug for an LSM to grant permissions beyond the core DAC model. So the worst I can see is an LSM not grokking user namespaces and getting confused and not restricting a process as much as the designer of the LSM would like.
Right. Suppose you have some program that has extra restrictions applied by an LSM. It executes a helper (e.g. Apache's suidexec thing, but I bet there are more examples) which is supposed to be very careful not to leak privileges. The LSM is set to restrict that helper less than the parent process. But that program was written before user namespaces existed, and it has a bug (or missing feature) that allows its parent to exploit it when run inside an unmapped user namespace. The parent can now escape from the LSM restrictions.
Quoted 1 line
no_new_privsis designed to prevent exactly this issue.
Currently the suid exec will fail because the uid's don't map.
I might switch that around to simply ignoring the change of uid on suid exec. I have a patch in my devel tree that plays with that idea. However as much as I hit that case once in testing (I think it was ping). I don't think running suid executables is particularly interesting.
Certainly the application program won't care or break, because we are still bounded by the usaual DAC security.
I wonder a little if the lsm might change labels on exec of a non suid binary. That case is more interesting in the unmapped unprivileged user namespace.
But I just can't seem to care. The LSM is the line behind which we hide the crazy.
The only real difference is that I can create namespaces, which are my process local environment. Unprivileged users setting up their own mount namespace will likely allow all kinds of ways to sneak through the path based protections of apparmor and tomoyo. As for smack and selinux shrug. I know selinux is at least a lot more path based than the developers like to admit. I know most of the /proc and /sys checks are path based, although I don't think they depend on where you mount things. I you can somehow trigger a selinux labelling spree with a different mount namespace selinux will like do some very wrong things. smack is simple so it will probably work as intended.
Shrug. There is nothing special here with the unmapped uid case of user namespaces. This is all things that have to be dealt with in some fashion, but I do believe that is for the LSM maintainers to worry about.
Quoted 17 lines
Quoted 9 lines
Quoted 3 lines
If a user namespace has no visible effect on processes that aren't descendents of whoever created it, then creating one in
no_new_privsmode should be safe. On the other hand, it could be somewhat useless.Creating a user namespace will allowing a process access to more kernel facilities. Aka you can (or at least will be able to) create network namespaces and mount namespaces and the like. That increases the surface of the kernel an attacker can hit.
Quoted 7 lines
So in a perfect kernel there are no affects on others. In a scenario where you are limiting how much of the kernel a user can use I think you would want that.
Still given that you aren't doing the very restrictive
current_cred()must not change I don't know how it matters, and a bpf based seccomp can pretty easily filter out new user namespace creation. Shrug.
Quoted 7 lines
I'm not worried about that. I'm more interested in whether unprivileged user namespace creation should require nnp and/or whether someone might want a mode in which a task is has nnp set but can create a user namespace that allows setuid execution inside the namespace in spite of the nnp setting. The latter is probably rather complicated to get right and depends on nonexistent filesystem features.
Hmm. If the goals is to avoid confusing lsms, I think when the user namespaces and no new privs meet it becomes sensible for no new privs to deny user namespace fiddling. No clone(CLONE_NEWUSER), no unshare(CLONE_NEWUSER) no setns(CLONE_NEWUSER). It becomes trivial to confuse path based lsms.
If the goal is to avoid confusing privileged executables with seccomp, I don't think it matters. The user namespace guarantees you can't get additional privileges.
As for requiring no new privs for creating a user namespace, ick. I think that will just break things. suid exec is otherwise safe in a user namespace and it needs to be supported. If the LSMs have problems the LSMs need to figure out how to cope.
I do think no new privs makes sense inside a user namespace exactly the same way it makes sense if you don't think about user namespaces.
So I expect a really tight security policy use a user_namespace + seccomp + no new privs.
Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 95 lines · Eric W. Biederman
Quoted 80 lines · Andrew Lutomirski
Quoted 16 lines · Eric W. Biederman
Quoted 8 lines · Andrew Lutomirski
Quoted 5 lines · Eric W. Biederman
Andy Lutomirski <[email protected]> writes:
My understanding of
no_new_privsis thatcurrent_cred()including the user, the user namespace and the security label will never change, with the goal of making the security analysis simple.Quoted 5 lines
They can change but only if you already have the privilege to change them yourself and then you do so. For example,
PR_SET_NO_NEW_PRIVS, setuid, then drop caps is allowed and useful -- it's a race-free way to make sure that a given uid never executes withoutno_new_privsset. I've implemented this as a pam module.Quoted 5 lines
Careful. There is the
security_task_fix_setuidcall that will raise your capabilities fromcap->effectivetocap->permittedif you call setuid(0). Which in the general case means you can regain all of the root privileges if you only haveCAP_SETUID.That's fine. If you're running with
CAP_SETUIDand default securebits, then you effectively have all capabilities already and don't need to exploit setuid binaries to gain them. no_new_privs doesn't change that. If you don't want to be able to gain all privs, change securebits or dropCAP_SETUID. seccomp reduces the kernel attack surface;no_new_privsreduces the userspace attack surface. But see below...Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I don't recall how seccomp filters are dealt with if you don't have
no_new_privsenabled. If seccomp filters installed by root are dropped when we change privilege levels it might be worth looking at how to keep a seccomp filter installed as long as you stay in a user namespace.Quoted 6 lines
Quoted 2 lines
They're not dropped. I think in the current implementation they can't be dropped at all.
Which makes sense. Is this why you need
no_new_privs? So you can't run seccomp on higher privileged executables and confusing them into keeping privileges when they should not?Exactly. seccomp is flexible enough that it's probably possible to confuse many setuid executables with it.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
The emphasis is a bit different from
new_new_privsas theuser_namespacedoes not need to guarantee that the lsm will not change security labels, etc.Hmm. Is this safe? For example, if there's a program that LSM policy grants extra privileges that malfunctions when run inside a user namespace, can that be used to break out of LSM restrictions?
I can't see how it would not be safe.
Quoted 8 lines
Except for the user namespace pointer the state the LSM and the rest of the kernel sees is the same state the kernel sees. Aka userspace sees uid 0, the LSM does not. So I don't know why a LSM would get confused.
Beyond that it is a bug for an LSM to grant permissions beyond the core DAC model. So the worst I can see is an LSM not grokking user namespaces and getting confused and not restricting a process as much as the designer of the LSM would like.
Right. Suppose you have some program that has extra restrictions applied by an LSM. It executes a helper (e.g. Apache's suidexec thing, but I bet there are more examples) which is supposed to be very careful not to leak privileges. The LSM is set to restrict that helper less than the parent process. But that program was written before user namespaces existed, and it has a bug (or missing feature) that allows its parent to exploit it when run inside an unmapped user namespace. The parent can now escape from the LSM restrictions.
Quoted 1 line
no_new_privsis designed to prevent exactly this issue.Currently the suid exec will fail because the uid's don't map.
I might switch that around to simply ignoring the change of uid on suid exec. I have a patch in my devel tree that plays with that idea. However as much as I hit that case once in testing (I think it was ping). I don't think running suid executables is particularly interesting.
Certainly the application program won't care or break, because we are still bounded by the usaual DAC security.
Quoted 6 lines
I wonder a little if the lsm might change labels on exec of a non suid binary. That case is more interesting in the unmapped unprivileged user namespace.
But I just can't seem to care. The LSM is the line behind which we hide the crazy.
Sounds like you're reinventing (something very similar to) no_new_privs. Why not just require no_new_privs as a prerequisite for creating a user namespace if you're unprivileged?
--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Andrew Lutomirski
On Tue, Apr 10, 2012 at 6:01 PM, Eric W. Biederman <[email protected]> wrote:
Sounds like you're reinventing (something very similar to)
no_new_privs. Why not just requireno_new_privsas a prerequisite for creating a user namespace if you're unprivileged?
As I said in the part of my email you snipped, because no_new_privs will break suid exec in the user namespace.
I am most definitely not going to require something that will make implementing/using user namespaces almost pointless.
Eric
Quoted 9 lines · Eric W. Biederman
Quoted 6 lines · Andrew Lutomirski
On Tue, Apr 10, 2012 at 6:01 PM, Eric W. Biederman <[email protected]> wrote:
Sounds like you're reinventing (something very similar to)
no_new_privs. Why not just requireno_new_privsas a prerequisite for creating a user namespace if you're unprivileged?
Quoted 5 lines
As I said in the part of my email you snipped, because
no_new_privswill break suid exec in the user namespace.I am most definitely not going to require something that will make implementing/using user namespaces almost pointless.
This part:
Quoted 7 lines
Currently the suid exec will fail because the uid's don't map.
I might switch that around to simply ignoring the change of uid on suid exec. I have a patch in my devel tree that plays with that idea. However as much as I hit that case once in testing (I think it was ping). I don't think running suid executables is particularly interesting.
I'm totally lost now. I'll wait until I play around with the patches some more.
--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 11 lines · Eric W. Biederman
Quoted 6 lines · Andrew Lutomirski
On Tue, Apr 10, 2012 at 6:01 PM, Eric W. Biederman <[email protected]> wrote:
Sounds like you're reinventing (something very similar to)
no_new_privs. Why not just requireno_new_privsas a prerequisite for creating a user namespace if you're unprivileged?As I said in the part of my email you snipped, because
no_new_privswill break suid exec in the user namespace.
Andrew,
note that once you create a new user namespace, you cannot change your credentials in the ancestor user namespaces. So in effect you already have no_new_privs for those namespaces.
So if I'm uid 1001 and I create a task in a new user namespace where 50000 on host is mapped to uid 0 in userns. Now I try to execute a file belonging to uid 500 on the host and setuid. Note that 500 is not mapped into my user namespace. That is what Eric meant by either exec being refused or setuid being ignored. Either way, the file would be executed using uid 50000 on the host (and 0 in the user namespace).
-serge
Quoted 92 lines · Eric W. Biederman
Quoted 80 lines · Andrew Lutomirski
Quoted 16 lines · Eric W. Biederman
Quoted 8 lines · Andrew Lutomirski
Quoted 5 lines · Eric W. Biederman
Andy Lutomirski <[email protected]> writes:
My understanding of
no_new_privsis thatcurrent_cred()including the user, the user namespace and the security label will never change, with the goal of making the security analysis simple.Quoted 5 lines
They can change but only if you already have the privilege to change them yourself and then you do so. For example,
PR_SET_NO_NEW_PRIVS, setuid, then drop caps is allowed and useful -- it's a race-free way to make sure that a given uid never executes withoutno_new_privsset. I've implemented this as a pam module.Quoted 5 lines
Careful. There is the
security_task_fix_setuidcall that will raise your capabilities fromcap->effectivetocap->permittedif you call setuid(0). Which in the general case means you can regain all of the root privileges if you only haveCAP_SETUID.That's fine. If you're running with
CAP_SETUIDand default securebits, then you effectively have all capabilities already and don't need to exploit setuid binaries to gain them.no_new_privsdoesn't change that. If you don't want to be able to gain all privs, change securebits or dropCAP_SETUID. seccomp reduces the kernel attack surface;no_new_privsreduces the userspace attack surface. But see below...Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I don't recall how seccomp filters are dealt with if you don't have
no_new_privsenabled. If seccomp filters installed by root are dropped when we change privilege levels it might be worth looking at how to keep a seccomp filter installed as long as you stay in a user namespace.Quoted 6 lines
Quoted 2 lines
They're not dropped. I think in the current implementation they can't be dropped at all.
Which makes sense. Is this why you need
no_new_privs? So you can't run seccomp on higher privileged executables and confusing them into keeping privileges when they should not?Exactly. seccomp is flexible enough that it's probably possible to confuse many setuid executables with it.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
The emphasis is a bit different from
new_new_privsas theuser_namespacedoes not need to guarantee that the lsm will not change security labels, etc.Hmm. Is this safe? For example, if there's a program that LSM policy grants extra privileges that malfunctions when run inside a user namespace, can that be used to break out of LSM restrictions?
I can't see how it would not be safe.
Quoted 8 lines
Except for the user namespace pointer the state the LSM and the rest of the kernel sees is the same state the kernel sees. Aka userspace sees uid 0, the LSM does not. So I don't know why a LSM would get confused.
Beyond that it is a bug for an LSM to grant permissions beyond the core DAC model. So the worst I can see is an LSM not grokking user namespaces and getting confused and not restricting a process as much as the designer of the LSM would like.
Right. Suppose you have some program that has extra restrictions applied by an LSM. It executes a helper (e.g. Apache's suidexec thing, but I bet there are more examples) which is supposed to be very careful not to leak privileges. The LSM is set to restrict that helper less than the parent process. But that program was written before user namespaces existed, and it has a bug (or missing feature) that allows its parent to exploit it when run inside an unmapped user namespace. The parent can now escape from the LSM restrictions.
Quoted 1 line
no_new_privsis designed to prevent exactly this issue.Currently the suid exec will fail because the uid's don't map.
I might switch that around to simply ignoring the change of uid on suid exec. I have a patch in my devel tree that plays with that idea. However as much as I hit that case once in testing (I think it was ping). I don't think running suid executables is particularly interesting.
Quoted 6 lines
Certainly the application program won't care or break, because we are still bounded by the usaual DAC security.
I wonder a little if the lsm might change labels on exec of a non suid binary. That case is more interesting in the unmapped unprivileged user namespace.
They will (change labels on exec of non suid binary). But. First, any well behaved user of user namespaces will switch to a (selinux, smack, apparmor, whatever) context which is aware it is namespaced so that only desired transitions happen. So we're left with the concern of uid 1001 creates an unprivileged user namespace and runs a program (as uid 0) which transitions him to uber_client_t. Since as Eric has pointed out the MAC can't override the DAC rules, it still won't be able to write to files not owned by uid 1001 in the initial user namespace. We might worry about it connecting to the privileged server and passing its uber_client_t credentials to pass a request. The server being in the initial user ns will get uid 1001, not 0.
Perhaps the client checks its uid (0 in its user namespace) and passes it to the server (as a simple message), which blindly accepts that. In that case the server could just as easily be exploited without user namespaces.
It's possible that there's another way this can be exploited, but I haven't thought of it yet.
-serge
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · Eric W. Biederman
Andrew Lutomirski <[email protected]> writes:
Still given that you aren't doing the very restrictivecurrent_cred()must not change I don't know how it matters, and a bpf based seccomp can pretty easily filter out new user namespace creation. Shrug.
I very much want and intend to use both user namespaces and seccomp2 together. Speaking in terms of the old userns implementation, once a container has been created, no child of my task will change uid/gid or gain/move capabilities in the original user namespace. But they're free to do so at will in the child user namespace. Since the capabilities are targeted at the child namespaces, that's fine. And as Eric noted the user namespaces will allow us to increase the attack surface, but at the same time I'm hoping to offset that somewhat using seccomp2.
-serge
Please include user-namespace.git in linux-next
In reply to Eric W. BiedermanIn linux-next please include git://pub/scm/linux/kernel/git/ebiederm/user-namespace.git for-next
This tree includes the fixed versions of the 43 patches I sent out for review a few weeks ago, plus an updated Kconfig options so the parts that won't build can't build can't be selected making allyesconfig and allnoconfig safe.
The discussion of this work was covered in lwn at:
http://lwn.net/Articles/491310
There are a bunch more trivial patches to go that still need to be reviewed but the core has been reviewed and tested left/right up/down and sideways and it looks like all of the bugs have fallen out.
Eric
Re: Please include user-namespace.git in linux-next
HI Eric,
Quoted 2 lines · On Fri, 11 May 2012 16:20:54 -0700 ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]…
In linux-next please include
git://pub/scm/linux/kernel/git/ebiederm/user-namespace.gitfor-next
I assume you left out "git.kernel.org/" :-)
Included from today.
Thanks for adding your subsystem tree as a participant of linux-next. As you may know, this is not a judgment of your code. The purpose of linux-next is for integration testing and to lower the impact of conflicts between subsystems in the next merge window.
You will need to ensure that the patches/commits in your tree/series have been:
* submitted under GPL v2 (or later) and include the Contributor's Signed-off-by,
* posted to the relevant mailing list,
* reviewed by you (or another maintainer of your subsystem tree),
* successfully unit tested, and
* destined for the current or next Linux merge window.
Basically, this should be just what you would send to Linus (or ask him to fetch). It is allowed to be rebased if you deem it necessary.
Signature · 15 lines
Cheers, Stephen Rothwell [email protected] Legal Stuff: By participating in linux-next, your subsystem tree contributions are public and will be included in the linux-next trees. You may be sent e-mail messages indicating errors or other issues when the patches/commits from your subsystem tree are merged and tested in linux-next. These messages may also be cross-posted to the linux-next mailing list, the linux-kernel mailing list, etc. The linux-next tree project and IBM (my employer) make no warranties regarding the linux-next project, the testing procedures, the results, the e-mails, etc. If you don't agree to these ground rules, let me know and I'll remove your tree from participation in linux-next.
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linuxfoundation.org/mailman/listinfo/containers
Re: Please include user-namespace.git in linux-next
In reply to Eric W. BiedermanI think something is wrong with commit e1c972b6 "userns: Add negative depends on entries to avoid building code that is userns unsafe".
With gcc 4.4.6 on CentOS 6.2, "make allnoconfig" where UIDGID_CONVERTED should become y is showing
Symbol: USER_NS [=n]
Type : boolean
Prompt: User namespace (EXPERIMENTAL)
Defined at init/Kconfig:880
Depends on: NAMESPACES [=y] && EXPERIMENTAL [=n] && UIDGID_CONVERTED [=n] Location:
-> General setup
-> Namespaces support (NAMESPACES [=y]) Selects: UIDGID_STRICT_TYPE_CHECKS [=n]
.
I think this commit meant "!FOO" rather than "FOO = n", othwewise there is no way for linux-next-20120518 to enable USER_NS.
----------------------------------------
PATCH: user_ns: Fix wrong dependency in UIDGID_CONVERTED.
"depends on FOO = n" should be "depends on !FOO".
----------
init/Kconfig +96 -96
@@ -917,110 +917,110 @@ config UIDGID_CONVERTED # List of kernel pieces that need user namespace work # Features - depends on SYSVIPC = n - depends on IMA = n - depends on EVM = n - depends on KEYS = n - depends on AUDIT = n - depends on AUDITSYSCALL = n - depends on TASKSTATS = n - depends on TRACING = n - depends on FS_POSIX_ACL = n - depends on QUOTA = n - depends on QUOTACTL = n - depends on DEBUG_CREDENTIALS = n - depends on BSD_PROCESS_ACCT = n - depends on DRM = n - depends on PROC_EVENTS = n + depends on !SYSVIPC + depends on !IMA + depends on !EVM + depends on !KEYS + depends on !AUDIT + depends on !AUDITSYSCALL + depends on !TASKSTATS + depends on !TRACING + depends on !FS_POSIX_ACL + depends on !QUOTA + depends on !QUOTACTL + depends on !DEBUG_CREDENTIALS + depends on !BSD_PROCESS_ACCT + depends on !DRM + depends on !PROC_EVENTS # Networking - depends on NET = n - depends on NET_9P = n - depends on IPX = n - depends on PHONET = n - depends on NET_CLS_FLOW = n - depends on NETFILTER_XT_MATCH_OWNER = n - depends on NETFILTER_XT_MATCH_RECENT = n - depends on NETFILTER_XT_TARGET_LOG = n - depends on NETFILTER_NETLINK_LOG = n - depends on INET = n - depends on IPV6 = n - depends on IP_SCTP = n - depends on AF_RXRPC = n - depends on LLC2 = n - depends on NET_KEY = n - depends on INET_DIAG = n - depends on DNS_RESOLVER = n - depends on AX25 = n - depends on ATALK = n + depends on !NET + depends on !NET_9P + depends on !IPX + depends on !PHONET + depends on !NET_CLS_FLOW + depends on !NETFILTER_XT_MATCH_OWNER + depends on !NETFILTER_XT_MATCH_RECENT + depends on !NETFILTER_XT_TARGET_LOG + depends on !NETFILTER_NETLINK_LOG + depends on !INET + depends on !IPV6 + depends on !IP_SCTP + depends on !AF_RXRPC + depends on !LLC2 + depends on !NET_KEY + depends on !INET_DIAG + depends on !DNS_RESOLVER + depends on !AX25 + depends on !ATALK # Filesystems - depends on USB_DEVICEFS = n - depends on USB_GADGETFS = n - depends on USB_FUNCTIONFS = n - depends on DEVTMPFS = n - depends on XENFS = n - - depends on 9P_FS = n - depends on ADFS_FS = n - depends on AFFS_FS = n - depends on AFS_FS = n - depends on AUTOFS4_FS = n - depends on BEFS_FS = n - depends on BFS_FS = n - depends on BTRFS_FS = n - depends on CEPH_FS = n - depends on CIFS = n - depends on CODA_FS = n - depends on CONFIGFS_FS = n - depends on CRAMFS = n - depends on DEBUG_FS = n - depends on ECRYPT_FS = n - depends on EFS_FS = n - depends on EXOFS_FS = n - depends on FAT_FS = n - depends on FUSE_FS = n - depends on GFS2_FS = n - depends on HFS_FS = n - depends on HFSPLUS_FS = n - depends on HPFS_FS = n - depends on HUGETLBFS = n - depends on ISO9660_FS = n - depends on JFFS2_FS = n - depends on JFS_FS = n - depends on LOGFS = n - depends on MINIX_FS = n - depends on NCP_FS = n - depends on NFSD = n - depends on NFS_FS = n - depends on NILFS2_FS = n - depends on NTFS_FS = n - depends on OCFS2_FS = n - depends on OMFS_FS = n - depends on QNX4FS_FS = n - depends on QNX6FS_FS = n - depends on REISERFS_FS = n - depends on SQUASHFS = n - depends on SYSV_FS = n - depends on UBIFS_FS = n - depends on UDF_FS = n - depends on UFS_FS = n - depends on VXFS_FS = n - depends on XFS_FS = n - - depends on !UML || HOSTFS = n + depends on !USB_DEVICEFS + depends on !USB_GADGETFS + depends on !USB_FUNCTIONFS + depends on !DEVTMPFS + depends on !XENFS + + depends on !9P_FS + depends on !ADFS_FS + depends on !AFFS_FS + depends on !AFS_FS + depends on !AUTOFS4_FS + depends on !BEFS_FS + depends on !BFS_FS + depends on !BTRFS_FS + depends on !CEPH_FS + depends on !CIFS + depends on !CODA_FS + depends on !CONFIGFS_FS + depends on !CRAMFS + depends on !DEBUG_FS + depends on !ECRYPT_FS + depends on !EFS_FS + depends on !EXOFS_FS + depends on !FAT_FS + depends on !FUSE_FS + depends on !GFS2_FS + depends on !HFS_FS + depends on !HFSPLUS_FS + depends on !HPFS_FS + depends on !HUGETLBFS + depends on !ISO9660_FS + depends on !JFFS2_FS + depends on !JFS_FS + depends on !LOGFS + depends on !MINIX_FS + depends on !NCP_FS + depends on !NFSD + depends on !NFS_FS + depends on !NILFS2_FS + depends on !NTFS_FS + depends on !OCFS2_FS + depends on !OMFS_FS + depends on !QNX4FS_FS + depends on !QNX6FS_FS + depends on !REISERFS_FS + depends on !SQUASHFS + depends on !SYSV_FS + depends on !UBIFS_FS + depends on !UDF_FS + depends on !UFS_FS + depends on !VXFS_FS + depends on !XFS_FS + + depends on !UML || !HOSTFS # The rare drivers that won't build - depends on AIRO = n - depends on AIRO_CS = n - depends on TUN = n - depends on INFINIBAND_QIB = n - depends on BLK_DEV_LOOP = n - depends on ANDROID_BINDER_IPC = n + depends on !AIRO + depends on !AIRO_CS + depends on !TUN + depends on !INFINIBAND_QIB + depends on !BLK_DEV_LOOP + depends on !ANDROID_BINDER_IPC # Security modules - depends on SECURITY_TOMOYO = n - depends on SECURITY_APPARMOR = n + depends on !SECURITY_TOMOYO + depends on !SECURITY_APPARMOR config UIDGID_STRICT_TYPE_CHECKS bool "Require conversions between uid/gids and their internal representation"
Re: Please include user-namespace.git in linux-next
Quoted 2 lines · Tetsuo Handa
I think something is wrong with commit
e1c972b6"userns: Add negative depends on entries to avoid building code that is userns unsafe".
My apologies for the delayed reply.
Quoted 11 lines
With gcc 4.4.6 on CentOS 6.2, "make allnoconfig" where
UIDGID_CONVERTEDshould become y is showingSymbol:
USER_NS[=n]
Type : boolean
Prompt: User namespace (EXPERIMENTAL)
Defined at init/Kconfig:880
Depends on: NAMESPACES [=y] && EXPERIMENTAL [=n] &&UIDGID_CONVERTED[=n] Location:-> General setup -> Namespaces support (NAMESPACES [=y])
Quoted 7 lines
Selects:
UIDGID_STRICT_TYPE_CHECKS[=n].
I think this commit meant "!FOO" rather than "FOO = n", othwewise there is no way for linux-next-20120518 to enableUSER_NS.
----------------------------------------
PATCH:user_ns: Fix wrong dependency inUIDGID_CONVERTED.
It turns out to be more subtle than that. The issue is that I have "depends on USB_DEVICEFS = n" and then USB_DEVICEFS was removed.
"depends on FOO = n" is the only way I found that will succeed when in verifying that FOO is neither enabled nor modular. "depends on !FOO" appears to succeed when FOO = m which is not at all what I want.
After both trees are merged I will have to remove that "depends on USB_DEVICEFS = n" dependency.
I can't see any possible way to do hand this before then.
Eric