aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/cipso_ipv4.h
diff options
context:
space:
mode:
authorPaul Moore <pmoore@redhat.com>2015-02-11 14:46:37 -0500
committerPaul Moore <pmoore@redhat.com>2015-02-11 14:46:37 -0500
commit04f81f0154e4bf002be6f4d85668ce1257efa4d9 (patch)
tree6572c58a65fe65aa738419e43e45e59c32538357 /include/net/cipso_ipv4.h
parent6eb4e2b41b264f57ee02d16ee61683952945484d (diff)
cipso: don't use IPCB() to locate the CIPSO IP option
Using the IPCB() macro to get the IPv4 options is convenient, but unfortunately NetLabel often needs to examine the CIPSO option outside of the scope of the IP layer in the stack. While historically IPCB() worked above the IP layer, due to the inclusion of the inet_skb_param struct at the head of the {tcp,udp}_skb_cb structs, recent commit 971f10ec ("tcp: better TCP_SKB_CB layout to reduce cache line misses") reordered the tcp_skb_cb struct and invalidated this IPCB() trick. This patch fixes the problem by creating a new function, cipso_v4_optptr(), which locates the CIPSO option inside the IP header without calling IPCB(). Unfortunately, this isn't as fast as a simple lookup so some additional tweaks were made to limit the use of this new function. Cc: <stable@vger.kernel.org> # 3.18 Reported-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Paul Moore <pmoore@redhat.com> Tested-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'include/net/cipso_ipv4.h')
-rw-r--r--include/net/cipso_ipv4.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
index a6fd939f202d..3ebb168b9afc 100644
--- a/include/net/cipso_ipv4.h
+++ b/include/net/cipso_ipv4.h
@@ -121,13 +121,6 @@ extern int cipso_v4_rbm_strictvalid;
121#endif 121#endif
122 122
123/* 123/*
124 * Helper Functions
125 */
126
127#define CIPSO_V4_OPTEXIST(x) (IPCB(x)->opt.cipso != 0)
128#define CIPSO_V4_OPTPTR(x) (skb_network_header(x) + IPCB(x)->opt.cipso)
129
130/*
131 * DOI List Functions 124 * DOI List Functions
132 */ 125 */
133 126
@@ -190,7 +183,7 @@ static inline int cipso_v4_doi_domhsh_remove(struct cipso_v4_doi *doi_def,
190 183
191#ifdef CONFIG_NETLABEL 184#ifdef CONFIG_NETLABEL
192void cipso_v4_cache_invalidate(void); 185void cipso_v4_cache_invalidate(void);
193int cipso_v4_cache_add(const struct sk_buff *skb, 186int cipso_v4_cache_add(const unsigned char *cipso_ptr,
194 const struct netlbl_lsm_secattr *secattr); 187 const struct netlbl_lsm_secattr *secattr);
195#else 188#else
196static inline void cipso_v4_cache_invalidate(void) 189static inline void cipso_v4_cache_invalidate(void)
@@ -198,7 +191,7 @@ static inline void cipso_v4_cache_invalidate(void)
198 return; 191 return;
199} 192}
200 193
201static inline int cipso_v4_cache_add(const struct sk_buff *skb, 194static inline int cipso_v4_cache_add(const unsigned char *cipso_ptr,
202 const struct netlbl_lsm_secattr *secattr) 195 const struct netlbl_lsm_secattr *secattr)
203{ 196{
204 return 0; 197 return 0;
@@ -211,6 +204,8 @@ static inline int cipso_v4_cache_add(const struct sk_buff *skb,
211 204
212#ifdef CONFIG_NETLABEL 205#ifdef CONFIG_NETLABEL
213void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway); 206void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway);
207int cipso_v4_getattr(const unsigned char *cipso,
208 struct netlbl_lsm_secattr *secattr);
214int cipso_v4_sock_setattr(struct sock *sk, 209int cipso_v4_sock_setattr(struct sock *sk,
215 const struct cipso_v4_doi *doi_def, 210 const struct cipso_v4_doi *doi_def,
216 const struct netlbl_lsm_secattr *secattr); 211 const struct netlbl_lsm_secattr *secattr);
@@ -226,6 +221,7 @@ int cipso_v4_skbuff_setattr(struct sk_buff *skb,
226int cipso_v4_skbuff_delattr(struct sk_buff *skb); 221int cipso_v4_skbuff_delattr(struct sk_buff *skb);
227int cipso_v4_skbuff_getattr(const struct sk_buff *skb, 222int cipso_v4_skbuff_getattr(const struct sk_buff *skb,
228 struct netlbl_lsm_secattr *secattr); 223 struct netlbl_lsm_secattr *secattr);
224unsigned char *cipso_v4_optptr(const struct sk_buff *skb);
229int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option); 225int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option);
230#else 226#else
231static inline void cipso_v4_error(struct sk_buff *skb, 227static inline void cipso_v4_error(struct sk_buff *skb,
@@ -235,6 +231,12 @@ static inline void cipso_v4_error(struct sk_buff *skb,
235 return; 231 return;
236} 232}
237 233
234static inline int cipso_v4_getattr(const unsigned char *cipso,
235 struct netlbl_lsm_secattr *secattr)
236{
237 return -ENOSYS;
238}
239
238static inline int cipso_v4_sock_setattr(struct sock *sk, 240static inline int cipso_v4_sock_setattr(struct sock *sk,
239 const struct cipso_v4_doi *doi_def, 241 const struct cipso_v4_doi *doi_def,
240 const struct netlbl_lsm_secattr *secattr) 242 const struct netlbl_lsm_secattr *secattr)
@@ -282,6 +284,11 @@ static inline int cipso_v4_skbuff_getattr(const struct sk_buff *skb,
282 return -ENOSYS; 284 return -ENOSYS;
283} 285}
284 286
287static inline unsigned char *cipso_v4_optptr(const struct sk_buff *skb)
288{
289 return NULL;
290}
291
285static inline int cipso_v4_validate(const struct sk_buff *skb, 292static inline int cipso_v4_validate(const struct sk_buff *skb,
286 unsigned char **option) 293 unsigned char **option)
287{ 294{