Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81d8f99

Browse files
snjsnj
authored andcommitted
Pull up following revision(s) (requested by maxv in ticket #1536):
sys/netipsec/ipsec_input.c: 1.57-1.58 Extend these #ifdef notyet. The m_copydata's in these branches are wrong, we are not guaranteed to have enough room for another struct ip, and we may crash here. Triggerable remotely, but after authentication, by sending an AH packet that has a one-byte-sized IPIP payload. -- Argh, in my previous commit in this file I forgot to fix the IPv6 entry point; apply the same fix there.
1 parent 9a5c0bd commit 81d8f99

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

sys/netipsec/ipsec_input.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: ipsec_input.c,v 1.29 2012/01/25 21:58:10 drochner Exp $ */
1+
/* $NetBSD: ipsec_input.c,v 1.29.8.1 2018/03/13 17:47:11 snj Exp $ */
22
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $ */
33
/* $OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $ */
44

@@ -39,7 +39,7 @@
3939
*/
4040

4141
#include <sys/cdefs.h>
42-
__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.29 2012/01/25 21:58:10 drochner Exp $");
42+
__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.29.8.1 2018/03/13 17:47:11 snj Exp $");
4343

4444
/*
4545
* IPsec input processing.
@@ -332,14 +332,15 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
332332
ip->ip_len = htons(m->m_pkthdr.len);
333333
prot = ip->ip_p;
334334

335+
#ifdef notyet
335336
/* IP-in-IP encapsulation */
336337
if (prot == IPPROTO_IPIP) {
337338
struct ip ipn;
338339

339340
/* ipn will now contain the inner IPv4 header */
341+
/* XXX: check m_pkthdr.len */
340342
m_copydata(m, ip->ip_hl << 2, sizeof(struct ip), &ipn);
341343

342-
#ifdef notyet
343344
/* XXX PROXY address isn't recorded in SAH */
344345
/*
345346
* Check that the inner source address is the same as
@@ -367,17 +368,16 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
367368
error = EACCES;
368369
goto bad;
369370
}
370-
#endif /*XXX*/
371371
}
372372
#if INET6
373373
/* IPv6-in-IP encapsulation. */
374374
if (prot == IPPROTO_IPV6) {
375375
struct ip6_hdr ip6n;
376376

377377
/* ip6n will now contain the inner IPv6 header. */
378+
/* XXX: check m_pkthdr.len */
378379
m_copydata(m, ip->ip_hl << 2, sizeof(struct ip6_hdr), &ip6n);
379380

380-
#ifdef notyet
381381
/*
382382
* Check that the inner source address is the same as
383383
* the proxy address, if available.
@@ -403,9 +403,9 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
403403
error = EACCES;
404404
goto bad;
405405
}
406-
#endif /*XXX*/
407406
}
408407
#endif /* INET6 */
408+
#endif /* notyet */
409409

410410
/*
411411
* Record what we've done to the packet (under what SA it was
@@ -651,15 +651,16 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
651651
/* Save protocol */
652652
m_copydata(m, protoff, 1, &prot);
653653

654+
#ifdef notyet
654655
#ifdef INET
655656
/* IP-in-IP encapsulation */
656657
if (prot == IPPROTO_IPIP) {
657658
struct ip ipn;
658659

659660
/* ipn will now contain the inner IPv4 header */
661+
/* XXX: check m_pkthdr.len */
660662
m_copydata(m, skip, sizeof(struct ip), &ipn);
661663

662-
#ifdef notyet
663664
/*
664665
* Check that the inner source address is the same as
665666
* the proxy address, if available.
@@ -683,18 +684,16 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
683684
error = EACCES;
684685
goto bad;
685686
}
686-
#endif /*XXX*/
687687
}
688688
#endif /* INET */
689-
690689
/* IPv6-in-IP encapsulation */
691690
if (prot == IPPROTO_IPV6) {
692691
struct ip6_hdr ip6n;
693692

694693
/* ip6n will now contain the inner IPv6 header. */
694+
/* XXX: check m_pkthdr.len */
695695
m_copydata(m, skip, sizeof(struct ip6_hdr), &ip6n);
696696

697-
#ifdef notyet
698697
/*
699698
* Check that the inner source address is the same as
700699
* the proxy address, if available.
@@ -719,8 +718,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
719718
error = EACCES;
720719
goto bad;
721720
}
722-
#endif /*XXX*/
723721
}
722+
#endif /* notyet */
724723

725724
/*
726725
* Record what we've done to the packet (under what SA it was

0 commit comments

Comments
 (0)