blob: 8c59b8f150e888edf09195dedd1c687f9b0784fe [file] [log] [blame]
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07001/*
2 * SELinux interface to the NetLabel subsystem
3 *
Paul Moore82c21bf2011-08-01 11:10:33 +00004 * Author: Paul Moore <paul@paul-moore.com>
Venkat Yekkirala7420ed22006-08-04 23:17:57 -07005 *
6 */
7
8/*
9 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
19 * the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#ifndef _SELINUX_NETLABEL_H_
28#define _SELINUX_NETLABEL_H_
29
Paul Moore7a0e1d62006-08-29 17:56:04 -070030#include <linux/types.h>
31#include <linux/fs.h>
32#include <linux/net.h>
33#include <linux/skbuff.h>
34#include <net/sock.h>
Paul Moore389fb8002009-03-27 17:10:34 -040035#include <net/request_sock.h>
Paul Moore7a0e1d62006-08-29 17:56:04 -070036
37#include "avc.h"
38#include "objsec.h"
39
Venkat Yekkirala7420ed22006-08-04 23:17:57 -070040#ifdef CONFIG_NETLABEL
41void selinux_netlbl_cache_invalidate(void);
Paul Moore5778eab2007-02-28 15:14:22 -050042
Paul Mooredfaebe92008-10-10 10:16:31 -040043void selinux_netlbl_err(struct sk_buff *skb, int error, int gateway);
44
Eric Parisdd3e7832010-04-07 15:08:46 -040045void selinux_netlbl_sk_security_free(struct sk_security_struct *sksec);
46void selinux_netlbl_sk_security_reset(struct sk_security_struct *sksec);
Paul Moore5778eab2007-02-28 15:14:22 -050047
Paul Moore75e22912008-01-29 08:38:04 -050048int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
49 u16 family,
Paul Moore220deb92008-01-29 08:38:23 -050050 u32 *type,
Paul Moore75e22912008-01-29 08:38:04 -050051 u32 *sid);
Paul Moore948bf852008-10-10 10:16:32 -040052int selinux_netlbl_skbuff_setsid(struct sk_buff *skb,
53 u16 family,
54 u32 sid);
Paul Moore5778eab2007-02-28 15:14:22 -050055
Paul Moore389fb8002009-03-27 17:10:34 -040056int selinux_netlbl_inet_conn_request(struct request_sock *req, u16 family);
57void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family);
58int selinux_netlbl_socket_post_create(struct sock *sk, u16 family);
Paul Moore5778eab2007-02-28 15:14:22 -050059int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
60 struct sk_buff *skb,
Paul Moore75e22912008-01-29 08:38:04 -050061 u16 family,
Thomas Liu2bf49692009-07-14 12:14:09 -040062 struct common_audit_data *ad);
Paul Mooref8687af2006-10-30 15:22:15 -080063int selinux_netlbl_socket_setsockopt(struct socket *sock,
64 int level,
65 int optname);
Paul Moore014ab192008-10-10 10:16:33 -040066int selinux_netlbl_socket_connect(struct sock *sk, struct sockaddr *addr);
67
Venkat Yekkirala7420ed22006-08-04 23:17:57 -070068#else
69static inline void selinux_netlbl_cache_invalidate(void)
70{
71 return;
72}
73
Paul Mooredfaebe92008-10-10 10:16:31 -040074static inline void selinux_netlbl_err(struct sk_buff *skb,
75 int error,
76 int gateway)
77{
78 return;
79}
80
Paul Moore6c5b3fc2008-10-10 10:16:33 -040081static inline void selinux_netlbl_sk_security_free(
Eric Parisdd3e7832010-04-07 15:08:46 -040082 struct sk_security_struct *sksec)
Paul Moore6c5b3fc2008-10-10 10:16:33 -040083{
84 return;
85}
86
Paul Moore5778eab2007-02-28 15:14:22 -050087static inline void selinux_netlbl_sk_security_reset(
Eric Parisdd3e7832010-04-07 15:08:46 -040088 struct sk_security_struct *sksec)
Paul Moore5778eab2007-02-28 15:14:22 -050089{
90 return;
91}
Paul Moore5778eab2007-02-28 15:14:22 -050092
Paul Moore3de4bab2006-11-17 17:38:54 -050093static inline int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
Paul Moore75e22912008-01-29 08:38:04 -050094 u16 family,
Paul Moore220deb92008-01-29 08:38:23 -050095 u32 *type,
Paul Moore3de4bab2006-11-17 17:38:54 -050096 u32 *sid)
97{
Paul Moore220deb92008-01-29 08:38:23 -050098 *type = NETLBL_NLTYPE_NONE;
Paul Moore3de4bab2006-11-17 17:38:54 -050099 *sid = SECSID_NULL;
100 return 0;
101}
Paul Moore948bf852008-10-10 10:16:32 -0400102static inline int selinux_netlbl_skbuff_setsid(struct sk_buff *skb,
103 u16 family,
104 u32 sid)
105{
106 return 0;
107}
Paul Moore3de4bab2006-11-17 17:38:54 -0500108
Paul Moore014ab192008-10-10 10:16:33 -0400109static inline int selinux_netlbl_conn_setsid(struct sock *sk,
110 struct sockaddr *addr)
111{
112 return 0;
113}
114
Paul Moore389fb8002009-03-27 17:10:34 -0400115static inline int selinux_netlbl_inet_conn_request(struct request_sock *req,
116 u16 family)
Paul Moore5778eab2007-02-28 15:14:22 -0500117{
118 return 0;
119}
Paul Moore389fb8002009-03-27 17:10:34 -0400120static inline void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family)
121{
122 return;
123}
124static inline int selinux_netlbl_socket_post_create(struct sock *sk,
125 u16 family)
Paul Moore5778eab2007-02-28 15:14:22 -0500126{
127 return 0;
128}
Venkat Yekkirala7420ed22006-08-04 23:17:57 -0700129static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
130 struct sk_buff *skb,
Paul Moore75e22912008-01-29 08:38:04 -0500131 u16 family,
Thomas Liu2bf49692009-07-14 12:14:09 -0400132 struct common_audit_data *ad)
Venkat Yekkirala7420ed22006-08-04 23:17:57 -0700133{
134 return 0;
135}
Paul Mooref8687af2006-10-30 15:22:15 -0800136static inline int selinux_netlbl_socket_setsockopt(struct socket *sock,
137 int level,
138 int optname)
139{
140 return 0;
141}
Paul Moore014ab192008-10-10 10:16:33 -0400142static inline int selinux_netlbl_socket_connect(struct sock *sk,
143 struct sockaddr *addr)
144{
145 return 0;
146}
Venkat Yekkirala7420ed22006-08-04 23:17:57 -0700147#endif /* CONFIG_NETLABEL */
148
149#endif