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 for-linus

Conflicts:
lib/flex_array.c
security/selinux/avc.c
security/selinux/hooks.c
security/selinux/ss/policydb.c
security/smack/smack_lsm.c

Manually resolve conflicts.

Signed-off-by: James Morris <jmorris@namei.org>

+399 -221
+2 -1
MAINTAINERS
··· 5592 5592 M: Eric Paris <eparis@parisplace.org> 5593 5593 L: selinux@tycho.nsa.gov (subscribers-only, general discussion) 5594 5594 W: http://selinuxproject.org 5595 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6.git 5595 + T: git git://git.infradead.org/users/eparis/selinux.git 5596 5596 S: Supported 5597 5597 F: include/linux/selinux* 5598 5598 F: security/selinux/ 5599 + F: scripts/selinux/ 5599 5600 5600 5601 APPARMOR SECURITY MODULE 5601 5602 M: John Johansen <john.johansen@canonical.com>
+6 -5
include/linux/lsm_audit.h
··· 27 27 /* Auxiliary data to use in generating the audit record. */ 28 28 struct common_audit_data { 29 29 char type; 30 - #define LSM_AUDIT_DATA_FS 1 30 + #define LSM_AUDIT_DATA_PATH 1 31 31 #define LSM_AUDIT_DATA_NET 2 32 32 #define LSM_AUDIT_DATA_CAP 3 33 33 #define LSM_AUDIT_DATA_IPC 4 ··· 35 35 #define LSM_AUDIT_DATA_KEY 6 36 36 #define LSM_AUDIT_DATA_NONE 7 37 37 #define LSM_AUDIT_DATA_KMOD 8 38 + #define LSM_AUDIT_DATA_INODE 9 39 + #define LSM_AUDIT_DATA_DENTRY 10 38 40 struct task_struct *tsk; 39 41 union { 40 - struct { 41 - struct path path; 42 - struct inode *inode; 43 - } fs; 42 + struct path path; 43 + struct dentry *dentry; 44 + struct inode *inode; 44 45 struct { 45 46 int netif; 46 47 struct sock *sk;
+20 -6
lib/flex_array.c
··· 88 88 gfp_t flags) 89 89 { 90 90 struct flex_array *ret; 91 - int max_size = FLEX_ARRAY_NR_BASE_PTRS * 92 - FLEX_ARRAY_ELEMENTS_PER_PART(element_size); 91 + int max_size = 0; 92 + 93 + if (element_size) 94 + max_size = FLEX_ARRAY_NR_BASE_PTRS * 95 + FLEX_ARRAY_ELEMENTS_PER_PART(element_size); 93 96 94 97 /* max_size will end up 0 if element_size > PAGE_SIZE */ 95 98 if (total > max_size) ··· 186 183 int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src, 187 184 gfp_t flags) 188 185 { 189 - int part_nr = fa_element_to_part_nr(fa, element_nr); 186 + int part_nr; 190 187 struct flex_array_part *part; 191 188 void *dst; 192 189 193 190 if (element_nr >= fa->total_nr_elements) 194 191 return -ENOSPC; 192 + if (!fa->element_size) 193 + return 0; 195 194 if (elements_fit_in_base(fa)) 196 195 part = (struct flex_array_part *)&fa->parts[0]; 197 196 else { 197 + part_nr = fa_element_to_part_nr(fa, element_nr); 198 198 part = __fa_get_part(fa, part_nr, flags); 199 199 if (!part) 200 200 return -ENOMEM; ··· 217 211 */ 218 212 int flex_array_clear(struct flex_array *fa, unsigned int element_nr) 219 213 { 220 - int part_nr = fa_element_to_part_nr(fa, element_nr); 214 + int part_nr; 221 215 struct flex_array_part *part; 222 216 void *dst; 223 217 224 218 if (element_nr >= fa->total_nr_elements) 225 219 return -ENOSPC; 220 + if (!fa->element_size) 221 + return 0; 226 222 if (elements_fit_in_base(fa)) 227 223 part = (struct flex_array_part *)&fa->parts[0]; 228 224 else { 225 + part_nr = fa_element_to_part_nr(fa, element_nr); 229 226 part = fa->parts[part_nr]; 230 227 if (!part) 231 228 return -EINVAL; ··· 273 264 274 265 if (end >= fa->total_nr_elements) 275 266 return -ENOSPC; 267 + if (!fa->element_size) 268 + return 0; 276 269 if (elements_fit_in_base(fa)) 277 270 return 0; 278 271 start_part = fa_element_to_part_nr(fa, start); ··· 302 291 */ 303 292 void *flex_array_get(struct flex_array *fa, unsigned int element_nr) 304 293 { 305 - int part_nr = fa_element_to_part_nr(fa, element_nr); 294 + int part_nr; 306 295 struct flex_array_part *part; 307 296 297 + if (!fa->element_size) 298 + return NULL; 308 299 if (element_nr >= fa->total_nr_elements) 309 300 return NULL; 310 301 if (elements_fit_in_base(fa)) 311 302 part = (struct flex_array_part *)&fa->parts[0]; 312 303 else { 304 + part_nr = fa_element_to_part_nr(fa, element_nr); 313 305 part = fa->parts[part_nr]; 314 306 if (!part) 315 307 return NULL; ··· 367 353 int part_nr; 368 354 int ret = 0; 369 355 370 - if (!fa->total_nr_elements) 356 + if (!fa->total_nr_elements || !fa->element_size) 371 357 return 0; 372 358 if (elements_fit_in_base(fa)) 373 359 return ret;
+36 -23
security/lsm_audit.c
··· 210 210 static void dump_common_audit_data(struct audit_buffer *ab, 211 211 struct common_audit_data *a) 212 212 { 213 - struct inode *inode = NULL; 214 213 struct task_struct *tsk = current; 215 214 216 215 if (a->tsk) ··· 228 229 case LSM_AUDIT_DATA_CAP: 229 230 audit_log_format(ab, " capability=%d ", a->u.cap); 230 231 break; 231 - case LSM_AUDIT_DATA_FS: 232 - if (a->u.fs.path.dentry) { 233 - struct dentry *dentry = a->u.fs.path.dentry; 234 - if (a->u.fs.path.mnt) { 235 - audit_log_d_path(ab, "path=", &a->u.fs.path); 236 - } else { 237 - audit_log_format(ab, " name="); 238 - audit_log_untrustedstring(ab, 239 - dentry->d_name.name); 240 - } 241 - inode = dentry->d_inode; 242 - } else if (a->u.fs.inode) { 243 - struct dentry *dentry; 244 - inode = a->u.fs.inode; 245 - dentry = d_find_alias(inode); 246 - if (dentry) { 247 - audit_log_format(ab, " name="); 248 - audit_log_untrustedstring(ab, 249 - dentry->d_name.name); 250 - dput(dentry); 251 - } 252 - } 232 + case LSM_AUDIT_DATA_PATH: { 233 + struct inode *inode; 234 + 235 + audit_log_d_path(ab, "path=", &a->u.path); 236 + 237 + inode = a->u.path.dentry->d_inode; 253 238 if (inode) 254 239 audit_log_format(ab, " dev=%s ino=%lu", 255 240 inode->i_sb->s_id, 256 241 inode->i_ino); 257 242 break; 243 + } 244 + case LSM_AUDIT_DATA_DENTRY: { 245 + struct inode *inode; 246 + 247 + audit_log_format(ab, " name="); 248 + audit_log_untrustedstring(ab, a->u.dentry->d_name.name); 249 + 250 + inode = a->u.dentry->d_inode; 251 + if (inode) 252 + audit_log_format(ab, " dev=%s ino=%lu", 253 + inode->i_sb->s_id, 254 + inode->i_ino); 255 + break; 256 + } 257 + case LSM_AUDIT_DATA_INODE: { 258 + struct dentry *dentry; 259 + struct inode *inode; 260 + 261 + inode = a->u.inode; 262 + dentry = d_find_alias(inode); 263 + if (dentry) { 264 + audit_log_format(ab, " name="); 265 + audit_log_untrustedstring(ab, 266 + dentry->d_name.name); 267 + dput(dentry); 268 + } 269 + audit_log_format(ab, " dev=%s ino=%lu", inode->i_sb->s_id, 270 + inode->i_ino); 271 + break; 272 + } 258 273 case LSM_AUDIT_DATA_TASK: 259 274 tsk = a->u.tsk; 260 275 if (tsk && tsk->pid) {
+1 -1
security/selinux/avc.c
··· 526 526 * during retry. However this is logically just as if the operation 527 527 * happened a little later. 528 528 */ 529 - if ((a->type == LSM_AUDIT_DATA_FS) && 529 + if ((a->type == LSM_AUDIT_DATA_INODE) && 530 530 (flags & IPERM_FLAG_RCU)) 531 531 return -ECHILD; 532 532
+55 -37
security/selinux/hooks.c
··· 990 990 continue; 991 991 default: 992 992 BUG(); 993 + return; 993 994 }; 994 995 /* we need a comma before each option */ 995 996 seq_putc(m, ','); ··· 1444 1443 printk(KERN_ERR 1445 1444 "SELinux: out of range capability %d\n", cap); 1446 1445 BUG(); 1446 + return -EINVAL; 1447 1447 } 1448 1448 1449 1449 rc = avc_has_perm_noaudit(sid, sid, sclass, av, 0, &avd); ··· 1489 1487 1490 1488 if (!adp) { 1491 1489 adp = &ad; 1492 - COMMON_AUDIT_DATA_INIT(&ad, FS); 1493 - ad.u.fs.inode = inode; 1490 + COMMON_AUDIT_DATA_INIT(&ad, INODE); 1491 + ad.u.inode = inode; 1494 1492 } 1495 1493 1496 1494 return avc_has_perm_flags(sid, isec->sid, isec->sclass, perms, adp, flags); ··· 1500 1498 the dentry to help the auditing code to more easily generate the 1501 1499 pathname if needed. */ 1502 1500 static inline int dentry_has_perm(const struct cred *cred, 1503 - struct vfsmount *mnt, 1504 1501 struct dentry *dentry, 1505 1502 u32 av) 1506 1503 { 1507 1504 struct inode *inode = dentry->d_inode; 1508 1505 struct common_audit_data ad; 1509 1506 1510 - COMMON_AUDIT_DATA_INIT(&ad, FS); 1511 - ad.u.fs.path.mnt = mnt; 1512 - ad.u.fs.path.dentry = dentry; 1507 + COMMON_AUDIT_DATA_INIT(&ad, DENTRY); 1508 + ad.u.dentry = dentry; 1509 + return inode_has_perm(cred, inode, av, &ad, 0); 1510 + } 1511 + 1512 + /* Same as inode_has_perm, but pass explicit audit data containing 1513 + the path to help the auditing code to more easily generate the 1514 + pathname if needed. */ 1515 + static inline int path_has_perm(const struct cred *cred, 1516 + struct path *path, 1517 + u32 av) 1518 + { 1519 + struct inode *inode = path->dentry->d_inode; 1520 + struct common_audit_data ad; 1521 + 1522 + COMMON_AUDIT_DATA_INIT(&ad, PATH); 1523 + ad.u.path = *path; 1513 1524 return inode_has_perm(cred, inode, av, &ad, 0); 1514 1525 } 1515 1526 ··· 1544 1529 u32 sid = cred_sid(cred); 1545 1530 int rc; 1546 1531 1547 - COMMON_AUDIT_DATA_INIT(&ad, FS); 1548 - ad.u.fs.path = file->f_path; 1532 + COMMON_AUDIT_DATA_INIT(&ad, PATH); 1533 + ad.u.path = file->f_path; 1549 1534 1550 1535 if (sid != fsec->sid) { 1551 1536 rc = avc_has_perm(sid, fsec->sid, ··· 1583 1568 sid = tsec->sid; 1584 1569 newsid = tsec->create_sid; 1585 1570 1586 - COMMON_AUDIT_DATA_INIT(&ad, FS); 1587 - ad.u.fs.path.dentry = dentry; 1571 + COMMON_AUDIT_DATA_INIT(&ad, DENTRY); 1572 + ad.u.dentry = dentry; 1588 1573 1589 1574 rc = avc_has_perm(sid, dsec->sid, SECCLASS_DIR, 1590 1575 DIR__ADD_NAME | DIR__SEARCH, ··· 1636 1621 dsec = dir->i_security; 1637 1622 isec = dentry->d_inode->i_security; 1638 1623 1639 - COMMON_AUDIT_DATA_INIT(&ad, FS); 1640 - ad.u.fs.path.dentry = dentry; 1624 + COMMON_AUDIT_DATA_INIT(&ad, DENTRY); 1625 + ad.u.dentry = dentry; 1641 1626 1642 1627 av = DIR__SEARCH; 1643 1628 av |= (kind ? DIR__REMOVE_NAME : DIR__ADD_NAME); ··· 1682 1667 old_is_dir = S_ISDIR(old_dentry->d_inode->i_mode); 1683 1668 new_dsec = new_dir->i_security; 1684 1669 1685 - COMMON_AUDIT_DATA_INIT(&ad, FS); 1670 + COMMON_AUDIT_DATA_INIT(&ad, DENTRY); 1686 1671 1687 - ad.u.fs.path.dentry = old_dentry; 1672 + ad.u.dentry = old_dentry; 1688 1673 rc = avc_has_perm(sid, old_dsec->sid, SECCLASS_DIR, 1689 1674 DIR__REMOVE_NAME | DIR__SEARCH, &ad); 1690 1675 if (rc) ··· 1700 1685 return rc; 1701 1686 } 1702 1687 1703 - ad.u.fs.path.dentry = new_dentry; 1688 + ad.u.dentry = new_dentry; 1704 1689 av = DIR__ADD_NAME | DIR__SEARCH; 1705 1690 if (new_dentry->d_inode) 1706 1691 av |= DIR__REMOVE_NAME; ··· 1910 1895 { 1911 1896 const struct cred *cred = current_cred(); 1912 1897 1913 - return dentry_has_perm(cred, NULL, dentry, FILE__QUOTAON); 1898 + return dentry_has_perm(cred, dentry, FILE__QUOTAON); 1914 1899 } 1915 1900 1916 1901 static int selinux_syslog(int type) ··· 2007 1992 return rc; 2008 1993 } 2009 1994 2010 - COMMON_AUDIT_DATA_INIT(&ad, FS); 2011 - ad.u.fs.path = bprm->file->f_path; 1995 + COMMON_AUDIT_DATA_INIT(&ad, PATH); 1996 + ad.u.path = bprm->file->f_path; 2012 1997 2013 1998 if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID) 2014 1999 new_tsec->sid = old_tsec->sid; ··· 2136 2121 2137 2122 /* Revalidate access to inherited open files. */ 2138 2123 2139 - COMMON_AUDIT_DATA_INIT(&ad, FS); 2124 + COMMON_AUDIT_DATA_INIT(&ad, INODE); 2140 2125 2141 2126 spin_lock(&files->file_lock); 2142 2127 for (;;) { ··· 2484 2469 if (flags & MS_KERNMOUNT) 2485 2470 return 0; 2486 2471 2487 - COMMON_AUDIT_DATA_INIT(&ad, FS); 2488 - ad.u.fs.path.dentry = sb->s_root; 2472 + COMMON_AUDIT_DATA_INIT(&ad, DENTRY); 2473 + ad.u.dentry = sb->s_root; 2489 2474 return superblock_has_perm(cred, sb, FILESYSTEM__MOUNT, &ad); 2490 2475 } 2491 2476 ··· 2494 2479 const struct cred *cred = current_cred(); 2495 2480 struct common_audit_data ad; 2496 2481 2497 - COMMON_AUDIT_DATA_INIT(&ad, FS); 2498 - ad.u.fs.path.dentry = dentry->d_sb->s_root; 2482 + COMMON_AUDIT_DATA_INIT(&ad, DENTRY); 2483 + ad.u.dentry = dentry->d_sb->s_root; 2499 2484 return superblock_has_perm(cred, dentry->d_sb, FILESYSTEM__GETATTR, &ad); 2500 2485 } 2501 2486 ··· 2511 2496 return superblock_has_perm(cred, path->mnt->mnt_sb, 2512 2497 FILESYSTEM__REMOUNT, NULL); 2513 2498 else 2514 - return dentry_has_perm(cred, path->mnt, path->dentry, 2515 - FILE__MOUNTON); 2499 + return path_has_perm(cred, path, FILE__MOUNTON); 2516 2500 } 2517 2501 2518 2502 static int selinux_umount(struct vfsmount *mnt, int flags) ··· 2644 2630 { 2645 2631 const struct cred *cred = current_cred(); 2646 2632 2647 - return dentry_has_perm(cred, NULL, dentry, FILE__READ); 2633 + return dentry_has_perm(cred, dentry, FILE__READ); 2648 2634 } 2649 2635 2650 2636 static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *nameidata) 2651 2637 { 2652 2638 const struct cred *cred = current_cred(); 2653 2639 2654 - return dentry_has_perm(cred, NULL, dentry, FILE__READ); 2640 + return dentry_has_perm(cred, dentry, FILE__READ); 2655 2641 } 2656 2642 2657 2643 static int selinux_inode_permission(struct inode *inode, int mask, unsigned flags) ··· 2668 2654 if (!mask) 2669 2655 return 0; 2670 2656 2671 - COMMON_AUDIT_DATA_INIT(&ad, FS); 2672 - ad.u.fs.inode = inode; 2657 + COMMON_AUDIT_DATA_INIT(&ad, INODE); 2658 + ad.u.inode = inode; 2673 2659 2674 2660 if (from_access) 2675 2661 ad.selinux_audit_data.auditdeny |= FILE__AUDIT_ACCESS; ··· 2694 2680 2695 2681 if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | 2696 2682 ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_TIMES_SET)) 2697 - return dentry_has_perm(cred, NULL, dentry, FILE__SETATTR); 2683 + return dentry_has_perm(cred, dentry, FILE__SETATTR); 2698 2684 2699 - return dentry_has_perm(cred, NULL, dentry, FILE__WRITE); 2685 + return dentry_has_perm(cred, dentry, FILE__WRITE); 2700 2686 } 2701 2687 2702 2688 static int selinux_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) 2703 2689 { 2704 2690 const struct cred *cred = current_cred(); 2691 + struct path path; 2705 2692 2706 - return dentry_has_perm(cred, mnt, dentry, FILE__GETATTR); 2693 + path.dentry = dentry; 2694 + path.mnt = mnt; 2695 + 2696 + return path_has_perm(cred, &path, FILE__GETATTR); 2707 2697 } 2708 2698 2709 2699 static int selinux_inode_setotherxattr(struct dentry *dentry, const char *name) ··· 2728 2710 2729 2711 /* Not an attribute we recognize, so just check the 2730 2712 ordinary setattr permission. */ 2731 - return dentry_has_perm(cred, NULL, dentry, FILE__SETATTR); 2713 + return dentry_has_perm(cred, dentry, FILE__SETATTR); 2732 2714 } 2733 2715 2734 2716 static int selinux_inode_setxattr(struct dentry *dentry, const char *name, ··· 2751 2733 if (!inode_owner_or_capable(inode)) 2752 2734 return -EPERM; 2753 2735 2754 - COMMON_AUDIT_DATA_INIT(&ad, FS); 2755 - ad.u.fs.path.dentry = dentry; 2736 + COMMON_AUDIT_DATA_INIT(&ad, DENTRY); 2737 + ad.u.dentry = dentry; 2756 2738 2757 2739 rc = avc_has_perm(sid, isec->sid, isec->sclass, 2758 2740 FILE__RELABELFROM, &ad); ··· 2815 2797 { 2816 2798 const struct cred *cred = current_cred(); 2817 2799 2818 - return dentry_has_perm(cred, NULL, dentry, FILE__GETATTR); 2800 + return dentry_has_perm(cred, dentry, FILE__GETATTR); 2819 2801 } 2820 2802 2821 2803 static int selinux_inode_listxattr(struct dentry *dentry) 2822 2804 { 2823 2805 const struct cred *cred = current_cred(); 2824 2806 2825 - return dentry_has_perm(cred, NULL, dentry, FILE__GETATTR); 2807 + return dentry_has_perm(cred, dentry, FILE__GETATTR); 2826 2808 } 2827 2809 2828 2810 static int selinux_inode_removexattr(struct dentry *dentry, const char *name)
+5 -4
security/selinux/include/security.h
··· 30 30 #define POLICYDB_VERSION_PERMISSIVE 23 31 31 #define POLICYDB_VERSION_BOUNDARY 24 32 32 #define POLICYDB_VERSION_FILENAME_TRANS 25 33 + #define POLICYDB_VERSION_ROLETRANS 26 33 34 34 35 /* Range of policy versions we understand*/ 35 36 #define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE 36 37 #ifdef CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX 37 38 #define POLICYDB_VERSION_MAX CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE 38 39 #else 39 - #define POLICYDB_VERSION_MAX POLICYDB_VERSION_FILENAME_TRANS 40 + #define POLICYDB_VERSION_MAX POLICYDB_VERSION_ROLETRANS 40 41 #endif 41 42 42 43 /* Mask for just the mount related flags */ ··· 86 85 int security_mls_enabled(void); 87 86 88 87 int security_load_policy(void *data, size_t len); 89 - int security_read_policy(void **data, ssize_t *len); 88 + int security_read_policy(void **data, size_t *len); 90 89 size_t security_policydb_len(void); 91 90 92 91 int security_policycap_supported(unsigned int req_cap); ··· 112 111 int security_transition_sid(u32 ssid, u32 tsid, u16 tclass, 113 112 const struct qstr *qstr, u32 *out_sid); 114 113 115 - int security_transition_sid_user(u32 ssid, u32 tsid, 116 - u16 tclass, u32 *out_sid); 114 + int security_transition_sid_user(u32 ssid, u32 tsid, u16 tclass, 115 + const char *objname, u32 *out_sid); 117 116 118 117 int security_member_sid(u32 ssid, u32 tsid, 119 118 u16 tclass, u32 *out_sid);
+1
security/selinux/netnode.c
··· 141 141 break; 142 142 default: 143 143 BUG(); 144 + return NULL; 144 145 } 145 146 146 147 list_for_each_entry_rcu(node, &sel_netnode_hash[idx].list, list)
+26 -4
security/selinux/selinuxfs.c
··· 28 28 #include <linux/percpu.h> 29 29 #include <linux/audit.h> 30 30 #include <linux/uaccess.h> 31 + #include <linux/kobject.h> 31 32 32 33 /* selinuxfs pseudo filesystem for exporting the security policy API. 33 34 Based on the proc code and the fs/nfsd/nfsctl.c code. */ ··· 754 753 static ssize_t sel_write_create(struct file *file, char *buf, size_t size) 755 754 { 756 755 char *scon = NULL, *tcon = NULL; 756 + char *namebuf = NULL, *objname = NULL; 757 757 u32 ssid, tsid, newsid; 758 758 u16 tclass; 759 759 ssize_t length; 760 760 char *newcon = NULL; 761 761 u32 len; 762 + int nargs; 762 763 763 764 length = task_has_security(current, SECURITY__COMPUTE_CREATE); 764 765 if (length) ··· 776 773 if (!tcon) 777 774 goto out; 778 775 779 - length = -EINVAL; 780 - if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 776 + length = -ENOMEM; 777 + namebuf = kzalloc(size + 1, GFP_KERNEL); 778 + if (!namebuf) 781 779 goto out; 780 + 781 + length = -EINVAL; 782 + nargs = sscanf(buf, "%s %s %hu %s", scon, tcon, &tclass, namebuf); 783 + if (nargs < 3 || nargs > 4) 784 + goto out; 785 + if (nargs == 4) 786 + objname = namebuf; 782 787 783 788 length = security_context_to_sid(scon, strlen(scon) + 1, &ssid); 784 789 if (length) ··· 796 785 if (length) 797 786 goto out; 798 787 799 - length = security_transition_sid_user(ssid, tsid, tclass, &newsid); 788 + length = security_transition_sid_user(ssid, tsid, tclass, 789 + objname, &newsid); 800 790 if (length) 801 791 goto out; 802 792 ··· 816 804 length = len; 817 805 out: 818 806 kfree(newcon); 807 + kfree(namebuf); 819 808 kfree(tcon); 820 809 kfree(scon); 821 810 return length; ··· 1914 1901 }; 1915 1902 1916 1903 struct vfsmount *selinuxfs_mount; 1904 + static struct kobject *selinuxfs_kobj; 1917 1905 1918 1906 static int __init init_sel_fs(void) 1919 1907 { ··· 1922 1908 1923 1909 if (!selinux_enabled) 1924 1910 return 0; 1911 + 1912 + selinuxfs_kobj = kobject_create_and_add("selinux", fs_kobj); 1913 + if (!selinuxfs_kobj) 1914 + return -ENOMEM; 1915 + 1925 1916 err = register_filesystem(&sel_fs_type); 1926 - if (err) 1917 + if (err) { 1918 + kobject_put(selinuxfs_kobj); 1927 1919 return err; 1920 + } 1928 1921 1929 1922 selinuxfs_mount = kern_mount(&sel_fs_type); 1930 1923 if (IS_ERR(selinuxfs_mount)) { ··· 1948 1927 #ifdef CONFIG_SECURITY_SELINUX_DISABLE 1949 1928 void exit_sel_fs(void) 1950 1929 { 1930 + kobject_put(selinuxfs_kobj); 1951 1931 unregister_filesystem(&sel_fs_type); 1952 1932 } 1953 1933 #endif
+169 -77
security/selinux/ss/policydb.c
··· 128 128 .sym_num = SYM_NUM, 129 129 .ocon_num = OCON_NUM, 130 130 }, 131 + { 132 + .version = POLICYDB_VERSION_ROLETRANS, 133 + .sym_num = SYM_NUM, 134 + .ocon_num = OCON_NUM, 135 + }, 131 136 }; 132 137 133 138 static struct policydb_compat_info *policydb_lookup_compat(int version) ··· 182 177 kfree(key); 183 178 kfree(role); 184 179 return rc; 180 + } 181 + 182 + static u32 filenametr_hash(struct hashtab *h, const void *k) 183 + { 184 + const struct filename_trans *ft = k; 185 + unsigned long hash; 186 + unsigned int byte_num; 187 + unsigned char focus; 188 + 189 + hash = ft->stype ^ ft->ttype ^ ft->tclass; 190 + 191 + byte_num = 0; 192 + while ((focus = ft->name[byte_num++])) 193 + hash = partial_name_hash(focus, hash); 194 + return hash & (h->size - 1); 195 + } 196 + 197 + static int filenametr_cmp(struct hashtab *h, const void *k1, const void *k2) 198 + { 199 + const struct filename_trans *ft1 = k1; 200 + const struct filename_trans *ft2 = k2; 201 + int v; 202 + 203 + v = ft1->stype - ft2->stype; 204 + if (v) 205 + return v; 206 + 207 + v = ft1->ttype - ft2->ttype; 208 + if (v) 209 + return v; 210 + 211 + v = ft1->tclass - ft2->tclass; 212 + if (v) 213 + return v; 214 + 215 + return strcmp(ft1->name, ft2->name); 216 + 185 217 } 186 218 187 219 static u32 rangetr_hash(struct hashtab *h, const void *k) ··· 273 231 if (rc) 274 232 goto out; 275 233 234 + p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 << 10)); 235 + if (!p->filename_trans) 236 + goto out; 237 + 276 238 p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256); 277 239 if (!p->range_tr) 278 240 goto out; 279 241 242 + ebitmap_init(&p->filename_trans_ttypes); 280 243 ebitmap_init(&p->policycaps); 281 244 ebitmap_init(&p->permissive_map); 282 245 283 246 return 0; 284 247 out: 248 + hashtab_destroy(p->filename_trans); 249 + hashtab_destroy(p->range_tr); 285 250 for (i = 0; i < SYM_NUM; i++) 286 251 hashtab_destroy(p->symtab[i].table); 287 252 return rc; ··· 466 417 }; 467 418 468 419 #ifdef DEBUG_HASHES 469 - static void symtab_hash_eval(struct symtab *s) 470 - { 471 - int i; 472 - 473 - for (i = 0; i < SYM_NUM; i++) { 474 - struct hashtab *h = s[i].table; 475 - struct hashtab_info info; 476 - 477 - hashtab_stat(h, &info); 478 - printk(KERN_DEBUG "SELinux: %s: %d entries and %d/%d buckets used, " 479 - "longest chain length %d\n", symtab_name[i], h->nel, 480 - info.slots_used, h->size, info.max_chain_len); 481 - } 482 - } 483 - 484 - static void rangetr_hash_eval(struct hashtab *h) 420 + static void hash_eval(struct hashtab *h, const char *hash_name) 485 421 { 486 422 struct hashtab_info info; 487 423 488 424 hashtab_stat(h, &info); 489 - printk(KERN_DEBUG "SELinux: rangetr: %d entries and %d/%d buckets used, " 490 - "longest chain length %d\n", h->nel, 425 + printk(KERN_DEBUG "SELinux: %s: %d entries and %d/%d buckets used, " 426 + "longest chain length %d\n", hash_name, h->nel, 491 427 info.slots_used, h->size, info.max_chain_len); 492 428 } 429 + 430 + static void symtab_hash_eval(struct symtab *s) 431 + { 432 + int i; 433 + 434 + for (i = 0; i < SYM_NUM; i++) 435 + hash_eval(s[i].table, symtab_name[i]); 436 + } 437 + 493 438 #else 494 - static inline void rangetr_hash_eval(struct hashtab *h) 439 + static inline void hash_eval(struct hashtab *h, char *hash_name) 495 440 { 496 441 } 497 442 #endif ··· 718 675 cat_destroy, 719 676 }; 720 677 678 + static int filenametr_destroy(void *key, void *datum, void *p) 679 + { 680 + struct filename_trans *ft = key; 681 + kfree(ft->name); 682 + kfree(key); 683 + kfree(datum); 684 + cond_resched(); 685 + return 0; 686 + } 687 + 721 688 static int range_tr_destroy(void *key, void *datum, void *p) 722 689 { 723 690 struct mls_range *rt = datum; ··· 762 709 int i; 763 710 struct role_allow *ra, *lra = NULL; 764 711 struct role_trans *tr, *ltr = NULL; 765 - struct filename_trans *ft, *nft; 766 712 767 713 for (i = 0; i < SYM_NUM; i++) { 768 714 cond_resched(); ··· 825 773 } 826 774 kfree(lra); 827 775 776 + hashtab_map(p->filename_trans, filenametr_destroy, NULL); 777 + hashtab_destroy(p->filename_trans); 778 + 828 779 hashtab_map(p->range_tr, range_tr_destroy, NULL); 829 780 hashtab_destroy(p->range_tr); 830 781 ··· 843 788 flex_array_free(p->type_attr_map_array); 844 789 } 845 790 846 - ft = p->filename_trans; 847 - while (ft) { 848 - nft = ft->next; 849 - kfree(ft->name); 850 - kfree(ft); 851 - ft = nft; 852 - } 853 - 791 + ebitmap_destroy(&p->filename_trans_ttypes); 854 792 ebitmap_destroy(&p->policycaps); 855 793 ebitmap_destroy(&p->permissive_map); 856 794 ··· 1843 1795 rt = NULL; 1844 1796 r = NULL; 1845 1797 } 1846 - rangetr_hash_eval(p->range_tr); 1798 + hash_eval(p->range_tr, "rangetr"); 1847 1799 rc = 0; 1848 1800 out: 1849 1801 kfree(rt); ··· 1853 1805 1854 1806 static int filename_trans_read(struct policydb *p, void *fp) 1855 1807 { 1856 - struct filename_trans *ft, *last; 1857 - u32 nel, len; 1808 + struct filename_trans *ft; 1809 + struct filename_trans_datum *otype; 1858 1810 char *name; 1811 + u32 nel, len; 1859 1812 __le32 buf[4]; 1860 1813 int rc, i; 1861 1814 ··· 1865 1816 1866 1817 rc = next_entry(buf, fp, sizeof(u32)); 1867 1818 if (rc) 1868 - goto out; 1819 + return rc; 1869 1820 nel = le32_to_cpu(buf[0]); 1870 1821 1871 - last = p->filename_trans; 1872 - while (last && last->next) 1873 - last = last->next; 1874 - 1875 1822 for (i = 0; i < nel; i++) { 1823 + ft = NULL; 1824 + otype = NULL; 1825 + name = NULL; 1826 + 1876 1827 rc = -ENOMEM; 1877 1828 ft = kzalloc(sizeof(*ft), GFP_KERNEL); 1878 1829 if (!ft) 1879 1830 goto out; 1880 1831 1881 - /* add it to the tail of the list */ 1882 - if (!last) 1883 - p->filename_trans = ft; 1884 - else 1885 - last->next = ft; 1886 - last = ft; 1832 + rc = -ENOMEM; 1833 + otype = kmalloc(sizeof(*otype), GFP_KERNEL); 1834 + if (!otype) 1835 + goto out; 1887 1836 1888 1837 /* length of the path component string */ 1889 1838 rc = next_entry(buf, fp, sizeof(u32)); ··· 1909 1862 ft->stype = le32_to_cpu(buf[0]); 1910 1863 ft->ttype = le32_to_cpu(buf[1]); 1911 1864 ft->tclass = le32_to_cpu(buf[2]); 1912 - ft->otype = le32_to_cpu(buf[3]); 1865 + 1866 + otype->otype = le32_to_cpu(buf[3]); 1867 + 1868 + rc = ebitmap_set_bit(&p->filename_trans_ttypes, ft->ttype, 1); 1869 + if (rc) 1870 + goto out; 1871 + 1872 + hashtab_insert(p->filename_trans, ft, otype); 1913 1873 } 1914 - rc = 0; 1874 + hash_eval(p->filename_trans, "filenametr"); 1875 + return 0; 1915 1876 out: 1877 + kfree(ft); 1878 + kfree(name); 1879 + kfree(otype); 1880 + 1916 1881 return rc; 1917 1882 } 1918 1883 ··· 2325 2266 p->symtab[i].nprim = nprim; 2326 2267 } 2327 2268 2269 + rc = -EINVAL; 2270 + p->process_class = string_to_security_class(p, "process"); 2271 + if (!p->process_class) 2272 + goto bad; 2273 + 2328 2274 rc = avtab_read(&p->te_avtab, fp, p); 2329 2275 if (rc) 2330 2276 goto bad; ··· 2362 2298 tr->role = le32_to_cpu(buf[0]); 2363 2299 tr->type = le32_to_cpu(buf[1]); 2364 2300 tr->new_role = le32_to_cpu(buf[2]); 2301 + if (p->policyvers >= POLICYDB_VERSION_ROLETRANS) { 2302 + rc = next_entry(buf, fp, sizeof(u32)); 2303 + if (rc) 2304 + goto bad; 2305 + tr->tclass = le32_to_cpu(buf[0]); 2306 + } else 2307 + tr->tclass = p->process_class; 2308 + 2365 2309 if (!policydb_role_isvalid(p, tr->role) || 2366 2310 !policydb_type_isvalid(p, tr->type) || 2311 + !policydb_class_isvalid(p, tr->tclass) || 2367 2312 !policydb_role_isvalid(p, tr->new_role)) 2368 2313 goto bad; 2369 2314 ltr = tr; ··· 2411 2338 2412 2339 rc = policydb_index(p); 2413 2340 if (rc) 2414 - goto bad; 2415 - 2416 - rc = -EINVAL; 2417 - p->process_class = string_to_security_class(p, "process"); 2418 - if (!p->process_class) 2419 2341 goto bad; 2420 2342 2421 2343 rc = -EINVAL; ··· 2585 2517 return 0; 2586 2518 } 2587 2519 2588 - static int role_trans_write(struct role_trans *r, void *fp) 2520 + static int role_trans_write(struct policydb *p, void *fp) 2589 2521 { 2522 + struct role_trans *r = p->role_tr; 2590 2523 struct role_trans *tr; 2591 2524 u32 buf[3]; 2592 2525 size_t nel; ··· 2607 2538 rc = put_entry(buf, sizeof(u32), 3, fp); 2608 2539 if (rc) 2609 2540 return rc; 2541 + if (p->policyvers >= POLICYDB_VERSION_ROLETRANS) { 2542 + buf[0] = cpu_to_le32(tr->tclass); 2543 + rc = put_entry(buf, sizeof(u32), 1, fp); 2544 + if (rc) 2545 + return rc; 2546 + } 2610 2547 } 2611 2548 2612 2549 return 0; ··· 3120 3045 return 0; 3121 3046 } 3122 3047 3123 - static int range_count(void *key, void *data, void *ptr) 3048 + static int hashtab_cnt(void *key, void *data, void *ptr) 3124 3049 { 3125 3050 int *cnt = ptr; 3126 3051 *cnt = *cnt + 1; ··· 3168 3093 3169 3094 /* count the number of entries in the hashtab */ 3170 3095 nel = 0; 3171 - rc = hashtab_map(p->range_tr, range_count, &nel); 3096 + rc = hashtab_map(p->range_tr, hashtab_cnt, &nel); 3172 3097 if (rc) 3173 3098 return rc; 3174 3099 ··· 3185 3110 return 0; 3186 3111 } 3187 3112 3113 + static int filename_write_helper(void *key, void *data, void *ptr) 3114 + { 3115 + __le32 buf[4]; 3116 + struct filename_trans *ft = key; 3117 + struct filename_trans_datum *otype = data; 3118 + void *fp = ptr; 3119 + int rc; 3120 + u32 len; 3121 + 3122 + len = strlen(ft->name); 3123 + buf[0] = cpu_to_le32(len); 3124 + rc = put_entry(buf, sizeof(u32), 1, fp); 3125 + if (rc) 3126 + return rc; 3127 + 3128 + rc = put_entry(ft->name, sizeof(char), len, fp); 3129 + if (rc) 3130 + return rc; 3131 + 3132 + buf[0] = ft->stype; 3133 + buf[1] = ft->ttype; 3134 + buf[2] = ft->tclass; 3135 + buf[3] = otype->otype; 3136 + 3137 + rc = put_entry(buf, sizeof(u32), 4, fp); 3138 + if (rc) 3139 + return rc; 3140 + 3141 + return 0; 3142 + } 3143 + 3188 3144 static int filename_trans_write(struct policydb *p, void *fp) 3189 3145 { 3190 - struct filename_trans *ft; 3191 - u32 len, nel = 0; 3192 - __le32 buf[4]; 3146 + u32 nel; 3147 + __le32 buf[1]; 3193 3148 int rc; 3194 3149 3195 - for (ft = p->filename_trans; ft; ft = ft->next) 3196 - nel++; 3150 + nel = 0; 3151 + rc = hashtab_map(p->filename_trans, hashtab_cnt, &nel); 3152 + if (rc) 3153 + return rc; 3197 3154 3198 3155 buf[0] = cpu_to_le32(nel); 3199 3156 rc = put_entry(buf, sizeof(u32), 1, fp); 3200 3157 if (rc) 3201 3158 return rc; 3202 3159 3203 - for (ft = p->filename_trans; ft; ft = ft->next) { 3204 - len = strlen(ft->name); 3205 - buf[0] = cpu_to_le32(len); 3206 - rc = put_entry(buf, sizeof(u32), 1, fp); 3207 - if (rc) 3208 - return rc; 3160 + rc = hashtab_map(p->filename_trans, filename_write_helper, fp); 3161 + if (rc) 3162 + return rc; 3209 3163 3210 - rc = put_entry(ft->name, sizeof(char), len, fp); 3211 - if (rc) 3212 - return rc; 3213 - 3214 - buf[0] = ft->stype; 3215 - buf[1] = ft->ttype; 3216 - buf[2] = ft->tclass; 3217 - buf[3] = ft->otype; 3218 - 3219 - rc = put_entry(buf, sizeof(u32), 4, fp); 3220 - if (rc) 3221 - return rc; 3222 - } 3223 3164 return 0; 3224 3165 } 3166 + 3225 3167 /* 3226 3168 * Write the configuration data in a policy database 3227 3169 * structure to a policy database binary representation ··· 3341 3249 if (rc) 3342 3250 return rc; 3343 3251 3344 - rc = role_trans_write(p->role_tr, fp); 3252 + rc = role_trans_write(p, fp); 3345 3253 if (rc) 3346 3254 return rc; 3347 3255
+9 -3
security/selinux/ss/policydb.h
··· 72 72 73 73 struct role_trans { 74 74 u32 role; /* current role */ 75 - u32 type; /* program executable type */ 75 + u32 type; /* program executable type, or new object type */ 76 + u32 tclass; /* process class, or new object class */ 76 77 u32 new_role; /* new role */ 77 78 struct role_trans *next; 78 79 }; 79 80 80 81 struct filename_trans { 81 - struct filename_trans *next; 82 82 u32 stype; /* current process */ 83 83 u32 ttype; /* parent dir context */ 84 84 u16 tclass; /* class of new object */ 85 85 const char *name; /* last path component */ 86 + }; 87 + 88 + struct filename_trans_datum { 86 89 u32 otype; /* expected of new object */ 87 90 }; 88 91 ··· 230 227 struct role_trans *role_tr; 231 228 232 229 /* file transitions with the last path component */ 233 - struct filename_trans *filename_trans; 230 + /* quickly exclude lookups when parent ttype has no rules */ 231 + struct ebitmap filename_trans_ttypes; 232 + /* actual set of filename_trans rules */ 233 + struct hashtab *filename_trans; 234 234 235 235 /* bools indexed by (value - 1) */ 236 236 struct cond_bool_datum **bool_val_to_struct;
+39 -31
security/selinux/ss/services.c
··· 1359 1359 } 1360 1360 1361 1361 static void filename_compute_type(struct policydb *p, struct context *newcontext, 1362 - u32 scon, u32 tcon, u16 tclass, 1363 - const struct qstr *qstr) 1362 + u32 stype, u32 ttype, u16 tclass, 1363 + const char *objname) 1364 1364 { 1365 - struct filename_trans *ft; 1366 - for (ft = p->filename_trans; ft; ft = ft->next) { 1367 - if (ft->stype == scon && 1368 - ft->ttype == tcon && 1369 - ft->tclass == tclass && 1370 - !strcmp(ft->name, qstr->name)) { 1371 - newcontext->type = ft->otype; 1372 - return; 1373 - } 1374 - } 1365 + struct filename_trans ft; 1366 + struct filename_trans_datum *otype; 1367 + 1368 + /* 1369 + * Most filename trans rules are going to live in specific directories 1370 + * like /dev or /var/run. This bitmap will quickly skip rule searches 1371 + * if the ttype does not contain any rules. 1372 + */ 1373 + if (!ebitmap_get_bit(&p->filename_trans_ttypes, ttype)) 1374 + return; 1375 + 1376 + ft.stype = stype; 1377 + ft.ttype = ttype; 1378 + ft.tclass = tclass; 1379 + ft.name = objname; 1380 + 1381 + otype = hashtab_search(p->filename_trans, &ft); 1382 + if (otype) 1383 + newcontext->type = otype->otype; 1375 1384 } 1376 1385 1377 1386 static int security_compute_sid(u32 ssid, 1378 1387 u32 tsid, 1379 1388 u16 orig_tclass, 1380 1389 u32 specified, 1381 - const struct qstr *qstr, 1390 + const char *objname, 1382 1391 u32 *out_sid, 1383 1392 bool kern) 1384 1393 { ··· 1487 1478 newcontext.type = avdatum->data; 1488 1479 } 1489 1480 1490 - /* if we have a qstr this is a file trans check so check those rules */ 1491 - if (qstr) 1481 + /* if we have a objname this is a file trans check so check those rules */ 1482 + if (objname) 1492 1483 filename_compute_type(&policydb, &newcontext, scontext->type, 1493 - tcontext->type, tclass, qstr); 1484 + tcontext->type, tclass, objname); 1494 1485 1495 1486 /* Check for class-specific changes. */ 1496 - if (tclass == policydb.process_class) { 1497 - if (specified & AVTAB_TRANSITION) { 1498 - /* Look for a role transition rule. */ 1499 - for (roletr = policydb.role_tr; roletr; 1500 - roletr = roletr->next) { 1501 - if (roletr->role == scontext->role && 1502 - roletr->type == tcontext->type) { 1503 - /* Use the role transition rule. */ 1504 - newcontext.role = roletr->new_role; 1505 - break; 1506 - } 1487 + if (specified & AVTAB_TRANSITION) { 1488 + /* Look for a role transition rule. */ 1489 + for (roletr = policydb.role_tr; roletr; roletr = roletr->next) { 1490 + if ((roletr->role == scontext->role) && 1491 + (roletr->type == tcontext->type) && 1492 + (roletr->tclass == tclass)) { 1493 + /* Use the role transition rule. */ 1494 + newcontext.role = roletr->new_role; 1495 + break; 1507 1496 } 1508 1497 } 1509 1498 } ··· 1548 1541 const struct qstr *qstr, u32 *out_sid) 1549 1542 { 1550 1543 return security_compute_sid(ssid, tsid, tclass, AVTAB_TRANSITION, 1551 - qstr, out_sid, true); 1544 + qstr ? qstr->name : NULL, out_sid, true); 1552 1545 } 1553 1546 1554 - int security_transition_sid_user(u32 ssid, u32 tsid, u16 tclass, u32 *out_sid) 1547 + int security_transition_sid_user(u32 ssid, u32 tsid, u16 tclass, 1548 + const char *objname, u32 *out_sid) 1555 1549 { 1556 1550 return security_compute_sid(ssid, tsid, tclass, AVTAB_TRANSITION, 1557 - NULL, out_sid, false); 1551 + objname, out_sid, false); 1558 1552 } 1559 1553 1560 1554 /** ··· 3198 3190 * @len: length of data in bytes 3199 3191 * 3200 3192 */ 3201 - int security_read_policy(void **data, ssize_t *len) 3193 + int security_read_policy(void **data, size_t *len) 3202 3194 { 3203 3195 int rc; 3204 3196 struct policy_file fp;
+3 -8
security/smack/smack.h
··· 316 316 static inline void smk_ad_setfield_u_fs_path_dentry(struct smk_audit_info *a, 317 317 struct dentry *d) 318 318 { 319 - a->a.u.fs.path.dentry = d; 320 - } 321 - static inline void smk_ad_setfield_u_fs_path_mnt(struct smk_audit_info *a, 322 - struct vfsmount *m) 323 - { 324 - a->a.u.fs.path.mnt = m; 319 + a->a.u.dentry = d; 325 320 } 326 321 static inline void smk_ad_setfield_u_fs_inode(struct smk_audit_info *a, 327 322 struct inode *i) 328 323 { 329 - a->a.u.fs.inode = i; 324 + a->a.u.inode = i; 330 325 } 331 326 static inline void smk_ad_setfield_u_fs_path(struct smk_audit_info *a, 332 327 struct path p) 333 328 { 334 - a->a.u.fs.path = p; 329 + a->a.u.path = p; 335 330 } 336 331 static inline void smk_ad_setfield_u_net_sk(struct smk_audit_info *a, 337 332 struct sock *sk)
+27 -21
security/smack/smack_lsm.c
··· 383 383 int rc; 384 384 struct smk_audit_info ad; 385 385 386 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 386 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 387 387 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 388 388 389 389 rc = smk_curacc(sbp->smk_floor, MAY_READ, &ad); ··· 407 407 struct superblock_smack *sbp = path->mnt->mnt_sb->s_security; 408 408 struct smk_audit_info ad; 409 409 410 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 410 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); 411 411 smk_ad_setfield_u_fs_path(&ad, *path); 412 412 413 413 return smk_curacc(sbp->smk_floor, MAY_WRITE, &ad); ··· 425 425 { 426 426 struct superblock_smack *sbp; 427 427 struct smk_audit_info ad; 428 + struct path path; 428 429 429 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 430 - smk_ad_setfield_u_fs_path_dentry(&ad, mnt->mnt_root); 431 - smk_ad_setfield_u_fs_path_mnt(&ad, mnt); 430 + path.dentry = mnt->mnt_root; 431 + path.mnt = mnt; 432 + 433 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); 434 + smk_ad_setfield_u_fs_path(&ad, path); 432 435 433 436 sbp = mnt->mnt_sb->s_security; 434 437 return smk_curacc(sbp->smk_floor, MAY_WRITE, &ad); ··· 566 563 struct smk_audit_info ad; 567 564 int rc; 568 565 569 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 566 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 570 567 smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry); 571 568 572 569 isp = smk_of_inode(old_dentry->d_inode); ··· 595 592 struct smk_audit_info ad; 596 593 int rc; 597 594 598 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 595 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 599 596 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 600 597 601 598 /* ··· 626 623 struct smk_audit_info ad; 627 624 int rc; 628 625 629 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 626 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 630 627 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 631 628 632 629 /* ··· 666 663 char *isp; 667 664 struct smk_audit_info ad; 668 665 669 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 666 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 670 667 smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry); 671 668 672 669 isp = smk_of_inode(old_dentry->d_inode); ··· 703 700 /* May be droppable after audit */ 704 701 if (flags & IPERM_FLAG_RCU) 705 702 return -ECHILD; 706 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 703 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_INODE); 707 704 smk_ad_setfield_u_fs_inode(&ad, inode); 708 705 return smk_curacc(smk_of_inode(inode), mask, &ad); 709 706 } ··· 723 720 */ 724 721 if (iattr->ia_valid & ATTR_FORCE) 725 722 return 0; 726 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 723 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 727 724 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 728 725 729 726 return smk_curacc(smk_of_inode(dentry->d_inode), MAY_WRITE, &ad); ··· 739 736 static int smack_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) 740 737 { 741 738 struct smk_audit_info ad; 739 + struct path path; 742 740 743 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 744 - smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 745 - smk_ad_setfield_u_fs_path_mnt(&ad, mnt); 741 + path.dentry = dentry; 742 + path.mnt = mnt; 743 + 744 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); 745 + smk_ad_setfield_u_fs_path(&ad, path); 746 746 return smk_curacc(smk_of_inode(dentry->d_inode), MAY_READ, &ad); 747 747 } 748 748 ··· 790 784 } else 791 785 rc = cap_inode_setxattr(dentry, name, value, size, flags); 792 786 793 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 787 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 794 788 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 795 789 796 790 if (rc == 0) ··· 851 845 { 852 846 struct smk_audit_info ad; 853 847 854 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 848 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 855 849 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 856 850 857 851 return smk_curacc(smk_of_inode(dentry->d_inode), MAY_READ, &ad); ··· 883 877 } else 884 878 rc = cap_inode_removexattr(dentry, name); 885 879 886 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 880 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 887 881 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 888 882 if (rc == 0) 889 883 rc = smk_curacc(smk_of_inode(dentry->d_inode), MAY_WRITE, &ad); ··· 1053 1047 int rc = 0; 1054 1048 struct smk_audit_info ad; 1055 1049 1056 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 1050 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); 1057 1051 smk_ad_setfield_u_fs_path(&ad, file->f_path); 1058 1052 1059 1053 if (_IOC_DIR(cmd) & _IOC_WRITE) ··· 1076 1070 { 1077 1071 struct smk_audit_info ad; 1078 1072 1079 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 1080 - smk_ad_setfield_u_fs_path_dentry(&ad, file->f_path.dentry); 1073 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); 1074 + smk_ad_setfield_u_fs_path(&ad, file->f_path); 1081 1075 return smk_curacc(file->f_security, MAY_WRITE, &ad); 1082 1076 } 1083 1077 ··· 1095 1089 struct smk_audit_info ad; 1096 1090 int rc; 1097 1091 1098 - smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS); 1092 + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); 1099 1093 smk_ad_setfield_u_fs_path(&ad, file->f_path); 1100 1094 1101 1095 switch (cmd) {