Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'master' of git://git.infradead.org/users/eparis/selinux into next

+594 -323
+7 -6
fs/btrfs/inode.c
··· 90 90 unsigned long *nr_written, int unlock); 91 91 92 92 static int btrfs_init_inode_security(struct btrfs_trans_handle *trans, 93 - struct inode *inode, struct inode *dir) 93 + struct inode *inode, struct inode *dir, 94 + const struct qstr *qstr) 94 95 { 95 96 int err; 96 97 97 98 err = btrfs_init_acl(trans, inode, dir); 98 99 if (!err) 99 - err = btrfs_xattr_security_init(trans, inode, dir); 100 + err = btrfs_xattr_security_init(trans, inode, dir, qstr); 100 101 return err; 101 102 } 102 103 ··· 4705 4704 if (IS_ERR(inode)) 4706 4705 goto out_unlock; 4707 4706 4708 - err = btrfs_init_inode_security(trans, inode, dir); 4707 + err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); 4709 4708 if (err) { 4710 4709 drop_inode = 1; 4711 4710 goto out_unlock; ··· 4766 4765 if (IS_ERR(inode)) 4767 4766 goto out_unlock; 4768 4767 4769 - err = btrfs_init_inode_security(trans, inode, dir); 4768 + err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); 4770 4769 if (err) { 4771 4770 drop_inode = 1; 4772 4771 goto out_unlock; ··· 4894 4893 4895 4894 drop_on_err = 1; 4896 4895 4897 - err = btrfs_init_inode_security(trans, inode, dir); 4896 + err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); 4898 4897 if (err) 4899 4898 goto out_fail; 4900 4899 ··· 7105 7104 if (IS_ERR(inode)) 7106 7105 goto out_unlock; 7107 7106 7108 - err = btrfs_init_inode_security(trans, inode, dir); 7107 + err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); 7109 7108 if (err) { 7110 7109 drop_inode = 1; 7111 7110 goto out_unlock;
+4 -2
fs/btrfs/xattr.c
··· 370 370 } 371 371 372 372 int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, 373 - struct inode *inode, struct inode *dir) 373 + struct inode *inode, struct inode *dir, 374 + const struct qstr *qstr) 374 375 { 375 376 int err; 376 377 size_t len; ··· 379 378 char *suffix; 380 379 char *name; 381 380 382 - err = security_inode_init_security(inode, dir, &suffix, &value, &len); 381 + err = security_inode_init_security(inode, dir, qstr, &suffix, &value, 382 + &len); 383 383 if (err) { 384 384 if (err == -EOPNOTSUPP) 385 385 return 0;
+2 -1
fs/btrfs/xattr.h
··· 37 37 extern int btrfs_removexattr(struct dentry *dentry, const char *name); 38 38 39 39 extern int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, 40 - struct inode *inode, struct inode *dir); 40 + struct inode *inode, struct inode *dir, 41 + const struct qstr *qstr); 41 42 42 43 #endif /* __XATTR__ */
+1 -1
fs/ext2/ext2.h
··· 110 110 extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int); 111 111 112 112 /* ialloc.c */ 113 - extern struct inode * ext2_new_inode (struct inode *, int); 113 + extern struct inode * ext2_new_inode (struct inode *, int, const struct qstr *); 114 114 extern void ext2_free_inode (struct inode *); 115 115 extern unsigned long ext2_count_free_inodes (struct super_block *); 116 116 extern void ext2_check_inodes_bitmap (struct super_block *);
+3 -2
fs/ext2/ialloc.c
··· 429 429 return group; 430 430 } 431 431 432 - struct inode *ext2_new_inode(struct inode *dir, int mode) 432 + struct inode *ext2_new_inode(struct inode *dir, int mode, 433 + const struct qstr *qstr) 433 434 { 434 435 struct super_block *sb; 435 436 struct buffer_head *bitmap_bh = NULL; ··· 586 585 if (err) 587 586 goto fail_free_drop; 588 587 589 - err = ext2_init_security(inode,dir); 588 + err = ext2_init_security(inode, dir, qstr); 590 589 if (err) 591 590 goto fail_free_drop; 592 591
+4 -4
fs/ext2/namei.c
··· 104 104 105 105 dquot_initialize(dir); 106 106 107 - inode = ext2_new_inode(dir, mode); 107 + inode = ext2_new_inode(dir, mode, &dentry->d_name); 108 108 if (IS_ERR(inode)) 109 109 return PTR_ERR(inode); 110 110 ··· 133 133 134 134 dquot_initialize(dir); 135 135 136 - inode = ext2_new_inode (dir, mode); 136 + inode = ext2_new_inode (dir, mode, &dentry->d_name); 137 137 err = PTR_ERR(inode); 138 138 if (!IS_ERR(inode)) { 139 139 init_special_inode(inode, inode->i_mode, rdev); ··· 159 159 160 160 dquot_initialize(dir); 161 161 162 - inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO); 162 + inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO, &dentry->d_name); 163 163 err = PTR_ERR(inode); 164 164 if (IS_ERR(inode)) 165 165 goto out; ··· 230 230 231 231 inode_inc_link_count(dir); 232 232 233 - inode = ext2_new_inode (dir, S_IFDIR | mode); 233 + inode = ext2_new_inode(dir, S_IFDIR | mode, &dentry->d_name); 234 234 err = PTR_ERR(inode); 235 235 if (IS_ERR(inode)) 236 236 goto out_dir;
+4 -2
fs/ext2/xattr.h
··· 116 116 # endif /* CONFIG_EXT2_FS_XATTR */ 117 117 118 118 #ifdef CONFIG_EXT2_FS_SECURITY 119 - extern int ext2_init_security(struct inode *inode, struct inode *dir); 119 + extern int ext2_init_security(struct inode *inode, struct inode *dir, 120 + const struct qstr *qstr); 120 121 #else 121 - static inline int ext2_init_security(struct inode *inode, struct inode *dir) 122 + static inline int ext2_init_security(struct inode *inode, struct inode *dir, 123 + const struct qstr *qstr) 122 124 { 123 125 return 0; 124 126 }
+3 -2
fs/ext2/xattr_security.c
··· 47 47 } 48 48 49 49 int 50 - ext2_init_security(struct inode *inode, struct inode *dir) 50 + ext2_init_security(struct inode *inode, struct inode *dir, 51 + const struct qstr *qstr) 51 52 { 52 53 int err; 53 54 size_t len; 54 55 void *value; 55 56 char *name; 56 57 57 - err = security_inode_init_security(inode, dir, &name, &value, &len); 58 + err = security_inode_init_security(inode, dir, qstr, &name, &value, &len); 58 59 if (err) { 59 60 if (err == -EOPNOTSUPP) 60 61 return 0;
+3 -2
fs/ext3/ialloc.c
··· 404 404 * For other inodes, search forward from the parent directory's block 405 405 * group to find a free inode. 406 406 */ 407 - struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) 407 + struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, 408 + const struct qstr *qstr, int mode) 408 409 { 409 410 struct super_block *sb; 410 411 struct buffer_head *bitmap_bh = NULL; ··· 590 589 if (err) 591 590 goto fail_free_drop; 592 591 593 - err = ext3_init_security(handle,inode, dir); 592 + err = ext3_init_security(handle, inode, dir, qstr); 594 593 if (err) 595 594 goto fail_free_drop; 596 595
+4 -4
fs/ext3/namei.c
··· 1710 1710 if (IS_DIRSYNC(dir)) 1711 1711 handle->h_sync = 1; 1712 1712 1713 - inode = ext3_new_inode (handle, dir, mode); 1713 + inode = ext3_new_inode (handle, dir, &dentry->d_name, mode); 1714 1714 err = PTR_ERR(inode); 1715 1715 if (!IS_ERR(inode)) { 1716 1716 inode->i_op = &ext3_file_inode_operations; ··· 1746 1746 if (IS_DIRSYNC(dir)) 1747 1747 handle->h_sync = 1; 1748 1748 1749 - inode = ext3_new_inode (handle, dir, mode); 1749 + inode = ext3_new_inode (handle, dir, &dentry->d_name, mode); 1750 1750 err = PTR_ERR(inode); 1751 1751 if (!IS_ERR(inode)) { 1752 1752 init_special_inode(inode, inode->i_mode, rdev); ··· 1784 1784 if (IS_DIRSYNC(dir)) 1785 1785 handle->h_sync = 1; 1786 1786 1787 - inode = ext3_new_inode (handle, dir, S_IFDIR | mode); 1787 + inode = ext3_new_inode (handle, dir, &dentry->d_name, S_IFDIR | mode); 1788 1788 err = PTR_ERR(inode); 1789 1789 if (IS_ERR(inode)) 1790 1790 goto out_stop; ··· 2206 2206 if (IS_DIRSYNC(dir)) 2207 2207 handle->h_sync = 1; 2208 2208 2209 - inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO); 2209 + inode = ext3_new_inode (handle, dir, &dentry->d_name, S_IFLNK|S_IRWXUGO); 2210 2210 err = PTR_ERR(inode); 2211 2211 if (IS_ERR(inode)) 2212 2212 goto out_stop;
+2 -2
fs/ext3/xattr.h
··· 128 128 129 129 #ifdef CONFIG_EXT3_FS_SECURITY 130 130 extern int ext3_init_security(handle_t *handle, struct inode *inode, 131 - struct inode *dir); 131 + struct inode *dir, const struct qstr *qstr); 132 132 #else 133 133 static inline int ext3_init_security(handle_t *handle, struct inode *inode, 134 - struct inode *dir) 134 + struct inode *dir, const struct qstr *qstr) 135 135 { 136 136 return 0; 137 137 }
+3 -2
fs/ext3/xattr_security.c
··· 49 49 } 50 50 51 51 int 52 - ext3_init_security(handle_t *handle, struct inode *inode, struct inode *dir) 52 + ext3_init_security(handle_t *handle, struct inode *inode, struct inode *dir, 53 + const struct qstr *qstr) 53 54 { 54 55 int err; 55 56 size_t len; 56 57 void *value; 57 58 char *name; 58 59 59 - err = security_inode_init_security(inode, dir, &name, &value, &len); 60 + err = security_inode_init_security(inode, dir, qstr, &name, &value, &len); 60 61 if (err) { 61 62 if (err == -EOPNOTSUPP) 62 63 return 0;
+1 -1
fs/ext4/ialloc.c
··· 1042 1042 if (err) 1043 1043 goto fail_free_drop; 1044 1044 1045 - err = ext4_init_security(handle, inode, dir); 1045 + err = ext4_init_security(handle, inode, dir, qstr); 1046 1046 if (err) 1047 1047 goto fail_free_drop; 1048 1048
+2 -2
fs/ext4/xattr.h
··· 145 145 146 146 #ifdef CONFIG_EXT4_FS_SECURITY 147 147 extern int ext4_init_security(handle_t *handle, struct inode *inode, 148 - struct inode *dir); 148 + struct inode *dir, const struct qstr *qstr); 149 149 #else 150 150 static inline int ext4_init_security(handle_t *handle, struct inode *inode, 151 - struct inode *dir) 151 + struct inode *dir, const struct qstr *qstr) 152 152 { 153 153 return 0; 154 154 }
+3 -2
fs/ext4/xattr_security.c
··· 49 49 } 50 50 51 51 int 52 - ext4_init_security(handle_t *handle, struct inode *inode, struct inode *dir) 52 + ext4_init_security(handle_t *handle, struct inode *inode, struct inode *dir, 53 + const struct qstr *qstr) 53 54 { 54 55 int err; 55 56 size_t len; 56 57 void *value; 57 58 char *name; 58 59 59 - err = security_inode_init_security(inode, dir, &name, &value, &len); 60 + err = security_inode_init_security(inode, dir, qstr, &name, &value, &len); 60 61 if (err) { 61 62 if (err == -EOPNOTSUPP) 62 63 return 0;
+4 -3
fs/gfs2/inode.c
··· 763 763 return error; 764 764 } 765 765 766 - static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip) 766 + static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip, 767 + const struct qstr *qstr) 767 768 { 768 769 int err; 769 770 size_t len; 770 771 void *value; 771 772 char *name; 772 773 773 - err = security_inode_init_security(&ip->i_inode, &dip->i_inode, 774 + err = security_inode_init_security(&ip->i_inode, &dip->i_inode, qstr, 774 775 &name, &value, &len); 775 776 776 777 if (err) { ··· 855 854 if (error) 856 855 goto fail_gunlock2; 857 856 858 - error = gfs2_security_init(dip, GFS2_I(inode)); 857 + error = gfs2_security_init(dip, GFS2_I(inode), name); 859 858 if (error) 860 859 goto fail_gunlock2; 861 860
+4 -5
fs/jffs2/dir.c
··· 215 215 no chance of AB-BA deadlock involving its f->sem). */ 216 216 mutex_unlock(&f->sem); 217 217 218 - ret = jffs2_do_create(c, dir_f, f, ri, 219 - dentry->d_name.name, dentry->d_name.len); 218 + ret = jffs2_do_create(c, dir_f, f, ri, &dentry->d_name); 220 219 if (ret) 221 220 goto fail; 222 221 ··· 385 386 386 387 jffs2_complete_reservation(c); 387 388 388 - ret = jffs2_init_security(inode, dir_i); 389 + ret = jffs2_init_security(inode, dir_i, &dentry->d_name); 389 390 if (ret) 390 391 goto fail; 391 392 ··· 529 530 530 531 jffs2_complete_reservation(c); 531 532 532 - ret = jffs2_init_security(inode, dir_i); 533 + ret = jffs2_init_security(inode, dir_i, &dentry->d_name); 533 534 if (ret) 534 535 goto fail; 535 536 ··· 702 703 703 704 jffs2_complete_reservation(c); 704 705 705 - ret = jffs2_init_security(inode, dir_i); 706 + ret = jffs2_init_security(inode, dir_i, &dentry->d_name); 706 707 if (ret) 707 708 goto fail; 708 709
+1 -1
fs/jffs2/nodelist.h
··· 401 401 struct jffs2_raw_inode *ri, unsigned char *buf, 402 402 uint32_t offset, uint32_t writelen, uint32_t *retlen); 403 403 int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f, 404 - struct jffs2_raw_inode *ri, const char *name, int namelen); 404 + struct jffs2_raw_inode *ri, const struct qstr *qstr); 405 405 int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, const char *name, 406 406 int namelen, struct jffs2_inode_info *dead_f, uint32_t time); 407 407 int jffs2_do_link(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint32_t ino,
+3 -2
fs/jffs2/security.c
··· 23 23 #include "nodelist.h" 24 24 25 25 /* ---- Initial Security Label Attachment -------------- */ 26 - int jffs2_init_security(struct inode *inode, struct inode *dir) 26 + int jffs2_init_security(struct inode *inode, struct inode *dir, 27 + const struct qstr *qstr) 27 28 { 28 29 int rc; 29 30 size_t len; 30 31 void *value; 31 32 char *name; 32 33 33 - rc = security_inode_init_security(inode, dir, &name, &value, &len); 34 + rc = security_inode_init_security(inode, dir, qstr, &name, &value, &len); 34 35 if (rc) { 35 36 if (rc == -EOPNOTSUPP) 36 37 return 0;
+10 -8
fs/jffs2/write.c
··· 424 424 return ret; 425 425 } 426 426 427 - int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const char *name, int namelen) 427 + int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, 428 + struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, 429 + const struct qstr *qstr) 428 430 { 429 431 struct jffs2_raw_dirent *rd; 430 432 struct jffs2_full_dnode *fn; ··· 468 466 mutex_unlock(&f->sem); 469 467 jffs2_complete_reservation(c); 470 468 471 - ret = jffs2_init_security(&f->vfs_inode, &dir_f->vfs_inode); 469 + ret = jffs2_init_security(&f->vfs_inode, &dir_f->vfs_inode, qstr); 472 470 if (ret) 473 471 return ret; 474 472 ret = jffs2_init_acl_post(&f->vfs_inode); 475 473 if (ret) 476 474 return ret; 477 475 478 - ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen, 479 - ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 476 + ret = jffs2_reserve_space(c, sizeof(*rd)+qstr->len, &alloclen, 477 + ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(qstr->len)); 480 478 481 479 if (ret) { 482 480 /* Eep. */ ··· 495 493 496 494 rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 497 495 rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); 498 - rd->totlen = cpu_to_je32(sizeof(*rd) + namelen); 496 + rd->totlen = cpu_to_je32(sizeof(*rd) + qstr->len); 499 497 rd->hdr_crc = cpu_to_je32(crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)); 500 498 501 499 rd->pino = cpu_to_je32(dir_f->inocache->ino); 502 500 rd->version = cpu_to_je32(++dir_f->highest_version); 503 501 rd->ino = ri->ino; 504 502 rd->mctime = ri->ctime; 505 - rd->nsize = namelen; 503 + rd->nsize = qstr->len; 506 504 rd->type = DT_REG; 507 505 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); 508 - rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); 506 + rd->name_crc = cpu_to_je32(crc32(0, qstr->name, qstr->len)); 509 507 510 - fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, ALLOC_NORMAL); 508 + fd = jffs2_write_dirent(c, dir_f, rd, qstr->name, qstr->len, ALLOC_NORMAL); 511 509 512 510 jffs2_free_raw_dirent(rd); 513 511
+3 -2
fs/jffs2/xattr.h
··· 121 121 #endif /* CONFIG_JFFS2_FS_XATTR */ 122 122 123 123 #ifdef CONFIG_JFFS2_FS_SECURITY 124 - extern int jffs2_init_security(struct inode *inode, struct inode *dir); 124 + extern int jffs2_init_security(struct inode *inode, struct inode *dir, 125 + const struct qstr *qstr); 125 126 extern const struct xattr_handler jffs2_security_xattr_handler; 126 127 #else 127 - #define jffs2_init_security(inode,dir) (0) 128 + #define jffs2_init_security(inode,dir,qstr) (0) 128 129 #endif /* CONFIG_JFFS2_FS_SECURITY */ 129 130 130 131 #endif /* _JFFS2_FS_XATTR_H_ */
+3 -2
fs/jfs/jfs_xattr.h
··· 62 62 extern int jfs_removexattr(struct dentry *, const char *); 63 63 64 64 #ifdef CONFIG_JFS_SECURITY 65 - extern int jfs_init_security(tid_t, struct inode *, struct inode *); 65 + extern int jfs_init_security(tid_t, struct inode *, struct inode *, 66 + const struct qstr *); 66 67 #else 67 68 static inline int jfs_init_security(tid_t tid, struct inode *inode, 68 - struct inode *dir) 69 + struct inode *dir, const struct qstr *qstr) 69 70 { 70 71 return 0; 71 72 }
+4 -4
fs/jfs/namei.c
··· 115 115 if (rc) 116 116 goto out3; 117 117 118 - rc = jfs_init_security(tid, ip, dip); 118 + rc = jfs_init_security(tid, ip, dip, &dentry->d_name); 119 119 if (rc) { 120 120 txAbort(tid, 0); 121 121 goto out3; ··· 253 253 if (rc) 254 254 goto out3; 255 255 256 - rc = jfs_init_security(tid, ip, dip); 256 + rc = jfs_init_security(tid, ip, dip, &dentry->d_name); 257 257 if (rc) { 258 258 txAbort(tid, 0); 259 259 goto out3; ··· 932 932 mutex_lock_nested(&JFS_IP(dip)->commit_mutex, COMMIT_MUTEX_PARENT); 933 933 mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD); 934 934 935 - rc = jfs_init_security(tid, ip, dip); 935 + rc = jfs_init_security(tid, ip, dip, &dentry->d_name); 936 936 if (rc) 937 937 goto out3; 938 938 ··· 1395 1395 if (rc) 1396 1396 goto out3; 1397 1397 1398 - rc = jfs_init_security(tid, ip, dir); 1398 + rc = jfs_init_security(tid, ip, dir, &dentry->d_name); 1399 1399 if (rc) { 1400 1400 txAbort(tid, 0); 1401 1401 goto out3;
+4 -2
fs/jfs/xattr.c
··· 1091 1091 } 1092 1092 1093 1093 #ifdef CONFIG_JFS_SECURITY 1094 - int jfs_init_security(tid_t tid, struct inode *inode, struct inode *dir) 1094 + int jfs_init_security(tid_t tid, struct inode *inode, struct inode *dir, 1095 + const struct qstr *qstr) 1095 1096 { 1096 1097 int rc; 1097 1098 size_t len; ··· 1100 1099 char *suffix; 1101 1100 char *name; 1102 1101 1103 - rc = security_inode_init_security(inode, dir, &suffix, &value, &len); 1102 + rc = security_inode_init_security(inode, dir, qstr, &suffix, &value, 1103 + &len); 1104 1104 if (rc) { 1105 1105 if (rc == -EOPNOTSUPP) 1106 1106 return 0;
+4
fs/namespace.c
··· 1767 1767 if (path->dentry != path->mnt->mnt_root) 1768 1768 return -EINVAL; 1769 1769 1770 + err = security_sb_remount(sb, data); 1771 + if (err) 1772 + return err; 1773 + 1770 1774 down_write(&sb->s_umount); 1771 1775 if (flags & MS_BIND) 1772 1776 err = change_mount_flags(path->mnt, flags);
+2 -2
fs/ocfs2/namei.c
··· 293 293 } 294 294 295 295 /* get security xattr */ 296 - status = ocfs2_init_security_get(inode, dir, &si); 296 + status = ocfs2_init_security_get(inode, dir, &dentry->d_name, &si); 297 297 if (status) { 298 298 if (status == -EOPNOTSUPP) 299 299 si.enable = 0; ··· 1665 1665 } 1666 1666 1667 1667 /* get security xattr */ 1668 - status = ocfs2_init_security_get(inode, dir, &si); 1668 + status = ocfs2_init_security_get(inode, dir, &dentry->d_name, &si); 1669 1669 if (status) { 1670 1670 if (status == -EOPNOTSUPP) 1671 1671 si.enable = 0;
+2 -1
fs/ocfs2/refcounttree.c
··· 4328 4328 4329 4329 /* If the security isn't preserved, we need to re-initialize them. */ 4330 4330 if (!preserve) { 4331 - error = ocfs2_init_security_and_acl(dir, new_orphan_inode); 4331 + error = ocfs2_init_security_and_acl(dir, new_orphan_inode, 4332 + &new_dentry->d_name); 4332 4333 if (error) 4333 4334 mlog_errno(error); 4334 4335 }
+6 -4
fs/ocfs2/xattr.c
··· 7185 7185 * must not hold any lock expect i_mutex. 7186 7186 */ 7187 7187 int ocfs2_init_security_and_acl(struct inode *dir, 7188 - struct inode *inode) 7188 + struct inode *inode, 7189 + const struct qstr *qstr) 7189 7190 { 7190 7191 int ret = 0; 7191 7192 struct buffer_head *dir_bh = NULL; ··· 7194 7193 .enable = 1, 7195 7194 }; 7196 7195 7197 - ret = ocfs2_init_security_get(inode, dir, &si); 7196 + ret = ocfs2_init_security_get(inode, dir, qstr, &si); 7198 7197 if (!ret) { 7199 7198 ret = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, 7200 7199 si.name, si.value, si.value_len, ··· 7262 7261 7263 7262 int ocfs2_init_security_get(struct inode *inode, 7264 7263 struct inode *dir, 7264 + const struct qstr *qstr, 7265 7265 struct ocfs2_security_xattr_info *si) 7266 7266 { 7267 7267 /* check whether ocfs2 support feature xattr */ 7268 7268 if (!ocfs2_supports_xattr(OCFS2_SB(dir->i_sb))) 7269 7269 return -EOPNOTSUPP; 7270 - return security_inode_init_security(inode, dir, &si->name, &si->value, 7271 - &si->value_len); 7270 + return security_inode_init_security(inode, dir, qstr, &si->name, 7271 + &si->value, &si->value_len); 7272 7272 } 7273 7273 7274 7274 int ocfs2_init_security_set(handle_t *handle,
+3 -1
fs/ocfs2/xattr.h
··· 57 57 struct ocfs2_dinode *di); 58 58 int ocfs2_xattr_remove(struct inode *, struct buffer_head *); 59 59 int ocfs2_init_security_get(struct inode *, struct inode *, 60 + const struct qstr *, 60 61 struct ocfs2_security_xattr_info *); 61 62 int ocfs2_init_security_set(handle_t *, struct inode *, 62 63 struct buffer_head *, ··· 95 94 struct buffer_head *new_bh, 96 95 bool preserve_security); 97 96 int ocfs2_init_security_and_acl(struct inode *dir, 98 - struct inode *inode); 97 + struct inode *inode, 98 + const struct qstr *qstr); 99 99 #endif /* OCFS2_XATTR_H */
-1
fs/proc/proc_sysctl.c
··· 32 32 ei->sysctl_entry = table; 33 33 34 34 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 35 - inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ 36 35 inode->i_mode = table->mode; 37 36 if (!table->child) { 38 37 inode->i_mode |= S_IFREG;
+5 -4
fs/reiserfs/namei.c
··· 593 593 new_inode_init(inode, dir, mode); 594 594 595 595 jbegin_count += reiserfs_cache_default_acl(dir); 596 - retval = reiserfs_security_init(dir, inode, &security); 596 + retval = reiserfs_security_init(dir, inode, &dentry->d_name, &security); 597 597 if (retval < 0) { 598 598 drop_new_inode(inode); 599 599 return retval; ··· 667 667 new_inode_init(inode, dir, mode); 668 668 669 669 jbegin_count += reiserfs_cache_default_acl(dir); 670 - retval = reiserfs_security_init(dir, inode, &security); 670 + retval = reiserfs_security_init(dir, inode, &dentry->d_name, &security); 671 671 if (retval < 0) { 672 672 drop_new_inode(inode); 673 673 return retval; ··· 747 747 new_inode_init(inode, dir, mode); 748 748 749 749 jbegin_count += reiserfs_cache_default_acl(dir); 750 - retval = reiserfs_security_init(dir, inode, &security); 750 + retval = reiserfs_security_init(dir, inode, &dentry->d_name, &security); 751 751 if (retval < 0) { 752 752 drop_new_inode(inode); 753 753 return retval; ··· 1032 1032 } 1033 1033 new_inode_init(inode, parent_dir, mode); 1034 1034 1035 - retval = reiserfs_security_init(parent_dir, inode, &security); 1035 + retval = reiserfs_security_init(parent_dir, inode, &dentry->d_name, 1036 + &security); 1036 1037 if (retval < 0) { 1037 1038 drop_new_inode(inode); 1038 1039 return retval;
+2 -1
fs/reiserfs/xattr_security.c
··· 54 54 * of blocks needed for the transaction. If successful, reiserfs_security 55 55 * must be released using reiserfs_security_free when the caller is done. */ 56 56 int reiserfs_security_init(struct inode *dir, struct inode *inode, 57 + const struct qstr *qstr, 57 58 struct reiserfs_security_handle *sec) 58 59 { 59 60 int blocks = 0; ··· 66 65 if (IS_PRIVATE(dir)) 67 66 return 0; 68 67 69 - error = security_inode_init_security(inode, dir, &sec->name, 68 + error = security_inode_init_security(inode, dir, qstr, &sec->name, 70 69 &sec->value, &sec->length); 71 70 if (error) { 72 71 if (error == -EOPNOTSUPP)
+5 -4
fs/xfs/linux-2.6/xfs_iops.c
··· 102 102 STATIC int 103 103 xfs_init_security( 104 104 struct inode *inode, 105 - struct inode *dir) 105 + struct inode *dir, 106 + const struct qstr *qstr) 106 107 { 107 108 struct xfs_inode *ip = XFS_I(inode); 108 109 size_t length; ··· 111 110 unsigned char *name; 112 111 int error; 113 112 114 - error = security_inode_init_security(inode, dir, (char **)&name, 113 + error = security_inode_init_security(inode, dir, qstr, (char **)&name, 115 114 &value, &length); 116 115 if (error) { 117 116 if (error == -EOPNOTSUPP) ··· 195 194 196 195 inode = VFS_I(ip); 197 196 198 - error = xfs_init_security(inode, dir); 197 + error = xfs_init_security(inode, dir, &dentry->d_name); 199 198 if (unlikely(error)) 200 199 goto out_cleanup_inode; 201 200 ··· 368 367 369 368 inode = VFS_I(cip); 370 369 371 - error = xfs_init_security(inode, dir); 370 + error = xfs_init_security(inode, dir, &dentry->d_name); 372 371 if (unlikely(error)) 373 372 goto out_cleanup_inode; 374 373
+2 -1
include/linux/ext3_fs.h
··· 884 884 dx_hash_info *hinfo); 885 885 886 886 /* ialloc.c */ 887 - extern struct inode * ext3_new_inode (handle_t *, struct inode *, int); 887 + extern struct inode * ext3_new_inode (handle_t *, struct inode *, 888 + const struct qstr *, int); 888 889 extern void ext3_free_inode (handle_t *, struct inode *); 889 890 extern struct inode * ext3_orphan_get (struct super_block *, unsigned long); 890 891 extern unsigned long ext3_count_free_inodes (struct super_block *);
+2
include/linux/reiserfs_xattr.h
··· 63 63 extern const struct xattr_handler reiserfs_xattr_security_handler; 64 64 #ifdef CONFIG_REISERFS_FS_SECURITY 65 65 int reiserfs_security_init(struct inode *dir, struct inode *inode, 66 + const struct qstr *qstr, 66 67 struct reiserfs_security_handle *sec); 67 68 int reiserfs_security_write(struct reiserfs_transaction_handle *th, 68 69 struct inode *inode, ··· 131 130 #ifndef CONFIG_REISERFS_FS_SECURITY 132 131 static inline int reiserfs_security_init(struct inode *dir, 133 132 struct inode *inode, 133 + const struct qstr *qstr, 134 134 struct reiserfs_security_handle *sec) 135 135 { 136 136 return 0;
+20 -15
include/linux/security.h
··· 25 25 #include <linux/fs.h> 26 26 #include <linux/fsnotify.h> 27 27 #include <linux/binfmts.h> 28 + #include <linux/dcache.h> 28 29 #include <linux/signal.h> 29 30 #include <linux/resource.h> 30 31 #include <linux/sem.h> ··· 268 267 * @orig the original mount data copied from userspace. 269 268 * @copy copied data which will be passed to the security module. 270 269 * Returns 0 if the copy was successful. 270 + * @sb_remount: 271 + * Extracts security system specifc mount options and verifys no changes 272 + * are being made to those options. 273 + * @sb superblock being remounted 274 + * @data contains the filesystem-specific data. 275 + * Return 0 if permission is granted. 271 276 * @sb_umount: 272 277 * Check permission before the @mnt file system is unmounted. 273 278 * @mnt contains the mounted file system. ··· 322 315 * then it should return -EOPNOTSUPP to skip this processing. 323 316 * @inode contains the inode structure of the newly created inode. 324 317 * @dir contains the inode structure of the parent directory. 318 + * @qstr contains the last path component of the new object 325 319 * @name will be set to the allocated name suffix (e.g. selinux). 326 320 * @value will be set to the allocated attribute value. 327 321 * @len will be set to the length of the value. ··· 1265 1257 * @cap contains the capability <include/linux/capability.h>. 1266 1258 * @audit: Whether to write an audit message or not 1267 1259 * Return 0 if the capability is granted for @tsk. 1268 - * @sysctl: 1269 - * Check permission before accessing the @table sysctl variable in the 1270 - * manner specified by @op. 1271 - * @table contains the ctl_table structure for the sysctl variable. 1272 - * @op contains the operation (001 = search, 002 = write, 004 = read). 1273 - * Return 0 if permission is granted. 1274 1260 * @syslog: 1275 1261 * Check permission before accessing the kernel message ring or changing 1276 1262 * logging to the console. ··· 1385 1383 const kernel_cap_t *permitted); 1386 1384 int (*capable) (struct task_struct *tsk, const struct cred *cred, 1387 1385 int cap, int audit); 1388 - int (*sysctl) (struct ctl_table *table, int op); 1389 1386 int (*quotactl) (int cmds, int type, int id, struct super_block *sb); 1390 1387 int (*quota_on) (struct dentry *dentry); 1391 1388 int (*syslog) (int type); ··· 1400 1399 int (*sb_alloc_security) (struct super_block *sb); 1401 1400 void (*sb_free_security) (struct super_block *sb); 1402 1401 int (*sb_copy_data) (char *orig, char *copy); 1402 + int (*sb_remount) (struct super_block *sb, void *data); 1403 1403 int (*sb_kern_mount) (struct super_block *sb, int flags, void *data); 1404 1404 int (*sb_show_options) (struct seq_file *m, struct super_block *sb); 1405 1405 int (*sb_statfs) (struct dentry *dentry); ··· 1437 1435 int (*inode_alloc_security) (struct inode *inode); 1438 1436 void (*inode_free_security) (struct inode *inode); 1439 1437 int (*inode_init_security) (struct inode *inode, struct inode *dir, 1440 - char **name, void **value, size_t *len); 1438 + const struct qstr *qstr, char **name, 1439 + void **value, size_t *len); 1441 1440 int (*inode_create) (struct inode *dir, 1442 1441 struct dentry *dentry, int mode); 1443 1442 int (*inode_link) (struct dentry *old_dentry, ··· 1668 1665 int security_capable(const struct cred *cred, int cap); 1669 1666 int security_real_capable(struct task_struct *tsk, int cap); 1670 1667 int security_real_capable_noaudit(struct task_struct *tsk, int cap); 1671 - int security_sysctl(struct ctl_table *table, int op); 1672 1668 int security_quotactl(int cmds, int type, int id, struct super_block *sb); 1673 1669 int security_quota_on(struct dentry *dentry); 1674 1670 int security_syslog(int type); ··· 1683 1681 int security_sb_alloc(struct super_block *sb); 1684 1682 void security_sb_free(struct super_block *sb); 1685 1683 int security_sb_copy_data(char *orig, char *copy); 1684 + int security_sb_remount(struct super_block *sb, void *data); 1686 1685 int security_sb_kern_mount(struct super_block *sb, int flags, void *data); 1687 1686 int security_sb_show_options(struct seq_file *m, struct super_block *sb); 1688 1687 int security_sb_statfs(struct dentry *dentry); ··· 1699 1696 int security_inode_alloc(struct inode *inode); 1700 1697 void security_inode_free(struct inode *inode); 1701 1698 int security_inode_init_security(struct inode *inode, struct inode *dir, 1702 - char **name, void **value, size_t *len); 1699 + const struct qstr *qstr, char **name, 1700 + void **value, size_t *len); 1703 1701 int security_inode_create(struct inode *dir, struct dentry *dentry, int mode); 1704 1702 int security_inode_link(struct dentry *old_dentry, struct inode *dir, 1705 1703 struct dentry *new_dentry); ··· 1887 1883 return ret; 1888 1884 } 1889 1885 1890 - static inline int security_sysctl(struct ctl_table *table, int op) 1891 - { 1892 - return 0; 1893 - } 1894 - 1895 1886 static inline int security_quotactl(int cmds, int type, int id, 1896 1887 struct super_block *sb) 1897 1888 { ··· 1963 1964 return 0; 1964 1965 } 1965 1966 1967 + static inline int security_sb_remount(struct super_block *sb, void *data) 1968 + { 1969 + return 0; 1970 + } 1971 + 1966 1972 static inline int security_sb_kern_mount(struct super_block *sb, int flags, void *data) 1967 1973 { 1968 1974 return 0; ··· 2027 2023 2028 2024 static inline int security_inode_init_security(struct inode *inode, 2029 2025 struct inode *dir, 2026 + const struct qstr *qstr, 2030 2027 char **name, 2031 2028 void **value, 2032 2029 size_t *len)
-5
kernel/sysctl.c
··· 1685 1685 1686 1686 int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 1687 1687 { 1688 - int error; 1689 1688 int mode; 1690 - 1691 - error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); 1692 - if (error) 1693 - return error; 1694 1689 1695 1690 if (root->permissions) 1696 1691 mode = root->permissions(root, current->nsproxy, table);
+5 -4
mm/shmem.c
··· 1843 1843 1844 1844 inode = shmem_get_inode(dir->i_sb, dir, mode, dev, VM_NORESERVE); 1845 1845 if (inode) { 1846 - error = security_inode_init_security(inode, dir, NULL, NULL, 1847 - NULL); 1846 + error = security_inode_init_security(inode, dir, 1847 + &dentry->d_name, NULL, 1848 + NULL, NULL); 1848 1849 if (error) { 1849 1850 if (error != -EOPNOTSUPP) { 1850 1851 iput(inode); ··· 1984 1983 if (!inode) 1985 1984 return -ENOSPC; 1986 1985 1987 - error = security_inode_init_security(inode, dir, NULL, NULL, 1988 - NULL); 1986 + error = security_inode_init_security(inode, dir, &dentry->d_name, NULL, 1987 + NULL, NULL); 1989 1988 if (error) { 1990 1989 if (error != -EOPNOTSUPP) { 1991 1990 iput(inode);
+20
scripts/selinux/genheaders/genheaders.c
··· 43 43 int i, j, k; 44 44 int isids_len; 45 45 FILE *fout; 46 + const char *needle = "SOCKET"; 47 + char *substr; 46 48 47 49 progname = argv[0]; 48 50 ··· 90 88 fprintf(fout, "%2d\n", i); 91 89 } 92 90 fprintf(fout, "\n#define SECINITSID_NUM %d\n", i-1); 91 + fprintf(fout, "\nstatic inline bool security_is_socket_class(u16 kern_tclass)\n"); 92 + fprintf(fout, "{\n"); 93 + fprintf(fout, "\tbool sock = false;\n\n"); 94 + fprintf(fout, "\tswitch (kern_tclass) {\n"); 95 + for (i = 0; secclass_map[i].name; i++) { 96 + struct security_class_mapping *map = &secclass_map[i]; 97 + substr = strstr(map->name, needle); 98 + if (substr && strcmp(substr, needle) == 0) 99 + fprintf(fout, "\tcase SECCLASS_%s:\n", map->name); 100 + } 101 + fprintf(fout, "\t\tsock = true;\n"); 102 + fprintf(fout, "\t\tbreak;\n"); 103 + fprintf(fout, "\tdefault:\n"); 104 + fprintf(fout, "\t\tbreak;\n"); 105 + fprintf(fout, "\t}\n\n"); 106 + fprintf(fout, "\treturn sock;\n"); 107 + fprintf(fout, "}\n"); 108 + 93 109 fprintf(fout, "\n#endif\n"); 94 110 fclose(fout); 95 111
+8 -7
security/capability.c
··· 12 12 13 13 #include <linux/security.h> 14 14 15 - static int cap_sysctl(ctl_table *table, int op) 16 - { 17 - return 0; 18 - } 19 - 20 15 static int cap_syslog(int type) 21 16 { 22 17 return 0; ··· 50 55 } 51 56 52 57 static int cap_sb_copy_data(char *orig, char *copy) 58 + { 59 + return 0; 60 + } 61 + 62 + static int cap_sb_remount(struct super_block *sb, void *data) 53 63 { 54 64 return 0; 55 65 } ··· 118 118 } 119 119 120 120 static int cap_inode_init_security(struct inode *inode, struct inode *dir, 121 - char **name, void **value, size_t *len) 121 + const struct qstr *qstr, char **name, 122 + void **value, size_t *len) 122 123 { 123 124 return -EOPNOTSUPP; 124 125 } ··· 881 880 set_to_cap_if_null(ops, capable); 882 881 set_to_cap_if_null(ops, quotactl); 883 882 set_to_cap_if_null(ops, quota_on); 884 - set_to_cap_if_null(ops, sysctl); 885 883 set_to_cap_if_null(ops, syslog); 886 884 set_to_cap_if_null(ops, settime); 887 885 set_to_cap_if_null(ops, vm_enough_memory); ··· 892 892 set_to_cap_if_null(ops, sb_alloc_security); 893 893 set_to_cap_if_null(ops, sb_free_security); 894 894 set_to_cap_if_null(ops, sb_copy_data); 895 + set_to_cap_if_null(ops, sb_remount); 895 896 set_to_cap_if_null(ops, sb_kern_mount); 896 897 set_to_cap_if_null(ops, sb_show_options); 897 898 set_to_cap_if_null(ops, sb_statfs);
+9 -7
security/security.c
··· 181 181 return ret; 182 182 } 183 183 184 - int security_sysctl(struct ctl_table *table, int op) 185 - { 186 - return security_ops->sysctl(table, op); 187 - } 188 - 189 184 int security_quotactl(int cmds, int type, int id, struct super_block *sb) 190 185 { 191 186 return security_ops->quotactl(cmds, type, id, sb); ··· 266 271 } 267 272 EXPORT_SYMBOL(security_sb_copy_data); 268 273 274 + int security_sb_remount(struct super_block *sb, void *data) 275 + { 276 + return security_ops->sb_remount(sb, data); 277 + } 278 + 269 279 int security_sb_kern_mount(struct super_block *sb, int flags, void *data) 270 280 { 271 281 return security_ops->sb_kern_mount(sb, flags, data); ··· 335 335 } 336 336 337 337 int security_inode_init_security(struct inode *inode, struct inode *dir, 338 - char **name, void **value, size_t *len) 338 + const struct qstr *qstr, char **name, 339 + void **value, size_t *len) 339 340 { 340 341 if (unlikely(IS_PRIVATE(inode))) 341 342 return -EOPNOTSUPP; 342 - return security_ops->inode_init_security(inode, dir, name, value, len); 343 + return security_ops->inode_init_security(inode, dir, qstr, name, value, 344 + len); 343 345 } 344 346 EXPORT_SYMBOL(security_inode_init_security); 345 347
+188 -162
security/selinux/hooks.c
··· 24 24 */ 25 25 26 26 #include <linux/init.h> 27 + #include <linux/kd.h> 27 28 #include <linux/kernel.h> 28 29 #include <linux/tracehook.h> 29 30 #include <linux/errno.h> 31 + #include <linux/ext2_fs.h> 30 32 #include <linux/sched.h> 31 33 #include <linux/security.h> 32 34 #include <linux/xattr.h> ··· 38 36 #include <linux/mman.h> 39 37 #include <linux/slab.h> 40 38 #include <linux/pagemap.h> 39 + #include <linux/proc_fs.h> 41 40 #include <linux/swap.h> 42 41 #include <linux/spinlock.h> 43 42 #include <linux/syscalls.h> 43 + #include <linux/dcache.h> 44 44 #include <linux/file.h> 45 45 #include <linux/fdtable.h> 46 46 #include <linux/namei.h> 47 47 #include <linux/mount.h> 48 - #include <linux/proc_fs.h> 49 48 #include <linux/netfilter_ipv4.h> 50 49 #include <linux/netfilter_ipv6.h> 51 50 #include <linux/tty.h> ··· 73 70 #include <net/ipv6.h> 74 71 #include <linux/hugetlb.h> 75 72 #include <linux/personality.h> 76 - #include <linux/sysctl.h> 77 73 #include <linux/audit.h> 78 74 #include <linux/string.h> 79 75 #include <linux/selinux.h> ··· 1122 1120 } 1123 1121 1124 1122 #ifdef CONFIG_PROC_FS 1125 - static int selinux_proc_get_sid(struct proc_dir_entry *de, 1123 + static int selinux_proc_get_sid(struct dentry *dentry, 1126 1124 u16 tclass, 1127 1125 u32 *sid) 1128 1126 { 1129 - int buflen, rc; 1130 - char *buffer, *path, *end; 1127 + int rc; 1128 + char *buffer, *path; 1131 1129 1132 1130 buffer = (char *)__get_free_page(GFP_KERNEL); 1133 1131 if (!buffer) 1134 1132 return -ENOMEM; 1135 1133 1136 - buflen = PAGE_SIZE; 1137 - end = buffer+buflen; 1138 - *--end = '\0'; 1139 - buflen--; 1140 - path = end-1; 1141 - *path = '/'; 1142 - while (de && de != de->parent) { 1143 - buflen -= de->namelen + 1; 1144 - if (buflen < 0) 1145 - break; 1146 - end -= de->namelen; 1147 - memcpy(end, de->name, de->namelen); 1148 - *--end = '/'; 1149 - path = end; 1150 - de = de->parent; 1134 + path = dentry_path_raw(dentry, buffer, PAGE_SIZE); 1135 + if (IS_ERR(path)) 1136 + rc = PTR_ERR(path); 1137 + else { 1138 + /* each process gets a /proc/PID/ entry. Strip off the 1139 + * PID part to get a valid selinux labeling. 1140 + * e.g. /proc/1/net/rpc/nfs -> /net/rpc/nfs */ 1141 + while (path[1] >= '0' && path[1] <= '9') { 1142 + path[1] = '/'; 1143 + path++; 1144 + } 1145 + rc = security_genfs_sid("proc", path, tclass, sid); 1151 1146 } 1152 - rc = security_genfs_sid("proc", path, tclass, sid); 1153 1147 free_page((unsigned long)buffer); 1154 1148 return rc; 1155 1149 } 1156 1150 #else 1157 - static int selinux_proc_get_sid(struct proc_dir_entry *de, 1151 + static int selinux_proc_get_sid(struct dentry *dentry, 1158 1152 u16 tclass, 1159 1153 u32 *sid) 1160 1154 { ··· 1298 1300 1299 1301 /* Try to obtain a transition SID. */ 1300 1302 isec->sclass = inode_mode_to_security_class(inode->i_mode); 1301 - rc = security_transition_sid(isec->task_sid, 1302 - sbsec->sid, 1303 - isec->sclass, 1304 - &sid); 1303 + rc = security_transition_sid(isec->task_sid, sbsec->sid, 1304 + isec->sclass, NULL, &sid); 1305 1305 if (rc) 1306 1306 goto out_unlock; 1307 1307 isec->sid = sid; ··· 1312 1316 isec->sid = sbsec->sid; 1313 1317 1314 1318 if ((sbsec->flags & SE_SBPROC) && !S_ISLNK(inode->i_mode)) { 1315 - struct proc_inode *proci = PROC_I(inode); 1316 - if (proci->pde) { 1319 + if (opt_dentry) { 1317 1320 isec->sclass = inode_mode_to_security_class(inode->i_mode); 1318 - rc = selinux_proc_get_sid(proci->pde, 1321 + rc = selinux_proc_get_sid(opt_dentry, 1319 1322 isec->sclass, 1320 1323 &sid); 1321 1324 if (rc) ··· 1573 1578 return rc; 1574 1579 1575 1580 if (!newsid || !(sbsec->flags & SE_SBLABELSUPP)) { 1576 - rc = security_transition_sid(sid, dsec->sid, tclass, &newsid); 1581 + rc = security_transition_sid(sid, dsec->sid, tclass, NULL, &newsid); 1577 1582 if (rc) 1578 1583 return rc; 1579 1584 } ··· 1857 1862 return task_has_capability(tsk, cred, cap, audit); 1858 1863 } 1859 1864 1860 - static int selinux_sysctl_get_sid(ctl_table *table, u16 tclass, u32 *sid) 1861 - { 1862 - int buflen, rc; 1863 - char *buffer, *path, *end; 1864 - 1865 - rc = -ENOMEM; 1866 - buffer = (char *)__get_free_page(GFP_KERNEL); 1867 - if (!buffer) 1868 - goto out; 1869 - 1870 - buflen = PAGE_SIZE; 1871 - end = buffer+buflen; 1872 - *--end = '\0'; 1873 - buflen--; 1874 - path = end-1; 1875 - *path = '/'; 1876 - while (table) { 1877 - const char *name = table->procname; 1878 - size_t namelen = strlen(name); 1879 - buflen -= namelen + 1; 1880 - if (buflen < 0) 1881 - goto out_free; 1882 - end -= namelen; 1883 - memcpy(end, name, namelen); 1884 - *--end = '/'; 1885 - path = end; 1886 - table = table->parent; 1887 - } 1888 - buflen -= 4; 1889 - if (buflen < 0) 1890 - goto out_free; 1891 - end -= 4; 1892 - memcpy(end, "/sys", 4); 1893 - path = end; 1894 - rc = security_genfs_sid("proc", path, tclass, sid); 1895 - out_free: 1896 - free_page((unsigned long)buffer); 1897 - out: 1898 - return rc; 1899 - } 1900 - 1901 - static int selinux_sysctl(ctl_table *table, int op) 1902 - { 1903 - int error = 0; 1904 - u32 av; 1905 - u32 tsid, sid; 1906 - int rc; 1907 - 1908 - sid = current_sid(); 1909 - 1910 - rc = selinux_sysctl_get_sid(table, (op == 0001) ? 1911 - SECCLASS_DIR : SECCLASS_FILE, &tsid); 1912 - if (rc) { 1913 - /* Default to the well-defined sysctl SID. */ 1914 - tsid = SECINITSID_SYSCTL; 1915 - } 1916 - 1917 - /* The op values are "defined" in sysctl.c, thereby creating 1918 - * a bad coupling between this module and sysctl.c */ 1919 - if (op == 001) { 1920 - error = avc_has_perm(sid, tsid, 1921 - SECCLASS_DIR, DIR__SEARCH, NULL); 1922 - } else { 1923 - av = 0; 1924 - if (op & 004) 1925 - av |= FILE__READ; 1926 - if (op & 002) 1927 - av |= FILE__WRITE; 1928 - if (av) 1929 - error = avc_has_perm(sid, tsid, 1930 - SECCLASS_FILE, av, NULL); 1931 - } 1932 - 1933 - return error; 1934 - } 1935 - 1936 1865 static int selinux_quotactl(int cmds, int type, int id, struct super_block *sb) 1937 1866 { 1938 1867 const struct cred *cred = current_cred(); ··· 1979 2060 } else { 1980 2061 /* Check for a default transition on this program. */ 1981 2062 rc = security_transition_sid(old_tsec->sid, isec->sid, 1982 - SECCLASS_PROCESS, &new_tsec->sid); 2063 + SECCLASS_PROCESS, NULL, 2064 + &new_tsec->sid); 1983 2065 if (rc) 1984 2066 return rc; 1985 2067 } ··· 2363 2443 return rc; 2364 2444 } 2365 2445 2446 + static int selinux_sb_remount(struct super_block *sb, void *data) 2447 + { 2448 + int rc, i, *flags; 2449 + struct security_mnt_opts opts; 2450 + char *secdata, **mount_options; 2451 + struct superblock_security_struct *sbsec = sb->s_security; 2452 + 2453 + if (!(sbsec->flags & SE_SBINITIALIZED)) 2454 + return 0; 2455 + 2456 + if (!data) 2457 + return 0; 2458 + 2459 + if (sb->s_type->fs_flags & FS_BINARY_MOUNTDATA) 2460 + return 0; 2461 + 2462 + security_init_mnt_opts(&opts); 2463 + secdata = alloc_secdata(); 2464 + if (!secdata) 2465 + return -ENOMEM; 2466 + rc = selinux_sb_copy_data(data, secdata); 2467 + if (rc) 2468 + goto out_free_secdata; 2469 + 2470 + rc = selinux_parse_opts_str(secdata, &opts); 2471 + if (rc) 2472 + goto out_free_secdata; 2473 + 2474 + mount_options = opts.mnt_opts; 2475 + flags = opts.mnt_opts_flags; 2476 + 2477 + for (i = 0; i < opts.num_mnt_opts; i++) { 2478 + u32 sid; 2479 + size_t len; 2480 + 2481 + if (flags[i] == SE_SBLABELSUPP) 2482 + continue; 2483 + len = strlen(mount_options[i]); 2484 + rc = security_context_to_sid(mount_options[i], len, &sid); 2485 + if (rc) { 2486 + printk(KERN_WARNING "SELinux: security_context_to_sid" 2487 + "(%s) failed for (dev %s, type %s) errno=%d\n", 2488 + mount_options[i], sb->s_id, sb->s_type->name, rc); 2489 + goto out_free_opts; 2490 + } 2491 + rc = -EINVAL; 2492 + switch (flags[i]) { 2493 + case FSCONTEXT_MNT: 2494 + if (bad_option(sbsec, FSCONTEXT_MNT, sbsec->sid, sid)) 2495 + goto out_bad_option; 2496 + break; 2497 + case CONTEXT_MNT: 2498 + if (bad_option(sbsec, CONTEXT_MNT, sbsec->mntpoint_sid, sid)) 2499 + goto out_bad_option; 2500 + break; 2501 + case ROOTCONTEXT_MNT: { 2502 + struct inode_security_struct *root_isec; 2503 + root_isec = sb->s_root->d_inode->i_security; 2504 + 2505 + if (bad_option(sbsec, ROOTCONTEXT_MNT, root_isec->sid, sid)) 2506 + goto out_bad_option; 2507 + break; 2508 + } 2509 + case DEFCONTEXT_MNT: 2510 + if (bad_option(sbsec, DEFCONTEXT_MNT, sbsec->def_sid, sid)) 2511 + goto out_bad_option; 2512 + break; 2513 + default: 2514 + goto out_free_opts; 2515 + } 2516 + } 2517 + 2518 + rc = 0; 2519 + out_free_opts: 2520 + security_free_mnt_opts(&opts); 2521 + out_free_secdata: 2522 + free_secdata(secdata); 2523 + return rc; 2524 + out_bad_option: 2525 + printk(KERN_WARNING "SELinux: unable to change security options " 2526 + "during remount (dev %s, type=%s)\n", sb->s_id, 2527 + sb->s_type->name); 2528 + goto out_free_opts; 2529 + } 2530 + 2366 2531 static int selinux_sb_kern_mount(struct super_block *sb, int flags, void *data) 2367 2532 { 2368 2533 const struct cred *cred = current_cred(); ··· 2514 2509 } 2515 2510 2516 2511 static int selinux_inode_init_security(struct inode *inode, struct inode *dir, 2517 - char **name, void **value, 2518 - size_t *len) 2512 + const struct qstr *qstr, char **name, 2513 + void **value, size_t *len) 2519 2514 { 2520 2515 const struct task_security_struct *tsec = current_security(); 2521 2516 struct inode_security_struct *dsec; ··· 2536 2531 else if (!newsid || !(sbsec->flags & SE_SBLABELSUPP)) { 2537 2532 rc = security_transition_sid(sid, dsec->sid, 2538 2533 inode_mode_to_security_class(inode->i_mode), 2539 - &newsid); 2534 + qstr, &newsid); 2540 2535 if (rc) { 2541 2536 printk(KERN_WARNING "%s: " 2542 2537 "security_transition_sid failed, rc=%d (dev=%s " ··· 2937 2932 unsigned long arg) 2938 2933 { 2939 2934 const struct cred *cred = current_cred(); 2940 - u32 av = 0; 2935 + int error = 0; 2941 2936 2942 - if (_IOC_DIR(cmd) & _IOC_WRITE) 2943 - av |= FILE__WRITE; 2944 - if (_IOC_DIR(cmd) & _IOC_READ) 2945 - av |= FILE__READ; 2946 - if (!av) 2947 - av = FILE__IOCTL; 2937 + switch (cmd) { 2938 + case FIONREAD: 2939 + /* fall through */ 2940 + case FIBMAP: 2941 + /* fall through */ 2942 + case FIGETBSZ: 2943 + /* fall through */ 2944 + case EXT2_IOC_GETFLAGS: 2945 + /* fall through */ 2946 + case EXT2_IOC_GETVERSION: 2947 + error = file_has_perm(cred, file, FILE__GETATTR); 2948 + break; 2948 2949 2949 - return file_has_perm(cred, file, av); 2950 + case EXT2_IOC_SETFLAGS: 2951 + /* fall through */ 2952 + case EXT2_IOC_SETVERSION: 2953 + error = file_has_perm(cred, file, FILE__SETATTR); 2954 + break; 2955 + 2956 + /* sys_ioctl() checks */ 2957 + case FIONBIO: 2958 + /* fall through */ 2959 + case FIOASYNC: 2960 + error = file_has_perm(cred, file, 0); 2961 + break; 2962 + 2963 + case KDSKBENT: 2964 + case KDSKBSENT: 2965 + error = task_has_capability(current, cred, CAP_SYS_TTY_CONFIG, 2966 + SECURITY_CAP_AUDIT); 2967 + break; 2968 + 2969 + /* default case assumes that the command will go 2970 + * to the file's ioctl() function. 2971 + */ 2972 + default: 2973 + error = file_has_perm(cred, file, FILE__IOCTL); 2974 + } 2975 + return error; 2950 2976 } 2951 2977 2952 2978 static int default_noexec; ··· 3680 3644 3681 3645 /* socket security operations */ 3682 3646 3683 - static u32 socket_sockcreate_sid(const struct task_security_struct *tsec) 3647 + static int socket_sockcreate_sid(const struct task_security_struct *tsec, 3648 + u16 secclass, u32 *socksid) 3684 3649 { 3685 - return tsec->sockcreate_sid ? : tsec->sid; 3650 + if (tsec->sockcreate_sid > SECSID_NULL) { 3651 + *socksid = tsec->sockcreate_sid; 3652 + return 0; 3653 + } 3654 + 3655 + return security_transition_sid(tsec->sid, tsec->sid, secclass, NULL, 3656 + socksid); 3686 3657 } 3687 3658 3688 3659 static int sock_has_perm(struct task_struct *task, struct sock *sk, u32 perms) ··· 3713 3670 const struct task_security_struct *tsec = current_security(); 3714 3671 u32 newsid; 3715 3672 u16 secclass; 3673 + int rc; 3716 3674 3717 3675 if (kern) 3718 3676 return 0; 3719 3677 3720 - newsid = socket_sockcreate_sid(tsec); 3721 3678 secclass = socket_type_to_security_class(family, type, protocol); 3679 + rc = socket_sockcreate_sid(tsec, secclass, &newsid); 3680 + if (rc) 3681 + return rc; 3682 + 3722 3683 return avc_has_perm(tsec->sid, newsid, secclass, SOCKET__CREATE, NULL); 3723 3684 } 3724 3685 ··· 3734 3687 struct sk_security_struct *sksec; 3735 3688 int err = 0; 3736 3689 3690 + isec->sclass = socket_type_to_security_class(family, type, protocol); 3691 + 3737 3692 if (kern) 3738 3693 isec->sid = SECINITSID_KERNEL; 3739 - else 3740 - isec->sid = socket_sockcreate_sid(tsec); 3694 + else { 3695 + err = socket_sockcreate_sid(tsec, isec->sclass, &(isec->sid)); 3696 + if (err) 3697 + return err; 3698 + } 3741 3699 3742 - isec->sclass = socket_type_to_security_class(family, type, protocol); 3743 3700 isec->initialized = 1; 3744 3701 3745 3702 if (sock->sk) { ··· 4053 4002 { 4054 4003 int err = 0; 4055 4004 struct sk_security_struct *sksec = sk->sk_security; 4056 - u32 peer_sid; 4057 4005 u32 sk_sid = sksec->sid; 4058 4006 struct common_audit_data ad; 4059 4007 char *addrp; ··· 4071 4021 return err; 4072 4022 } 4073 4023 4074 - if (selinux_policycap_netpeer) { 4075 - err = selinux_skb_peerlbl_sid(skb, family, &peer_sid); 4076 - if (err) 4077 - return err; 4078 - err = avc_has_perm(sk_sid, peer_sid, 4079 - SECCLASS_PEER, PEER__RECV, &ad); 4080 - if (err) 4081 - selinux_netlbl_err(skb, err, 0); 4082 - } else { 4083 - err = selinux_netlbl_sock_rcv_skb(sksec, skb, family, &ad); 4084 - if (err) 4085 - return err; 4086 - err = selinux_xfrm_sock_rcv_skb(sksec->sid, skb, &ad); 4087 - } 4024 + err = selinux_netlbl_sock_rcv_skb(sksec, skb, family, &ad); 4025 + if (err) 4026 + return err; 4027 + err = selinux_xfrm_sock_rcv_skb(sksec->sid, skb, &ad); 4088 4028 4089 4029 return err; 4090 4030 } ··· 4569 4529 SECCLASS_PACKET, PACKET__SEND, &ad)) 4570 4530 return NF_DROP_ERR(-ECONNREFUSED); 4571 4531 4572 - if (selinux_policycap_netpeer) 4573 - if (selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto)) 4574 - return NF_DROP_ERR(-ECONNREFUSED); 4532 + if (selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto)) 4533 + return NF_DROP_ERR(-ECONNREFUSED); 4575 4534 4576 4535 return NF_ACCEPT; 4577 4536 } ··· 4613 4574 * from the sending socket, otherwise use the kernel's sid */ 4614 4575 sk = skb->sk; 4615 4576 if (sk == NULL) { 4616 - switch (family) { 4617 - case PF_INET: 4618 - if (IPCB(skb)->flags & IPSKB_FORWARDED) 4619 - secmark_perm = PACKET__FORWARD_OUT; 4620 - else 4621 - secmark_perm = PACKET__SEND; 4622 - break; 4623 - case PF_INET6: 4624 - if (IP6CB(skb)->flags & IP6SKB_FORWARDED) 4625 - secmark_perm = PACKET__FORWARD_OUT; 4626 - else 4627 - secmark_perm = PACKET__SEND; 4628 - break; 4629 - default: 4630 - return NF_DROP_ERR(-ECONNREFUSED); 4631 - } 4632 - if (secmark_perm == PACKET__FORWARD_OUT) { 4577 + if (skb->skb_iif) { 4578 + secmark_perm = PACKET__FORWARD_OUT; 4633 4579 if (selinux_skb_peerlbl_sid(skb, family, &peer_sid)) 4634 4580 return NF_DROP; 4635 - } else 4581 + } else { 4582 + secmark_perm = PACKET__SEND; 4636 4583 peer_sid = SECINITSID_KERNEL; 4584 + } 4637 4585 } else { 4638 4586 struct sk_security_struct *sksec = sk->sk_security; 4639 4587 peer_sid = sksec->sid; ··· 4874 4848 * message queue this message will be stored in 4875 4849 */ 4876 4850 rc = security_transition_sid(sid, isec->sid, SECCLASS_MSG, 4877 - &msec->sid); 4851 + NULL, &msec->sid); 4878 4852 if (rc) 4879 4853 return rc; 4880 4854 } ··· 5428 5402 .ptrace_traceme = selinux_ptrace_traceme, 5429 5403 .capget = selinux_capget, 5430 5404 .capset = selinux_capset, 5431 - .sysctl = selinux_sysctl, 5432 5405 .capable = selinux_capable, 5433 5406 .quotactl = selinux_quotactl, 5434 5407 .quota_on = selinux_quota_on, ··· 5445 5420 .sb_alloc_security = selinux_sb_alloc_security, 5446 5421 .sb_free_security = selinux_sb_free_security, 5447 5422 .sb_copy_data = selinux_sb_copy_data, 5423 + .sb_remount = selinux_sb_remount, 5448 5424 .sb_kern_mount = selinux_sb_kern_mount, 5449 5425 .sb_show_options = selinux_sb_show_options, 5450 5426 .sb_statfs = selinux_sb_statfs,
+5 -2
security/selinux/include/classmap.h
··· 12 12 #define COMMON_IPC_PERMS "create", "destroy", "getattr", "setattr", "read", \ 13 13 "write", "associate", "unix_read", "unix_write" 14 14 15 + /* 16 + * Note: The name for any socket class should be suffixed by "socket", 17 + * and doesn't contain more than one substr of "socket". 18 + */ 15 19 struct security_class_mapping secclass_map[] = { 16 20 { "security", 17 21 { "compute_av", "compute_create", "compute_member", ··· 136 132 { "appletalk_socket", 137 133 { COMMON_SOCK_PERMS, NULL } }, 138 134 { "packet", 139 - { "send", "recv", "relabelto", "flow_in", "flow_out", 140 - "forward_in", "forward_out", NULL } }, 135 + { "send", "recv", "relabelto", "forward_in", "forward_out", NULL } }, 141 136 { "key", 142 137 { "view", "read", "write", "search", "link", "setattr", "create", 143 138 NULL } },
+5 -3
security/selinux/include/security.h
··· 8 8 #ifndef _SELINUX_SECURITY_H_ 9 9 #define _SELINUX_SECURITY_H_ 10 10 11 + #include <linux/dcache.h> 11 12 #include <linux/magic.h> 12 13 #include <linux/types.h> 13 14 #include "flask.h" ··· 29 28 #define POLICYDB_VERSION_POLCAP 22 30 29 #define POLICYDB_VERSION_PERMISSIVE 23 31 30 #define POLICYDB_VERSION_BOUNDARY 24 31 + #define POLICYDB_VERSION_FILENAME_TRANS 25 32 32 33 33 /* Range of policy versions we understand*/ 34 34 #define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE 35 35 #ifdef CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX 36 36 #define POLICYDB_VERSION_MAX CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE 37 37 #else 38 - #define POLICYDB_VERSION_MAX POLICYDB_VERSION_BOUNDARY 38 + #define POLICYDB_VERSION_MAX POLICYDB_VERSION_FILENAME_TRANS 39 39 #endif 40 40 41 41 /* Mask for just the mount related flags */ ··· 108 106 void security_compute_av_user(u32 ssid, u32 tsid, 109 107 u16 tclass, struct av_decision *avd); 110 108 111 - int security_transition_sid(u32 ssid, u32 tsid, 112 - u16 tclass, u32 *out_sid); 109 + int security_transition_sid(u32 ssid, u32 tsid, u16 tclass, 110 + const struct qstr *qstr, u32 *out_sid); 113 111 114 112 int security_transition_sid_user(u32 ssid, u32 tsid, 115 113 u16 tclass, u32 *out_sid);
+11 -11
security/selinux/ss/avtab.h
··· 14 14 * 15 15 * Copyright (C) 2003 Tresys Technology, LLC 16 16 * This program is free software; you can redistribute it and/or modify 17 - * it under the terms of the GNU General Public License as published by 17 + * it under the terms of the GNU General Public License as published by 18 18 * the Free Software Foundation, version 2. 19 19 * 20 20 * Updated: Yuichi Nakamura <ynakam@hitachisoft.jp> ··· 27 27 u16 source_type; /* source type */ 28 28 u16 target_type; /* target type */ 29 29 u16 target_class; /* target object class */ 30 - #define AVTAB_ALLOWED 1 31 - #define AVTAB_AUDITALLOW 2 32 - #define AVTAB_AUDITDENY 4 33 - #define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY) 34 - #define AVTAB_TRANSITION 16 35 - #define AVTAB_MEMBER 32 36 - #define AVTAB_CHANGE 64 37 - #define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE) 38 - #define AVTAB_ENABLED_OLD 0x80000000 /* reserved for used in cond_avtab */ 39 - #define AVTAB_ENABLED 0x8000 /* reserved for used in cond_avtab */ 30 + #define AVTAB_ALLOWED 0x0001 31 + #define AVTAB_AUDITALLOW 0x0002 32 + #define AVTAB_AUDITDENY 0x0004 33 + #define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY) 34 + #define AVTAB_TRANSITION 0x0010 35 + #define AVTAB_MEMBER 0x0020 36 + #define AVTAB_CHANGE 0x0040 37 + #define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE) 38 + #define AVTAB_ENABLED_OLD 0x80000000 /* reserved for used in cond_avtab */ 39 + #define AVTAB_ENABLED 0x8000 /* reserved for used in cond_avtab */ 40 40 u16 specified; /* what field is specified */ 41 41 }; 42 42
+3 -2
security/selinux/ss/mls.c
··· 512 512 struct context *tcontext, 513 513 u16 tclass, 514 514 u32 specified, 515 - struct context *newcontext) 515 + struct context *newcontext, 516 + bool sock) 516 517 { 517 518 struct range_trans rtr; 518 519 struct mls_range *r; ··· 532 531 return mls_range_set(newcontext, r); 533 532 /* Fallthrough */ 534 533 case AVTAB_CHANGE: 535 - if (tclass == policydb.process_class) 534 + if ((tclass == policydb.process_class) || (sock == true)) 536 535 /* Use the process MLS attributes. */ 537 536 return mls_context_cpy(newcontext, scontext); 538 537 else
+2 -1
security/selinux/ss/mls.h
··· 49 49 struct context *tcontext, 50 50 u16 tclass, 51 51 u32 specified, 52 - struct context *newcontext); 52 + struct context *newcontext, 53 + bool sock); 53 54 54 55 int mls_setup_user_range(struct context *fromcon, struct user_datum *user, 55 56 struct context *usercon);
+130
security/selinux/ss/policydb.c
··· 123 123 .sym_num = SYM_NUM, 124 124 .ocon_num = OCON_NUM, 125 125 }, 126 + { 127 + .version = POLICYDB_VERSION_FILENAME_TRANS, 128 + .sym_num = SYM_NUM, 129 + .ocon_num = OCON_NUM, 130 + }, 126 131 }; 127 132 128 133 static struct policydb_compat_info *policydb_lookup_compat(int version) ··· 709 704 int i; 710 705 struct role_allow *ra, *lra = NULL; 711 706 struct role_trans *tr, *ltr = NULL; 707 + struct filename_trans *ft, *nft; 712 708 713 709 for (i = 0; i < SYM_NUM; i++) { 714 710 cond_resched(); ··· 787 781 } 788 782 flex_array_free(p->type_attr_map_array); 789 783 } 784 + 785 + ft = p->filename_trans; 786 + while (ft) { 787 + nft = ft->next; 788 + kfree(ft->name); 789 + kfree(ft); 790 + ft = nft; 791 + } 792 + 790 793 ebitmap_destroy(&p->policycaps); 791 794 ebitmap_destroy(&p->permissive_map); 792 795 ··· 1803 1788 return rc; 1804 1789 } 1805 1790 1791 + static int filename_trans_read(struct policydb *p, void *fp) 1792 + { 1793 + struct filename_trans *ft, *last; 1794 + u32 nel, len; 1795 + char *name; 1796 + __le32 buf[4]; 1797 + int rc, i; 1798 + 1799 + if (p->policyvers < POLICYDB_VERSION_FILENAME_TRANS) 1800 + return 0; 1801 + 1802 + rc = next_entry(buf, fp, sizeof(u32)); 1803 + if (rc) 1804 + goto out; 1805 + nel = le32_to_cpu(buf[0]); 1806 + 1807 + printk(KERN_ERR "%s: nel=%d\n", __func__, nel); 1808 + 1809 + last = p->filename_trans; 1810 + while (last && last->next) 1811 + last = last->next; 1812 + 1813 + for (i = 0; i < nel; i++) { 1814 + rc = -ENOMEM; 1815 + ft = kzalloc(sizeof(*ft), GFP_KERNEL); 1816 + if (!ft) 1817 + goto out; 1818 + 1819 + /* add it to the tail of the list */ 1820 + if (!last) 1821 + p->filename_trans = ft; 1822 + else 1823 + last->next = ft; 1824 + last = ft; 1825 + 1826 + /* length of the path component string */ 1827 + rc = next_entry(buf, fp, sizeof(u32)); 1828 + if (rc) 1829 + goto out; 1830 + len = le32_to_cpu(buf[0]); 1831 + 1832 + rc = -ENOMEM; 1833 + name = kmalloc(len + 1, GFP_KERNEL); 1834 + if (!name) 1835 + goto out; 1836 + 1837 + ft->name = name; 1838 + 1839 + /* path component string */ 1840 + rc = next_entry(name, fp, len); 1841 + if (rc) 1842 + goto out; 1843 + name[len] = 0; 1844 + 1845 + printk(KERN_ERR "%s: ft=%p ft->name=%p ft->name=%s\n", __func__, ft, ft->name, ft->name); 1846 + 1847 + rc = next_entry(buf, fp, sizeof(u32) * 4); 1848 + if (rc) 1849 + goto out; 1850 + 1851 + ft->stype = le32_to_cpu(buf[0]); 1852 + ft->ttype = le32_to_cpu(buf[1]); 1853 + ft->tclass = le32_to_cpu(buf[2]); 1854 + ft->otype = le32_to_cpu(buf[3]); 1855 + } 1856 + rc = 0; 1857 + out: 1858 + return rc; 1859 + } 1860 + 1806 1861 static int genfs_read(struct policydb *p, void *fp) 1807 1862 { 1808 1863 int i, j, rc; ··· 2335 2250 goto bad; 2336 2251 lra = ra; 2337 2252 } 2253 + 2254 + rc = filename_trans_read(p, fp); 2255 + if (rc) 2256 + goto bad; 2338 2257 2339 2258 rc = policydb_index(p); 2340 2259 if (rc) ··· 3114 3025 return 0; 3115 3026 } 3116 3027 3028 + static int filename_trans_write(struct policydb *p, void *fp) 3029 + { 3030 + struct filename_trans *ft; 3031 + u32 len, nel = 0; 3032 + __le32 buf[4]; 3033 + int rc; 3034 + 3035 + for (ft = p->filename_trans; ft; ft = ft->next) 3036 + nel++; 3037 + 3038 + buf[0] = cpu_to_le32(nel); 3039 + rc = put_entry(buf, sizeof(u32), 1, fp); 3040 + if (rc) 3041 + return rc; 3042 + 3043 + for (ft = p->filename_trans; ft; ft = ft->next) { 3044 + len = strlen(ft->name); 3045 + buf[0] = cpu_to_le32(len); 3046 + rc = put_entry(buf, sizeof(u32), 1, fp); 3047 + if (rc) 3048 + return rc; 3049 + 3050 + rc = put_entry(ft->name, sizeof(char), len, fp); 3051 + if (rc) 3052 + return rc; 3053 + 3054 + buf[0] = ft->stype; 3055 + buf[1] = ft->ttype; 3056 + buf[2] = ft->tclass; 3057 + buf[3] = ft->otype; 3058 + 3059 + rc = put_entry(buf, sizeof(u32), 4, fp); 3060 + if (rc) 3061 + return rc; 3062 + } 3063 + return 0; 3064 + } 3117 3065 /* 3118 3066 * Write the configuration data in a policy database 3119 3067 * structure to a policy database binary representation ··· 3258 3132 return rc; 3259 3133 3260 3134 rc = role_allow_write(p->role_allow, fp); 3135 + if (rc) 3136 + return rc; 3137 + 3138 + rc = filename_trans_write(p, fp); 3261 3139 if (rc) 3262 3140 return rc; 3263 3141
+13 -1
security/selinux/ss/policydb.h
··· 77 77 struct role_trans *next; 78 78 }; 79 79 80 + struct filename_trans { 81 + struct filename_trans *next; 82 + u32 stype; /* current process */ 83 + u32 ttype; /* parent dir context */ 84 + u16 tclass; /* class of new object */ 85 + const char *name; /* last path component */ 86 + u32 otype; /* expected of new object */ 87 + }; 88 + 80 89 struct role_allow { 81 90 u32 role; /* current role */ 82 91 u32 new_role; /* new role */ ··· 226 217 /* role transitions */ 227 218 struct role_trans *role_tr; 228 219 220 + /* file transitions with the last path component */ 221 + struct filename_trans *filename_trans; 222 + 229 223 /* bools indexed by (value - 1) */ 230 224 struct cond_bool_datum **bool_val_to_struct; 231 225 /* type enforcement conditional access vectors and transitions */ ··· 314 302 return 0; 315 303 } 316 304 317 - static inline int put_entry(void *buf, size_t bytes, int num, struct policy_file *fp) 305 + static inline int put_entry(const void *buf, size_t bytes, int num, struct policy_file *fp) 318 306 { 319 307 size_t len = bytes * num; 320 308
+55 -18
security/selinux/ss/services.c
··· 201 201 return tclass; 202 202 } 203 203 204 + /* 205 + * Get kernel value for class from its policy value 206 + */ 207 + static u16 map_class(u16 pol_value) 208 + { 209 + u16 i; 210 + 211 + for (i = 1; i < current_mapping_size; i++) { 212 + if (current_mapping[i].value == pol_value) 213 + return i; 214 + } 215 + 216 + return pol_value; 217 + } 218 + 204 219 static void map_decision(u16 tclass, struct av_decision *avd, 205 220 int allow_unknown) 206 221 { ··· 1358 1343 return -EACCES; 1359 1344 } 1360 1345 1346 + static void filename_compute_type(struct policydb *p, struct context *newcontext, 1347 + u32 scon, u32 tcon, u16 tclass, 1348 + const struct qstr *qstr) 1349 + { 1350 + struct filename_trans *ft; 1351 + for (ft = p->filename_trans; ft; ft = ft->next) { 1352 + if (ft->stype == scon && 1353 + ft->ttype == tcon && 1354 + ft->tclass == tclass && 1355 + !strcmp(ft->name, qstr->name)) { 1356 + newcontext->type = ft->otype; 1357 + return; 1358 + } 1359 + } 1360 + } 1361 + 1361 1362 static int security_compute_sid(u32 ssid, 1362 1363 u32 tsid, 1363 1364 u16 orig_tclass, 1364 1365 u32 specified, 1366 + const struct qstr *qstr, 1365 1367 u32 *out_sid, 1366 1368 bool kern) 1367 1369 { ··· 1389 1357 struct avtab_node *node; 1390 1358 u16 tclass; 1391 1359 int rc = 0; 1360 + bool sock; 1392 1361 1393 1362 if (!ss_initialized) { 1394 1363 switch (orig_tclass) { ··· 1407 1374 1408 1375 read_lock(&policy_rwlock); 1409 1376 1410 - if (kern) 1377 + if (kern) { 1411 1378 tclass = unmap_class(orig_tclass); 1412 - else 1379 + sock = security_is_socket_class(orig_tclass); 1380 + } else { 1413 1381 tclass = orig_tclass; 1382 + sock = security_is_socket_class(map_class(tclass)); 1383 + } 1414 1384 1415 1385 scontext = sidtab_search(&sidtab, ssid); 1416 1386 if (!scontext) { ··· 1444 1408 } 1445 1409 1446 1410 /* Set the role and type to default values. */ 1447 - if (tclass == policydb.process_class) { 1411 + if ((tclass == policydb.process_class) || (sock == true)) { 1448 1412 /* Use the current role and type of process. */ 1449 1413 newcontext.role = scontext->role; 1450 1414 newcontext.type = scontext->type; ··· 1478 1442 newcontext.type = avdatum->data; 1479 1443 } 1480 1444 1445 + /* if we have a qstr this is a file trans check so check those rules */ 1446 + if (qstr) 1447 + filename_compute_type(&policydb, &newcontext, scontext->type, 1448 + tcontext->type, tclass, qstr); 1449 + 1481 1450 /* Check for class-specific changes. */ 1482 1451 if (tclass == policydb.process_class) { 1483 1452 if (specified & AVTAB_TRANSITION) { ··· 1501 1460 1502 1461 /* Set the MLS attributes. 1503 1462 This is done last because it may allocate memory. */ 1504 - rc = mls_compute_sid(scontext, tcontext, tclass, specified, &newcontext); 1463 + rc = mls_compute_sid(scontext, tcontext, tclass, specified, 1464 + &newcontext, sock); 1505 1465 if (rc) 1506 1466 goto out_unlock; 1507 1467 ··· 1537 1495 * if insufficient memory is available, or %0 if the new SID was 1538 1496 * computed successfully. 1539 1497 */ 1540 - int security_transition_sid(u32 ssid, 1541 - u32 tsid, 1542 - u16 tclass, 1543 - u32 *out_sid) 1498 + int security_transition_sid(u32 ssid, u32 tsid, u16 tclass, 1499 + const struct qstr *qstr, u32 *out_sid) 1544 1500 { 1545 1501 return security_compute_sid(ssid, tsid, tclass, AVTAB_TRANSITION, 1546 - out_sid, true); 1502 + qstr, out_sid, true); 1547 1503 } 1548 1504 1549 - int security_transition_sid_user(u32 ssid, 1550 - u32 tsid, 1551 - u16 tclass, 1552 - u32 *out_sid) 1505 + int security_transition_sid_user(u32 ssid, u32 tsid, u16 tclass, u32 *out_sid) 1553 1506 { 1554 1507 return security_compute_sid(ssid, tsid, tclass, AVTAB_TRANSITION, 1555 - out_sid, false); 1508 + NULL, out_sid, false); 1556 1509 } 1557 1510 1558 1511 /** ··· 1568 1531 u16 tclass, 1569 1532 u32 *out_sid) 1570 1533 { 1571 - return security_compute_sid(ssid, tsid, tclass, AVTAB_MEMBER, out_sid, 1572 - false); 1534 + return security_compute_sid(ssid, tsid, tclass, AVTAB_MEMBER, NULL, 1535 + out_sid, false); 1573 1536 } 1574 1537 1575 1538 /** ··· 1590 1553 u16 tclass, 1591 1554 u32 *out_sid) 1592 1555 { 1593 - return security_compute_sid(ssid, tsid, tclass, AVTAB_CHANGE, out_sid, 1594 - false); 1556 + return security_compute_sid(ssid, tsid, tclass, AVTAB_CHANGE, NULL, 1557 + out_sid, false); 1595 1558 } 1596 1559 1597 1560 /* Clone the SID into the new SID table. */
+1 -1
security/selinux/xfrm.c
··· 208 208 if (!uctx) 209 209 goto not_from_user; 210 210 211 - if (uctx->ctx_doi != XFRM_SC_ALG_SELINUX) 211 + if (uctx->ctx_alg != XFRM_SC_ALG_SELINUX) 212 212 return -EINVAL; 213 213 214 214 str_len = uctx->ctx_len;
+4 -1
security/smack/smack_lsm.c
··· 33 33 #include <net/cipso_ipv4.h> 34 34 #include <linux/audit.h> 35 35 #include <linux/magic.h> 36 + #include <linux/dcache.h> 36 37 #include "smack.h" 37 38 38 39 #define task_security(task) (task_cred_xxx((task), security)) ··· 502 501 * smack_inode_init_security - copy out the smack from an inode 503 502 * @inode: the inode 504 503 * @dir: unused 504 + * @qstr: unused 505 505 * @name: where to put the attribute name 506 506 * @value: where to put the attribute value 507 507 * @len: where to put the length of the attribute ··· 510 508 * Returns 0 if it all works out, -ENOMEM if there's no memory 511 509 */ 512 510 static int smack_inode_init_security(struct inode *inode, struct inode *dir, 513 - char **name, void **value, size_t *len) 511 + const struct qstr *qstr, char **name, 512 + void **value, size_t *len) 514 513 { 515 514 char *isp = smk_of_inode(inode); 516 515 char *dsp = smk_of_inode(dir);