diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/security.h | 24 | ||||
-rw-r--r-- | include/net/flow.h | 2 | ||||
-rw-r--r-- | include/net/inet_timewait_sock.h | 1 | ||||
-rw-r--r-- | include/net/netlabel.h | 62 | ||||
-rw-r--r-- | include/net/sctp/sctp.h | 14 | ||||
-rw-r--r-- | include/net/sctp/ulpevent.h | 1 | ||||
-rw-r--r-- | include/net/timewait_sock.h | 7 | ||||
-rw-r--r-- | include/net/xfrm.h | 3 |
8 files changed, 82 insertions, 32 deletions
diff --git a/include/linux/security.h b/include/linux/security.h index 9b5fea81f55e..b200b9856f32 100644 --- a/include/linux/security.h +++ b/include/linux/security.h | |||
@@ -882,7 +882,8 @@ struct request_sock; | |||
882 | * Check permission when a flow selects a xfrm_policy for processing | 882 | * Check permission when a flow selects a xfrm_policy for processing |
883 | * XFRMs on a packet. The hook is called when selecting either a | 883 | * XFRMs on a packet. The hook is called when selecting either a |
884 | * per-socket policy or a generic xfrm policy. | 884 | * per-socket policy or a generic xfrm policy. |
885 | * Return 0 if permission is granted. | 885 | * Return 0 if permission is granted, -ESRCH otherwise, or -errno |
886 | * on other errors. | ||
886 | * @xfrm_state_pol_flow_match: | 887 | * @xfrm_state_pol_flow_match: |
887 | * @x contains the state to match. | 888 | * @x contains the state to match. |
888 | * @xp contains the policy to check for a match. | 889 | * @xp contains the policy to check for a match. |
@@ -891,6 +892,7 @@ struct request_sock; | |||
891 | * @xfrm_flow_state_match: | 892 | * @xfrm_flow_state_match: |
892 | * @fl contains the flow key to match. | 893 | * @fl contains the flow key to match. |
893 | * @xfrm points to the xfrm_state to match. | 894 | * @xfrm points to the xfrm_state to match. |
895 | * @xp points to the xfrm_policy to match. | ||
894 | * Return 1 if there is a match. | 896 | * Return 1 if there is a match. |
895 | * @xfrm_decode_session: | 897 | * @xfrm_decode_session: |
896 | * @skb points to skb to decode. | 898 | * @skb points to skb to decode. |
@@ -1388,7 +1390,8 @@ struct security_operations { | |||
1388 | int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir); | 1390 | int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir); |
1389 | int (*xfrm_state_pol_flow_match)(struct xfrm_state *x, | 1391 | int (*xfrm_state_pol_flow_match)(struct xfrm_state *x, |
1390 | struct xfrm_policy *xp, struct flowi *fl); | 1392 | struct xfrm_policy *xp, struct flowi *fl); |
1391 | int (*xfrm_flow_state_match)(struct flowi *fl, struct xfrm_state *xfrm); | 1393 | int (*xfrm_flow_state_match)(struct flowi *fl, struct xfrm_state *xfrm, |
1394 | struct xfrm_policy *xp); | ||
1392 | int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall); | 1395 | int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall); |
1393 | #endif /* CONFIG_SECURITY_NETWORK_XFRM */ | 1396 | #endif /* CONFIG_SECURITY_NETWORK_XFRM */ |
1394 | 1397 | ||
@@ -3120,11 +3123,6 @@ static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm | |||
3120 | return security_ops->xfrm_policy_alloc_security(xp, sec_ctx, NULL); | 3123 | return security_ops->xfrm_policy_alloc_security(xp, sec_ctx, NULL); |
3121 | } | 3124 | } |
3122 | 3125 | ||
3123 | static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk) | ||
3124 | { | ||
3125 | return security_ops->xfrm_policy_alloc_security(xp, NULL, sk); | ||
3126 | } | ||
3127 | |||
3128 | static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) | 3126 | static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) |
3129 | { | 3127 | { |
3130 | return security_ops->xfrm_policy_clone_security(old, new); | 3128 | return security_ops->xfrm_policy_clone_security(old, new); |
@@ -3175,9 +3173,10 @@ static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x, | |||
3175 | return security_ops->xfrm_state_pol_flow_match(x, xp, fl); | 3173 | return security_ops->xfrm_state_pol_flow_match(x, xp, fl); |
3176 | } | 3174 | } |
3177 | 3175 | ||
3178 | static inline int security_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm) | 3176 | static inline int security_xfrm_flow_state_match(struct flowi *fl, |
3177 | struct xfrm_state *xfrm, struct xfrm_policy *xp) | ||
3179 | { | 3178 | { |
3180 | return security_ops->xfrm_flow_state_match(fl, xfrm); | 3179 | return security_ops->xfrm_flow_state_match(fl, xfrm, xp); |
3181 | } | 3180 | } |
3182 | 3181 | ||
3183 | static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) | 3182 | static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) |
@@ -3197,11 +3196,6 @@ static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm | |||
3197 | return 0; | 3196 | return 0; |
3198 | } | 3197 | } |
3199 | 3198 | ||
3200 | static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk) | ||
3201 | { | ||
3202 | return 0; | ||
3203 | } | ||
3204 | |||
3205 | static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) | 3199 | static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) |
3206 | { | 3200 | { |
3207 | return 0; | 3201 | return 0; |
@@ -3249,7 +3243,7 @@ static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x, | |||
3249 | } | 3243 | } |
3250 | 3244 | ||
3251 | static inline int security_xfrm_flow_state_match(struct flowi *fl, | 3245 | static inline int security_xfrm_flow_state_match(struct flowi *fl, |
3252 | struct xfrm_state *xfrm) | 3246 | struct xfrm_state *xfrm, struct xfrm_policy *xp) |
3253 | { | 3247 | { |
3254 | return 1; | 3248 | return 1; |
3255 | } | 3249 | } |
diff --git a/include/net/flow.h b/include/net/flow.h index ddf5f3ca1720..3b44d72b27d3 100644 --- a/include/net/flow.h +++ b/include/net/flow.h | |||
@@ -97,7 +97,7 @@ struct flowi { | |||
97 | #define FLOW_DIR_FWD 2 | 97 | #define FLOW_DIR_FWD 2 |
98 | 98 | ||
99 | struct sock; | 99 | struct sock; |
100 | typedef void (*flow_resolve_t)(struct flowi *key, u16 family, u8 dir, | 100 | typedef int (*flow_resolve_t)(struct flowi *key, u16 family, u8 dir, |
101 | void **objp, atomic_t **obj_refp); | 101 | void **objp, atomic_t **obj_refp); |
102 | 102 | ||
103 | extern void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir, | 103 | extern void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir, |
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index 6d14c22a00c5..5f48748fe017 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h | |||
@@ -196,6 +196,7 @@ static inline void inet_twsk_put(struct inet_timewait_sock *tw) | |||
196 | { | 196 | { |
197 | if (atomic_dec_and_test(&tw->tw_refcnt)) { | 197 | if (atomic_dec_and_test(&tw->tw_refcnt)) { |
198 | struct module *owner = tw->tw_prot->owner; | 198 | struct module *owner = tw->tw_prot->owner; |
199 | twsk_destructor((struct sock *)tw); | ||
199 | #ifdef SOCK_REFCNT_DEBUG | 200 | #ifdef SOCK_REFCNT_DEBUG |
200 | printk(KERN_DEBUG "%s timewait_sock %p released\n", | 201 | printk(KERN_DEBUG "%s timewait_sock %p released\n", |
201 | tw->tw_prot->name, tw); | 202 | tw->tw_prot->name, tw); |
diff --git a/include/net/netlabel.h b/include/net/netlabel.h index c63a58058e21..113337c27955 100644 --- a/include/net/netlabel.h +++ b/include/net/netlabel.h | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/net.h> | 34 | #include <linux/net.h> |
35 | #include <linux/skbuff.h> | 35 | #include <linux/skbuff.h> |
36 | #include <net/netlink.h> | 36 | #include <net/netlink.h> |
37 | #include <asm/atomic.h> | ||
37 | 38 | ||
38 | /* | 39 | /* |
39 | * NetLabel - A management interface for maintaining network packet label | 40 | * NetLabel - A management interface for maintaining network packet label |
@@ -106,6 +107,7 @@ int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info); | |||
106 | 107 | ||
107 | /* LSM security attributes */ | 108 | /* LSM security attributes */ |
108 | struct netlbl_lsm_cache { | 109 | struct netlbl_lsm_cache { |
110 | atomic_t refcount; | ||
109 | void (*free) (const void *data); | 111 | void (*free) (const void *data); |
110 | void *data; | 112 | void *data; |
111 | }; | 113 | }; |
@@ -117,7 +119,7 @@ struct netlbl_lsm_secattr { | |||
117 | unsigned char *mls_cat; | 119 | unsigned char *mls_cat; |
118 | size_t mls_cat_len; | 120 | size_t mls_cat_len; |
119 | 121 | ||
120 | struct netlbl_lsm_cache cache; | 122 | struct netlbl_lsm_cache *cache; |
121 | }; | 123 | }; |
122 | 124 | ||
123 | /* | 125 | /* |
@@ -126,6 +128,43 @@ struct netlbl_lsm_secattr { | |||
126 | 128 | ||
127 | 129 | ||
128 | /** | 130 | /** |
131 | * netlbl_secattr_cache_alloc - Allocate and initialize a secattr cache | ||
132 | * @flags: the memory allocation flags | ||
133 | * | ||
134 | * Description: | ||
135 | * Allocate and initialize a netlbl_lsm_cache structure. Returns a pointer | ||
136 | * on success, NULL on failure. | ||
137 | * | ||
138 | */ | ||
139 | static inline struct netlbl_lsm_cache *netlbl_secattr_cache_alloc(int flags) | ||
140 | { | ||
141 | struct netlbl_lsm_cache *cache; | ||
142 | |||
143 | cache = kzalloc(sizeof(*cache), flags); | ||
144 | if (cache) | ||
145 | atomic_set(&cache->refcount, 1); | ||
146 | return cache; | ||
147 | } | ||
148 | |||
149 | /** | ||
150 | * netlbl_secattr_cache_free - Frees a netlbl_lsm_cache struct | ||
151 | * @cache: the struct to free | ||
152 | * | ||
153 | * Description: | ||
154 | * Frees @secattr including all of the internal buffers. | ||
155 | * | ||
156 | */ | ||
157 | static inline void netlbl_secattr_cache_free(struct netlbl_lsm_cache *cache) | ||
158 | { | ||
159 | if (!atomic_dec_and_test(&cache->refcount)) | ||
160 | return; | ||
161 | |||
162 | if (cache->free) | ||
163 | cache->free(cache->data); | ||
164 | kfree(cache); | ||
165 | } | ||
166 | |||
167 | /** | ||
129 | * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct | 168 | * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct |
130 | * @secattr: the struct to initialize | 169 | * @secattr: the struct to initialize |
131 | * | 170 | * |
@@ -143,20 +182,16 @@ static inline int netlbl_secattr_init(struct netlbl_lsm_secattr *secattr) | |||
143 | /** | 182 | /** |
144 | * netlbl_secattr_destroy - Clears a netlbl_lsm_secattr struct | 183 | * netlbl_secattr_destroy - Clears a netlbl_lsm_secattr struct |
145 | * @secattr: the struct to clear | 184 | * @secattr: the struct to clear |
146 | * @clear_cache: cache clear flag | ||
147 | * | 185 | * |
148 | * Description: | 186 | * Description: |
149 | * Destroys the @secattr struct, including freeing all of the internal buffers. | 187 | * Destroys the @secattr struct, including freeing all of the internal buffers. |
150 | * If @clear_cache is true then free the cache fields, otherwise leave them | 188 | * The struct must be reset with a call to netlbl_secattr_init() before reuse. |
151 | * intact. The struct must be reset with a call to netlbl_secattr_init() | ||
152 | * before reuse. | ||
153 | * | 189 | * |
154 | */ | 190 | */ |
155 | static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr, | 191 | static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr) |
156 | u32 clear_cache) | ||
157 | { | 192 | { |
158 | if (clear_cache && secattr->cache.data != NULL && secattr->cache.free) | 193 | if (secattr->cache) |
159 | secattr->cache.free(secattr->cache.data); | 194 | netlbl_secattr_cache_free(secattr->cache); |
160 | kfree(secattr->domain); | 195 | kfree(secattr->domain); |
161 | kfree(secattr->mls_cat); | 196 | kfree(secattr->mls_cat); |
162 | } | 197 | } |
@@ -178,17 +213,14 @@ static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc(int flags) | |||
178 | /** | 213 | /** |
179 | * netlbl_secattr_free - Frees a netlbl_lsm_secattr struct | 214 | * netlbl_secattr_free - Frees a netlbl_lsm_secattr struct |
180 | * @secattr: the struct to free | 215 | * @secattr: the struct to free |
181 | * @clear_cache: cache clear flag | ||
182 | * | 216 | * |
183 | * Description: | 217 | * Description: |
184 | * Frees @secattr including all of the internal buffers. If @clear_cache is | 218 | * Frees @secattr including all of the internal buffers. |
185 | * true then free the cache fields, otherwise leave them intact. | ||
186 | * | 219 | * |
187 | */ | 220 | */ |
188 | static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr, | 221 | static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr) |
189 | u32 clear_cache) | ||
190 | { | 222 | { |
191 | netlbl_secattr_destroy(secattr, clear_cache); | 223 | netlbl_secattr_destroy(secattr); |
192 | kfree(secattr); | 224 | kfree(secattr); |
193 | } | 225 | } |
194 | 226 | ||
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index ee68a3124076..764e3af5be93 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h | |||
@@ -139,6 +139,7 @@ int sctp_inet_listen(struct socket *sock, int backlog); | |||
139 | void sctp_write_space(struct sock *sk); | 139 | void sctp_write_space(struct sock *sk); |
140 | unsigned int sctp_poll(struct file *file, struct socket *sock, | 140 | unsigned int sctp_poll(struct file *file, struct socket *sock, |
141 | poll_table *wait); | 141 | poll_table *wait); |
142 | void sctp_sock_rfree(struct sk_buff *skb); | ||
142 | 143 | ||
143 | /* | 144 | /* |
144 | * sctp/primitive.c | 145 | * sctp/primitive.c |
@@ -444,6 +445,19 @@ static inline struct list_head *sctp_list_dequeue(struct list_head *list) | |||
444 | return result; | 445 | return result; |
445 | } | 446 | } |
446 | 447 | ||
448 | /* SCTP version of skb_set_owner_r. We need this one because | ||
449 | * of the way we have to do receive buffer accounting on bundled | ||
450 | * chunks. | ||
451 | */ | ||
452 | static inline void sctp_skb_set_owner_r(struct sk_buff *skb, struct sock *sk) | ||
453 | { | ||
454 | struct sctp_ulpevent *event = sctp_skb2event(skb); | ||
455 | |||
456 | skb->sk = sk; | ||
457 | skb->destructor = sctp_sock_rfree; | ||
458 | atomic_add(event->rmem_len, &sk->sk_rmem_alloc); | ||
459 | } | ||
460 | |||
447 | /* Tests if the list has one and only one entry. */ | 461 | /* Tests if the list has one and only one entry. */ |
448 | static inline int sctp_list_single_entry(struct list_head *head) | 462 | static inline int sctp_list_single_entry(struct list_head *head) |
449 | { | 463 | { |
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h index 6c40cfc4832d..1a4ddc1ec7d2 100644 --- a/include/net/sctp/ulpevent.h +++ b/include/net/sctp/ulpevent.h | |||
@@ -63,6 +63,7 @@ struct sctp_ulpevent { | |||
63 | __u32 cumtsn; | 63 | __u32 cumtsn; |
64 | int msg_flags; | 64 | int msg_flags; |
65 | int iif; | 65 | int iif; |
66 | unsigned int rmem_len; | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | /* Retrieve the skb this event sits inside of. */ | 69 | /* Retrieve the skb this event sits inside of. */ |
diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h index 2544281e1d5e..be293d795e38 100644 --- a/include/net/timewait_sock.h +++ b/include/net/timewait_sock.h | |||
@@ -19,6 +19,7 @@ struct timewait_sock_ops { | |||
19 | unsigned int twsk_obj_size; | 19 | unsigned int twsk_obj_size; |
20 | int (*twsk_unique)(struct sock *sk, | 20 | int (*twsk_unique)(struct sock *sk, |
21 | struct sock *sktw, void *twp); | 21 | struct sock *sktw, void *twp); |
22 | void (*twsk_destructor)(struct sock *sk); | ||
22 | }; | 23 | }; |
23 | 24 | ||
24 | static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp) | 25 | static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp) |
@@ -28,4 +29,10 @@ static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp) | |||
28 | return 0; | 29 | return 0; |
29 | } | 30 | } |
30 | 31 | ||
32 | static inline void twsk_destructor(struct sock *sk) | ||
33 | { | ||
34 | if (sk->sk_prot->twsk_prot->twsk_destructor != NULL) | ||
35 | sk->sk_prot->twsk_prot->twsk_destructor(sk); | ||
36 | } | ||
37 | |||
31 | #endif /* _TIMEWAIT_SOCK_H */ | 38 | #endif /* _TIMEWAIT_SOCK_H */ |
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 1e2a4ddec96e..737fdb2ee8a4 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -995,7 +995,8 @@ struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, | |||
995 | int create, unsigned short family); | 995 | int create, unsigned short family); |
996 | extern void xfrm_policy_flush(u8 type); | 996 | extern void xfrm_policy_flush(u8 type); |
997 | extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); | 997 | extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); |
998 | extern int xfrm_bundle_ok(struct xfrm_dst *xdst, struct flowi *fl, int family, int strict); | 998 | extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst, |
999 | struct flowi *fl, int family, int strict); | ||
999 | extern void xfrm_init_pmtu(struct dst_entry *dst); | 1000 | extern void xfrm_init_pmtu(struct dst_entry *dst); |
1000 | 1001 | ||
1001 | extern wait_queue_head_t km_waitq; | 1002 | extern wait_queue_head_t km_waitq; |