aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/security.h
diff options
context:
space:
mode:
authorPaul Moore <paul.moore@hp.com>2009-08-28 18:12:43 -0400
committerJames Morris <jmorris@namei.org>2009-08-31 18:29:48 -0400
commit2b980dbd77d229eb60588802162c9659726b11f4 (patch)
tree78a7f734d0721029e4b4c961ca61d35abe9e6dbc /include/linux/security.h
parentd8e180dcd5bbbab9cd3ff2e779efcf70692ef541 (diff)
lsm: Add hooks to the TUN driver
The TUN driver lacks any LSM hooks which makes it difficult for LSM modules, such as SELinux, to enforce access controls on network traffic generated by TUN users; this is particularly problematic for virtualization apps such as QEMU and KVM. This patch adds three new LSM hooks designed to control the creation and attachment of TUN devices, the hooks are: * security_tun_dev_create() Provides access control for the creation of new TUN devices * security_tun_dev_post_create() Provides the ability to create the necessary socket LSM state for newly created TUN devices * security_tun_dev_attach() Provides access control for attaching to existing, persistent TUN devices and the ability to update the TUN device's socket LSM state as necessary Signed-off-by: Paul Moore <paul.moore@hp.com> Acked-by: Eric Paris <eparis@parisplace.org> Acked-by: Serge Hallyn <serue@us.ibm.com> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'include/linux/security.h')
-rw-r--r--include/linux/security.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index a16d6b7c4ebe..40ba39ea68ce 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -998,6 +998,17 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
998 * Sets the connection's peersid to the secmark on skb. 998 * Sets the connection's peersid to the secmark on skb.
999 * @req_classify_flow: 999 * @req_classify_flow:
1000 * Sets the flow's sid to the openreq sid. 1000 * Sets the flow's sid to the openreq sid.
1001 * @tun_dev_create:
1002 * Check permissions prior to creating a new TUN device.
1003 * @tun_dev_post_create:
1004 * This hook allows a module to update or allocate a per-socket security
1005 * structure.
1006 * @sk contains the newly created sock structure.
1007 * @tun_dev_attach:
1008 * Check permissions prior to attaching to a persistent TUN device. This
1009 * hook can also be used by the module to update any security state
1010 * associated with the TUN device's sock structure.
1011 * @sk contains the existing sock structure.
1001 * 1012 *
1002 * Security hooks for XFRM operations. 1013 * Security hooks for XFRM operations.
1003 * 1014 *
@@ -1597,6 +1608,9 @@ struct security_operations {
1597 void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req); 1608 void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
1598 void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb); 1609 void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
1599 void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl); 1610 void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
1611 int (*tun_dev_create)(void);
1612 void (*tun_dev_post_create)(struct sock *sk);
1613 int (*tun_dev_attach)(struct sock *sk);
1600#endif /* CONFIG_SECURITY_NETWORK */ 1614#endif /* CONFIG_SECURITY_NETWORK */
1601 1615
1602#ifdef CONFIG_SECURITY_NETWORK_XFRM 1616#ifdef CONFIG_SECURITY_NETWORK_XFRM
@@ -2586,6 +2600,9 @@ void security_inet_csk_clone(struct sock *newsk,
2586 const struct request_sock *req); 2600 const struct request_sock *req);
2587void security_inet_conn_established(struct sock *sk, 2601void security_inet_conn_established(struct sock *sk,
2588 struct sk_buff *skb); 2602 struct sk_buff *skb);
2603int security_tun_dev_create(void);
2604void security_tun_dev_post_create(struct sock *sk);
2605int security_tun_dev_attach(struct sock *sk);
2589 2606
2590#else /* CONFIG_SECURITY_NETWORK */ 2607#else /* CONFIG_SECURITY_NETWORK */
2591static inline int security_unix_stream_connect(struct socket *sock, 2608static inline int security_unix_stream_connect(struct socket *sock,
@@ -2736,6 +2753,20 @@ static inline void security_inet_conn_established(struct sock *sk,
2736 struct sk_buff *skb) 2753 struct sk_buff *skb)
2737{ 2754{
2738} 2755}
2756
2757static inline int security_tun_dev_create(void)
2758{
2759 return 0;
2760}
2761
2762static inline void security_tun_dev_post_create(struct sock *sk)
2763{
2764}
2765
2766static inline int security_tun_dev_attach(struct sock *sk)
2767{
2768 return 0;
2769}
2739#endif /* CONFIG_SECURITY_NETWORK */ 2770#endif /* CONFIG_SECURITY_NETWORK */
2740 2771
2741#ifdef CONFIG_SECURITY_NETWORK_XFRM 2772#ifdef CONFIG_SECURITY_NETWORK_XFRM