aboutsummaryrefslogtreecommitdiffstats
path: root/security/security.c
diff options
context:
space:
mode:
authorPaul Moore <pmoore@redhat.com>2013-01-14 02:12:19 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-14 18:16:59 -0500
commit5dbbaf2de89613d19a9286d4db0a535ca2735d26 (patch)
tree1eaa64968a8ecf83aee4d2f6792840abde6c4916 /security/security.c
parent6f96c142f77c96a34ac377a3616ee7abcd77fb4d (diff)
tun: fix LSM/SELinux labeling of tun/tap devices
This patch corrects some problems with LSM/SELinux that were introduced with the multiqueue patchset. The problem stems from the fact that the multiqueue work changed the relationship between the tun device and its associated socket; before the socket persisted for the life of the device, however after the multiqueue changes the socket only persisted for the life of the userspace connection (fd open). For non-persistent devices this is not an issue, but for persistent devices this can cause the tun device to lose its SELinux label. We correct this problem by adding an opaque LSM security blob to the tun device struct which allows us to have the LSM security state, e.g. SELinux labeling information, persist for the lifetime of the tun device. In the process we tweak the LSM hooks to work with this new approach to TUN device/socket labeling and introduce a new LSM hook, security_tun_dev_attach_queue(), to approve requests to attach to a TUN queue via TUNSETQUEUE. The SELinux code has been adjusted to match the new LSM hooks, the other LSMs do not make use of the LSM TUN controls. This patch makes use of the recently added "tun_socket:attach_queue" permission to restrict access to the TUNSETQUEUE operation. On older SELinux policies which do not define the "tun_socket:attach_queue" permission the access control decision for TUNSETQUEUE will be handled according to the SELinux policy's unknown permission setting. Signed-off-by: Paul Moore <pmoore@redhat.com> Acked-by: Eric Paris <eparis@parisplace.org> Tested-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'security/security.c')
-rw-r--r--security/security.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/security/security.c b/security/security.c
index daa97f4ac9d1..7b88c6aeaed4 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1254,24 +1254,42 @@ void security_secmark_refcount_dec(void)
1254} 1254}
1255EXPORT_SYMBOL(security_secmark_refcount_dec); 1255EXPORT_SYMBOL(security_secmark_refcount_dec);
1256 1256
1257int security_tun_dev_alloc_security(void **security)
1258{
1259 return security_ops->tun_dev_alloc_security(security);
1260}
1261EXPORT_SYMBOL(security_tun_dev_alloc_security);
1262
1263void security_tun_dev_free_security(void *security)
1264{
1265 security_ops->tun_dev_free_security(security);
1266}
1267EXPORT_SYMBOL(security_tun_dev_free_security);
1268
1257int security_tun_dev_create(void) 1269int security_tun_dev_create(void)
1258{ 1270{
1259 return security_ops->tun_dev_create(); 1271 return security_ops->tun_dev_create();
1260} 1272}
1261EXPORT_SYMBOL(security_tun_dev_create); 1273EXPORT_SYMBOL(security_tun_dev_create);
1262 1274
1263void security_tun_dev_post_create(struct sock *sk) 1275int security_tun_dev_attach_queue(void *security)
1264{ 1276{
1265 return security_ops->tun_dev_post_create(sk); 1277 return security_ops->tun_dev_attach_queue(security);
1266} 1278}
1267EXPORT_SYMBOL(security_tun_dev_post_create); 1279EXPORT_SYMBOL(security_tun_dev_attach_queue);
1268 1280
1269int security_tun_dev_attach(struct sock *sk) 1281int security_tun_dev_attach(struct sock *sk, void *security)
1270{ 1282{
1271 return security_ops->tun_dev_attach(sk); 1283 return security_ops->tun_dev_attach(sk, security);
1272} 1284}
1273EXPORT_SYMBOL(security_tun_dev_attach); 1285EXPORT_SYMBOL(security_tun_dev_attach);
1274 1286
1287int security_tun_dev_open(void *security)
1288{
1289 return security_ops->tun_dev_open(security);
1290}
1291EXPORT_SYMBOL(security_tun_dev_open);
1292
1275#endif /* CONFIG_SECURITY_NETWORK */ 1293#endif /* CONFIG_SECURITY_NETWORK */
1276 1294
1277#ifdef CONFIG_SECURITY_NETWORK_XFRM 1295#ifdef CONFIG_SECURITY_NETWORK_XFRM