diff options
-rw-r--r-- | Documentation/DocBook/kernel-api.tmpl | 2 | ||||
-rw-r--r-- | Documentation/kernel-parameters.txt | 17 | ||||
-rw-r--r-- | include/linux/security.h | 1190 | ||||
-rw-r--r-- | security/Kconfig | 6 | ||||
-rw-r--r-- | security/capability.c | 24 | ||||
-rw-r--r-- | security/commoncap.c | 3 | ||||
-rw-r--r-- | security/dummy.c | 1 | ||||
-rw-r--r-- | security/root_plug.c | 31 | ||||
-rw-r--r-- | security/security.c | 964 | ||||
-rw-r--r-- | security/selinux/hooks.c | 2 | ||||
-rw-r--r-- | security/selinux/xfrm.c | 1 |
11 files changed, 1185 insertions, 1056 deletions
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl index 083258f0eab5..d3290c46af51 100644 --- a/Documentation/DocBook/kernel-api.tmpl +++ b/Documentation/DocBook/kernel-api.tmpl | |||
@@ -340,7 +340,7 @@ X!Earch/x86/kernel/mca_32.c | |||
340 | 340 | ||
341 | <chapter id="security"> | 341 | <chapter id="security"> |
342 | <title>Security Framework</title> | 342 | <title>Security Framework</title> |
343 | !Esecurity/security.c | 343 | !Isecurity/security.c |
344 | </chapter> | 344 | </chapter> |
345 | 345 | ||
346 | <chapter id="audit"> | 346 | <chapter id="audit"> |
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index a0ed205e5351..63bda3637085 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -75,10 +75,12 @@ parameter is applicable: | |||
75 | PPT Parallel port support is enabled. | 75 | PPT Parallel port support is enabled. |
76 | PS2 Appropriate PS/2 support is enabled. | 76 | PS2 Appropriate PS/2 support is enabled. |
77 | RAM RAM disk support is enabled. | 77 | RAM RAM disk support is enabled. |
78 | ROOTPLUG The example Root Plug LSM is enabled. | ||
78 | S390 S390 architecture is enabled. | 79 | S390 S390 architecture is enabled. |
79 | SCSI Appropriate SCSI support is enabled. | 80 | SCSI Appropriate SCSI support is enabled. |
80 | A lot of drivers has their options described inside of | 81 | A lot of drivers has their options described inside of |
81 | Documentation/scsi/. | 82 | Documentation/scsi/. |
83 | SECURITY Different security models are enabled. | ||
82 | SELINUX SELinux support is enabled. | 84 | SELINUX SELinux support is enabled. |
83 | SERIAL Serial support is enabled. | 85 | SERIAL Serial support is enabled. |
84 | SH SuperH architecture is enabled. | 86 | SH SuperH architecture is enabled. |
@@ -373,6 +375,12 @@ and is between 256 and 4096 characters. It is defined in the file | |||
373 | possible to determine what the correct size should be. | 375 | possible to determine what the correct size should be. |
374 | This option provides an override for these situations. | 376 | This option provides an override for these situations. |
375 | 377 | ||
378 | capability.disable= | ||
379 | [SECURITY] Disable capabilities. This would normally | ||
380 | be used only if an alternative security model is to be | ||
381 | configured. Potentially dangerous and should only be | ||
382 | used if you are entirely sure of the consequences. | ||
383 | |||
376 | chandev= [HW,NET] Generic channel device initialisation | 384 | chandev= [HW,NET] Generic channel device initialisation |
377 | 385 | ||
378 | checkreqprot [SELINUX] Set initial checkreqprot flag value. | 386 | checkreqprot [SELINUX] Set initial checkreqprot flag value. |
@@ -1539,6 +1547,15 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1539 | Useful for devices that are detected asynchronously | 1547 | Useful for devices that are detected asynchronously |
1540 | (e.g. USB and MMC devices). | 1548 | (e.g. USB and MMC devices). |
1541 | 1549 | ||
1550 | root_plug.vendor_id= | ||
1551 | [ROOTPLUG] Override the default vendor ID | ||
1552 | |||
1553 | root_plug.product_id= | ||
1554 | [ROOTPLUG] Override the default product ID | ||
1555 | |||
1556 | root_plug.debug= | ||
1557 | [ROOTPLUG] Enable debugging output | ||
1558 | |||
1542 | rw [KNL] Mount root device read-write on boot | 1559 | rw [KNL] Mount root device read-write on boot |
1543 | 1560 | ||
1544 | S [KNL] Run init in single mode | 1561 | S [KNL] Run init in single mode |
diff --git a/include/linux/security.h b/include/linux/security.h index 928d4793c6f4..a300a3f2fe68 100644 --- a/include/linux/security.h +++ b/include/linux/security.h | |||
@@ -54,7 +54,7 @@ extern int cap_inode_removexattr(struct dentry *dentry, char *name); | |||
54 | extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags); | 54 | extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags); |
55 | extern void cap_task_reparent_to_init (struct task_struct *p); | 55 | extern void cap_task_reparent_to_init (struct task_struct *p); |
56 | extern int cap_syslog (int type); | 56 | extern int cap_syslog (int type); |
57 | extern int cap_vm_enough_memory (struct mm_struct *mm, long pages); | 57 | extern int cap_vm_enough_memory(struct mm_struct *mm, long pages); |
58 | 58 | ||
59 | struct msghdr; | 59 | struct msghdr; |
60 | struct sk_buff; | 60 | struct sk_buff; |
@@ -1409,742 +1409,6 @@ struct security_operations { | |||
1409 | 1409 | ||
1410 | }; | 1410 | }; |
1411 | 1411 | ||
1412 | /* global variables */ | ||
1413 | extern struct security_operations *security_ops; | ||
1414 | |||
1415 | /* inline stuff */ | ||
1416 | static inline int security_ptrace (struct task_struct * parent, struct task_struct * child) | ||
1417 | { | ||
1418 | return security_ops->ptrace (parent, child); | ||
1419 | } | ||
1420 | |||
1421 | static inline int security_capget (struct task_struct *target, | ||
1422 | kernel_cap_t *effective, | ||
1423 | kernel_cap_t *inheritable, | ||
1424 | kernel_cap_t *permitted) | ||
1425 | { | ||
1426 | return security_ops->capget (target, effective, inheritable, permitted); | ||
1427 | } | ||
1428 | |||
1429 | static inline int security_capset_check (struct task_struct *target, | ||
1430 | kernel_cap_t *effective, | ||
1431 | kernel_cap_t *inheritable, | ||
1432 | kernel_cap_t *permitted) | ||
1433 | { | ||
1434 | return security_ops->capset_check (target, effective, inheritable, permitted); | ||
1435 | } | ||
1436 | |||
1437 | static inline void security_capset_set (struct task_struct *target, | ||
1438 | kernel_cap_t *effective, | ||
1439 | kernel_cap_t *inheritable, | ||
1440 | kernel_cap_t *permitted) | ||
1441 | { | ||
1442 | security_ops->capset_set (target, effective, inheritable, permitted); | ||
1443 | } | ||
1444 | |||
1445 | static inline int security_capable(struct task_struct *tsk, int cap) | ||
1446 | { | ||
1447 | return security_ops->capable(tsk, cap); | ||
1448 | } | ||
1449 | |||
1450 | static inline int security_acct (struct file *file) | ||
1451 | { | ||
1452 | return security_ops->acct (file); | ||
1453 | } | ||
1454 | |||
1455 | static inline int security_sysctl(struct ctl_table *table, int op) | ||
1456 | { | ||
1457 | return security_ops->sysctl(table, op); | ||
1458 | } | ||
1459 | |||
1460 | static inline int security_quotactl (int cmds, int type, int id, | ||
1461 | struct super_block *sb) | ||
1462 | { | ||
1463 | return security_ops->quotactl (cmds, type, id, sb); | ||
1464 | } | ||
1465 | |||
1466 | static inline int security_quota_on (struct dentry * dentry) | ||
1467 | { | ||
1468 | return security_ops->quota_on (dentry); | ||
1469 | } | ||
1470 | |||
1471 | static inline int security_syslog(int type) | ||
1472 | { | ||
1473 | return security_ops->syslog(type); | ||
1474 | } | ||
1475 | |||
1476 | static inline int security_settime(struct timespec *ts, struct timezone *tz) | ||
1477 | { | ||
1478 | return security_ops->settime(ts, tz); | ||
1479 | } | ||
1480 | |||
1481 | static inline int security_vm_enough_memory(long pages) | ||
1482 | { | ||
1483 | return security_ops->vm_enough_memory(current->mm, pages); | ||
1484 | } | ||
1485 | |||
1486 | static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) | ||
1487 | { | ||
1488 | return security_ops->vm_enough_memory(mm, pages); | ||
1489 | } | ||
1490 | |||
1491 | static inline int security_bprm_alloc (struct linux_binprm *bprm) | ||
1492 | { | ||
1493 | return security_ops->bprm_alloc_security (bprm); | ||
1494 | } | ||
1495 | static inline void security_bprm_free (struct linux_binprm *bprm) | ||
1496 | { | ||
1497 | security_ops->bprm_free_security (bprm); | ||
1498 | } | ||
1499 | static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe) | ||
1500 | { | ||
1501 | security_ops->bprm_apply_creds (bprm, unsafe); | ||
1502 | } | ||
1503 | static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm) | ||
1504 | { | ||
1505 | security_ops->bprm_post_apply_creds (bprm); | ||
1506 | } | ||
1507 | static inline int security_bprm_set (struct linux_binprm *bprm) | ||
1508 | { | ||
1509 | return security_ops->bprm_set_security (bprm); | ||
1510 | } | ||
1511 | |||
1512 | static inline int security_bprm_check (struct linux_binprm *bprm) | ||
1513 | { | ||
1514 | return security_ops->bprm_check_security (bprm); | ||
1515 | } | ||
1516 | |||
1517 | static inline int security_bprm_secureexec (struct linux_binprm *bprm) | ||
1518 | { | ||
1519 | return security_ops->bprm_secureexec (bprm); | ||
1520 | } | ||
1521 | |||
1522 | static inline int security_sb_alloc (struct super_block *sb) | ||
1523 | { | ||
1524 | return security_ops->sb_alloc_security (sb); | ||
1525 | } | ||
1526 | |||
1527 | static inline void security_sb_free (struct super_block *sb) | ||
1528 | { | ||
1529 | security_ops->sb_free_security (sb); | ||
1530 | } | ||
1531 | |||
1532 | static inline int security_sb_copy_data (struct file_system_type *type, | ||
1533 | void *orig, void *copy) | ||
1534 | { | ||
1535 | return security_ops->sb_copy_data (type, orig, copy); | ||
1536 | } | ||
1537 | |||
1538 | static inline int security_sb_kern_mount (struct super_block *sb, void *data) | ||
1539 | { | ||
1540 | return security_ops->sb_kern_mount (sb, data); | ||
1541 | } | ||
1542 | |||
1543 | static inline int security_sb_statfs (struct dentry *dentry) | ||
1544 | { | ||
1545 | return security_ops->sb_statfs (dentry); | ||
1546 | } | ||
1547 | |||
1548 | static inline int security_sb_mount (char *dev_name, struct nameidata *nd, | ||
1549 | char *type, unsigned long flags, | ||
1550 | void *data) | ||
1551 | { | ||
1552 | return security_ops->sb_mount (dev_name, nd, type, flags, data); | ||
1553 | } | ||
1554 | |||
1555 | static inline int security_sb_check_sb (struct vfsmount *mnt, | ||
1556 | struct nameidata *nd) | ||
1557 | { | ||
1558 | return security_ops->sb_check_sb (mnt, nd); | ||
1559 | } | ||
1560 | |||
1561 | static inline int security_sb_umount (struct vfsmount *mnt, int flags) | ||
1562 | { | ||
1563 | return security_ops->sb_umount (mnt, flags); | ||
1564 | } | ||
1565 | |||
1566 | static inline void security_sb_umount_close (struct vfsmount *mnt) | ||
1567 | { | ||
1568 | security_ops->sb_umount_close (mnt); | ||
1569 | } | ||
1570 | |||
1571 | static inline void security_sb_umount_busy (struct vfsmount *mnt) | ||
1572 | { | ||
1573 | security_ops->sb_umount_busy (mnt); | ||
1574 | } | ||
1575 | |||
1576 | static inline void security_sb_post_remount (struct vfsmount *mnt, | ||
1577 | unsigned long flags, void *data) | ||
1578 | { | ||
1579 | security_ops->sb_post_remount (mnt, flags, data); | ||
1580 | } | ||
1581 | |||
1582 | static inline void security_sb_post_mountroot (void) | ||
1583 | { | ||
1584 | security_ops->sb_post_mountroot (); | ||
1585 | } | ||
1586 | |||
1587 | static inline void security_sb_post_addmount (struct vfsmount *mnt, | ||
1588 | struct nameidata *mountpoint_nd) | ||
1589 | { | ||
1590 | security_ops->sb_post_addmount (mnt, mountpoint_nd); | ||
1591 | } | ||
1592 | |||
1593 | static inline int security_sb_pivotroot (struct nameidata *old_nd, | ||
1594 | struct nameidata *new_nd) | ||
1595 | { | ||
1596 | return security_ops->sb_pivotroot (old_nd, new_nd); | ||
1597 | } | ||
1598 | |||
1599 | static inline void security_sb_post_pivotroot (struct nameidata *old_nd, | ||
1600 | struct nameidata *new_nd) | ||
1601 | { | ||
1602 | security_ops->sb_post_pivotroot (old_nd, new_nd); | ||
1603 | } | ||
1604 | |||
1605 | static inline int security_inode_alloc (struct inode *inode) | ||
1606 | { | ||
1607 | inode->i_security = NULL; | ||
1608 | return security_ops->inode_alloc_security (inode); | ||
1609 | } | ||
1610 | |||
1611 | static inline void security_inode_free (struct inode *inode) | ||
1612 | { | ||
1613 | security_ops->inode_free_security (inode); | ||
1614 | } | ||
1615 | |||
1616 | static inline int security_inode_init_security (struct inode *inode, | ||
1617 | struct inode *dir, | ||
1618 | char **name, | ||
1619 | void **value, | ||
1620 | size_t *len) | ||
1621 | { | ||
1622 | if (unlikely (IS_PRIVATE (inode))) | ||
1623 | return -EOPNOTSUPP; | ||
1624 | return security_ops->inode_init_security (inode, dir, name, value, len); | ||
1625 | } | ||
1626 | |||
1627 | static inline int security_inode_create (struct inode *dir, | ||
1628 | struct dentry *dentry, | ||
1629 | int mode) | ||
1630 | { | ||
1631 | if (unlikely (IS_PRIVATE (dir))) | ||
1632 | return 0; | ||
1633 | return security_ops->inode_create (dir, dentry, mode); | ||
1634 | } | ||
1635 | |||
1636 | static inline int security_inode_link (struct dentry *old_dentry, | ||
1637 | struct inode *dir, | ||
1638 | struct dentry *new_dentry) | ||
1639 | { | ||
1640 | if (unlikely (IS_PRIVATE (old_dentry->d_inode))) | ||
1641 | return 0; | ||
1642 | return security_ops->inode_link (old_dentry, dir, new_dentry); | ||
1643 | } | ||
1644 | |||
1645 | static inline int security_inode_unlink (struct inode *dir, | ||
1646 | struct dentry *dentry) | ||
1647 | { | ||
1648 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1649 | return 0; | ||
1650 | return security_ops->inode_unlink (dir, dentry); | ||
1651 | } | ||
1652 | |||
1653 | static inline int security_inode_symlink (struct inode *dir, | ||
1654 | struct dentry *dentry, | ||
1655 | const char *old_name) | ||
1656 | { | ||
1657 | if (unlikely (IS_PRIVATE (dir))) | ||
1658 | return 0; | ||
1659 | return security_ops->inode_symlink (dir, dentry, old_name); | ||
1660 | } | ||
1661 | |||
1662 | static inline int security_inode_mkdir (struct inode *dir, | ||
1663 | struct dentry *dentry, | ||
1664 | int mode) | ||
1665 | { | ||
1666 | if (unlikely (IS_PRIVATE (dir))) | ||
1667 | return 0; | ||
1668 | return security_ops->inode_mkdir (dir, dentry, mode); | ||
1669 | } | ||
1670 | |||
1671 | static inline int security_inode_rmdir (struct inode *dir, | ||
1672 | struct dentry *dentry) | ||
1673 | { | ||
1674 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1675 | return 0; | ||
1676 | return security_ops->inode_rmdir (dir, dentry); | ||
1677 | } | ||
1678 | |||
1679 | static inline int security_inode_mknod (struct inode *dir, | ||
1680 | struct dentry *dentry, | ||
1681 | int mode, dev_t dev) | ||
1682 | { | ||
1683 | if (unlikely (IS_PRIVATE (dir))) | ||
1684 | return 0; | ||
1685 | return security_ops->inode_mknod (dir, dentry, mode, dev); | ||
1686 | } | ||
1687 | |||
1688 | static inline int security_inode_rename (struct inode *old_dir, | ||
1689 | struct dentry *old_dentry, | ||
1690 | struct inode *new_dir, | ||
1691 | struct dentry *new_dentry) | ||
1692 | { | ||
1693 | if (unlikely (IS_PRIVATE (old_dentry->d_inode) || | ||
1694 | (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode)))) | ||
1695 | return 0; | ||
1696 | return security_ops->inode_rename (old_dir, old_dentry, | ||
1697 | new_dir, new_dentry); | ||
1698 | } | ||
1699 | |||
1700 | static inline int security_inode_readlink (struct dentry *dentry) | ||
1701 | { | ||
1702 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1703 | return 0; | ||
1704 | return security_ops->inode_readlink (dentry); | ||
1705 | } | ||
1706 | |||
1707 | static inline int security_inode_follow_link (struct dentry *dentry, | ||
1708 | struct nameidata *nd) | ||
1709 | { | ||
1710 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1711 | return 0; | ||
1712 | return security_ops->inode_follow_link (dentry, nd); | ||
1713 | } | ||
1714 | |||
1715 | static inline int security_inode_permission (struct inode *inode, int mask, | ||
1716 | struct nameidata *nd) | ||
1717 | { | ||
1718 | if (unlikely (IS_PRIVATE (inode))) | ||
1719 | return 0; | ||
1720 | return security_ops->inode_permission (inode, mask, nd); | ||
1721 | } | ||
1722 | |||
1723 | static inline int security_inode_setattr (struct dentry *dentry, | ||
1724 | struct iattr *attr) | ||
1725 | { | ||
1726 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1727 | return 0; | ||
1728 | return security_ops->inode_setattr (dentry, attr); | ||
1729 | } | ||
1730 | |||
1731 | static inline int security_inode_getattr (struct vfsmount *mnt, | ||
1732 | struct dentry *dentry) | ||
1733 | { | ||
1734 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1735 | return 0; | ||
1736 | return security_ops->inode_getattr (mnt, dentry); | ||
1737 | } | ||
1738 | |||
1739 | static inline void security_inode_delete (struct inode *inode) | ||
1740 | { | ||
1741 | if (unlikely (IS_PRIVATE (inode))) | ||
1742 | return; | ||
1743 | security_ops->inode_delete (inode); | ||
1744 | } | ||
1745 | |||
1746 | static inline int security_inode_setxattr (struct dentry *dentry, char *name, | ||
1747 | void *value, size_t size, int flags) | ||
1748 | { | ||
1749 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1750 | return 0; | ||
1751 | return security_ops->inode_setxattr (dentry, name, value, size, flags); | ||
1752 | } | ||
1753 | |||
1754 | static inline void security_inode_post_setxattr (struct dentry *dentry, char *name, | ||
1755 | void *value, size_t size, int flags) | ||
1756 | { | ||
1757 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1758 | return; | ||
1759 | security_ops->inode_post_setxattr (dentry, name, value, size, flags); | ||
1760 | } | ||
1761 | |||
1762 | static inline int security_inode_getxattr (struct dentry *dentry, char *name) | ||
1763 | { | ||
1764 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1765 | return 0; | ||
1766 | return security_ops->inode_getxattr (dentry, name); | ||
1767 | } | ||
1768 | |||
1769 | static inline int security_inode_listxattr (struct dentry *dentry) | ||
1770 | { | ||
1771 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1772 | return 0; | ||
1773 | return security_ops->inode_listxattr (dentry); | ||
1774 | } | ||
1775 | |||
1776 | static inline int security_inode_removexattr (struct dentry *dentry, char *name) | ||
1777 | { | ||
1778 | if (unlikely (IS_PRIVATE (dentry->d_inode))) | ||
1779 | return 0; | ||
1780 | return security_ops->inode_removexattr (dentry, name); | ||
1781 | } | ||
1782 | |||
1783 | static inline const char *security_inode_xattr_getsuffix(void) | ||
1784 | { | ||
1785 | return security_ops->inode_xattr_getsuffix(); | ||
1786 | } | ||
1787 | |||
1788 | static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err) | ||
1789 | { | ||
1790 | if (unlikely (IS_PRIVATE (inode))) | ||
1791 | return 0; | ||
1792 | return security_ops->inode_getsecurity(inode, name, buffer, size, err); | ||
1793 | } | ||
1794 | |||
1795 | static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags) | ||
1796 | { | ||
1797 | if (unlikely (IS_PRIVATE (inode))) | ||
1798 | return 0; | ||
1799 | return security_ops->inode_setsecurity(inode, name, value, size, flags); | ||
1800 | } | ||
1801 | |||
1802 | static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size) | ||
1803 | { | ||
1804 | if (unlikely (IS_PRIVATE (inode))) | ||
1805 | return 0; | ||
1806 | return security_ops->inode_listsecurity(inode, buffer, buffer_size); | ||
1807 | } | ||
1808 | |||
1809 | static inline int security_file_permission (struct file *file, int mask) | ||
1810 | { | ||
1811 | return security_ops->file_permission (file, mask); | ||
1812 | } | ||
1813 | |||
1814 | static inline int security_file_alloc (struct file *file) | ||
1815 | { | ||
1816 | return security_ops->file_alloc_security (file); | ||
1817 | } | ||
1818 | |||
1819 | static inline void security_file_free (struct file *file) | ||
1820 | { | ||
1821 | security_ops->file_free_security (file); | ||
1822 | } | ||
1823 | |||
1824 | static inline int security_file_ioctl (struct file *file, unsigned int cmd, | ||
1825 | unsigned long arg) | ||
1826 | { | ||
1827 | return security_ops->file_ioctl (file, cmd, arg); | ||
1828 | } | ||
1829 | |||
1830 | static inline int security_file_mmap (struct file *file, unsigned long reqprot, | ||
1831 | unsigned long prot, | ||
1832 | unsigned long flags, | ||
1833 | unsigned long addr, | ||
1834 | unsigned long addr_only) | ||
1835 | { | ||
1836 | return security_ops->file_mmap (file, reqprot, prot, flags, addr, | ||
1837 | addr_only); | ||
1838 | } | ||
1839 | |||
1840 | static inline int security_file_mprotect (struct vm_area_struct *vma, | ||
1841 | unsigned long reqprot, | ||
1842 | unsigned long prot) | ||
1843 | { | ||
1844 | return security_ops->file_mprotect (vma, reqprot, prot); | ||
1845 | } | ||
1846 | |||
1847 | static inline int security_file_lock (struct file *file, unsigned int cmd) | ||
1848 | { | ||
1849 | return security_ops->file_lock (file, cmd); | ||
1850 | } | ||
1851 | |||
1852 | static inline int security_file_fcntl (struct file *file, unsigned int cmd, | ||
1853 | unsigned long arg) | ||
1854 | { | ||
1855 | return security_ops->file_fcntl (file, cmd, arg); | ||
1856 | } | ||
1857 | |||
1858 | static inline int security_file_set_fowner (struct file *file) | ||
1859 | { | ||
1860 | return security_ops->file_set_fowner (file); | ||
1861 | } | ||
1862 | |||
1863 | static inline int security_file_send_sigiotask (struct task_struct *tsk, | ||
1864 | struct fown_struct *fown, | ||
1865 | int sig) | ||
1866 | { | ||
1867 | return security_ops->file_send_sigiotask (tsk, fown, sig); | ||
1868 | } | ||
1869 | |||
1870 | static inline int security_file_receive (struct file *file) | ||
1871 | { | ||
1872 | return security_ops->file_receive (file); | ||
1873 | } | ||
1874 | |||
1875 | static inline int security_dentry_open (struct file *file) | ||
1876 | { | ||
1877 | return security_ops->dentry_open (file); | ||
1878 | } | ||
1879 | |||
1880 | static inline int security_task_create (unsigned long clone_flags) | ||
1881 | { | ||
1882 | return security_ops->task_create (clone_flags); | ||
1883 | } | ||
1884 | |||
1885 | static inline int security_task_alloc (struct task_struct *p) | ||
1886 | { | ||
1887 | return security_ops->task_alloc_security (p); | ||
1888 | } | ||
1889 | |||
1890 | static inline void security_task_free (struct task_struct *p) | ||
1891 | { | ||
1892 | security_ops->task_free_security (p); | ||
1893 | } | ||
1894 | |||
1895 | static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2, | ||
1896 | int flags) | ||
1897 | { | ||
1898 | return security_ops->task_setuid (id0, id1, id2, flags); | ||
1899 | } | ||
1900 | |||
1901 | static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid, | ||
1902 | uid_t old_suid, int flags) | ||
1903 | { | ||
1904 | return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags); | ||
1905 | } | ||
1906 | |||
1907 | static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2, | ||
1908 | int flags) | ||
1909 | { | ||
1910 | return security_ops->task_setgid (id0, id1, id2, flags); | ||
1911 | } | ||
1912 | |||
1913 | static inline int security_task_setpgid (struct task_struct *p, pid_t pgid) | ||
1914 | { | ||
1915 | return security_ops->task_setpgid (p, pgid); | ||
1916 | } | ||
1917 | |||
1918 | static inline int security_task_getpgid (struct task_struct *p) | ||
1919 | { | ||
1920 | return security_ops->task_getpgid (p); | ||
1921 | } | ||
1922 | |||
1923 | static inline int security_task_getsid (struct task_struct *p) | ||
1924 | { | ||
1925 | return security_ops->task_getsid (p); | ||
1926 | } | ||
1927 | |||
1928 | static inline void security_task_getsecid (struct task_struct *p, u32 *secid) | ||
1929 | { | ||
1930 | security_ops->task_getsecid (p, secid); | ||
1931 | } | ||
1932 | |||
1933 | static inline int security_task_setgroups (struct group_info *group_info) | ||
1934 | { | ||
1935 | return security_ops->task_setgroups (group_info); | ||
1936 | } | ||
1937 | |||
1938 | static inline int security_task_setnice (struct task_struct *p, int nice) | ||
1939 | { | ||
1940 | return security_ops->task_setnice (p, nice); | ||
1941 | } | ||
1942 | |||
1943 | static inline int security_task_setioprio (struct task_struct *p, int ioprio) | ||
1944 | { | ||
1945 | return security_ops->task_setioprio (p, ioprio); | ||
1946 | } | ||
1947 | |||
1948 | static inline int security_task_getioprio (struct task_struct *p) | ||
1949 | { | ||
1950 | return security_ops->task_getioprio (p); | ||
1951 | } | ||
1952 | |||
1953 | static inline int security_task_setrlimit (unsigned int resource, | ||
1954 | struct rlimit *new_rlim) | ||
1955 | { | ||
1956 | return security_ops->task_setrlimit (resource, new_rlim); | ||
1957 | } | ||
1958 | |||
1959 | static inline int security_task_setscheduler (struct task_struct *p, | ||
1960 | int policy, | ||
1961 | struct sched_param *lp) | ||
1962 | { | ||
1963 | return security_ops->task_setscheduler (p, policy, lp); | ||
1964 | } | ||
1965 | |||
1966 | static inline int security_task_getscheduler (struct task_struct *p) | ||
1967 | { | ||
1968 | return security_ops->task_getscheduler (p); | ||
1969 | } | ||
1970 | |||
1971 | static inline int security_task_movememory (struct task_struct *p) | ||
1972 | { | ||
1973 | return security_ops->task_movememory (p); | ||
1974 | } | ||
1975 | |||
1976 | static inline int security_task_kill (struct task_struct *p, | ||
1977 | struct siginfo *info, int sig, | ||
1978 | u32 secid) | ||
1979 | { | ||
1980 | return security_ops->task_kill (p, info, sig, secid); | ||
1981 | } | ||
1982 | |||
1983 | static inline int security_task_wait (struct task_struct *p) | ||
1984 | { | ||
1985 | return security_ops->task_wait (p); | ||
1986 | } | ||
1987 | |||
1988 | static inline int security_task_prctl (int option, unsigned long arg2, | ||
1989 | unsigned long arg3, | ||
1990 | unsigned long arg4, | ||
1991 | unsigned long arg5) | ||
1992 | { | ||
1993 | return security_ops->task_prctl (option, arg2, arg3, arg4, arg5); | ||
1994 | } | ||
1995 | |||
1996 | static inline void security_task_reparent_to_init (struct task_struct *p) | ||
1997 | { | ||
1998 | security_ops->task_reparent_to_init (p); | ||
1999 | } | ||
2000 | |||
2001 | static inline void security_task_to_inode(struct task_struct *p, struct inode *inode) | ||
2002 | { | ||
2003 | security_ops->task_to_inode(p, inode); | ||
2004 | } | ||
2005 | |||
2006 | static inline int security_ipc_permission (struct kern_ipc_perm *ipcp, | ||
2007 | short flag) | ||
2008 | { | ||
2009 | return security_ops->ipc_permission (ipcp, flag); | ||
2010 | } | ||
2011 | |||
2012 | static inline int security_msg_msg_alloc (struct msg_msg * msg) | ||
2013 | { | ||
2014 | return security_ops->msg_msg_alloc_security (msg); | ||
2015 | } | ||
2016 | |||
2017 | static inline void security_msg_msg_free (struct msg_msg * msg) | ||
2018 | { | ||
2019 | security_ops->msg_msg_free_security(msg); | ||
2020 | } | ||
2021 | |||
2022 | static inline int security_msg_queue_alloc (struct msg_queue *msq) | ||
2023 | { | ||
2024 | return security_ops->msg_queue_alloc_security (msq); | ||
2025 | } | ||
2026 | |||
2027 | static inline void security_msg_queue_free (struct msg_queue *msq) | ||
2028 | { | ||
2029 | security_ops->msg_queue_free_security (msq); | ||
2030 | } | ||
2031 | |||
2032 | static inline int security_msg_queue_associate (struct msg_queue * msq, | ||
2033 | int msqflg) | ||
2034 | { | ||
2035 | return security_ops->msg_queue_associate (msq, msqflg); | ||
2036 | } | ||
2037 | |||
2038 | static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd) | ||
2039 | { | ||
2040 | return security_ops->msg_queue_msgctl (msq, cmd); | ||
2041 | } | ||
2042 | |||
2043 | static inline int security_msg_queue_msgsnd (struct msg_queue * msq, | ||
2044 | struct msg_msg * msg, int msqflg) | ||
2045 | { | ||
2046 | return security_ops->msg_queue_msgsnd (msq, msg, msqflg); | ||
2047 | } | ||
2048 | |||
2049 | static inline int security_msg_queue_msgrcv (struct msg_queue * msq, | ||
2050 | struct msg_msg * msg, | ||
2051 | struct task_struct * target, | ||
2052 | long type, int mode) | ||
2053 | { | ||
2054 | return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode); | ||
2055 | } | ||
2056 | |||
2057 | static inline int security_shm_alloc (struct shmid_kernel *shp) | ||
2058 | { | ||
2059 | return security_ops->shm_alloc_security (shp); | ||
2060 | } | ||
2061 | |||
2062 | static inline void security_shm_free (struct shmid_kernel *shp) | ||
2063 | { | ||
2064 | security_ops->shm_free_security (shp); | ||
2065 | } | ||
2066 | |||
2067 | static inline int security_shm_associate (struct shmid_kernel * shp, | ||
2068 | int shmflg) | ||
2069 | { | ||
2070 | return security_ops->shm_associate(shp, shmflg); | ||
2071 | } | ||
2072 | |||
2073 | static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd) | ||
2074 | { | ||
2075 | return security_ops->shm_shmctl (shp, cmd); | ||
2076 | } | ||
2077 | |||
2078 | static inline int security_shm_shmat (struct shmid_kernel * shp, | ||
2079 | char __user *shmaddr, int shmflg) | ||
2080 | { | ||
2081 | return security_ops->shm_shmat(shp, shmaddr, shmflg); | ||
2082 | } | ||
2083 | |||
2084 | static inline int security_sem_alloc (struct sem_array *sma) | ||
2085 | { | ||
2086 | return security_ops->sem_alloc_security (sma); | ||
2087 | } | ||
2088 | |||
2089 | static inline void security_sem_free (struct sem_array *sma) | ||
2090 | { | ||
2091 | security_ops->sem_free_security (sma); | ||
2092 | } | ||
2093 | |||
2094 | static inline int security_sem_associate (struct sem_array * sma, int semflg) | ||
2095 | { | ||
2096 | return security_ops->sem_associate (sma, semflg); | ||
2097 | } | ||
2098 | |||
2099 | static inline int security_sem_semctl (struct sem_array * sma, int cmd) | ||
2100 | { | ||
2101 | return security_ops->sem_semctl(sma, cmd); | ||
2102 | } | ||
2103 | |||
2104 | static inline int security_sem_semop (struct sem_array * sma, | ||
2105 | struct sembuf * sops, unsigned nsops, | ||
2106 | int alter) | ||
2107 | { | ||
2108 | return security_ops->sem_semop(sma, sops, nsops, alter); | ||
2109 | } | ||
2110 | |||
2111 | static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode) | ||
2112 | { | ||
2113 | if (unlikely (inode && IS_PRIVATE (inode))) | ||
2114 | return; | ||
2115 | security_ops->d_instantiate (dentry, inode); | ||
2116 | } | ||
2117 | |||
2118 | static inline int security_getprocattr(struct task_struct *p, char *name, char **value) | ||
2119 | { | ||
2120 | return security_ops->getprocattr(p, name, value); | ||
2121 | } | ||
2122 | |||
2123 | static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size) | ||
2124 | { | ||
2125 | return security_ops->setprocattr(p, name, value, size); | ||
2126 | } | ||
2127 | |||
2128 | static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb) | ||
2129 | { | ||
2130 | return security_ops->netlink_send(sk, skb); | ||
2131 | } | ||
2132 | |||
2133 | static inline int security_netlink_recv(struct sk_buff * skb, int cap) | ||
2134 | { | ||
2135 | return security_ops->netlink_recv(skb, cap); | ||
2136 | } | ||
2137 | |||
2138 | static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) | ||
2139 | { | ||
2140 | return security_ops->secid_to_secctx(secid, secdata, seclen); | ||
2141 | } | ||
2142 | |||
2143 | static inline void security_release_secctx(char *secdata, u32 seclen) | ||
2144 | { | ||
2145 | return security_ops->release_secctx(secdata, seclen); | ||
2146 | } | ||
2147 | |||
2148 | /* prototypes */ | 1412 | /* prototypes */ |
2149 | extern int security_init (void); | 1413 | extern int security_init (void); |
2150 | extern int register_security (struct security_operations *ops); | 1414 | extern int register_security (struct security_operations *ops); |
@@ -2158,6 +1422,157 @@ extern struct dentry *securityfs_create_dir(const char *name, struct dentry *par | |||
2158 | extern void securityfs_remove(struct dentry *dentry); | 1422 | extern void securityfs_remove(struct dentry *dentry); |
2159 | 1423 | ||
2160 | 1424 | ||
1425 | /* Security operations */ | ||
1426 | int security_ptrace(struct task_struct *parent, struct task_struct *child); | ||
1427 | int security_capget(struct task_struct *target, | ||
1428 | kernel_cap_t *effective, | ||
1429 | kernel_cap_t *inheritable, | ||
1430 | kernel_cap_t *permitted); | ||
1431 | int security_capset_check(struct task_struct *target, | ||
1432 | kernel_cap_t *effective, | ||
1433 | kernel_cap_t *inheritable, | ||
1434 | kernel_cap_t *permitted); | ||
1435 | void security_capset_set(struct task_struct *target, | ||
1436 | kernel_cap_t *effective, | ||
1437 | kernel_cap_t *inheritable, | ||
1438 | kernel_cap_t *permitted); | ||
1439 | int security_capable(struct task_struct *tsk, int cap); | ||
1440 | int security_acct(struct file *file); | ||
1441 | int security_sysctl(struct ctl_table *table, int op); | ||
1442 | int security_quotactl(int cmds, int type, int id, struct super_block *sb); | ||
1443 | int security_quota_on(struct dentry *dentry); | ||
1444 | int security_syslog(int type); | ||
1445 | int security_settime(struct timespec *ts, struct timezone *tz); | ||
1446 | int security_vm_enough_memory(long pages); | ||
1447 | int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); | ||
1448 | int security_bprm_alloc(struct linux_binprm *bprm); | ||
1449 | void security_bprm_free(struct linux_binprm *bprm); | ||
1450 | void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe); | ||
1451 | void security_bprm_post_apply_creds(struct linux_binprm *bprm); | ||
1452 | int security_bprm_set(struct linux_binprm *bprm); | ||
1453 | int security_bprm_check(struct linux_binprm *bprm); | ||
1454 | int security_bprm_secureexec(struct linux_binprm *bprm); | ||
1455 | int security_sb_alloc(struct super_block *sb); | ||
1456 | void security_sb_free(struct super_block *sb); | ||
1457 | int security_sb_copy_data(struct file_system_type *type, void *orig, void *copy); | ||
1458 | int security_sb_kern_mount(struct super_block *sb, void *data); | ||
1459 | int security_sb_statfs(struct dentry *dentry); | ||
1460 | int security_sb_mount(char *dev_name, struct nameidata *nd, | ||
1461 | char *type, unsigned long flags, void *data); | ||
1462 | int security_sb_check_sb(struct vfsmount *mnt, struct nameidata *nd); | ||
1463 | int security_sb_umount(struct vfsmount *mnt, int flags); | ||
1464 | void security_sb_umount_close(struct vfsmount *mnt); | ||
1465 | void security_sb_umount_busy(struct vfsmount *mnt); | ||
1466 | void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data); | ||
1467 | void security_sb_post_mountroot(void); | ||
1468 | void security_sb_post_addmount(struct vfsmount *mnt, struct nameidata *mountpoint_nd); | ||
1469 | int security_sb_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd); | ||
1470 | void security_sb_post_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd); | ||
1471 | int security_inode_alloc(struct inode *inode); | ||
1472 | void security_inode_free(struct inode *inode); | ||
1473 | int security_inode_init_security(struct inode *inode, struct inode *dir, | ||
1474 | char **name, void **value, size_t *len); | ||
1475 | int security_inode_create(struct inode *dir, struct dentry *dentry, int mode); | ||
1476 | int security_inode_link(struct dentry *old_dentry, struct inode *dir, | ||
1477 | struct dentry *new_dentry); | ||
1478 | int security_inode_unlink(struct inode *dir, struct dentry *dentry); | ||
1479 | int security_inode_symlink(struct inode *dir, struct dentry *dentry, | ||
1480 | const char *old_name); | ||
1481 | int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode); | ||
1482 | int security_inode_rmdir(struct inode *dir, struct dentry *dentry); | ||
1483 | int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev); | ||
1484 | int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, | ||
1485 | struct inode *new_dir, struct dentry *new_dentry); | ||
1486 | int security_inode_readlink(struct dentry *dentry); | ||
1487 | int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd); | ||
1488 | int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd); | ||
1489 | int security_inode_setattr(struct dentry *dentry, struct iattr *attr); | ||
1490 | int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry); | ||
1491 | void security_inode_delete(struct inode *inode); | ||
1492 | int security_inode_setxattr(struct dentry *dentry, char *name, | ||
1493 | void *value, size_t size, int flags); | ||
1494 | void security_inode_post_setxattr(struct dentry *dentry, char *name, | ||
1495 | void *value, size_t size, int flags); | ||
1496 | int security_inode_getxattr(struct dentry *dentry, char *name); | ||
1497 | int security_inode_listxattr(struct dentry *dentry); | ||
1498 | int security_inode_removexattr(struct dentry *dentry, char *name); | ||
1499 | const char *security_inode_xattr_getsuffix(void); | ||
1500 | int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err); | ||
1501 | int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags); | ||
1502 | int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size); | ||
1503 | int security_file_permission(struct file *file, int mask); | ||
1504 | int security_file_alloc(struct file *file); | ||
1505 | void security_file_free(struct file *file); | ||
1506 | int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg); | ||
1507 | int security_file_mmap(struct file *file, unsigned long reqprot, | ||
1508 | unsigned long prot, unsigned long flags, | ||
1509 | unsigned long addr, unsigned long addr_only); | ||
1510 | int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, | ||
1511 | unsigned long prot); | ||
1512 | int security_file_lock(struct file *file, unsigned int cmd); | ||
1513 | int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg); | ||
1514 | int security_file_set_fowner(struct file *file); | ||
1515 | int security_file_send_sigiotask(struct task_struct *tsk, | ||
1516 | struct fown_struct *fown, int sig); | ||
1517 | int security_file_receive(struct file *file); | ||
1518 | int security_dentry_open(struct file *file); | ||
1519 | int security_task_create(unsigned long clone_flags); | ||
1520 | int security_task_alloc(struct task_struct *p); | ||
1521 | void security_task_free(struct task_struct *p); | ||
1522 | int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags); | ||
1523 | int security_task_post_setuid(uid_t old_ruid, uid_t old_euid, | ||
1524 | uid_t old_suid, int flags); | ||
1525 | int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags); | ||
1526 | int security_task_setpgid(struct task_struct *p, pid_t pgid); | ||
1527 | int security_task_getpgid(struct task_struct *p); | ||
1528 | int security_task_getsid(struct task_struct *p); | ||
1529 | void security_task_getsecid(struct task_struct *p, u32 *secid); | ||
1530 | int security_task_setgroups(struct group_info *group_info); | ||
1531 | int security_task_setnice(struct task_struct *p, int nice); | ||
1532 | int security_task_setioprio(struct task_struct *p, int ioprio); | ||
1533 | int security_task_getioprio(struct task_struct *p); | ||
1534 | int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim); | ||
1535 | int security_task_setscheduler(struct task_struct *p, | ||
1536 | int policy, struct sched_param *lp); | ||
1537 | int security_task_getscheduler(struct task_struct *p); | ||
1538 | int security_task_movememory(struct task_struct *p); | ||
1539 | int security_task_kill(struct task_struct *p, struct siginfo *info, | ||
1540 | int sig, u32 secid); | ||
1541 | int security_task_wait(struct task_struct *p); | ||
1542 | int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, | ||
1543 | unsigned long arg4, unsigned long arg5); | ||
1544 | void security_task_reparent_to_init(struct task_struct *p); | ||
1545 | void security_task_to_inode(struct task_struct *p, struct inode *inode); | ||
1546 | int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); | ||
1547 | int security_msg_msg_alloc(struct msg_msg *msg); | ||
1548 | void security_msg_msg_free(struct msg_msg *msg); | ||
1549 | int security_msg_queue_alloc(struct msg_queue *msq); | ||
1550 | void security_msg_queue_free(struct msg_queue *msq); | ||
1551 | int security_msg_queue_associate(struct msg_queue *msq, int msqflg); | ||
1552 | int security_msg_queue_msgctl(struct msg_queue *msq, int cmd); | ||
1553 | int security_msg_queue_msgsnd(struct msg_queue *msq, | ||
1554 | struct msg_msg *msg, int msqflg); | ||
1555 | int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg, | ||
1556 | struct task_struct *target, long type, int mode); | ||
1557 | int security_shm_alloc(struct shmid_kernel *shp); | ||
1558 | void security_shm_free(struct shmid_kernel *shp); | ||
1559 | int security_shm_associate(struct shmid_kernel *shp, int shmflg); | ||
1560 | int security_shm_shmctl(struct shmid_kernel *shp, int cmd); | ||
1561 | int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg); | ||
1562 | int security_sem_alloc(struct sem_array *sma); | ||
1563 | void security_sem_free(struct sem_array *sma); | ||
1564 | int security_sem_associate(struct sem_array *sma, int semflg); | ||
1565 | int security_sem_semctl(struct sem_array *sma, int cmd); | ||
1566 | int security_sem_semop(struct sem_array *sma, struct sembuf *sops, | ||
1567 | unsigned nsops, int alter); | ||
1568 | void security_d_instantiate (struct dentry *dentry, struct inode *inode); | ||
1569 | int security_getprocattr(struct task_struct *p, char *name, char **value); | ||
1570 | int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size); | ||
1571 | int security_netlink_send(struct sock *sk, struct sk_buff *skb); | ||
1572 | int security_netlink_recv(struct sk_buff *skb, int cap); | ||
1573 | int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen); | ||
1574 | void security_release_secctx(char *secdata, u32 seclen); | ||
1575 | |||
2161 | #else /* CONFIG_SECURITY */ | 1576 | #else /* CONFIG_SECURITY */ |
2162 | 1577 | ||
2163 | /* | 1578 | /* |
@@ -2834,170 +2249,43 @@ static inline void security_release_secctx(char *secdata, u32 seclen) | |||
2834 | #endif /* CONFIG_SECURITY */ | 2249 | #endif /* CONFIG_SECURITY */ |
2835 | 2250 | ||
2836 | #ifdef CONFIG_SECURITY_NETWORK | 2251 | #ifdef CONFIG_SECURITY_NETWORK |
2837 | static inline int security_unix_stream_connect(struct socket * sock, | ||
2838 | struct socket * other, | ||
2839 | struct sock * newsk) | ||
2840 | { | ||
2841 | return security_ops->unix_stream_connect(sock, other, newsk); | ||
2842 | } | ||
2843 | |||
2844 | |||
2845 | static inline int security_unix_may_send(struct socket * sock, | ||
2846 | struct socket * other) | ||
2847 | { | ||
2848 | return security_ops->unix_may_send(sock, other); | ||
2849 | } | ||
2850 | |||
2851 | static inline int security_socket_create (int family, int type, | ||
2852 | int protocol, int kern) | ||
2853 | { | ||
2854 | return security_ops->socket_create(family, type, protocol, kern); | ||
2855 | } | ||
2856 | |||
2857 | static inline int security_socket_post_create(struct socket * sock, | ||
2858 | int family, | ||
2859 | int type, | ||
2860 | int protocol, int kern) | ||
2861 | { | ||
2862 | return security_ops->socket_post_create(sock, family, type, | ||
2863 | protocol, kern); | ||
2864 | } | ||
2865 | |||
2866 | static inline int security_socket_bind(struct socket * sock, | ||
2867 | struct sockaddr * address, | ||
2868 | int addrlen) | ||
2869 | { | ||
2870 | return security_ops->socket_bind(sock, address, addrlen); | ||
2871 | } | ||
2872 | |||
2873 | static inline int security_socket_connect(struct socket * sock, | ||
2874 | struct sockaddr * address, | ||
2875 | int addrlen) | ||
2876 | { | ||
2877 | return security_ops->socket_connect(sock, address, addrlen); | ||
2878 | } | ||
2879 | |||
2880 | static inline int security_socket_listen(struct socket * sock, int backlog) | ||
2881 | { | ||
2882 | return security_ops->socket_listen(sock, backlog); | ||
2883 | } | ||
2884 | |||
2885 | static inline int security_socket_accept(struct socket * sock, | ||
2886 | struct socket * newsock) | ||
2887 | { | ||
2888 | return security_ops->socket_accept(sock, newsock); | ||
2889 | } | ||
2890 | |||
2891 | static inline void security_socket_post_accept(struct socket * sock, | ||
2892 | struct socket * newsock) | ||
2893 | { | ||
2894 | security_ops->socket_post_accept(sock, newsock); | ||
2895 | } | ||
2896 | |||
2897 | static inline int security_socket_sendmsg(struct socket * sock, | ||
2898 | struct msghdr * msg, int size) | ||
2899 | { | ||
2900 | return security_ops->socket_sendmsg(sock, msg, size); | ||
2901 | } | ||
2902 | |||
2903 | static inline int security_socket_recvmsg(struct socket * sock, | ||
2904 | struct msghdr * msg, int size, | ||
2905 | int flags) | ||
2906 | { | ||
2907 | return security_ops->socket_recvmsg(sock, msg, size, flags); | ||
2908 | } | ||
2909 | |||
2910 | static inline int security_socket_getsockname(struct socket * sock) | ||
2911 | { | ||
2912 | return security_ops->socket_getsockname(sock); | ||
2913 | } | ||
2914 | |||
2915 | static inline int security_socket_getpeername(struct socket * sock) | ||
2916 | { | ||
2917 | return security_ops->socket_getpeername(sock); | ||
2918 | } | ||
2919 | |||
2920 | static inline int security_socket_getsockopt(struct socket * sock, | ||
2921 | int level, int optname) | ||
2922 | { | ||
2923 | return security_ops->socket_getsockopt(sock, level, optname); | ||
2924 | } | ||
2925 | 2252 | ||
2926 | static inline int security_socket_setsockopt(struct socket * sock, | 2253 | int security_unix_stream_connect(struct socket *sock, struct socket *other, |
2927 | int level, int optname) | 2254 | struct sock *newsk); |
2928 | { | 2255 | int security_unix_may_send(struct socket *sock, struct socket *other); |
2929 | return security_ops->socket_setsockopt(sock, level, optname); | 2256 | int security_socket_create(int family, int type, int protocol, int kern); |
2930 | } | 2257 | int security_socket_post_create(struct socket *sock, int family, |
2258 | int type, int protocol, int kern); | ||
2259 | int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen); | ||
2260 | int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen); | ||
2261 | int security_socket_listen(struct socket *sock, int backlog); | ||
2262 | int security_socket_accept(struct socket *sock, struct socket *newsock); | ||
2263 | void security_socket_post_accept(struct socket *sock, struct socket *newsock); | ||
2264 | int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size); | ||
2265 | int security_socket_recvmsg(struct socket *sock, struct msghdr *msg, | ||
2266 | int size, int flags); | ||
2267 | int security_socket_getsockname(struct socket *sock); | ||
2268 | int security_socket_getpeername(struct socket *sock); | ||
2269 | int security_socket_getsockopt(struct socket *sock, int level, int optname); | ||
2270 | int security_socket_setsockopt(struct socket *sock, int level, int optname); | ||
2271 | int security_socket_shutdown(struct socket *sock, int how); | ||
2272 | int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb); | ||
2273 | int security_socket_getpeersec_stream(struct socket *sock, char __user *optval, | ||
2274 | int __user *optlen, unsigned len); | ||
2275 | int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid); | ||
2276 | int security_sk_alloc(struct sock *sk, int family, gfp_t priority); | ||
2277 | void security_sk_free(struct sock *sk); | ||
2278 | void security_sk_clone(const struct sock *sk, struct sock *newsk); | ||
2279 | void security_sk_classify_flow(struct sock *sk, struct flowi *fl); | ||
2280 | void security_req_classify_flow(const struct request_sock *req, struct flowi *fl); | ||
2281 | void security_sock_graft(struct sock*sk, struct socket *parent); | ||
2282 | int security_inet_conn_request(struct sock *sk, | ||
2283 | struct sk_buff *skb, struct request_sock *req); | ||
2284 | void security_inet_csk_clone(struct sock *newsk, | ||
2285 | const struct request_sock *req); | ||
2286 | void security_inet_conn_established(struct sock *sk, | ||
2287 | struct sk_buff *skb); | ||
2931 | 2288 | ||
2932 | static inline int security_socket_shutdown(struct socket * sock, int how) | ||
2933 | { | ||
2934 | return security_ops->socket_shutdown(sock, how); | ||
2935 | } | ||
2936 | |||
2937 | static inline int security_sock_rcv_skb (struct sock * sk, | ||
2938 | struct sk_buff * skb) | ||
2939 | { | ||
2940 | return security_ops->socket_sock_rcv_skb (sk, skb); | ||
2941 | } | ||
2942 | |||
2943 | static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval, | ||
2944 | int __user *optlen, unsigned len) | ||
2945 | { | ||
2946 | return security_ops->socket_getpeersec_stream(sock, optval, optlen, len); | ||
2947 | } | ||
2948 | |||
2949 | static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid) | ||
2950 | { | ||
2951 | return security_ops->socket_getpeersec_dgram(sock, skb, secid); | ||
2952 | } | ||
2953 | |||
2954 | static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority) | ||
2955 | { | ||
2956 | return security_ops->sk_alloc_security(sk, family, priority); | ||
2957 | } | ||
2958 | |||
2959 | static inline void security_sk_free(struct sock *sk) | ||
2960 | { | ||
2961 | return security_ops->sk_free_security(sk); | ||
2962 | } | ||
2963 | |||
2964 | static inline void security_sk_clone(const struct sock *sk, struct sock *newsk) | ||
2965 | { | ||
2966 | return security_ops->sk_clone_security(sk, newsk); | ||
2967 | } | ||
2968 | |||
2969 | static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl) | ||
2970 | { | ||
2971 | security_ops->sk_getsecid(sk, &fl->secid); | ||
2972 | } | ||
2973 | |||
2974 | static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl) | ||
2975 | { | ||
2976 | security_ops->req_classify_flow(req, fl); | ||
2977 | } | ||
2978 | |||
2979 | static inline void security_sock_graft(struct sock* sk, struct socket *parent) | ||
2980 | { | ||
2981 | security_ops->sock_graft(sk, parent); | ||
2982 | } | ||
2983 | |||
2984 | static inline int security_inet_conn_request(struct sock *sk, | ||
2985 | struct sk_buff *skb, struct request_sock *req) | ||
2986 | { | ||
2987 | return security_ops->inet_conn_request(sk, skb, req); | ||
2988 | } | ||
2989 | |||
2990 | static inline void security_inet_csk_clone(struct sock *newsk, | ||
2991 | const struct request_sock *req) | ||
2992 | { | ||
2993 | security_ops->inet_csk_clone(newsk, req); | ||
2994 | } | ||
2995 | |||
2996 | static inline void security_inet_conn_established(struct sock *sk, | ||
2997 | struct sk_buff *skb) | ||
2998 | { | ||
2999 | security_ops->inet_conn_established(sk, skb); | ||
3000 | } | ||
3001 | #else /* CONFIG_SECURITY_NETWORK */ | 2289 | #else /* CONFIG_SECURITY_NETWORK */ |
3002 | static inline int security_unix_stream_connect(struct socket * sock, | 2290 | static inline int security_unix_stream_connect(struct socket * sock, |
3003 | struct socket * other, | 2291 | struct socket * other, |
@@ -3155,77 +2443,24 @@ static inline void security_inet_conn_established(struct sock *sk, | |||
3155 | #endif /* CONFIG_SECURITY_NETWORK */ | 2443 | #endif /* CONFIG_SECURITY_NETWORK */ |
3156 | 2444 | ||
3157 | #ifdef CONFIG_SECURITY_NETWORK_XFRM | 2445 | #ifdef CONFIG_SECURITY_NETWORK_XFRM |
3158 | static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) | ||
3159 | { | ||
3160 | return security_ops->xfrm_policy_alloc_security(xp, sec_ctx); | ||
3161 | } | ||
3162 | 2446 | ||
3163 | static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) | 2447 | int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx); |
3164 | { | 2448 | int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new); |
3165 | return security_ops->xfrm_policy_clone_security(old, new); | 2449 | void security_xfrm_policy_free(struct xfrm_policy *xp); |
3166 | } | 2450 | int security_xfrm_policy_delete(struct xfrm_policy *xp); |
3167 | 2451 | int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); | |
3168 | static inline void security_xfrm_policy_free(struct xfrm_policy *xp) | 2452 | int security_xfrm_state_alloc_acquire(struct xfrm_state *x, |
3169 | { | 2453 | struct xfrm_sec_ctx *polsec, u32 secid); |
3170 | security_ops->xfrm_policy_free_security(xp); | 2454 | int security_xfrm_state_delete(struct xfrm_state *x); |
3171 | } | 2455 | void security_xfrm_state_free(struct xfrm_state *x); |
2456 | int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir); | ||
2457 | int security_xfrm_state_pol_flow_match(struct xfrm_state *x, | ||
2458 | struct xfrm_policy *xp, struct flowi *fl); | ||
2459 | int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid); | ||
2460 | void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl); | ||
3172 | 2461 | ||
3173 | static inline int security_xfrm_policy_delete(struct xfrm_policy *xp) | ||
3174 | { | ||
3175 | return security_ops->xfrm_policy_delete_security(xp); | ||
3176 | } | ||
3177 | |||
3178 | static inline int security_xfrm_state_alloc(struct xfrm_state *x, | ||
3179 | struct xfrm_user_sec_ctx *sec_ctx) | ||
3180 | { | ||
3181 | return security_ops->xfrm_state_alloc_security(x, sec_ctx, 0); | ||
3182 | } | ||
3183 | |||
3184 | static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x, | ||
3185 | struct xfrm_sec_ctx *polsec, u32 secid) | ||
3186 | { | ||
3187 | if (!polsec) | ||
3188 | return 0; | ||
3189 | /* | ||
3190 | * We want the context to be taken from secid which is usually | ||
3191 | * from the sock. | ||
3192 | */ | ||
3193 | return security_ops->xfrm_state_alloc_security(x, NULL, secid); | ||
3194 | } | ||
3195 | |||
3196 | static inline int security_xfrm_state_delete(struct xfrm_state *x) | ||
3197 | { | ||
3198 | return security_ops->xfrm_state_delete_security(x); | ||
3199 | } | ||
3200 | |||
3201 | static inline void security_xfrm_state_free(struct xfrm_state *x) | ||
3202 | { | ||
3203 | security_ops->xfrm_state_free_security(x); | ||
3204 | } | ||
3205 | |||
3206 | static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir) | ||
3207 | { | ||
3208 | return security_ops->xfrm_policy_lookup(xp, fl_secid, dir); | ||
3209 | } | ||
3210 | |||
3211 | static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x, | ||
3212 | struct xfrm_policy *xp, struct flowi *fl) | ||
3213 | { | ||
3214 | return security_ops->xfrm_state_pol_flow_match(x, xp, fl); | ||
3215 | } | ||
3216 | |||
3217 | static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) | ||
3218 | { | ||
3219 | return security_ops->xfrm_decode_session(skb, secid, 1); | ||
3220 | } | ||
3221 | |||
3222 | static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl) | ||
3223 | { | ||
3224 | int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0); | ||
3225 | |||
3226 | BUG_ON(rc); | ||
3227 | } | ||
3228 | #else /* CONFIG_SECURITY_NETWORK_XFRM */ | 2462 | #else /* CONFIG_SECURITY_NETWORK_XFRM */ |
2463 | |||
3229 | static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) | 2464 | static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) |
3230 | { | 2465 | { |
3231 | return 0; | 2466 | return 0; |
@@ -3290,24 +2525,11 @@ static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi | |||
3290 | 2525 | ||
3291 | #ifdef CONFIG_KEYS | 2526 | #ifdef CONFIG_KEYS |
3292 | #ifdef CONFIG_SECURITY | 2527 | #ifdef CONFIG_SECURITY |
3293 | static inline int security_key_alloc(struct key *key, | ||
3294 | struct task_struct *tsk, | ||
3295 | unsigned long flags) | ||
3296 | { | ||
3297 | return security_ops->key_alloc(key, tsk, flags); | ||
3298 | } | ||
3299 | |||
3300 | static inline void security_key_free(struct key *key) | ||
3301 | { | ||
3302 | security_ops->key_free(key); | ||
3303 | } | ||
3304 | 2528 | ||
3305 | static inline int security_key_permission(key_ref_t key_ref, | 2529 | int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long flags); |
3306 | struct task_struct *context, | 2530 | void security_key_free(struct key *key); |
3307 | key_perm_t perm) | 2531 | int security_key_permission(key_ref_t key_ref, |
3308 | { | 2532 | struct task_struct *context, key_perm_t perm); |
3309 | return security_ops->key_permission(key_ref, context, perm); | ||
3310 | } | ||
3311 | 2533 | ||
3312 | #else | 2534 | #else |
3313 | 2535 | ||
diff --git a/security/Kconfig b/security/Kconfig index 460e5c9cf496..a94ee94cf491 100644 --- a/security/Kconfig +++ b/security/Kconfig | |||
@@ -74,15 +74,15 @@ config SECURITY_NETWORK_XFRM | |||
74 | If you are unsure how to answer this question, answer N. | 74 | If you are unsure how to answer this question, answer N. |
75 | 75 | ||
76 | config SECURITY_CAPABILITIES | 76 | config SECURITY_CAPABILITIES |
77 | tristate "Default Linux Capabilities" | 77 | bool "Default Linux Capabilities" |
78 | depends on SECURITY | 78 | depends on SECURITY |
79 | help | 79 | help |
80 | This enables the "default" Linux capabilities functionality. | 80 | This enables the "default" Linux capabilities functionality. |
81 | If you are unsure how to answer this question, answer Y. | 81 | If you are unsure how to answer this question, answer Y. |
82 | 82 | ||
83 | config SECURITY_ROOTPLUG | 83 | config SECURITY_ROOTPLUG |
84 | tristate "Root Plug Support" | 84 | bool "Root Plug Support" |
85 | depends on USB && SECURITY | 85 | depends on USB=y && SECURITY |
86 | help | 86 | help |
87 | This is a sample LSM module that should only be used as such. | 87 | This is a sample LSM module that should only be used as such. |
88 | It prevents any programs running with egid == 0 if a specific | 88 | It prevents any programs running with egid == 0 if a specific |
diff --git a/security/capability.c b/security/capability.c index 38296a005465..fda6a14cb24d 100644 --- a/security/capability.c +++ b/security/capability.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/init.h> | 11 | #include <linux/init.h> |
13 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
14 | #include <linux/security.h> | 13 | #include <linux/security.h> |
@@ -52,7 +51,6 @@ static int secondary; | |||
52 | 51 | ||
53 | static int capability_disable; | 52 | static int capability_disable; |
54 | module_param_named(disable, capability_disable, int, 0); | 53 | module_param_named(disable, capability_disable, int, 0); |
55 | MODULE_PARM_DESC(disable, "To disable capabilities module set disable = 1"); | ||
56 | 54 | ||
57 | static int __init capability_init (void) | 55 | static int __init capability_init (void) |
58 | { | 56 | { |
@@ -75,26 +73,4 @@ static int __init capability_init (void) | |||
75 | return 0; | 73 | return 0; |
76 | } | 74 | } |
77 | 75 | ||
78 | static void __exit capability_exit (void) | ||
79 | { | ||
80 | if (capability_disable) | ||
81 | return; | ||
82 | /* remove ourselves from the security framework */ | ||
83 | if (secondary) { | ||
84 | if (mod_unreg_security (KBUILD_MODNAME, &capability_ops)) | ||
85 | printk (KERN_INFO "Failure unregistering capabilities " | ||
86 | "with primary module.\n"); | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | if (unregister_security (&capability_ops)) { | ||
91 | printk (KERN_INFO | ||
92 | "Failure unregistering capabilities with the kernel\n"); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | security_initcall (capability_init); | 76 | security_initcall (capability_init); |
97 | module_exit (capability_exit); | ||
98 | |||
99 | MODULE_DESCRIPTION("Standard Linux Capabilities Security Module"); | ||
100 | MODULE_LICENSE("GPL"); | ||
diff --git a/security/commoncap.c b/security/commoncap.c index 7520361663e8..0f8a2ce3f3a6 100644 --- a/security/commoncap.c +++ b/security/commoncap.c | |||
@@ -339,6 +339,3 @@ EXPORT_SYMBOL(cap_task_post_setuid); | |||
339 | EXPORT_SYMBOL(cap_task_reparent_to_init); | 339 | EXPORT_SYMBOL(cap_task_reparent_to_init); |
340 | EXPORT_SYMBOL(cap_syslog); | 340 | EXPORT_SYMBOL(cap_syslog); |
341 | EXPORT_SYMBOL(cap_vm_enough_memory); | 341 | EXPORT_SYMBOL(cap_vm_enough_memory); |
342 | |||
343 | MODULE_DESCRIPTION("Standard Linux Common Capabilities Security Module"); | ||
344 | MODULE_LICENSE("GPL"); | ||
diff --git a/security/dummy.c b/security/dummy.c index 64b647a0d9a6..4129dcf3daec 100644 --- a/security/dummy.c +++ b/security/dummy.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #undef DEBUG | 15 | #undef DEBUG |
16 | 16 | ||
17 | #include <linux/capability.h> | 17 | #include <linux/capability.h> |
18 | #include <linux/module.h> | ||
19 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
20 | #include <linux/mman.h> | 19 | #include <linux/mman.h> |
21 | #include <linux/pagemap.h> | 20 | #include <linux/pagemap.h> |
diff --git a/security/root_plug.c b/security/root_plug.c index 38dd4f3e641f..870f13095bb6 100644 --- a/security/root_plug.c +++ b/security/root_plug.c | |||
@@ -22,11 +22,11 @@ | |||
22 | * License. | 22 | * License. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
27 | #include <linux/init.h> | 26 | #include <linux/init.h> |
28 | #include <linux/security.h> | 27 | #include <linux/security.h> |
29 | #include <linux/usb.h> | 28 | #include <linux/usb.h> |
29 | #include <linux/moduleparam.h> | ||
30 | 30 | ||
31 | /* flag to keep track of how we were registered */ | 31 | /* flag to keep track of how we were registered */ |
32 | static int secondary; | 32 | static int secondary; |
@@ -36,22 +36,14 @@ static int vendor_id = 0x0557; | |||
36 | static int product_id = 0x2008; | 36 | static int product_id = 0x2008; |
37 | 37 | ||
38 | module_param(vendor_id, uint, 0400); | 38 | module_param(vendor_id, uint, 0400); |
39 | MODULE_PARM_DESC(vendor_id, "USB Vendor ID of device to look for"); | ||
40 | |||
41 | module_param(product_id, uint, 0400); | 39 | module_param(product_id, uint, 0400); |
42 | MODULE_PARM_DESC(product_id, "USB Product ID of device to look for"); | ||
43 | 40 | ||
44 | /* should we print out debug messages */ | 41 | /* should we print out debug messages */ |
45 | static int debug = 0; | 42 | static int debug = 0; |
46 | 43 | ||
47 | module_param(debug, bool, 0600); | 44 | module_param(debug, bool, 0600); |
48 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
49 | 45 | ||
50 | #if defined(CONFIG_SECURITY_ROOTPLUG_MODULE) | ||
51 | #define MY_NAME THIS_MODULE->name | ||
52 | #else | ||
53 | #define MY_NAME "root_plug" | 46 | #define MY_NAME "root_plug" |
54 | #endif | ||
55 | 47 | ||
56 | #define root_dbg(fmt, arg...) \ | 48 | #define root_dbg(fmt, arg...) \ |
57 | do { \ | 49 | do { \ |
@@ -117,25 +109,4 @@ static int __init rootplug_init (void) | |||
117 | return 0; | 109 | return 0; |
118 | } | 110 | } |
119 | 111 | ||
120 | static void __exit rootplug_exit (void) | ||
121 | { | ||
122 | /* remove ourselves from the security framework */ | ||
123 | if (secondary) { | ||
124 | if (mod_unreg_security (MY_NAME, &rootplug_security_ops)) | ||
125 | printk (KERN_INFO "Failure unregistering Root Plug " | ||
126 | " module with primary module.\n"); | ||
127 | } else { | ||
128 | if (unregister_security (&rootplug_security_ops)) { | ||
129 | printk (KERN_INFO "Failure unregistering Root Plug " | ||
130 | "module with the kernel\n"); | ||
131 | } | ||
132 | } | ||
133 | printk (KERN_INFO "Root Plug module removed\n"); | ||
134 | } | ||
135 | |||
136 | security_initcall (rootplug_init); | 112 | security_initcall (rootplug_init); |
137 | module_exit (rootplug_exit); | ||
138 | |||
139 | MODULE_DESCRIPTION("Root Plug sample LSM module, written for Linux Journal article"); | ||
140 | MODULE_LICENSE("GPL"); | ||
141 | |||
diff --git a/security/security.c b/security/security.c index 27e5863d30f1..5b1c034815a8 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/security.h> | 18 | #include <linux/security.h> |
19 | 19 | ||
20 | #define SECURITY_FRAMEWORK_VERSION "1.0.0" | ||
21 | 20 | ||
22 | /* things that live in dummy.c */ | 21 | /* things that live in dummy.c */ |
23 | extern struct security_operations dummy_security_ops; | 22 | extern struct security_operations dummy_security_ops; |
@@ -52,8 +51,7 @@ static void __init do_security_initcalls(void) | |||
52 | */ | 51 | */ |
53 | int __init security_init(void) | 52 | int __init security_init(void) |
54 | { | 53 | { |
55 | printk(KERN_INFO "Security Framework v" SECURITY_FRAMEWORK_VERSION | 54 | printk(KERN_INFO "Security Framework initialized\n"); |
56 | " initialized\n"); | ||
57 | 55 | ||
58 | if (verify(&dummy_security_ops)) { | 56 | if (verify(&dummy_security_ops)) { |
59 | printk(KERN_ERR "%s could not verify " | 57 | printk(KERN_ERR "%s could not verify " |
@@ -173,8 +171,958 @@ int mod_unreg_security(const char *name, struct security_operations *ops) | |||
173 | return security_ops->unregister_security(name, ops); | 171 | return security_ops->unregister_security(name, ops); |
174 | } | 172 | } |
175 | 173 | ||
176 | EXPORT_SYMBOL_GPL(register_security); | 174 | /* Security operations */ |
177 | EXPORT_SYMBOL_GPL(unregister_security); | 175 | |
178 | EXPORT_SYMBOL_GPL(mod_reg_security); | 176 | int security_ptrace(struct task_struct *parent, struct task_struct *child) |
179 | EXPORT_SYMBOL_GPL(mod_unreg_security); | 177 | { |
180 | EXPORT_SYMBOL(security_ops); | 178 | return security_ops->ptrace(parent, child); |
179 | } | ||
180 | |||
181 | int security_capget(struct task_struct *target, | ||
182 | kernel_cap_t *effective, | ||
183 | kernel_cap_t *inheritable, | ||
184 | kernel_cap_t *permitted) | ||
185 | { | ||
186 | return security_ops->capget(target, effective, inheritable, permitted); | ||
187 | } | ||
188 | |||
189 | int security_capset_check(struct task_struct *target, | ||
190 | kernel_cap_t *effective, | ||
191 | kernel_cap_t *inheritable, | ||
192 | kernel_cap_t *permitted) | ||
193 | { | ||
194 | return security_ops->capset_check(target, effective, inheritable, permitted); | ||
195 | } | ||
196 | |||
197 | void security_capset_set(struct task_struct *target, | ||
198 | kernel_cap_t *effective, | ||
199 | kernel_cap_t *inheritable, | ||
200 | kernel_cap_t *permitted) | ||
201 | { | ||
202 | security_ops->capset_set(target, effective, inheritable, permitted); | ||
203 | } | ||
204 | |||
205 | int security_capable(struct task_struct *tsk, int cap) | ||
206 | { | ||
207 | return security_ops->capable(tsk, cap); | ||
208 | } | ||
209 | |||
210 | int security_acct(struct file *file) | ||
211 | { | ||
212 | return security_ops->acct(file); | ||
213 | } | ||
214 | |||
215 | int security_sysctl(struct ctl_table *table, int op) | ||
216 | { | ||
217 | return security_ops->sysctl(table, op); | ||
218 | } | ||
219 | |||
220 | int security_quotactl(int cmds, int type, int id, struct super_block *sb) | ||
221 | { | ||
222 | return security_ops->quotactl(cmds, type, id, sb); | ||
223 | } | ||
224 | |||
225 | int security_quota_on(struct dentry *dentry) | ||
226 | { | ||
227 | return security_ops->quota_on(dentry); | ||
228 | } | ||
229 | |||
230 | int security_syslog(int type) | ||
231 | { | ||
232 | return security_ops->syslog(type); | ||
233 | } | ||
234 | |||
235 | int security_settime(struct timespec *ts, struct timezone *tz) | ||
236 | { | ||
237 | return security_ops->settime(ts, tz); | ||
238 | } | ||
239 | |||
240 | int security_vm_enough_memory(long pages) | ||
241 | { | ||
242 | return security_ops->vm_enough_memory(current->mm, pages); | ||
243 | } | ||
244 | |||
245 | int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) | ||
246 | { | ||
247 | return security_ops->vm_enough_memory(mm, pages); | ||
248 | } | ||
249 | |||
250 | int security_bprm_alloc(struct linux_binprm *bprm) | ||
251 | { | ||
252 | return security_ops->bprm_alloc_security(bprm); | ||
253 | } | ||
254 | |||
255 | void security_bprm_free(struct linux_binprm *bprm) | ||
256 | { | ||
257 | security_ops->bprm_free_security(bprm); | ||
258 | } | ||
259 | |||
260 | void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe) | ||
261 | { | ||
262 | security_ops->bprm_apply_creds(bprm, unsafe); | ||
263 | } | ||
264 | |||
265 | void security_bprm_post_apply_creds(struct linux_binprm *bprm) | ||
266 | { | ||
267 | security_ops->bprm_post_apply_creds(bprm); | ||
268 | } | ||
269 | |||
270 | int security_bprm_set(struct linux_binprm *bprm) | ||
271 | { | ||
272 | return security_ops->bprm_set_security(bprm); | ||
273 | } | ||
274 | |||
275 | int security_bprm_check(struct linux_binprm *bprm) | ||
276 | { | ||
277 | return security_ops->bprm_check_security(bprm); | ||
278 | } | ||
279 | |||
280 | int security_bprm_secureexec(struct linux_binprm *bprm) | ||
281 | { | ||
282 | return security_ops->bprm_secureexec(bprm); | ||
283 | } | ||
284 | |||
285 | int security_sb_alloc(struct super_block *sb) | ||
286 | { | ||
287 | return security_ops->sb_alloc_security(sb); | ||
288 | } | ||
289 | |||
290 | void security_sb_free(struct super_block *sb) | ||
291 | { | ||
292 | security_ops->sb_free_security(sb); | ||
293 | } | ||
294 | |||
295 | int security_sb_copy_data(struct file_system_type *type, void *orig, void *copy) | ||
296 | { | ||
297 | return security_ops->sb_copy_data(type, orig, copy); | ||
298 | } | ||
299 | |||
300 | int security_sb_kern_mount(struct super_block *sb, void *data) | ||
301 | { | ||
302 | return security_ops->sb_kern_mount(sb, data); | ||
303 | } | ||
304 | |||
305 | int security_sb_statfs(struct dentry *dentry) | ||
306 | { | ||
307 | return security_ops->sb_statfs(dentry); | ||
308 | } | ||
309 | |||
310 | int security_sb_mount(char *dev_name, struct nameidata *nd, | ||
311 | char *type, unsigned long flags, void *data) | ||
312 | { | ||
313 | return security_ops->sb_mount(dev_name, nd, type, flags, data); | ||
314 | } | ||
315 | |||
316 | int security_sb_check_sb(struct vfsmount *mnt, struct nameidata *nd) | ||
317 | { | ||
318 | return security_ops->sb_check_sb(mnt, nd); | ||
319 | } | ||
320 | |||
321 | int security_sb_umount(struct vfsmount *mnt, int flags) | ||
322 | { | ||
323 | return security_ops->sb_umount(mnt, flags); | ||
324 | } | ||
325 | |||
326 | void security_sb_umount_close(struct vfsmount *mnt) | ||
327 | { | ||
328 | security_ops->sb_umount_close(mnt); | ||
329 | } | ||
330 | |||
331 | void security_sb_umount_busy(struct vfsmount *mnt) | ||
332 | { | ||
333 | security_ops->sb_umount_busy(mnt); | ||
334 | } | ||
335 | |||
336 | void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data) | ||
337 | { | ||
338 | security_ops->sb_post_remount(mnt, flags, data); | ||
339 | } | ||
340 | |||
341 | void security_sb_post_mountroot(void) | ||
342 | { | ||
343 | security_ops->sb_post_mountroot(); | ||
344 | } | ||
345 | |||
346 | void security_sb_post_addmount(struct vfsmount *mnt, struct nameidata *mountpoint_nd) | ||
347 | { | ||
348 | security_ops->sb_post_addmount(mnt, mountpoint_nd); | ||
349 | } | ||
350 | |||
351 | int security_sb_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd) | ||
352 | { | ||
353 | return security_ops->sb_pivotroot(old_nd, new_nd); | ||
354 | } | ||
355 | |||
356 | void security_sb_post_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd) | ||
357 | { | ||
358 | security_ops->sb_post_pivotroot(old_nd, new_nd); | ||
359 | } | ||
360 | |||
361 | int security_inode_alloc(struct inode *inode) | ||
362 | { | ||
363 | inode->i_security = NULL; | ||
364 | return security_ops->inode_alloc_security(inode); | ||
365 | } | ||
366 | |||
367 | void security_inode_free(struct inode *inode) | ||
368 | { | ||
369 | security_ops->inode_free_security(inode); | ||
370 | } | ||
371 | |||
372 | int security_inode_init_security(struct inode *inode, struct inode *dir, | ||
373 | char **name, void **value, size_t *len) | ||
374 | { | ||
375 | if (unlikely(IS_PRIVATE(inode))) | ||
376 | return -EOPNOTSUPP; | ||
377 | return security_ops->inode_init_security(inode, dir, name, value, len); | ||
378 | } | ||
379 | EXPORT_SYMBOL(security_inode_init_security); | ||
380 | |||
381 | int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) | ||
382 | { | ||
383 | if (unlikely(IS_PRIVATE(dir))) | ||
384 | return 0; | ||
385 | return security_ops->inode_create(dir, dentry, mode); | ||
386 | } | ||
387 | |||
388 | int security_inode_link(struct dentry *old_dentry, struct inode *dir, | ||
389 | struct dentry *new_dentry) | ||
390 | { | ||
391 | if (unlikely(IS_PRIVATE(old_dentry->d_inode))) | ||
392 | return 0; | ||
393 | return security_ops->inode_link(old_dentry, dir, new_dentry); | ||
394 | } | ||
395 | |||
396 | int security_inode_unlink(struct inode *dir, struct dentry *dentry) | ||
397 | { | ||
398 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
399 | return 0; | ||
400 | return security_ops->inode_unlink(dir, dentry); | ||
401 | } | ||
402 | |||
403 | int security_inode_symlink(struct inode *dir, struct dentry *dentry, | ||
404 | const char *old_name) | ||
405 | { | ||
406 | if (unlikely(IS_PRIVATE(dir))) | ||
407 | return 0; | ||
408 | return security_ops->inode_symlink(dir, dentry, old_name); | ||
409 | } | ||
410 | |||
411 | int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode) | ||
412 | { | ||
413 | if (unlikely(IS_PRIVATE(dir))) | ||
414 | return 0; | ||
415 | return security_ops->inode_mkdir(dir, dentry, mode); | ||
416 | } | ||
417 | |||
418 | int security_inode_rmdir(struct inode *dir, struct dentry *dentry) | ||
419 | { | ||
420 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
421 | return 0; | ||
422 | return security_ops->inode_rmdir(dir, dentry); | ||
423 | } | ||
424 | |||
425 | int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | ||
426 | { | ||
427 | if (unlikely(IS_PRIVATE(dir))) | ||
428 | return 0; | ||
429 | return security_ops->inode_mknod(dir, dentry, mode, dev); | ||
430 | } | ||
431 | |||
432 | int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, | ||
433 | struct inode *new_dir, struct dentry *new_dentry) | ||
434 | { | ||
435 | if (unlikely(IS_PRIVATE(old_dentry->d_inode) || | ||
436 | (new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode)))) | ||
437 | return 0; | ||
438 | return security_ops->inode_rename(old_dir, old_dentry, | ||
439 | new_dir, new_dentry); | ||
440 | } | ||
441 | |||
442 | int security_inode_readlink(struct dentry *dentry) | ||
443 | { | ||
444 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
445 | return 0; | ||
446 | return security_ops->inode_readlink(dentry); | ||
447 | } | ||
448 | |||
449 | int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd) | ||
450 | { | ||
451 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
452 | return 0; | ||
453 | return security_ops->inode_follow_link(dentry, nd); | ||
454 | } | ||
455 | |||
456 | int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd) | ||
457 | { | ||
458 | if (unlikely(IS_PRIVATE(inode))) | ||
459 | return 0; | ||
460 | return security_ops->inode_permission(inode, mask, nd); | ||
461 | } | ||
462 | |||
463 | int security_inode_setattr(struct dentry *dentry, struct iattr *attr) | ||
464 | { | ||
465 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
466 | return 0; | ||
467 | return security_ops->inode_setattr(dentry, attr); | ||
468 | } | ||
469 | |||
470 | int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) | ||
471 | { | ||
472 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
473 | return 0; | ||
474 | return security_ops->inode_getattr(mnt, dentry); | ||
475 | } | ||
476 | |||
477 | void security_inode_delete(struct inode *inode) | ||
478 | { | ||
479 | if (unlikely(IS_PRIVATE(inode))) | ||
480 | return; | ||
481 | security_ops->inode_delete(inode); | ||
482 | } | ||
483 | |||
484 | int security_inode_setxattr(struct dentry *dentry, char *name, | ||
485 | void *value, size_t size, int flags) | ||
486 | { | ||
487 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
488 | return 0; | ||
489 | return security_ops->inode_setxattr(dentry, name, value, size, flags); | ||
490 | } | ||
491 | |||
492 | void security_inode_post_setxattr(struct dentry *dentry, char *name, | ||
493 | void *value, size_t size, int flags) | ||
494 | { | ||
495 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
496 | return; | ||
497 | security_ops->inode_post_setxattr(dentry, name, value, size, flags); | ||
498 | } | ||
499 | |||
500 | int security_inode_getxattr(struct dentry *dentry, char *name) | ||
501 | { | ||
502 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
503 | return 0; | ||
504 | return security_ops->inode_getxattr(dentry, name); | ||
505 | } | ||
506 | |||
507 | int security_inode_listxattr(struct dentry *dentry) | ||
508 | { | ||
509 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
510 | return 0; | ||
511 | return security_ops->inode_listxattr(dentry); | ||
512 | } | ||
513 | |||
514 | int security_inode_removexattr(struct dentry *dentry, char *name) | ||
515 | { | ||
516 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
517 | return 0; | ||
518 | return security_ops->inode_removexattr(dentry, name); | ||
519 | } | ||
520 | |||
521 | const char *security_inode_xattr_getsuffix(void) | ||
522 | { | ||
523 | return security_ops->inode_xattr_getsuffix(); | ||
524 | } | ||
525 | |||
526 | int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err) | ||
527 | { | ||
528 | if (unlikely(IS_PRIVATE(inode))) | ||
529 | return 0; | ||
530 | return security_ops->inode_getsecurity(inode, name, buffer, size, err); | ||
531 | } | ||
532 | |||
533 | int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags) | ||
534 | { | ||
535 | if (unlikely(IS_PRIVATE(inode))) | ||
536 | return 0; | ||
537 | return security_ops->inode_setsecurity(inode, name, value, size, flags); | ||
538 | } | ||
539 | |||
540 | int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size) | ||
541 | { | ||
542 | if (unlikely(IS_PRIVATE(inode))) | ||
543 | return 0; | ||
544 | return security_ops->inode_listsecurity(inode, buffer, buffer_size); | ||
545 | } | ||
546 | |||
547 | int security_file_permission(struct file *file, int mask) | ||
548 | { | ||
549 | return security_ops->file_permission(file, mask); | ||
550 | } | ||
551 | |||
552 | int security_file_alloc(struct file *file) | ||
553 | { | ||
554 | return security_ops->file_alloc_security(file); | ||
555 | } | ||
556 | |||
557 | void security_file_free(struct file *file) | ||
558 | { | ||
559 | security_ops->file_free_security(file); | ||
560 | } | ||
561 | |||
562 | int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
563 | { | ||
564 | return security_ops->file_ioctl(file, cmd, arg); | ||
565 | } | ||
566 | |||
567 | int security_file_mmap(struct file *file, unsigned long reqprot, | ||
568 | unsigned long prot, unsigned long flags, | ||
569 | unsigned long addr, unsigned long addr_only) | ||
570 | { | ||
571 | return security_ops->file_mmap(file, reqprot, prot, flags, addr, addr_only); | ||
572 | } | ||
573 | |||
574 | int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, | ||
575 | unsigned long prot) | ||
576 | { | ||
577 | return security_ops->file_mprotect(vma, reqprot, prot); | ||
578 | } | ||
579 | |||
580 | int security_file_lock(struct file *file, unsigned int cmd) | ||
581 | { | ||
582 | return security_ops->file_lock(file, cmd); | ||
583 | } | ||
584 | |||
585 | int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg) | ||
586 | { | ||
587 | return security_ops->file_fcntl(file, cmd, arg); | ||
588 | } | ||
589 | |||
590 | int security_file_set_fowner(struct file *file) | ||
591 | { | ||
592 | return security_ops->file_set_fowner(file); | ||
593 | } | ||
594 | |||
595 | int security_file_send_sigiotask(struct task_struct *tsk, | ||
596 | struct fown_struct *fown, int sig) | ||
597 | { | ||
598 | return security_ops->file_send_sigiotask(tsk, fown, sig); | ||
599 | } | ||
600 | |||
601 | int security_file_receive(struct file *file) | ||
602 | { | ||
603 | return security_ops->file_receive(file); | ||
604 | } | ||
605 | |||
606 | int security_dentry_open(struct file *file) | ||
607 | { | ||
608 | return security_ops->dentry_open(file); | ||
609 | } | ||
610 | |||
611 | int security_task_create(unsigned long clone_flags) | ||
612 | { | ||
613 | return security_ops->task_create(clone_flags); | ||
614 | } | ||
615 | |||
616 | int security_task_alloc(struct task_struct *p) | ||
617 | { | ||
618 | return security_ops->task_alloc_security(p); | ||
619 | } | ||
620 | |||
621 | void security_task_free(struct task_struct *p) | ||
622 | { | ||
623 | security_ops->task_free_security(p); | ||
624 | } | ||
625 | |||
626 | int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags) | ||
627 | { | ||
628 | return security_ops->task_setuid(id0, id1, id2, flags); | ||
629 | } | ||
630 | |||
631 | int security_task_post_setuid(uid_t old_ruid, uid_t old_euid, | ||
632 | uid_t old_suid, int flags) | ||
633 | { | ||
634 | return security_ops->task_post_setuid(old_ruid, old_euid, old_suid, flags); | ||
635 | } | ||
636 | |||
637 | int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags) | ||
638 | { | ||
639 | return security_ops->task_setgid(id0, id1, id2, flags); | ||
640 | } | ||
641 | |||
642 | int security_task_setpgid(struct task_struct *p, pid_t pgid) | ||
643 | { | ||
644 | return security_ops->task_setpgid(p, pgid); | ||
645 | } | ||
646 | |||
647 | int security_task_getpgid(struct task_struct *p) | ||
648 | { | ||
649 | return security_ops->task_getpgid(p); | ||
650 | } | ||
651 | |||
652 | int security_task_getsid(struct task_struct *p) | ||
653 | { | ||
654 | return security_ops->task_getsid(p); | ||
655 | } | ||
656 | |||
657 | void security_task_getsecid(struct task_struct *p, u32 *secid) | ||
658 | { | ||
659 | security_ops->task_getsecid(p, secid); | ||
660 | } | ||
661 | EXPORT_SYMBOL(security_task_getsecid); | ||
662 | |||
663 | int security_task_setgroups(struct group_info *group_info) | ||
664 | { | ||
665 | return security_ops->task_setgroups(group_info); | ||
666 | } | ||
667 | |||
668 | int security_task_setnice(struct task_struct *p, int nice) | ||
669 | { | ||
670 | return security_ops->task_setnice(p, nice); | ||
671 | } | ||
672 | |||
673 | int security_task_setioprio(struct task_struct *p, int ioprio) | ||
674 | { | ||
675 | return security_ops->task_setioprio(p, ioprio); | ||
676 | } | ||
677 | |||
678 | int security_task_getioprio(struct task_struct *p) | ||
679 | { | ||
680 | return security_ops->task_getioprio(p); | ||
681 | } | ||
682 | |||
683 | int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim) | ||
684 | { | ||
685 | return security_ops->task_setrlimit(resource, new_rlim); | ||
686 | } | ||
687 | |||
688 | int security_task_setscheduler(struct task_struct *p, | ||
689 | int policy, struct sched_param *lp) | ||
690 | { | ||
691 | return security_ops->task_setscheduler(p, policy, lp); | ||
692 | } | ||
693 | |||
694 | int security_task_getscheduler(struct task_struct *p) | ||
695 | { | ||
696 | return security_ops->task_getscheduler(p); | ||
697 | } | ||
698 | |||
699 | int security_task_movememory(struct task_struct *p) | ||
700 | { | ||
701 | return security_ops->task_movememory(p); | ||
702 | } | ||
703 | |||
704 | int security_task_kill(struct task_struct *p, struct siginfo *info, | ||
705 | int sig, u32 secid) | ||
706 | { | ||
707 | return security_ops->task_kill(p, info, sig, secid); | ||
708 | } | ||
709 | |||
710 | int security_task_wait(struct task_struct *p) | ||
711 | { | ||
712 | return security_ops->task_wait(p); | ||
713 | } | ||
714 | |||
715 | int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, | ||
716 | unsigned long arg4, unsigned long arg5) | ||
717 | { | ||
718 | return security_ops->task_prctl(option, arg2, arg3, arg4, arg5); | ||
719 | } | ||
720 | |||
721 | void security_task_reparent_to_init(struct task_struct *p) | ||
722 | { | ||
723 | security_ops->task_reparent_to_init(p); | ||
724 | } | ||
725 | |||
726 | void security_task_to_inode(struct task_struct *p, struct inode *inode) | ||
727 | { | ||
728 | security_ops->task_to_inode(p, inode); | ||
729 | } | ||
730 | |||
731 | int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag) | ||
732 | { | ||
733 | return security_ops->ipc_permission(ipcp, flag); | ||
734 | } | ||
735 | |||
736 | int security_msg_msg_alloc(struct msg_msg *msg) | ||
737 | { | ||
738 | return security_ops->msg_msg_alloc_security(msg); | ||
739 | } | ||
740 | |||
741 | void security_msg_msg_free(struct msg_msg *msg) | ||
742 | { | ||
743 | security_ops->msg_msg_free_security(msg); | ||
744 | } | ||
745 | |||
746 | int security_msg_queue_alloc(struct msg_queue *msq) | ||
747 | { | ||
748 | return security_ops->msg_queue_alloc_security(msq); | ||
749 | } | ||
750 | |||
751 | void security_msg_queue_free(struct msg_queue *msq) | ||
752 | { | ||
753 | security_ops->msg_queue_free_security(msq); | ||
754 | } | ||
755 | |||
756 | int security_msg_queue_associate(struct msg_queue *msq, int msqflg) | ||
757 | { | ||
758 | return security_ops->msg_queue_associate(msq, msqflg); | ||
759 | } | ||
760 | |||
761 | int security_msg_queue_msgctl(struct msg_queue *msq, int cmd) | ||
762 | { | ||
763 | return security_ops->msg_queue_msgctl(msq, cmd); | ||
764 | } | ||
765 | |||
766 | int security_msg_queue_msgsnd(struct msg_queue *msq, | ||
767 | struct msg_msg *msg, int msqflg) | ||
768 | { | ||
769 | return security_ops->msg_queue_msgsnd(msq, msg, msqflg); | ||
770 | } | ||
771 | |||
772 | int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg, | ||
773 | struct task_struct *target, long type, int mode) | ||
774 | { | ||
775 | return security_ops->msg_queue_msgrcv(msq, msg, target, type, mode); | ||
776 | } | ||
777 | |||
778 | int security_shm_alloc(struct shmid_kernel *shp) | ||
779 | { | ||
780 | return security_ops->shm_alloc_security(shp); | ||
781 | } | ||
782 | |||
783 | void security_shm_free(struct shmid_kernel *shp) | ||
784 | { | ||
785 | security_ops->shm_free_security(shp); | ||
786 | } | ||
787 | |||
788 | int security_shm_associate(struct shmid_kernel *shp, int shmflg) | ||
789 | { | ||
790 | return security_ops->shm_associate(shp, shmflg); | ||
791 | } | ||
792 | |||
793 | int security_shm_shmctl(struct shmid_kernel *shp, int cmd) | ||
794 | { | ||
795 | return security_ops->shm_shmctl(shp, cmd); | ||
796 | } | ||
797 | |||
798 | int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg) | ||
799 | { | ||
800 | return security_ops->shm_shmat(shp, shmaddr, shmflg); | ||
801 | } | ||
802 | |||
803 | int security_sem_alloc(struct sem_array *sma) | ||
804 | { | ||
805 | return security_ops->sem_alloc_security(sma); | ||
806 | } | ||
807 | |||
808 | void security_sem_free(struct sem_array *sma) | ||
809 | { | ||
810 | security_ops->sem_free_security(sma); | ||
811 | } | ||
812 | |||
813 | int security_sem_associate(struct sem_array *sma, int semflg) | ||
814 | { | ||
815 | return security_ops->sem_associate(sma, semflg); | ||
816 | } | ||
817 | |||
818 | int security_sem_semctl(struct sem_array *sma, int cmd) | ||
819 | { | ||
820 | return security_ops->sem_semctl(sma, cmd); | ||
821 | } | ||
822 | |||
823 | int security_sem_semop(struct sem_array *sma, struct sembuf *sops, | ||
824 | unsigned nsops, int alter) | ||
825 | { | ||
826 | return security_ops->sem_semop(sma, sops, nsops, alter); | ||
827 | } | ||
828 | |||
829 | void security_d_instantiate(struct dentry *dentry, struct inode *inode) | ||
830 | { | ||
831 | if (unlikely(inode && IS_PRIVATE(inode))) | ||
832 | return; | ||
833 | security_ops->d_instantiate(dentry, inode); | ||
834 | } | ||
835 | EXPORT_SYMBOL(security_d_instantiate); | ||
836 | |||
837 | int security_getprocattr(struct task_struct *p, char *name, char **value) | ||
838 | { | ||
839 | return security_ops->getprocattr(p, name, value); | ||
840 | } | ||
841 | |||
842 | int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size) | ||
843 | { | ||
844 | return security_ops->setprocattr(p, name, value, size); | ||
845 | } | ||
846 | |||
847 | int security_netlink_send(struct sock *sk, struct sk_buff *skb) | ||
848 | { | ||
849 | return security_ops->netlink_send(sk, skb); | ||
850 | } | ||
851 | EXPORT_SYMBOL(security_netlink_send); | ||
852 | |||
853 | int security_netlink_recv(struct sk_buff *skb, int cap) | ||
854 | { | ||
855 | return security_ops->netlink_recv(skb, cap); | ||
856 | } | ||
857 | EXPORT_SYMBOL(security_netlink_recv); | ||
858 | |||
859 | int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) | ||
860 | { | ||
861 | return security_ops->secid_to_secctx(secid, secdata, seclen); | ||
862 | } | ||
863 | EXPORT_SYMBOL(security_secid_to_secctx); | ||
864 | |||
865 | void security_release_secctx(char *secdata, u32 seclen) | ||
866 | { | ||
867 | return security_ops->release_secctx(secdata, seclen); | ||
868 | } | ||
869 | EXPORT_SYMBOL(security_release_secctx); | ||
870 | |||
871 | #ifdef CONFIG_SECURITY_NETWORK | ||
872 | |||
873 | int security_unix_stream_connect(struct socket *sock, struct socket *other, | ||
874 | struct sock *newsk) | ||
875 | { | ||
876 | return security_ops->unix_stream_connect(sock, other, newsk); | ||
877 | } | ||
878 | EXPORT_SYMBOL(security_unix_stream_connect); | ||
879 | |||
880 | int security_unix_may_send(struct socket *sock, struct socket *other) | ||
881 | { | ||
882 | return security_ops->unix_may_send(sock, other); | ||
883 | } | ||
884 | EXPORT_SYMBOL(security_unix_may_send); | ||
885 | |||
886 | int security_socket_create(int family, int type, int protocol, int kern) | ||
887 | { | ||
888 | return security_ops->socket_create(family, type, protocol, kern); | ||
889 | } | ||
890 | |||
891 | int security_socket_post_create(struct socket *sock, int family, | ||
892 | int type, int protocol, int kern) | ||
893 | { | ||
894 | return security_ops->socket_post_create(sock, family, type, | ||
895 | protocol, kern); | ||
896 | } | ||
897 | |||
898 | int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen) | ||
899 | { | ||
900 | return security_ops->socket_bind(sock, address, addrlen); | ||
901 | } | ||
902 | |||
903 | int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen) | ||
904 | { | ||
905 | return security_ops->socket_connect(sock, address, addrlen); | ||
906 | } | ||
907 | |||
908 | int security_socket_listen(struct socket *sock, int backlog) | ||
909 | { | ||
910 | return security_ops->socket_listen(sock, backlog); | ||
911 | } | ||
912 | |||
913 | int security_socket_accept(struct socket *sock, struct socket *newsock) | ||
914 | { | ||
915 | return security_ops->socket_accept(sock, newsock); | ||
916 | } | ||
917 | |||
918 | void security_socket_post_accept(struct socket *sock, struct socket *newsock) | ||
919 | { | ||
920 | security_ops->socket_post_accept(sock, newsock); | ||
921 | } | ||
922 | |||
923 | int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size) | ||
924 | { | ||
925 | return security_ops->socket_sendmsg(sock, msg, size); | ||
926 | } | ||
927 | |||
928 | int security_socket_recvmsg(struct socket *sock, struct msghdr *msg, | ||
929 | int size, int flags) | ||
930 | { | ||
931 | return security_ops->socket_recvmsg(sock, msg, size, flags); | ||
932 | } | ||
933 | |||
934 | int security_socket_getsockname(struct socket *sock) | ||
935 | { | ||
936 | return security_ops->socket_getsockname(sock); | ||
937 | } | ||
938 | |||
939 | int security_socket_getpeername(struct socket *sock) | ||
940 | { | ||
941 | return security_ops->socket_getpeername(sock); | ||
942 | } | ||
943 | |||
944 | int security_socket_getsockopt(struct socket *sock, int level, int optname) | ||
945 | { | ||
946 | return security_ops->socket_getsockopt(sock, level, optname); | ||
947 | } | ||
948 | |||
949 | int security_socket_setsockopt(struct socket *sock, int level, int optname) | ||
950 | { | ||
951 | return security_ops->socket_setsockopt(sock, level, optname); | ||
952 | } | ||
953 | |||
954 | int security_socket_shutdown(struct socket *sock, int how) | ||
955 | { | ||
956 | return security_ops->socket_shutdown(sock, how); | ||
957 | } | ||
958 | |||
959 | int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) | ||
960 | { | ||
961 | return security_ops->socket_sock_rcv_skb(sk, skb); | ||
962 | } | ||
963 | EXPORT_SYMBOL(security_sock_rcv_skb); | ||
964 | |||
965 | int security_socket_getpeersec_stream(struct socket *sock, char __user *optval, | ||
966 | int __user *optlen, unsigned len) | ||
967 | { | ||
968 | return security_ops->socket_getpeersec_stream(sock, optval, optlen, len); | ||
969 | } | ||
970 | |||
971 | int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid) | ||
972 | { | ||
973 | return security_ops->socket_getpeersec_dgram(sock, skb, secid); | ||
974 | } | ||
975 | EXPORT_SYMBOL(security_socket_getpeersec_dgram); | ||
976 | |||
977 | int security_sk_alloc(struct sock *sk, int family, gfp_t priority) | ||
978 | { | ||
979 | return security_ops->sk_alloc_security(sk, family, priority); | ||
980 | } | ||
981 | |||
982 | void security_sk_free(struct sock *sk) | ||
983 | { | ||
984 | return security_ops->sk_free_security(sk); | ||
985 | } | ||
986 | |||
987 | void security_sk_clone(const struct sock *sk, struct sock *newsk) | ||
988 | { | ||
989 | return security_ops->sk_clone_security(sk, newsk); | ||
990 | } | ||
991 | |||
992 | void security_sk_classify_flow(struct sock *sk, struct flowi *fl) | ||
993 | { | ||
994 | security_ops->sk_getsecid(sk, &fl->secid); | ||
995 | } | ||
996 | EXPORT_SYMBOL(security_sk_classify_flow); | ||
997 | |||
998 | void security_req_classify_flow(const struct request_sock *req, struct flowi *fl) | ||
999 | { | ||
1000 | security_ops->req_classify_flow(req, fl); | ||
1001 | } | ||
1002 | EXPORT_SYMBOL(security_req_classify_flow); | ||
1003 | |||
1004 | void security_sock_graft(struct sock *sk, struct socket *parent) | ||
1005 | { | ||
1006 | security_ops->sock_graft(sk, parent); | ||
1007 | } | ||
1008 | EXPORT_SYMBOL(security_sock_graft); | ||
1009 | |||
1010 | int security_inet_conn_request(struct sock *sk, | ||
1011 | struct sk_buff *skb, struct request_sock *req) | ||
1012 | { | ||
1013 | return security_ops->inet_conn_request(sk, skb, req); | ||
1014 | } | ||
1015 | EXPORT_SYMBOL(security_inet_conn_request); | ||
1016 | |||
1017 | void security_inet_csk_clone(struct sock *newsk, | ||
1018 | const struct request_sock *req) | ||
1019 | { | ||
1020 | security_ops->inet_csk_clone(newsk, req); | ||
1021 | } | ||
1022 | |||
1023 | void security_inet_conn_established(struct sock *sk, | ||
1024 | struct sk_buff *skb) | ||
1025 | { | ||
1026 | security_ops->inet_conn_established(sk, skb); | ||
1027 | } | ||
1028 | |||
1029 | #endif /* CONFIG_SECURITY_NETWORK */ | ||
1030 | |||
1031 | #ifdef CONFIG_SECURITY_NETWORK_XFRM | ||
1032 | |||
1033 | int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) | ||
1034 | { | ||
1035 | return security_ops->xfrm_policy_alloc_security(xp, sec_ctx); | ||
1036 | } | ||
1037 | EXPORT_SYMBOL(security_xfrm_policy_alloc); | ||
1038 | |||
1039 | int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) | ||
1040 | { | ||
1041 | return security_ops->xfrm_policy_clone_security(old, new); | ||
1042 | } | ||
1043 | |||
1044 | void security_xfrm_policy_free(struct xfrm_policy *xp) | ||
1045 | { | ||
1046 | security_ops->xfrm_policy_free_security(xp); | ||
1047 | } | ||
1048 | EXPORT_SYMBOL(security_xfrm_policy_free); | ||
1049 | |||
1050 | int security_xfrm_policy_delete(struct xfrm_policy *xp) | ||
1051 | { | ||
1052 | return security_ops->xfrm_policy_delete_security(xp); | ||
1053 | } | ||
1054 | |||
1055 | int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx) | ||
1056 | { | ||
1057 | return security_ops->xfrm_state_alloc_security(x, sec_ctx, 0); | ||
1058 | } | ||
1059 | EXPORT_SYMBOL(security_xfrm_state_alloc); | ||
1060 | |||
1061 | int security_xfrm_state_alloc_acquire(struct xfrm_state *x, | ||
1062 | struct xfrm_sec_ctx *polsec, u32 secid) | ||
1063 | { | ||
1064 | if (!polsec) | ||
1065 | return 0; | ||
1066 | /* | ||
1067 | * We want the context to be taken from secid which is usually | ||
1068 | * from the sock. | ||
1069 | */ | ||
1070 | return security_ops->xfrm_state_alloc_security(x, NULL, secid); | ||
1071 | } | ||
1072 | |||
1073 | int security_xfrm_state_delete(struct xfrm_state *x) | ||
1074 | { | ||
1075 | return security_ops->xfrm_state_delete_security(x); | ||
1076 | } | ||
1077 | EXPORT_SYMBOL(security_xfrm_state_delete); | ||
1078 | |||
1079 | void security_xfrm_state_free(struct xfrm_state *x) | ||
1080 | { | ||
1081 | security_ops->xfrm_state_free_security(x); | ||
1082 | } | ||
1083 | |||
1084 | int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir) | ||
1085 | { | ||
1086 | return security_ops->xfrm_policy_lookup(xp, fl_secid, dir); | ||
1087 | } | ||
1088 | |||
1089 | int security_xfrm_state_pol_flow_match(struct xfrm_state *x, | ||
1090 | struct xfrm_policy *xp, struct flowi *fl) | ||
1091 | { | ||
1092 | return security_ops->xfrm_state_pol_flow_match(x, xp, fl); | ||
1093 | } | ||
1094 | |||
1095 | int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) | ||
1096 | { | ||
1097 | return security_ops->xfrm_decode_session(skb, secid, 1); | ||
1098 | } | ||
1099 | |||
1100 | void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl) | ||
1101 | { | ||
1102 | int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0); | ||
1103 | |||
1104 | BUG_ON(rc); | ||
1105 | } | ||
1106 | EXPORT_SYMBOL(security_skb_classify_flow); | ||
1107 | |||
1108 | #endif /* CONFIG_SECURITY_NETWORK_XFRM */ | ||
1109 | |||
1110 | #ifdef CONFIG_KEYS | ||
1111 | |||
1112 | int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long flags) | ||
1113 | { | ||
1114 | return security_ops->key_alloc(key, tsk, flags); | ||
1115 | } | ||
1116 | |||
1117 | void security_key_free(struct key *key) | ||
1118 | { | ||
1119 | security_ops->key_free(key); | ||
1120 | } | ||
1121 | |||
1122 | int security_key_permission(key_ref_t key_ref, | ||
1123 | struct task_struct *context, key_perm_t perm) | ||
1124 | { | ||
1125 | return security_ops->key_permission(key_ref, context, perm); | ||
1126 | } | ||
1127 | |||
1128 | #endif /* CONFIG_KEYS */ | ||
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 97b7e2738097..83a535b7bc60 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -22,7 +22,6 @@ | |||
22 | * as published by the Free Software Foundation. | 22 | * as published by the Free Software Foundation. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/init.h> | 25 | #include <linux/init.h> |
27 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
28 | #include <linux/ptrace.h> | 27 | #include <linux/ptrace.h> |
@@ -86,6 +85,7 @@ | |||
86 | extern unsigned int policydb_loaded_version; | 85 | extern unsigned int policydb_loaded_version; |
87 | extern int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm); | 86 | extern int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm); |
88 | extern int selinux_compat_net; | 87 | extern int selinux_compat_net; |
88 | extern struct security_operations *security_ops; | ||
89 | 89 | ||
90 | #ifdef CONFIG_SECURITY_SELINUX_DEVELOP | 90 | #ifdef CONFIG_SECURITY_SELINUX_DEVELOP |
91 | int selinux_enforcing = 0; | 91 | int selinux_enforcing = 0; |
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c index ba715f40b658..cb008d9f0a82 100644 --- a/security/selinux/xfrm.c +++ b/security/selinux/xfrm.c | |||
@@ -31,7 +31,6 @@ | |||
31 | * 2. Emulating a reasonable SO_PEERSEC across machines | 31 | * 2. Emulating a reasonable SO_PEERSEC across machines |
32 | * 3. Testing addition of sk_policy's with security context via setsockopt | 32 | * 3. Testing addition of sk_policy's with security context via setsockopt |
33 | */ | 33 | */ |
34 | #include <linux/module.h> | ||
35 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
37 | #include <linux/security.h> | 36 | #include <linux/security.h> |