diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-13 13:00:44 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-13 13:00:44 -0400 |
| commit | 8d71ff0bef9cf4e70108a9a2762f2361e607abde (patch) | |
| tree | a79487fceb6ec18e956373a3019416a43b269f1d /security | |
| parent | 244dc4e54b73567fae7f8fd9ba56584be9375442 (diff) | |
| parent | 92562927826fceb2f8e69c89e28161b8c1e0b125 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6: (24 commits)
integrity: special fs magic
As pointed out by Jonathan Corbet, the timer must be deleted before
ERROR: code indent should use tabs where possible
The tpm_dev_release function is only called for platform devices, not pnp
Protect tpm_chip_list when transversing it.
Renames num_open to is_open, as only one process can open the file at a time.
Remove the BKL calls from the TPM driver, which were added in the overall
netlabel: Add configuration support for local labeling
cipso: Add support for native local labeling and fixup mapping names
netlabel: Changes to the NetLabel security attributes to allow LSMs to pass full contexts
selinux: Cache NetLabel secattrs in the socket's security struct
selinux: Set socket NetLabel based on connection endpoint
netlabel: Add functionality to set the security attributes of a packet
netlabel: Add network address selectors to the NetLabel/LSM domain mapping
netlabel: Add a generic way to create ordered linked lists of network addrs
netlabel: Replace protocol/NetLabel linking with refrerence counts
smack: Fix missing calls to netlbl_skbuff_err()
selinux: Fix missing calls to netlbl_skbuff_err()
selinux: Fix a problem in security_netlbl_sid_to_secattr()
selinux: Better local/forward check in selinux_ip_postroute()
...
Diffstat (limited to 'security')
| -rw-r--r-- | security/inode.c | 3 | ||||
| -rw-r--r-- | security/selinux/hooks.c | 229 | ||||
| -rw-r--r-- | security/selinux/include/netlabel.h | 44 | ||||
| -rw-r--r-- | security/selinux/include/objsec.h | 9 | ||||
| -rw-r--r-- | security/selinux/netlabel.c | 280 | ||||
| -rw-r--r-- | security/selinux/ss/services.c | 13 | ||||
| -rw-r--r-- | security/smack/smack_lsm.c | 5 | ||||
| -rw-r--r-- | security/smack/smackfs.c | 4 |
8 files changed, 473 insertions, 114 deletions
diff --git a/security/inode.c b/security/inode.c index ca4958ebad8d..efea5a605466 100644 --- a/security/inode.c +++ b/security/inode.c | |||
| @@ -20,8 +20,7 @@ | |||
| 20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 21 | #include <linux/namei.h> | 21 | #include <linux/namei.h> |
| 22 | #include <linux/security.h> | 22 | #include <linux/security.h> |
| 23 | 23 | #include <linux/magic.h> | |
| 24 | #define SECURITYFS_MAGIC 0x73636673 | ||
| 25 | 24 | ||
| 26 | static struct vfsmount *mount; | 25 | static struct vfsmount *mount; |
| 27 | static int mount_count; | 26 | static int mount_count; |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 48881394fbd4..88f19536efad 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
| @@ -291,6 +291,7 @@ static void sk_free_security(struct sock *sk) | |||
| 291 | struct sk_security_struct *ssec = sk->sk_security; | 291 | struct sk_security_struct *ssec = sk->sk_security; |
| 292 | 292 | ||
| 293 | sk->sk_security = NULL; | 293 | sk->sk_security = NULL; |
| 294 | selinux_netlbl_sk_security_free(ssec); | ||
| 294 | kfree(ssec); | 295 | kfree(ssec); |
| 295 | } | 296 | } |
| 296 | 297 | ||
| @@ -3800,6 +3801,7 @@ out: | |||
| 3800 | 3801 | ||
| 3801 | static int selinux_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen) | 3802 | static int selinux_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen) |
| 3802 | { | 3803 | { |
| 3804 | struct sock *sk = sock->sk; | ||
| 3803 | struct inode_security_struct *isec; | 3805 | struct inode_security_struct *isec; |
| 3804 | int err; | 3806 | int err; |
| 3805 | 3807 | ||
| @@ -3813,7 +3815,6 @@ static int selinux_socket_connect(struct socket *sock, struct sockaddr *address, | |||
| 3813 | isec = SOCK_INODE(sock)->i_security; | 3815 | isec = SOCK_INODE(sock)->i_security; |
| 3814 | if (isec->sclass == SECCLASS_TCP_SOCKET || | 3816 | if (isec->sclass == SECCLASS_TCP_SOCKET || |
| 3815 | isec->sclass == SECCLASS_DCCP_SOCKET) { | 3817 | isec->sclass == SECCLASS_DCCP_SOCKET) { |
| 3816 | struct sock *sk = sock->sk; | ||
| 3817 | struct avc_audit_data ad; | 3818 | struct avc_audit_data ad; |
| 3818 | struct sockaddr_in *addr4 = NULL; | 3819 | struct sockaddr_in *addr4 = NULL; |
| 3819 | struct sockaddr_in6 *addr6 = NULL; | 3820 | struct sockaddr_in6 *addr6 = NULL; |
| @@ -3847,6 +3848,8 @@ static int selinux_socket_connect(struct socket *sock, struct sockaddr *address, | |||
| 3847 | goto out; | 3848 | goto out; |
| 3848 | } | 3849 | } |
| 3849 | 3850 | ||
| 3851 | err = selinux_netlbl_socket_connect(sk, address); | ||
| 3852 | |||
| 3850 | out: | 3853 | out: |
| 3851 | return err; | 3854 | return err; |
| 3852 | } | 3855 | } |
| @@ -4076,20 +4079,28 @@ static int selinux_sock_rcv_skb_iptables_compat(struct sock *sk, | |||
| 4076 | } | 4079 | } |
| 4077 | 4080 | ||
| 4078 | static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb, | 4081 | static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb, |
| 4079 | struct avc_audit_data *ad, | 4082 | u16 family) |
| 4080 | u16 family, char *addrp) | ||
| 4081 | { | 4083 | { |
| 4082 | int err; | 4084 | int err; |
| 4083 | struct sk_security_struct *sksec = sk->sk_security; | 4085 | struct sk_security_struct *sksec = sk->sk_security; |
| 4084 | u32 peer_sid; | 4086 | u32 peer_sid; |
| 4085 | u32 sk_sid = sksec->sid; | 4087 | u32 sk_sid = sksec->sid; |
| 4088 | struct avc_audit_data ad; | ||
| 4089 | char *addrp; | ||
| 4090 | |||
| 4091 | AVC_AUDIT_DATA_INIT(&ad, NET); | ||
| 4092 | ad.u.net.netif = skb->iif; | ||
| 4093 | ad.u.net.family = family; | ||
| 4094 | err = selinux_parse_skb(skb, &ad, &addrp, 1, NULL); | ||
| 4095 | if (err) | ||
| 4096 | return err; | ||
| 4086 | 4097 | ||
| 4087 | if (selinux_compat_net) | 4098 | if (selinux_compat_net) |
| 4088 | err = selinux_sock_rcv_skb_iptables_compat(sk, skb, ad, | 4099 | err = selinux_sock_rcv_skb_iptables_compat(sk, skb, &ad, |
| 4089 | family, addrp); | 4100 | family, addrp); |
| 4090 | else | 4101 | else |
| 4091 | err = avc_has_perm(sk_sid, skb->secmark, SECCLASS_PACKET, | 4102 | err = avc_has_perm(sk_sid, skb->secmark, SECCLASS_PACKET, |
| 4092 | PACKET__RECV, ad); | 4103 | PACKET__RECV, &ad); |
| 4093 | if (err) | 4104 | if (err) |
| 4094 | return err; | 4105 | return err; |
| 4095 | 4106 | ||
| @@ -4098,12 +4109,14 @@ static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb, | |||
| 4098 | if (err) | 4109 | if (err) |
| 4099 | return err; | 4110 | return err; |
| 4100 | err = avc_has_perm(sk_sid, peer_sid, | 4111 | err = avc_has_perm(sk_sid, peer_sid, |
| 4101 | SECCLASS_PEER, PEER__RECV, ad); | 4112 | SECCLASS_PEER, PEER__RECV, &ad); |
| 4113 | if (err) | ||
| 4114 | selinux_netlbl_err(skb, err, 0); | ||
| 4102 | } else { | 4115 | } else { |
| 4103 | err = selinux_netlbl_sock_rcv_skb(sksec, skb, family, ad); | 4116 | err = selinux_netlbl_sock_rcv_skb(sksec, skb, family, &ad); |
| 4104 | if (err) | 4117 | if (err) |
| 4105 | return err; | 4118 | return err; |
| 4106 | err = selinux_xfrm_sock_rcv_skb(sksec->sid, skb, ad); | 4119 | err = selinux_xfrm_sock_rcv_skb(sksec->sid, skb, &ad); |
| 4107 | } | 4120 | } |
| 4108 | 4121 | ||
| 4109 | return err; | 4122 | return err; |
| @@ -4117,6 +4130,8 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 4117 | u32 sk_sid = sksec->sid; | 4130 | u32 sk_sid = sksec->sid; |
| 4118 | struct avc_audit_data ad; | 4131 | struct avc_audit_data ad; |
| 4119 | char *addrp; | 4132 | char *addrp; |
| 4133 | u8 secmark_active; | ||
| 4134 | u8 peerlbl_active; | ||
| 4120 | 4135 | ||
| 4121 | if (family != PF_INET && family != PF_INET6) | 4136 | if (family != PF_INET && family != PF_INET6) |
| 4122 | return 0; | 4137 | return 0; |
| @@ -4125,6 +4140,18 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 4125 | if (family == PF_INET6 && skb->protocol == htons(ETH_P_IP)) | 4140 | if (family == PF_INET6 && skb->protocol == htons(ETH_P_IP)) |
| 4126 | family = PF_INET; | 4141 | family = PF_INET; |
| 4127 | 4142 | ||
| 4143 | /* If any sort of compatibility mode is enabled then handoff processing | ||
| 4144 | * to the selinux_sock_rcv_skb_compat() function to deal with the | ||
| 4145 | * special handling. We do this in an attempt to keep this function | ||
| 4146 | * as fast and as clean as possible. */ | ||
| 4147 | if (selinux_compat_net || !selinux_policycap_netpeer) | ||
| 4148 | return selinux_sock_rcv_skb_compat(sk, skb, family); | ||
| 4149 | |||
| 4150 | secmark_active = selinux_secmark_enabled(); | ||
| 4151 | peerlbl_active = netlbl_enabled() || selinux_xfrm_enabled(); | ||
| 4152 | if (!secmark_active && !peerlbl_active) | ||
| 4153 | return 0; | ||
| 4154 | |||
| 4128 | AVC_AUDIT_DATA_INIT(&ad, NET); | 4155 | AVC_AUDIT_DATA_INIT(&ad, NET); |
| 4129 | ad.u.net.netif = skb->iif; | 4156 | ad.u.net.netif = skb->iif; |
| 4130 | ad.u.net.family = family; | 4157 | ad.u.net.family = family; |
| @@ -4132,15 +4159,7 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 4132 | if (err) | 4159 | if (err) |
| 4133 | return err; | 4160 | return err; |
| 4134 | 4161 | ||
| 4135 | /* If any sort of compatibility mode is enabled then handoff processing | 4162 | if (peerlbl_active) { |
| 4136 | * to the selinux_sock_rcv_skb_compat() function to deal with the | ||
| 4137 | * special handling. We do this in an attempt to keep this function | ||
| 4138 | * as fast and as clean as possible. */ | ||
| 4139 | if (selinux_compat_net || !selinux_policycap_netpeer) | ||
| 4140 | return selinux_sock_rcv_skb_compat(sk, skb, &ad, | ||
| 4141 | family, addrp); | ||
| 4142 | |||
| 4143 | if (netlbl_enabled() || selinux_xfrm_enabled()) { | ||
| 4144 | u32 peer_sid; | 4163 | u32 peer_sid; |
| 4145 | 4164 | ||
| 4146 | err = selinux_skb_peerlbl_sid(skb, family, &peer_sid); | 4165 | err = selinux_skb_peerlbl_sid(skb, family, &peer_sid); |
| @@ -4148,13 +4167,17 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 4148 | return err; | ||
