calipso: Add validation of CALIPSO option.
Subsystems (5)
PATCH v4 17/19 calipso: Add validation of CALIPSO option.
Lengths, checksum and the DOI are checked. Checking of the level and categories are left for the socket layer.
CRC validation is performed in the calipso module to avoid unconditionally linking crc_ccitt() into ipv6.
Signed-off-by Huw Davies <[email protected]>
--- include/net/calipso.h | 6 ++++++ net/ipv6/calipso.c | 41 +++++++++++++++++++++++++++++++++++++++++ net/ipv6/exthdrs.c | 27 +++++++++++++++++++++++++++ 3 files changed, 74 insertions(+)
include/net/calipso.h +6 -0
@@ -65,6 +65,7 @@ struct calipso_doi {#ifdef CONFIG_NETLABEL int __init calipso_init (void );void calipso_exit (void ); +bool calipso_validate (const struct sk_buff *skb,const unsigned char *option);#else static inline int __init calipso_init (void ) {
@@ -74,6 +75,11 @@ static inline int __init calipso_init(void)static inline void calipso_exit (void ) { } +static inline bool calipso_validate (const struct sk_buff *skb, +const unsigned char *option) +{ +return true; +}#endif /* CONFIG_NETLABEL */ #endif /* _CALIPSO_H */
net/ipv6/calipso.c +41 -0
47 lines not on this page · raw message
net/ipv6/exthdrs.c +27 -0
@@ -43,6 +43,7 @@#include <net/ndisc.h> #include <net/ip6_route.h> #include <net/addrconf.h> +#include <net/calipso.h> #if IS_ENABLED (CONFIG_IPV6_MIP6 )#include <net/xfrm.h> #endif
@@ -603,6 +604,28 @@ drop:return false; } +/* CALIPSO RFC 5570 */ + +static bool ipv6_hop_calipso (struct sk_buff *skb,int optoff) +{ +const unsigned char *nh =skb_network_header (skb); + +if (nh[optoff +1 ] <8 ) + goto drop; + +if (nh[optoff +6 ] *4 +8 > nh[optoff +1 ]) + goto drop; + +if (!calipso_validate (skb, nh + optoff)) + goto drop; + +return true; + +drop: +kfree_skb (skb); +return false; +} +static const struct tlvtype_proc tlvprochopopt_lst[] = { { .type =IPV6_TLV_ROUTERALERT ,
@@ -612,6 +635,10 @@ static const struct tlvtype_proc tlvprochopopt_lst[] = { .type = IPV6_TLV_JUMBO, .func = ipv6_hop_jumbo, }, + { + .type = IPV6_TLV_CALIPSO, + .func = ipv6_hop_calipso, + }, { -1, } };
Signature · 7 lines
2.7.4 _______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected] To get help, send an email containing "help" to [email protected]