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

LSM: Add security module hook list heads

Add a list header for each security hook. They aren't used until
later in the patch series. They are grouped together in a structure
so that there doesn't need to be an external address for each.

Macro-ize the initialization of the security_operations
for each security module in anticipation of changing out
the security_operations structure.

Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Paul Moore <paul@paul-moore.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <james.l.morris@oracle.com>

authored by

Casey Schaufler and committed by
James Morris
e20b043a f25fce3e

+583 -359
+220
include/linux/lsm_hooks.h
··· 1626 1626 #endif /* CONFIG_AUDIT */ 1627 1627 }; 1628 1628 1629 + struct security_hook_heads { 1630 + struct list_head binder_set_context_mgr; 1631 + struct list_head binder_transaction; 1632 + struct list_head binder_transfer_binder; 1633 + struct list_head binder_transfer_file; 1634 + struct list_head ptrace_access_check; 1635 + struct list_head ptrace_traceme; 1636 + struct list_head capget; 1637 + struct list_head capset; 1638 + struct list_head capable; 1639 + struct list_head quotactl; 1640 + struct list_head quota_on; 1641 + struct list_head syslog; 1642 + struct list_head settime; 1643 + struct list_head vm_enough_memory; 1644 + struct list_head bprm_set_creds; 1645 + struct list_head bprm_check_security; 1646 + struct list_head bprm_secureexec; 1647 + struct list_head bprm_committing_creds; 1648 + struct list_head bprm_committed_creds; 1649 + struct list_head sb_alloc_security; 1650 + struct list_head sb_free_security; 1651 + struct list_head sb_copy_data; 1652 + struct list_head sb_remount; 1653 + struct list_head sb_kern_mount; 1654 + struct list_head sb_show_options; 1655 + struct list_head sb_statfs; 1656 + struct list_head sb_mount; 1657 + struct list_head sb_umount; 1658 + struct list_head sb_pivotroot; 1659 + struct list_head sb_set_mnt_opts; 1660 + struct list_head sb_clone_mnt_opts; 1661 + struct list_head sb_parse_opts_str; 1662 + struct list_head dentry_init_security; 1663 + #ifdef CONFIG_SECURITY_PATH 1664 + struct list_head path_unlink; 1665 + struct list_head path_mkdir; 1666 + struct list_head path_rmdir; 1667 + struct list_head path_mknod; 1668 + struct list_head path_truncate; 1669 + struct list_head path_symlink; 1670 + struct list_head path_link; 1671 + struct list_head path_rename; 1672 + struct list_head path_chmod; 1673 + struct list_head path_chown; 1674 + struct list_head path_chroot; 1675 + #endif 1676 + struct list_head inode_alloc_security; 1677 + struct list_head inode_free_security; 1678 + struct list_head inode_init_security; 1679 + struct list_head inode_create; 1680 + struct list_head inode_link; 1681 + struct list_head inode_unlink; 1682 + struct list_head inode_symlink; 1683 + struct list_head inode_mkdir; 1684 + struct list_head inode_rmdir; 1685 + struct list_head inode_mknod; 1686 + struct list_head inode_rename; 1687 + struct list_head inode_readlink; 1688 + struct list_head inode_follow_link; 1689 + struct list_head inode_permission; 1690 + struct list_head inode_setattr; 1691 + struct list_head inode_getattr; 1692 + struct list_head inode_setxattr; 1693 + struct list_head inode_post_setxattr; 1694 + struct list_head inode_getxattr; 1695 + struct list_head inode_listxattr; 1696 + struct list_head inode_removexattr; 1697 + struct list_head inode_need_killpriv; 1698 + struct list_head inode_killpriv; 1699 + struct list_head inode_getsecurity; 1700 + struct list_head inode_setsecurity; 1701 + struct list_head inode_listsecurity; 1702 + struct list_head inode_getsecid; 1703 + struct list_head file_permission; 1704 + struct list_head file_alloc_security; 1705 + struct list_head file_free_security; 1706 + struct list_head file_ioctl; 1707 + struct list_head mmap_addr; 1708 + struct list_head mmap_file; 1709 + struct list_head file_mprotect; 1710 + struct list_head file_lock; 1711 + struct list_head file_fcntl; 1712 + struct list_head file_set_fowner; 1713 + struct list_head file_send_sigiotask; 1714 + struct list_head file_receive; 1715 + struct list_head file_open; 1716 + struct list_head task_create; 1717 + struct list_head task_free; 1718 + struct list_head cred_alloc_blank; 1719 + struct list_head cred_free; 1720 + struct list_head cred_prepare; 1721 + struct list_head cred_transfer; 1722 + struct list_head kernel_act_as; 1723 + struct list_head kernel_create_files_as; 1724 + struct list_head kernel_fw_from_file; 1725 + struct list_head kernel_module_request; 1726 + struct list_head kernel_module_from_file; 1727 + struct list_head task_fix_setuid; 1728 + struct list_head task_setpgid; 1729 + struct list_head task_getpgid; 1730 + struct list_head task_getsid; 1731 + struct list_head task_getsecid; 1732 + struct list_head task_setnice; 1733 + struct list_head task_setioprio; 1734 + struct list_head task_getioprio; 1735 + struct list_head task_setrlimit; 1736 + struct list_head task_setscheduler; 1737 + struct list_head task_getscheduler; 1738 + struct list_head task_movememory; 1739 + struct list_head task_kill; 1740 + struct list_head task_wait; 1741 + struct list_head task_prctl; 1742 + struct list_head task_to_inode; 1743 + struct list_head ipc_permission; 1744 + struct list_head ipc_getsecid; 1745 + struct list_head msg_msg_alloc_security; 1746 + struct list_head msg_msg_free_security; 1747 + struct list_head msg_queue_alloc_security; 1748 + struct list_head msg_queue_free_security; 1749 + struct list_head msg_queue_associate; 1750 + struct list_head msg_queue_msgctl; 1751 + struct list_head msg_queue_msgsnd; 1752 + struct list_head msg_queue_msgrcv; 1753 + struct list_head shm_alloc_security; 1754 + struct list_head shm_free_security; 1755 + struct list_head shm_associate; 1756 + struct list_head shm_shmctl; 1757 + struct list_head shm_shmat; 1758 + struct list_head sem_alloc_security; 1759 + struct list_head sem_free_security; 1760 + struct list_head sem_associate; 1761 + struct list_head sem_semctl; 1762 + struct list_head sem_semop; 1763 + struct list_head netlink_send; 1764 + struct list_head d_instantiate; 1765 + struct list_head getprocattr; 1766 + struct list_head setprocattr; 1767 + struct list_head ismaclabel; 1768 + struct list_head secid_to_secctx; 1769 + struct list_head secctx_to_secid; 1770 + struct list_head release_secctx; 1771 + struct list_head inode_notifysecctx; 1772 + struct list_head inode_setsecctx; 1773 + struct list_head inode_getsecctx; 1774 + #ifdef CONFIG_SECURITY_NETWORK 1775 + struct list_head unix_stream_connect; 1776 + struct list_head unix_may_send; 1777 + struct list_head socket_create; 1778 + struct list_head socket_post_create; 1779 + struct list_head socket_bind; 1780 + struct list_head socket_connect; 1781 + struct list_head socket_listen; 1782 + struct list_head socket_accept; 1783 + struct list_head socket_sendmsg; 1784 + struct list_head socket_recvmsg; 1785 + struct list_head socket_getsockname; 1786 + struct list_head socket_getpeername; 1787 + struct list_head socket_getsockopt; 1788 + struct list_head socket_setsockopt; 1789 + struct list_head socket_shutdown; 1790 + struct list_head socket_sock_rcv_skb; 1791 + struct list_head socket_getpeersec_stream; 1792 + struct list_head socket_getpeersec_dgram; 1793 + struct list_head sk_alloc_security; 1794 + struct list_head sk_free_security; 1795 + struct list_head sk_clone_security; 1796 + struct list_head sk_getsecid; 1797 + struct list_head sock_graft; 1798 + struct list_head inet_conn_request; 1799 + struct list_head inet_csk_clone; 1800 + struct list_head inet_conn_established; 1801 + struct list_head secmark_relabel_packet; 1802 + struct list_head secmark_refcount_inc; 1803 + struct list_head secmark_refcount_dec; 1804 + struct list_head req_classify_flow; 1805 + struct list_head tun_dev_alloc_security; 1806 + struct list_head tun_dev_free_security; 1807 + struct list_head tun_dev_create; 1808 + struct list_head tun_dev_attach_queue; 1809 + struct list_head tun_dev_attach; 1810 + struct list_head tun_dev_open; 1811 + struct list_head skb_owned_by; 1812 + #endif /* CONFIG_SECURITY_NETWORK */ 1813 + #ifdef CONFIG_SECURITY_NETWORK_XFRM 1814 + struct list_head xfrm_policy_alloc_security; 1815 + struct list_head xfrm_policy_clone_security; 1816 + struct list_head xfrm_policy_free_security; 1817 + struct list_head xfrm_policy_delete_security; 1818 + struct list_head xfrm_state_alloc; 1819 + struct list_head xfrm_state_alloc_acquire; 1820 + struct list_head xfrm_state_free_security; 1821 + struct list_head xfrm_state_delete_security; 1822 + struct list_head xfrm_policy_lookup; 1823 + struct list_head xfrm_state_pol_flow_match; 1824 + struct list_head xfrm_decode_session; 1825 + #endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1826 + #ifdef CONFIG_KEYS 1827 + struct list_head key_alloc; 1828 + struct list_head key_free; 1829 + struct list_head key_permission; 1830 + struct list_head key_getsecurity; 1831 + #endif /* CONFIG_KEYS */ 1832 + #ifdef CONFIG_AUDIT 1833 + struct list_head audit_rule_init; 1834 + struct list_head audit_rule_known; 1835 + struct list_head audit_rule_match; 1836 + struct list_head audit_rule_free; 1837 + #endif /* CONFIG_AUDIT */ 1838 + }; 1839 + 1840 + /* 1841 + * Initializing a security_hook_list structure takes 1842 + * up a lot of space in a source file. This macro takes 1843 + * care of the common case and reduces the amount of 1844 + * text involved. 1845 + * Casey says: Comment is true in the next patch. 1846 + */ 1847 + #define LSM_HOOK_INIT(HEAD, HOOK) .HEAD = HOOK 1848 + 1629 1849 /* prototypes */ 1630 1850 extern int security_module_enable(struct security_operations *ops); 1631 1851 extern int register_security(struct security_operations *ops);
+35 -35
security/apparmor/lsm.c
··· 616 616 } 617 617 618 618 static struct security_operations apparmor_ops = { 619 - .name = "apparmor", 619 + LSM_HOOK_INIT(name, "apparmor"), 620 620 621 - .ptrace_access_check = apparmor_ptrace_access_check, 622 - .ptrace_traceme = apparmor_ptrace_traceme, 623 - .capget = apparmor_capget, 624 - .capable = apparmor_capable, 621 + LSM_HOOK_INIT(ptrace_access_check, apparmor_ptrace_access_check), 622 + LSM_HOOK_INIT(ptrace_traceme, apparmor_ptrace_traceme), 623 + LSM_HOOK_INIT(capget, apparmor_capget), 624 + LSM_HOOK_INIT(capable, apparmor_capable), 625 625 626 - .path_link = apparmor_path_link, 627 - .path_unlink = apparmor_path_unlink, 628 - .path_symlink = apparmor_path_symlink, 629 - .path_mkdir = apparmor_path_mkdir, 630 - .path_rmdir = apparmor_path_rmdir, 631 - .path_mknod = apparmor_path_mknod, 632 - .path_rename = apparmor_path_rename, 633 - .path_chmod = apparmor_path_chmod, 634 - .path_chown = apparmor_path_chown, 635 - .path_truncate = apparmor_path_truncate, 636 - .inode_getattr = apparmor_inode_getattr, 626 + LSM_HOOK_INIT(path_link, apparmor_path_link), 627 + LSM_HOOK_INIT(path_unlink, apparmor_path_unlink), 628 + LSM_HOOK_INIT(path_symlink, apparmor_path_symlink), 629 + LSM_HOOK_INIT(path_mkdir, apparmor_path_mkdir), 630 + LSM_HOOK_INIT(path_rmdir, apparmor_path_rmdir), 631 + LSM_HOOK_INIT(path_mknod, apparmor_path_mknod), 632 + LSM_HOOK_INIT(path_rename, apparmor_path_rename), 633 + LSM_HOOK_INIT(path_chmod, apparmor_path_chmod), 634 + LSM_HOOK_INIT(path_chown, apparmor_path_chown), 635 + LSM_HOOK_INIT(path_truncate, apparmor_path_truncate), 636 + LSM_HOOK_INIT(inode_getattr, apparmor_inode_getattr), 637 637 638 - .file_open = apparmor_file_open, 639 - .file_permission = apparmor_file_permission, 640 - .file_alloc_security = apparmor_file_alloc_security, 641 - .file_free_security = apparmor_file_free_security, 642 - .mmap_file = apparmor_mmap_file, 643 - .mmap_addr = cap_mmap_addr, 644 - .file_mprotect = apparmor_file_mprotect, 645 - .file_lock = apparmor_file_lock, 638 + LSM_HOOK_INIT(file_open, apparmor_file_open), 639 + LSM_HOOK_INIT(file_permission, apparmor_file_permission), 640 + LSM_HOOK_INIT(file_alloc_security, apparmor_file_alloc_security), 641 + LSM_HOOK_INIT(file_free_security, apparmor_file_free_security), 642 + LSM_HOOK_INIT(mmap_file, apparmor_mmap_file), 643 + LSM_HOOK_INIT(mmap_addr, cap_mmap_addr), 644 + LSM_HOOK_INIT(file_mprotect, apparmor_file_mprotect), 645 + LSM_HOOK_INIT(file_lock, apparmor_file_lock), 646 646 647 - .getprocattr = apparmor_getprocattr, 648 - .setprocattr = apparmor_setprocattr, 647 + LSM_HOOK_INIT(getprocattr, apparmor_getprocattr), 648 + LSM_HOOK_INIT(setprocattr, apparmor_setprocattr), 649 649 650 - .cred_alloc_blank = apparmor_cred_alloc_blank, 651 - .cred_free = apparmor_cred_free, 652 - .cred_prepare = apparmor_cred_prepare, 653 - .cred_transfer = apparmor_cred_transfer, 650 + LSM_HOOK_INIT(cred_alloc_blank, apparmor_cred_alloc_blank), 651 + LSM_HOOK_INIT(cred_free, apparmor_cred_free), 652 + LSM_HOOK_INIT(cred_prepare, apparmor_cred_prepare), 653 + LSM_HOOK_INIT(cred_transfer, apparmor_cred_transfer), 654 654 655 - .bprm_set_creds = apparmor_bprm_set_creds, 656 - .bprm_committing_creds = apparmor_bprm_committing_creds, 657 - .bprm_committed_creds = apparmor_bprm_committed_creds, 658 - .bprm_secureexec = apparmor_bprm_secureexec, 655 + LSM_HOOK_INIT(bprm_set_creds, apparmor_bprm_set_creds), 656 + LSM_HOOK_INIT(bprm_committing_creds, apparmor_bprm_committing_creds), 657 + LSM_HOOK_INIT(bprm_committed_creds, apparmor_bprm_committed_creds), 658 + LSM_HOOK_INIT(bprm_secureexec, apparmor_bprm_secureexec), 659 659 660 - .task_setrlimit = apparmor_task_setrlimit, 660 + LSM_HOOK_INIT(task_setrlimit, apparmor_task_setrlimit), 661 661 }; 662 662 663 663 /*
+181 -177
security/selinux/hooks.c
··· 5841 5841 #endif 5842 5842 5843 5843 static struct security_operations selinux_ops = { 5844 - .name = "selinux", 5844 + LSM_HOOK_INIT(name, "selinux"), 5845 5845 5846 - .binder_set_context_mgr = selinux_binder_set_context_mgr, 5847 - .binder_transaction = selinux_binder_transaction, 5848 - .binder_transfer_binder = selinux_binder_transfer_binder, 5849 - .binder_transfer_file = selinux_binder_transfer_file, 5846 + LSM_HOOK_INIT(binder_set_context_mgr, selinux_binder_set_context_mgr), 5847 + LSM_HOOK_INIT(binder_transaction, selinux_binder_transaction), 5848 + LSM_HOOK_INIT(binder_transfer_binder, selinux_binder_transfer_binder), 5849 + LSM_HOOK_INIT(binder_transfer_file, selinux_binder_transfer_file), 5850 5850 5851 - .ptrace_access_check = selinux_ptrace_access_check, 5852 - .ptrace_traceme = selinux_ptrace_traceme, 5853 - .capget = selinux_capget, 5854 - .capset = selinux_capset, 5855 - .capable = selinux_capable, 5856 - .quotactl = selinux_quotactl, 5857 - .quota_on = selinux_quota_on, 5858 - .syslog = selinux_syslog, 5859 - .vm_enough_memory = selinux_vm_enough_memory, 5851 + LSM_HOOK_INIT(ptrace_access_check, selinux_ptrace_access_check), 5852 + LSM_HOOK_INIT(ptrace_traceme, selinux_ptrace_traceme), 5853 + LSM_HOOK_INIT(capget, selinux_capget), 5854 + LSM_HOOK_INIT(capset, selinux_capset), 5855 + LSM_HOOK_INIT(capable, selinux_capable), 5856 + LSM_HOOK_INIT(quotactl, selinux_quotactl), 5857 + LSM_HOOK_INIT(quota_on, selinux_quota_on), 5858 + LSM_HOOK_INIT(syslog, selinux_syslog), 5859 + LSM_HOOK_INIT(vm_enough_memory, selinux_vm_enough_memory), 5860 5860 5861 - .netlink_send = selinux_netlink_send, 5861 + LSM_HOOK_INIT(netlink_send, selinux_netlink_send), 5862 5862 5863 - .bprm_set_creds = selinux_bprm_set_creds, 5864 - .bprm_committing_creds = selinux_bprm_committing_creds, 5865 - .bprm_committed_creds = selinux_bprm_committed_creds, 5866 - .bprm_secureexec = selinux_bprm_secureexec, 5863 + LSM_HOOK_INIT(bprm_set_creds, selinux_bprm_set_creds), 5864 + LSM_HOOK_INIT(bprm_committing_creds, selinux_bprm_committing_creds), 5865 + LSM_HOOK_INIT(bprm_committed_creds, selinux_bprm_committed_creds), 5866 + LSM_HOOK_INIT(bprm_secureexec, selinux_bprm_secureexec), 5867 5867 5868 - .sb_alloc_security = selinux_sb_alloc_security, 5869 - .sb_free_security = selinux_sb_free_security, 5870 - .sb_copy_data = selinux_sb_copy_data, 5871 - .sb_remount = selinux_sb_remount, 5872 - .sb_kern_mount = selinux_sb_kern_mount, 5873 - .sb_show_options = selinux_sb_show_options, 5874 - .sb_statfs = selinux_sb_statfs, 5875 - .sb_mount = selinux_mount, 5876 - .sb_umount = selinux_umount, 5877 - .sb_set_mnt_opts = selinux_set_mnt_opts, 5878 - .sb_clone_mnt_opts = selinux_sb_clone_mnt_opts, 5879 - .sb_parse_opts_str = selinux_parse_opts_str, 5868 + LSM_HOOK_INIT(sb_alloc_security, selinux_sb_alloc_security), 5869 + LSM_HOOK_INIT(sb_free_security, selinux_sb_free_security), 5870 + LSM_HOOK_INIT(sb_copy_data, selinux_sb_copy_data), 5871 + LSM_HOOK_INIT(sb_remount, selinux_sb_remount), 5872 + LSM_HOOK_INIT(sb_kern_mount, selinux_sb_kern_mount), 5873 + LSM_HOOK_INIT(sb_show_options, selinux_sb_show_options), 5874 + LSM_HOOK_INIT(sb_statfs, selinux_sb_statfs), 5875 + LSM_HOOK_INIT(sb_mount, selinux_mount), 5876 + LSM_HOOK_INIT(sb_umount, selinux_umount), 5877 + LSM_HOOK_INIT(sb_set_mnt_opts, selinux_set_mnt_opts), 5878 + LSM_HOOK_INIT(sb_clone_mnt_opts, selinux_sb_clone_mnt_opts), 5879 + LSM_HOOK_INIT(sb_parse_opts_str, selinux_parse_opts_str), 5880 5880 5881 - .dentry_init_security = selinux_dentry_init_security, 5881 + LSM_HOOK_INIT(dentry_init_security, selinux_dentry_init_security), 5882 5882 5883 - .inode_alloc_security = selinux_inode_alloc_security, 5884 - .inode_free_security = selinux_inode_free_security, 5885 - .inode_init_security = selinux_inode_init_security, 5886 - .inode_create = selinux_inode_create, 5887 - .inode_link = selinux_inode_link, 5888 - .inode_unlink = selinux_inode_unlink, 5889 - .inode_symlink = selinux_inode_symlink, 5890 - .inode_mkdir = selinux_inode_mkdir, 5891 - .inode_rmdir = selinux_inode_rmdir, 5892 - .inode_mknod = selinux_inode_mknod, 5893 - .inode_rename = selinux_inode_rename, 5894 - .inode_readlink = selinux_inode_readlink, 5895 - .inode_follow_link = selinux_inode_follow_link, 5896 - .inode_permission = selinux_inode_permission, 5897 - .inode_setattr = selinux_inode_setattr, 5898 - .inode_getattr = selinux_inode_getattr, 5899 - .inode_setxattr = selinux_inode_setxattr, 5900 - .inode_post_setxattr = selinux_inode_post_setxattr, 5901 - .inode_getxattr = selinux_inode_getxattr, 5902 - .inode_listxattr = selinux_inode_listxattr, 5903 - .inode_removexattr = selinux_inode_removexattr, 5904 - .inode_getsecurity = selinux_inode_getsecurity, 5905 - .inode_setsecurity = selinux_inode_setsecurity, 5906 - .inode_listsecurity = selinux_inode_listsecurity, 5907 - .inode_getsecid = selinux_inode_getsecid, 5883 + LSM_HOOK_INIT(inode_alloc_security, selinux_inode_alloc_security), 5884 + LSM_HOOK_INIT(inode_free_security, selinux_inode_free_security), 5885 + LSM_HOOK_INIT(inode_init_security, selinux_inode_init_security), 5886 + LSM_HOOK_INIT(inode_create, selinux_inode_create), 5887 + LSM_HOOK_INIT(inode_link, selinux_inode_link), 5888 + LSM_HOOK_INIT(inode_unlink, selinux_inode_unlink), 5889 + LSM_HOOK_INIT(inode_symlink, selinux_inode_symlink), 5890 + LSM_HOOK_INIT(inode_mkdir, selinux_inode_mkdir), 5891 + LSM_HOOK_INIT(inode_rmdir, selinux_inode_rmdir), 5892 + LSM_HOOK_INIT(inode_mknod, selinux_inode_mknod), 5893 + LSM_HOOK_INIT(inode_rename, selinux_inode_rename), 5894 + LSM_HOOK_INIT(inode_readlink, selinux_inode_readlink), 5895 + LSM_HOOK_INIT(inode_follow_link, selinux_inode_follow_link), 5896 + LSM_HOOK_INIT(inode_permission, selinux_inode_permission), 5897 + LSM_HOOK_INIT(inode_setattr, selinux_inode_setattr), 5898 + LSM_HOOK_INIT(inode_getattr, selinux_inode_getattr), 5899 + LSM_HOOK_INIT(inode_setxattr, selinux_inode_setxattr), 5900 + LSM_HOOK_INIT(inode_post_setxattr, selinux_inode_post_setxattr), 5901 + LSM_HOOK_INIT(inode_getxattr, selinux_inode_getxattr), 5902 + LSM_HOOK_INIT(inode_listxattr, selinux_inode_listxattr), 5903 + LSM_HOOK_INIT(inode_removexattr, selinux_inode_removexattr), 5904 + LSM_HOOK_INIT(inode_getsecurity, selinux_inode_getsecurity), 5905 + LSM_HOOK_INIT(inode_setsecurity, selinux_inode_setsecurity), 5906 + LSM_HOOK_INIT(inode_listsecurity, selinux_inode_listsecurity), 5907 + LSM_HOOK_INIT(inode_getsecid, selinux_inode_getsecid), 5908 5908 5909 - .file_permission = selinux_file_permission, 5910 - .file_alloc_security = selinux_file_alloc_security, 5911 - .file_free_security = selinux_file_free_security, 5912 - .file_ioctl = selinux_file_ioctl, 5913 - .mmap_file = selinux_mmap_file, 5914 - .mmap_addr = selinux_mmap_addr, 5915 - .file_mprotect = selinux_file_mprotect, 5916 - .file_lock = selinux_file_lock, 5917 - .file_fcntl = selinux_file_fcntl, 5918 - .file_set_fowner = selinux_file_set_fowner, 5919 - .file_send_sigiotask = selinux_file_send_sigiotask, 5920 - .file_receive = selinux_file_receive, 5909 + LSM_HOOK_INIT(file_permission, selinux_file_permission), 5910 + LSM_HOOK_INIT(file_alloc_security, selinux_file_alloc_security), 5911 + LSM_HOOK_INIT(file_free_security, selinux_file_free_security), 5912 + LSM_HOOK_INIT(file_ioctl, selinux_file_ioctl), 5913 + LSM_HOOK_INIT(mmap_file, selinux_mmap_file), 5914 + LSM_HOOK_INIT(mmap_addr, selinux_mmap_addr), 5915 + LSM_HOOK_INIT(file_mprotect, selinux_file_mprotect), 5916 + LSM_HOOK_INIT(file_lock, selinux_file_lock), 5917 + LSM_HOOK_INIT(file_fcntl, selinux_file_fcntl), 5918 + LSM_HOOK_INIT(file_set_fowner, selinux_file_set_fowner), 5919 + LSM_HOOK_INIT(file_send_sigiotask, selinux_file_send_sigiotask), 5920 + LSM_HOOK_INIT(file_receive, selinux_file_receive), 5921 5921 5922 - .file_open = selinux_file_open, 5922 + LSM_HOOK_INIT(file_open, selinux_file_open), 5923 5923 5924 - .task_create = selinux_task_create, 5925 - .cred_alloc_blank = selinux_cred_alloc_blank, 5926 - .cred_free = selinux_cred_free, 5927 - .cred_prepare = selinux_cred_prepare, 5928 - .cred_transfer = selinux_cred_transfer, 5929 - .kernel_act_as = selinux_kernel_act_as, 5930 - .kernel_create_files_as = selinux_kernel_create_files_as, 5931 - .kernel_module_request = selinux_kernel_module_request, 5932 - .task_setpgid = selinux_task_setpgid, 5933 - .task_getpgid = selinux_task_getpgid, 5934 - .task_getsid = selinux_task_getsid, 5935 - .task_getsecid = selinux_task_getsecid, 5936 - .task_setnice = selinux_task_setnice, 5937 - .task_setioprio = selinux_task_setioprio, 5938 - .task_getioprio = selinux_task_getioprio, 5939 - .task_setrlimit = selinux_task_setrlimit, 5940 - .task_setscheduler = selinux_task_setscheduler, 5941 - .task_getscheduler = selinux_task_getscheduler, 5942 - .task_movememory = selinux_task_movememory, 5943 - .task_kill = selinux_task_kill, 5944 - .task_wait = selinux_task_wait, 5945 - .task_to_inode = selinux_task_to_inode, 5924 + LSM_HOOK_INIT(task_create, selinux_task_create), 5925 + LSM_HOOK_INIT(cred_alloc_blank, selinux_cred_alloc_blank), 5926 + LSM_HOOK_INIT(cred_free, selinux_cred_free), 5927 + LSM_HOOK_INIT(cred_prepare, selinux_cred_prepare), 5928 + LSM_HOOK_INIT(cred_transfer, selinux_cred_transfer), 5929 + LSM_HOOK_INIT(kernel_act_as, selinux_kernel_act_as), 5930 + LSM_HOOK_INIT(kernel_create_files_as, selinux_kernel_create_files_as), 5931 + LSM_HOOK_INIT(kernel_module_request, selinux_kernel_module_request), 5932 + LSM_HOOK_INIT(task_setpgid, selinux_task_setpgid), 5933 + LSM_HOOK_INIT(task_getpgid, selinux_task_getpgid), 5934 + LSM_HOOK_INIT(task_getsid, selinux_task_getsid), 5935 + LSM_HOOK_INIT(task_getsecid, selinux_task_getsecid), 5936 + LSM_HOOK_INIT(task_setnice, selinux_task_setnice), 5937 + LSM_HOOK_INIT(task_setioprio, selinux_task_setioprio), 5938 + LSM_HOOK_INIT(task_getioprio, selinux_task_getioprio), 5939 + LSM_HOOK_INIT(task_setrlimit, selinux_task_setrlimit), 5940 + LSM_HOOK_INIT(task_setscheduler, selinux_task_setscheduler), 5941 + LSM_HOOK_INIT(task_getscheduler, selinux_task_getscheduler), 5942 + LSM_HOOK_INIT(task_movememory, selinux_task_movememory), 5943 + LSM_HOOK_INIT(task_kill, selinux_task_kill), 5944 + LSM_HOOK_INIT(task_wait, selinux_task_wait), 5945 + LSM_HOOK_INIT(task_to_inode, selinux_task_to_inode), 5946 5946 5947 - .ipc_permission = selinux_ipc_permission, 5948 - .ipc_getsecid = selinux_ipc_getsecid, 5947 + LSM_HOOK_INIT(ipc_permission, selinux_ipc_permission), 5948 + LSM_HOOK_INIT(ipc_getsecid, selinux_ipc_getsecid), 5949 5949 5950 - .msg_msg_alloc_security = selinux_msg_msg_alloc_security, 5951 - .msg_msg_free_security = selinux_msg_msg_free_security, 5950 + LSM_HOOK_INIT(msg_msg_alloc_security, selinux_msg_msg_alloc_security), 5951 + LSM_HOOK_INIT(msg_msg_free_security, selinux_msg_msg_free_security), 5952 5952 5953 - .msg_queue_alloc_security = selinux_msg_queue_alloc_security, 5954 - .msg_queue_free_security = selinux_msg_queue_free_security, 5955 - .msg_queue_associate = selinux_msg_queue_associate, 5956 - .msg_queue_msgctl = selinux_msg_queue_msgctl, 5957 - .msg_queue_msgsnd = selinux_msg_queue_msgsnd, 5958 - .msg_queue_msgrcv = selinux_msg_queue_msgrcv, 5953 + LSM_HOOK_INIT(msg_queue_alloc_security, 5954 + selinux_msg_queue_alloc_security), 5955 + LSM_HOOK_INIT(msg_queue_free_security, selinux_msg_queue_free_security), 5956 + LSM_HOOK_INIT(msg_queue_associate, selinux_msg_queue_associate), 5957 + LSM_HOOK_INIT(msg_queue_msgctl, selinux_msg_queue_msgctl), 5958 + LSM_HOOK_INIT(msg_queue_msgsnd, selinux_msg_queue_msgsnd), 5959 + LSM_HOOK_INIT(msg_queue_msgrcv, selinux_msg_queue_msgrcv), 5959 5960 5960 - .shm_alloc_security = selinux_shm_alloc_security, 5961 - .shm_free_security = selinux_shm_free_security, 5962 - .shm_associate = selinux_shm_associate, 5963 - .shm_shmctl = selinux_shm_shmctl, 5964 - .shm_shmat = selinux_shm_shmat, 5961 + LSM_HOOK_INIT(shm_alloc_security, selinux_shm_alloc_security), 5962 + LSM_HOOK_INIT(shm_free_security, selinux_shm_free_security), 5963 + LSM_HOOK_INIT(shm_associate, selinux_shm_associate), 5964 + LSM_HOOK_INIT(shm_shmctl, selinux_shm_shmctl), 5965 + LSM_HOOK_INIT(shm_shmat, selinux_shm_shmat), 5965 5966 5966 - .sem_alloc_security = selinux_sem_alloc_security, 5967 - .sem_free_security = selinux_sem_free_security, 5968 - .sem_associate = selinux_sem_associate, 5969 - .sem_semctl = selinux_sem_semctl, 5970 - .sem_semop = selinux_sem_semop, 5967 + LSM_HOOK_INIT(sem_alloc_security, selinux_sem_alloc_security), 5968 + LSM_HOOK_INIT(sem_free_security, selinux_sem_free_security), 5969 + LSM_HOOK_INIT(sem_associate, selinux_sem_associate), 5970 + LSM_HOOK_INIT(sem_semctl, selinux_sem_semctl), 5971 + LSM_HOOK_INIT(sem_semop, selinux_sem_semop), 5971 5972 5972 - .d_instantiate = selinux_d_instantiate, 5973 + LSM_HOOK_INIT(d_instantiate, selinux_d_instantiate), 5973 5974 5974 - .getprocattr = selinux_getprocattr, 5975 - .setprocattr = selinux_setprocattr, 5975 + LSM_HOOK_INIT(getprocattr, selinux_getprocattr), 5976 + LSM_HOOK_INIT(setprocattr, selinux_setprocattr), 5976 5977 5977 - .ismaclabel = selinux_ismaclabel, 5978 - .secid_to_secctx = selinux_secid_to_secctx, 5979 - .secctx_to_secid = selinux_secctx_to_secid, 5980 - .release_secctx = selinux_release_secctx, 5981 - .inode_notifysecctx = selinux_inode_notifysecctx, 5982 - .inode_setsecctx = selinux_inode_setsecctx, 5983 - .inode_getsecctx = selinux_inode_getsecctx, 5978 + LSM_HOOK_INIT(ismaclabel, selinux_ismaclabel), 5979 + LSM_HOOK_INIT(secid_to_secctx, selinux_secid_to_secctx), 5980 + LSM_HOOK_INIT(secctx_to_secid, selinux_secctx_to_secid), 5981 + LSM_HOOK_INIT(release_secctx, selinux_release_secctx), 5982 + LSM_HOOK_INIT(inode_notifysecctx, selinux_inode_notifysecctx), 5983 + LSM_HOOK_INIT(inode_setsecctx, selinux_inode_setsecctx), 5984 + LSM_HOOK_INIT(inode_getsecctx, selinux_inode_getsecctx), 5984 5985 5985 - .unix_stream_connect = selinux_socket_unix_stream_connect, 5986 - .unix_may_send = selinux_socket_unix_may_send, 5986 + LSM_HOOK_INIT(unix_stream_connect, selinux_socket_unix_stream_connect), 5987 + LSM_HOOK_INIT(unix_may_send, selinux_socket_unix_may_send), 5987 5988 5988 - .socket_create = selinux_socket_create, 5989 - .socket_post_create = selinux_socket_post_create, 5990 - .socket_bind = selinux_socket_bind, 5991 - .socket_connect = selinux_socket_connect, 5992 - .socket_listen = selinux_socket_listen, 5993 - .socket_accept = selinux_socket_accept, 5994 - .socket_sendmsg = selinux_socket_sendmsg, 5995 - .socket_recvmsg = selinux_socket_recvmsg, 5996 - .socket_getsockname = selinux_socket_getsockname, 5997 - .socket_getpeername = selinux_socket_getpeername, 5998 - .socket_getsockopt = selinux_socket_getsockopt, 5999 - .socket_setsockopt = selinux_socket_setsockopt, 6000 - .socket_shutdown = selinux_socket_shutdown, 6001 - .socket_sock_rcv_skb = selinux_socket_sock_rcv_skb, 6002 - .socket_getpeersec_stream = selinux_socket_getpeersec_stream, 6003 - .socket_getpeersec_dgram = selinux_socket_getpeersec_dgram, 6004 - .sk_alloc_security = selinux_sk_alloc_security, 6005 - .sk_free_security = selinux_sk_free_security, 6006 - .sk_clone_security = selinux_sk_clone_security, 6007 - .sk_getsecid = selinux_sk_getsecid, 6008 - .sock_graft = selinux_sock_graft, 6009 - .inet_conn_request = selinux_inet_conn_request, 6010 - .inet_csk_clone = selinux_inet_csk_clone, 6011 - .inet_conn_established = selinux_inet_conn_established, 6012 - .secmark_relabel_packet = selinux_secmark_relabel_packet, 6013 - .secmark_refcount_inc = selinux_secmark_refcount_inc, 6014 - .secmark_refcount_dec = selinux_secmark_refcount_dec, 6015 - .req_classify_flow = selinux_req_classify_flow, 6016 - .tun_dev_alloc_security = selinux_tun_dev_alloc_security, 6017 - .tun_dev_free_security = selinux_tun_dev_free_security, 6018 - .tun_dev_create = selinux_tun_dev_create, 6019 - .tun_dev_attach_queue = selinux_tun_dev_attach_queue, 6020 - .tun_dev_attach = selinux_tun_dev_attach, 6021 - .tun_dev_open = selinux_tun_dev_open, 5989 + LSM_HOOK_INIT(socket_create, selinux_socket_create), 5990 + LSM_HOOK_INIT(socket_post_create, selinux_socket_post_create), 5991 + LSM_HOOK_INIT(socket_bind, selinux_socket_bind), 5992 + LSM_HOOK_INIT(socket_connect, selinux_socket_connect), 5993 + LSM_HOOK_INIT(socket_listen, selinux_socket_listen), 5994 + LSM_HOOK_INIT(socket_accept, selinux_socket_accept), 5995 + LSM_HOOK_INIT(socket_sendmsg, selinux_socket_sendmsg), 5996 + LSM_HOOK_INIT(socket_recvmsg, selinux_socket_recvmsg), 5997 + LSM_HOOK_INIT(socket_getsockname, selinux_socket_getsockname), 5998 + LSM_HOOK_INIT(socket_getpeername, selinux_socket_getpeername), 5999 + LSM_HOOK_INIT(socket_getsockopt, selinux_socket_getsockopt), 6000 + LSM_HOOK_INIT(socket_setsockopt, selinux_socket_setsockopt), 6001 + LSM_HOOK_INIT(socket_shutdown, selinux_socket_shutdown), 6002 + LSM_HOOK_INIT(socket_sock_rcv_skb, selinux_socket_sock_rcv_skb), 6003 + LSM_HOOK_INIT(socket_getpeersec_stream, 6004 + selinux_socket_getpeersec_stream), 6005 + LSM_HOOK_INIT(socket_getpeersec_dgram, selinux_socket_getpeersec_dgram), 6006 + LSM_HOOK_INIT(sk_alloc_security, selinux_sk_alloc_security), 6007 + LSM_HOOK_INIT(sk_free_security, selinux_sk_free_security), 6008 + LSM_HOOK_INIT(sk_clone_security, selinux_sk_clone_security), 6009 + LSM_HOOK_INIT(sk_getsecid, selinux_sk_getsecid), 6010 + LSM_HOOK_INIT(sock_graft, selinux_sock_graft), 6011 + LSM_HOOK_INIT(inet_conn_request, selinux_inet_conn_request), 6012 + LSM_HOOK_INIT(inet_csk_clone, selinux_inet_csk_clone), 6013 + LSM_HOOK_INIT(inet_conn_established, selinux_inet_conn_established), 6014 + LSM_HOOK_INIT(secmark_relabel_packet, selinux_secmark_relabel_packet), 6015 + LSM_HOOK_INIT(secmark_refcount_inc, selinux_secmark_refcount_inc), 6016 + LSM_HOOK_INIT(secmark_refcount_dec, selinux_secmark_refcount_dec), 6017 + LSM_HOOK_INIT(req_classify_flow, selinux_req_classify_flow), 6018 + LSM_HOOK_INIT(tun_dev_alloc_security, selinux_tun_dev_alloc_security), 6019 + LSM_HOOK_INIT(tun_dev_free_security, selinux_tun_dev_free_security), 6020 + LSM_HOOK_INIT(tun_dev_create, selinux_tun_dev_create), 6021 + LSM_HOOK_INIT(tun_dev_attach_queue, selinux_tun_dev_attach_queue), 6022 + LSM_HOOK_INIT(tun_dev_attach, selinux_tun_dev_attach), 6023 + LSM_HOOK_INIT(tun_dev_open, selinux_tun_dev_open), 6022 6024 6023 6025 #ifdef CONFIG_SECURITY_NETWORK_XFRM 6024 - .xfrm_policy_alloc_security = selinux_xfrm_policy_alloc, 6025 - .xfrm_policy_clone_security = selinux_xfrm_policy_clone, 6026 - .xfrm_policy_free_security = selinux_xfrm_policy_free, 6027 - .xfrm_policy_delete_security = selinux_xfrm_policy_delete, 6028 - .xfrm_state_alloc = selinux_xfrm_state_alloc, 6029 - .xfrm_state_alloc_acquire = selinux_xfrm_state_alloc_acquire, 6030 - .xfrm_state_free_security = selinux_xfrm_state_free, 6031 - .xfrm_state_delete_security = selinux_xfrm_state_delete, 6032 - .xfrm_policy_lookup = selinux_xfrm_policy_lookup, 6033 - .xfrm_state_pol_flow_match = selinux_xfrm_state_pol_flow_match, 6034 - .xfrm_decode_session = selinux_xfrm_decode_session, 6026 + LSM_HOOK_INIT(xfrm_policy_alloc_security, selinux_xfrm_policy_alloc), 6027 + LSM_HOOK_INIT(xfrm_policy_clone_security, selinux_xfrm_policy_clone), 6028 + LSM_HOOK_INIT(xfrm_policy_free_security, selinux_xfrm_policy_free), 6029 + LSM_HOOK_INIT(xfrm_policy_delete_security, selinux_xfrm_policy_delete), 6030 + LSM_HOOK_INIT(xfrm_state_alloc, selinux_xfrm_state_alloc), 6031 + LSM_HOOK_INIT(xfrm_state_alloc_acquire, 6032 + selinux_xfrm_state_alloc_acquire), 6033 + LSM_HOOK_INIT(xfrm_state_free_security, selinux_xfrm_state_free), 6034 + LSM_HOOK_INIT(xfrm_state_delete_security, selinux_xfrm_state_delete), 6035 + LSM_HOOK_INIT(xfrm_policy_lookup, selinux_xfrm_policy_lookup), 6036 + LSM_HOOK_INIT(xfrm_state_pol_flow_match, 6037 + selinux_xfrm_state_pol_flow_match), 6038 + LSM_HOOK_INIT(xfrm_decode_session, selinux_xfrm_decode_session), 6035 6039 #endif 6036 6040 6037 6041 #ifdef CONFIG_KEYS 6038 - .key_alloc = selinux_key_alloc, 6039 - .key_free = selinux_key_free, 6040 - .key_permission = selinux_key_permission, 6041 - .key_getsecurity = selinux_key_getsecurity, 6042 + LSM_HOOK_INIT(key_alloc, selinux_key_alloc), 6043 + LSM_HOOK_INIT(key_free, selinux_key_free), 6044 + LSM_HOOK_INIT(key_permission, selinux_key_permission), 6045 + LSM_HOOK_INIT(key_getsecurity, selinux_key_getsecurity), 6042 6046 #endif 6043 6047 6044 6048 #ifdef CONFIG_AUDIT 6045 - .audit_rule_init = selinux_audit_rule_init, 6046 - .audit_rule_known = selinux_audit_rule_known, 6047 - .audit_rule_match = selinux_audit_rule_match, 6048 - .audit_rule_free = selinux_audit_rule_free, 6049 + LSM_HOOK_INIT(audit_rule_init, selinux_audit_rule_init), 6050 + LSM_HOOK_INIT(audit_rule_known, selinux_audit_rule_known), 6051 + LSM_HOOK_INIT(audit_rule_match, selinux_audit_rule_match), 6052 + LSM_HOOK_INIT(audit_rule_free, selinux_audit_rule_free), 6049 6053 #endif 6050 6054 }; 6051 6055
+113 -113
security/smack/smack_lsm.c
··· 4267 4267 } 4268 4268 4269 4269 struct security_operations smack_ops = { 4270 - .name = "smack", 4270 + LSM_HOOK_INIT(name, "smack"), 4271 4271 4272 - .ptrace_access_check = smack_ptrace_access_check, 4273 - .ptrace_traceme = smack_ptrace_traceme, 4274 - .syslog = smack_syslog, 4272 + LSM_HOOK_INIT(ptrace_access_check, smack_ptrace_access_check), 4273 + LSM_HOOK_INIT(ptrace_traceme, smack_ptrace_traceme), 4274 + LSM_HOOK_INIT(syslog, smack_syslog), 4275 4275 4276 - .sb_alloc_security = smack_sb_alloc_security, 4277 - .sb_free_security = smack_sb_free_security, 4278 - .sb_copy_data = smack_sb_copy_data, 4279 - .sb_kern_mount = smack_sb_kern_mount, 4280 - .sb_statfs = smack_sb_statfs, 4276 + LSM_HOOK_INIT(sb_alloc_security, smack_sb_alloc_security), 4277 + LSM_HOOK_INIT(sb_free_security, smack_sb_free_security), 4278 + LSM_HOOK_INIT(sb_copy_data, smack_sb_copy_data), 4279 + LSM_HOOK_INIT(sb_kern_mount, smack_sb_kern_mount), 4280 + LSM_HOOK_INIT(sb_statfs, smack_sb_statfs), 4281 4281 4282 - .bprm_set_creds = smack_bprm_set_creds, 4283 - .bprm_committing_creds = smack_bprm_committing_creds, 4284 - .bprm_secureexec = smack_bprm_secureexec, 4282 + LSM_HOOK_INIT(bprm_set_creds, smack_bprm_set_creds), 4283 + LSM_HOOK_INIT(bprm_committing_creds, smack_bprm_committing_creds), 4284 + LSM_HOOK_INIT(bprm_secureexec, smack_bprm_secureexec), 4285 4285 4286 - .inode_alloc_security = smack_inode_alloc_security, 4287 - .inode_free_security = smack_inode_free_security, 4288 - .inode_init_security = smack_inode_init_security, 4289 - .inode_link = smack_inode_link, 4290 - .inode_unlink = smack_inode_unlink, 4291 - .inode_rmdir = smack_inode_rmdir, 4292 - .inode_rename = smack_inode_rename, 4293 - .inode_permission = smack_inode_permission, 4294 - .inode_setattr = smack_inode_setattr, 4295 - .inode_getattr = smack_inode_getattr, 4296 - .inode_setxattr = smack_inode_setxattr, 4297 - .inode_post_setxattr = smack_inode_post_setxattr, 4298 - .inode_getxattr = smack_inode_getxattr, 4299 - .inode_removexattr = smack_inode_removexattr, 4300 - .inode_getsecurity = smack_inode_getsecurity, 4301 - .inode_setsecurity = smack_inode_setsecurity, 4302 - .inode_listsecurity = smack_inode_listsecurity, 4303 - .inode_getsecid = smack_inode_getsecid, 4286 + LSM_HOOK_INIT(inode_alloc_security, smack_inode_alloc_security), 4287 + LSM_HOOK_INIT(inode_free_security, smack_inode_free_security), 4288 + LSM_HOOK_INIT(inode_init_security, smack_inode_init_security), 4289 + LSM_HOOK_INIT(inode_link, smack_inode_link), 4290 + LSM_HOOK_INIT(inode_unlink, smack_inode_unlink), 4291 + LSM_HOOK_INIT(inode_rmdir, smack_inode_rmdir), 4292 + LSM_HOOK_INIT(inode_rename, smack_inode_rename), 4293 + LSM_HOOK_INIT(inode_permission, smack_inode_permission), 4294 + LSM_HOOK_INIT(inode_setattr, smack_inode_setattr), 4295 + LSM_HOOK_INIT(inode_getattr, smack_inode_getattr), 4296 + LSM_HOOK_INIT(inode_setxattr, smack_inode_setxattr), 4297 + LSM_HOOK_INIT(inode_post_setxattr, smack_inode_post_setxattr), 4298 + LSM_HOOK_INIT(inode_getxattr, smack_inode_getxattr), 4299 + LSM_HOOK_INIT(inode_removexattr, smack_inode_removexattr), 4300 + LSM_HOOK_INIT(inode_getsecurity, smack_inode_getsecurity), 4301 + LSM_HOOK_INIT(inode_setsecurity, smack_inode_setsecurity), 4302 + LSM_HOOK_INIT(inode_listsecurity, smack_inode_listsecurity), 4303 + LSM_HOOK_INIT(inode_getsecid, smack_inode_getsecid), 4304 4304 4305 - .file_permission = smack_file_permission, 4306 - .file_alloc_security = smack_file_alloc_security, 4307 - .file_free_security = smack_file_free_security, 4308 - .file_ioctl = smack_file_ioctl, 4309 - .file_lock = smack_file_lock, 4310 - .file_fcntl = smack_file_fcntl, 4311 - .mmap_file = smack_mmap_file, 4312 - .mmap_addr = cap_mmap_addr, 4313 - .file_set_fowner = smack_file_set_fowner, 4314 - .file_send_sigiotask = smack_file_send_sigiotask, 4315 - .file_receive = smack_file_receive, 4305 + LSM_HOOK_INIT(file_permission, smack_file_permission), 4306 + LSM_HOOK_INIT(file_alloc_security, smack_file_alloc_security), 4307 + LSM_HOOK_INIT(file_free_security, smack_file_free_security), 4308 + LSM_HOOK_INIT(file_ioctl, smack_file_ioctl), 4309 + LSM_HOOK_INIT(file_lock, smack_file_lock), 4310 + LSM_HOOK_INIT(file_fcntl, smack_file_fcntl), 4311 + LSM_HOOK_INIT(mmap_file, smack_mmap_file), 4312 + LSM_HOOK_INIT(mmap_addr, cap_mmap_addr), 4313 + LSM_HOOK_INIT(file_set_fowner, smack_file_set_fowner), 4314 + LSM_HOOK_INIT(file_send_sigiotask, smack_file_send_sigiotask), 4315 + LSM_HOOK_INIT(file_receive, smack_file_receive), 4316 4316 4317 - .file_open = smack_file_open, 4317 + LSM_HOOK_INIT(file_open, smack_file_open), 4318 4318 4319 - .cred_alloc_blank = smack_cred_alloc_blank, 4320 - .cred_free = smack_cred_free, 4321 - .cred_prepare = smack_cred_prepare, 4322 - .cred_transfer = smack_cred_transfer, 4323 - .kernel_act_as = smack_kernel_act_as, 4324 - .kernel_create_files_as = smack_kernel_create_files_as, 4325 - .task_setpgid = smack_task_setpgid, 4326 - .task_getpgid = smack_task_getpgid, 4327 - .task_getsid = smack_task_getsid, 4328 - .task_getsecid = smack_task_getsecid, 4329 - .task_setnice = smack_task_setnice, 4330 - .task_setioprio = smack_task_setioprio, 4331 - .task_getioprio = smack_task_getioprio, 4332 - .task_setscheduler = smack_task_setscheduler, 4333 - .task_getscheduler = smack_task_getscheduler, 4334 - .task_movememory = smack_task_movememory, 4335 - .task_kill = smack_task_kill, 4336 - .task_wait = smack_task_wait, 4337 - .task_to_inode = smack_task_to_inode, 4319 + LSM_HOOK_INIT(cred_alloc_blank, smack_cred_alloc_blank), 4320 + LSM_HOOK_INIT(cred_free, smack_cred_free), 4321 + LSM_HOOK_INIT(cred_prepare, smack_cred_prepare), 4322 + LSM_HOOK_INIT(cred_transfer, smack_cred_transfer), 4323 + LSM_HOOK_INIT(kernel_act_as, smack_kernel_act_as), 4324 + LSM_HOOK_INIT(kernel_create_files_as, smack_kernel_create_files_as), 4325 + LSM_HOOK_INIT(task_setpgid, smack_task_setpgid), 4326 + LSM_HOOK_INIT(task_getpgid, smack_task_getpgid), 4327 + LSM_HOOK_INIT(task_getsid, smack_task_getsid), 4328 + LSM_HOOK_INIT(task_getsecid, smack_task_getsecid), 4329 + LSM_HOOK_INIT(task_setnice, smack_task_setnice), 4330 + LSM_HOOK_INIT(task_setioprio, smack_task_setioprio), 4331 + LSM_HOOK_INIT(task_getioprio, smack_task_getioprio), 4332 + LSM_HOOK_INIT(task_setscheduler, smack_task_setscheduler), 4333 + LSM_HOOK_INIT(task_getscheduler, smack_task_getscheduler), 4334 + LSM_HOOK_INIT(task_movememory, smack_task_movememory), 4335 + LSM_HOOK_INIT(task_kill, smack_task_kill), 4336 + LSM_HOOK_INIT(task_wait, smack_task_wait), 4337 + LSM_HOOK_INIT(task_to_inode, smack_task_to_inode), 4338 4338 4339 - .ipc_permission = smack_ipc_permission, 4340 - .ipc_getsecid = smack_ipc_getsecid, 4339 + LSM_HOOK_INIT(ipc_permission, smack_ipc_permission), 4340 + LSM_HOOK_INIT(ipc_getsecid, smack_ipc_getsecid), 4341 4341 4342 - .msg_msg_alloc_security = smack_msg_msg_alloc_security, 4343 - .msg_msg_free_security = smack_msg_msg_free_security, 4342 + LSM_HOOK_INIT(msg_msg_alloc_security, smack_msg_msg_alloc_security), 4343 + LSM_HOOK_INIT(msg_msg_free_security, smack_msg_msg_free_security), 4344 4344 4345 - .msg_queue_alloc_security = smack_msg_queue_alloc_security, 4346 - .msg_queue_free_security = smack_msg_queue_free_security, 4347 - .msg_queue_associate = smack_msg_queue_associate, 4348 - .msg_queue_msgctl = smack_msg_queue_msgctl, 4349 - .msg_queue_msgsnd = smack_msg_queue_msgsnd, 4350 - .msg_queue_msgrcv = smack_msg_queue_msgrcv, 4345 + LSM_HOOK_INIT(msg_queue_alloc_security, smack_msg_queue_alloc_security), 4346 + LSM_HOOK_INIT(msg_queue_free_security, smack_msg_queue_free_security), 4347 + LSM_HOOK_INIT(msg_queue_associate, smack_msg_queue_associate), 4348 + LSM_HOOK_INIT(msg_queue_msgctl, smack_msg_queue_msgctl), 4349 + LSM_HOOK_INIT(msg_queue_msgsnd, smack_msg_queue_msgsnd), 4350 + LSM_HOOK_INIT(msg_queue_msgrcv, smack_msg_queue_msgrcv), 4351 4351 4352 - .shm_alloc_security = smack_shm_alloc_security, 4353 - .shm_free_security = smack_shm_free_security, 4354 - .shm_associate = smack_shm_associate, 4355 - .shm_shmctl = smack_shm_shmctl, 4356 - .shm_shmat = smack_shm_shmat, 4352 + LSM_HOOK_INIT(shm_alloc_security, smack_shm_alloc_security), 4353 + LSM_HOOK_INIT(shm_free_security, smack_shm_free_security), 4354 + LSM_HOOK_INIT(shm_associate, smack_shm_associate), 4355 + LSM_HOOK_INIT(shm_shmctl, smack_shm_shmctl), 4356 + LSM_HOOK_INIT(shm_shmat, smack_shm_shmat), 4357 4357 4358 - .sem_alloc_security = smack_sem_alloc_security, 4359 - .sem_free_security = smack_sem_free_security, 4360 - .sem_associate = smack_sem_associate, 4361 - .sem_semctl = smack_sem_semctl, 4362 - .sem_semop = smack_sem_semop, 4358 + LSM_HOOK_INIT(sem_alloc_security, smack_sem_alloc_security), 4359 + LSM_HOOK_INIT(sem_free_security, smack_sem_free_security), 4360 + LSM_HOOK_INIT(sem_associate, smack_sem_associate), 4361 + LSM_HOOK_INIT(sem_semctl, smack_sem_semctl), 4362 + LSM_HOOK_INIT(sem_semop, smack_sem_semop), 4363 4363 4364 - .d_instantiate = smack_d_instantiate, 4364 + LSM_HOOK_INIT(d_instantiate, smack_d_instantiate), 4365 4365 4366 - .getprocattr = smack_getprocattr, 4367 - .setprocattr = smack_setprocattr, 4366 + LSM_HOOK_INIT(getprocattr, smack_getprocattr), 4367 + LSM_HOOK_INIT(setprocattr, smack_setprocattr), 4368 4368 4369 - .unix_stream_connect = smack_unix_stream_connect, 4370 - .unix_may_send = smack_unix_may_send, 4369 + LSM_HOOK_INIT(unix_stream_connect, smack_unix_stream_connect), 4370 + LSM_HOOK_INIT(unix_may_send, smack_unix_may_send), 4371 4371 4372 - .socket_post_create = smack_socket_post_create, 4372 + LSM_HOOK_INIT(socket_post_create, smack_socket_post_create), 4373 4373 #ifndef CONFIG_SECURITY_SMACK_NETFILTER 4374 - .socket_bind = smack_socket_bind, 4374 + LSM_HOOK_INIT(socket_bind, smack_socket_bind), 4375 4375 #endif /* CONFIG_SECURITY_SMACK_NETFILTER */ 4376 - .socket_connect = smack_socket_connect, 4377 - .socket_sendmsg = smack_socket_sendmsg, 4378 - .socket_sock_rcv_skb = smack_socket_sock_rcv_skb, 4379 - .socket_getpeersec_stream = smack_socket_getpeersec_stream, 4380 - .socket_getpeersec_dgram = smack_socket_getpeersec_dgram, 4381 - .sk_alloc_security = smack_sk_alloc_security, 4382 - .sk_free_security = smack_sk_free_security, 4383 - .sock_graft = smack_sock_graft, 4384 - .inet_conn_request = smack_inet_conn_request, 4385 - .inet_csk_clone = smack_inet_csk_clone, 4376 + LSM_HOOK_INIT(socket_connect, smack_socket_connect), 4377 + LSM_HOOK_INIT(socket_sendmsg, smack_socket_sendmsg), 4378 + LSM_HOOK_INIT(socket_sock_rcv_skb, smack_socket_sock_rcv_skb), 4379 + LSM_HOOK_INIT(socket_getpeersec_stream, smack_socket_getpeersec_stream), 4380 + LSM_HOOK_INIT(socket_getpeersec_dgram, smack_socket_getpeersec_dgram), 4381 + LSM_HOOK_INIT(sk_alloc_security, smack_sk_alloc_security), 4382 + LSM_HOOK_INIT(sk_free_security, smack_sk_free_security), 4383 + LSM_HOOK_INIT(sock_graft, smack_sock_graft), 4384 + LSM_HOOK_INIT(inet_conn_request, smack_inet_conn_request), 4385 + LSM_HOOK_INIT(inet_csk_clone, smack_inet_csk_clone), 4386 4386 4387 4387 /* key management security hooks */ 4388 4388 #ifdef CONFIG_KEYS 4389 - .key_alloc = smack_key_alloc, 4390 - .key_free = smack_key_free, 4391 - .key_permission = smack_key_permission, 4392 - .key_getsecurity = smack_key_getsecurity, 4389 + LSM_HOOK_INIT(key_alloc, smack_key_alloc), 4390 + LSM_HOOK_INIT(key_free, smack_key_free), 4391 + LSM_HOOK_INIT(key_permission, smack_key_permission), 4392 + LSM_HOOK_INIT(key_getsecurity, smack_key_getsecurity), 4393 4393 #endif /* CONFIG_KEYS */ 4394 4394 4395 4395 /* Audit hooks */ 4396 4396 #ifdef CONFIG_AUDIT 4397 - .audit_rule_init = smack_audit_rule_init, 4398 - .audit_rule_known = smack_audit_rule_known, 4399 - .audit_rule_match = smack_audit_rule_match, 4400 - .audit_rule_free = smack_audit_rule_free, 4397 + LSM_HOOK_INIT(audit_rule_init, smack_audit_rule_init), 4398 + LSM_HOOK_INIT(audit_rule_known, smack_audit_rule_known), 4399 + LSM_HOOK_INIT(audit_rule_match, smack_audit_rule_match), 4400 + LSM_HOOK_INIT(audit_rule_free, smack_audit_rule_free), 4401 4401 #endif /* CONFIG_AUDIT */ 4402 4402 4403 - .ismaclabel = smack_ismaclabel, 4404 - .secid_to_secctx = smack_secid_to_secctx, 4405 - .secctx_to_secid = smack_secctx_to_secid, 4406 - .release_secctx = smack_release_secctx, 4407 - .inode_notifysecctx = smack_inode_notifysecctx, 4408 - .inode_setsecctx = smack_inode_setsecctx, 4409 - .inode_getsecctx = smack_inode_getsecctx, 4403 + LSM_HOOK_INIT(ismaclabel, smack_ismaclabel), 4404 + LSM_HOOK_INIT(secid_to_secctx, smack_secid_to_secctx), 4405 + LSM_HOOK_INIT(secctx_to_secid, smack_secctx_to_secid), 4406 + LSM_HOOK_INIT(release_secctx, smack_release_secctx), 4407 + LSM_HOOK_INIT(inode_notifysecctx, smack_inode_notifysecctx), 4408 + LSM_HOOK_INIT(inode_setsecctx, smack_inode_setsecctx), 4409 + LSM_HOOK_INIT(inode_getsecctx, smack_inode_getsecctx), 4410 4410 }; 4411 4411 4412 4412
+29 -29
security/tomoyo/tomoyo.c
··· 503 503 * registering TOMOYO. 504 504 */ 505 505 static struct security_operations tomoyo_security_ops = { 506 - .name = "tomoyo", 507 - .cred_alloc_blank = tomoyo_cred_alloc_blank, 508 - .cred_prepare = tomoyo_cred_prepare, 509 - .cred_transfer = tomoyo_cred_transfer, 510 - .cred_free = tomoyo_cred_free, 511 - .bprm_set_creds = tomoyo_bprm_set_creds, 512 - .bprm_check_security = tomoyo_bprm_check_security, 513 - .file_fcntl = tomoyo_file_fcntl, 514 - .file_open = tomoyo_file_open, 515 - .path_truncate = tomoyo_path_truncate, 516 - .path_unlink = tomoyo_path_unlink, 517 - .path_mkdir = tomoyo_path_mkdir, 518 - .path_rmdir = tomoyo_path_rmdir, 519 - .path_symlink = tomoyo_path_symlink, 520 - .path_mknod = tomoyo_path_mknod, 521 - .path_link = tomoyo_path_link, 522 - .path_rename = tomoyo_path_rename, 523 - .inode_getattr = tomoyo_inode_getattr, 524 - .file_ioctl = tomoyo_file_ioctl, 525 - .path_chmod = tomoyo_path_chmod, 526 - .path_chown = tomoyo_path_chown, 527 - .path_chroot = tomoyo_path_chroot, 528 - .sb_mount = tomoyo_sb_mount, 529 - .sb_umount = tomoyo_sb_umount, 530 - .sb_pivotroot = tomoyo_sb_pivotroot, 531 - .socket_bind = tomoyo_socket_bind, 532 - .socket_connect = tomoyo_socket_connect, 533 - .socket_listen = tomoyo_socket_listen, 534 - .socket_sendmsg = tomoyo_socket_sendmsg, 506 + LSM_HOOK_INIT(name, "tomoyo"), 507 + LSM_HOOK_INIT(cred_alloc_blank, tomoyo_cred_alloc_blank), 508 + LSM_HOOK_INIT(cred_prepare, tomoyo_cred_prepare), 509 + LSM_HOOK_INIT(cred_transfer, tomoyo_cred_transfer), 510 + LSM_HOOK_INIT(cred_free, tomoyo_cred_free), 511 + LSM_HOOK_INIT(bprm_set_creds, tomoyo_bprm_set_creds), 512 + LSM_HOOK_INIT(bprm_check_security, tomoyo_bprm_check_security), 513 + LSM_HOOK_INIT(file_fcntl, tomoyo_file_fcntl), 514 + LSM_HOOK_INIT(file_open, tomoyo_file_open), 515 + LSM_HOOK_INIT(path_truncate, tomoyo_path_truncate), 516 + LSM_HOOK_INIT(path_unlink, tomoyo_path_unlink), 517 + LSM_HOOK_INIT(path_mkdir, tomoyo_path_mkdir), 518 + LSM_HOOK_INIT(path_rmdir, tomoyo_path_rmdir), 519 + LSM_HOOK_INIT(path_symlink, tomoyo_path_symlink), 520 + LSM_HOOK_INIT(path_mknod, tomoyo_path_mknod), 521 + LSM_HOOK_INIT(path_link, tomoyo_path_link), 522 + LSM_HOOK_INIT(path_rename, tomoyo_path_rename), 523 + LSM_HOOK_INIT(inode_getattr, tomoyo_inode_getattr), 524 + LSM_HOOK_INIT(file_ioctl, tomoyo_file_ioctl), 525 + LSM_HOOK_INIT(path_chmod, tomoyo_path_chmod), 526 + LSM_HOOK_INIT(path_chown, tomoyo_path_chown), 527 + LSM_HOOK_INIT(path_chroot, tomoyo_path_chroot), 528 + LSM_HOOK_INIT(sb_mount, tomoyo_sb_mount), 529 + LSM_HOOK_INIT(sb_umount, tomoyo_sb_umount), 530 + LSM_HOOK_INIT(sb_pivotroot, tomoyo_sb_pivotroot), 531 + LSM_HOOK_INIT(socket_bind, tomoyo_socket_bind), 532 + LSM_HOOK_INIT(socket_connect, tomoyo_socket_connect), 533 + LSM_HOOK_INIT(socket_listen, tomoyo_socket_listen), 534 + LSM_HOOK_INIT(socket_sendmsg, tomoyo_socket_sendmsg), 535 535 }; 536 536 537 537 /* Lock for GC. */
+5 -5
security/yama/yama_lsm.c
··· 366 366 367 367 #ifndef CONFIG_SECURITY_YAMA_STACKED 368 368 static struct security_operations yama_ops = { 369 - .name = "yama", 369 + LSM_HOOK_INIT(name, "yama"), 370 370 371 - .ptrace_access_check = yama_ptrace_access_check, 372 - .ptrace_traceme = yama_ptrace_traceme, 373 - .task_prctl = yama_task_prctl, 374 - .task_free = yama_task_free, 371 + LSM_HOOK_INIT(ptrace_access_check, yama_ptrace_access_check), 372 + LSM_HOOK_INIT(ptrace_traceme, yama_ptrace_traceme), 373 + LSM_HOOK_INIT(task_prctl, yama_task_prctl), 374 + LSM_HOOK_INIT(task_free, yama_task_free), 375 375 }; 376 376 #endif 377 377