Skip to content

Commit c056ab5

Browse files
committed
Implement a fix from OpenBSD 5.6-stable:
Check the header fields of GRE and MPPE packets strictly.
1 parent 7eac19d commit c056ab5

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

sys/net/pipex.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: pipex.c,v 1.55 2014/07/22 11:06:10 mpi Exp $ */
1+
/* $OpenBSD: pipex.c,v 1.55.4.1 2014/12/01 06:57:33 yasuoka Exp $ */
22

33
/*-
44
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -1037,6 +1037,7 @@ pipex_ppp_input(struct mbuf *m0, struct pipex_session *session, int decrypted)
10371037
struct m_tag *mtag;
10381038
struct pipex_tag *tag;
10391039

1040+
KASSERT(m0->m_pkthdr.len >= PIPEX_PPPMINLEN);
10401041
proto = pipex_ppp_proto(m0, session, 0, &hlen);
10411042
#ifdef PIPEX_MPPE
10421043
if (proto == PPP_COMP) {
@@ -1294,7 +1295,8 @@ pipex_common_input(struct pipex_session *session, struct mbuf *m0, int hlen,
12941295
int proto, ppphlen;
12951296
u_char code;
12961297

1297-
if (m0->m_pkthdr.len < hlen + PIPEX_PPPMINLEN)
1298+
if ((m0->m_pkthdr.len < hlen + PIPEX_PPPMINLEN) ||
1299+
(plen < PIPEX_PPPMINLEN))
12981300
goto drop;
12991301

13001302
proto = pipex_ppp_proto(m0, session, hlen, &ppphlen);
@@ -1358,6 +1360,7 @@ pipex_ppp_proto(struct mbuf *m0, struct pipex_session *session, int off,
13581360
int proto;
13591361
u_char *cp, pktbuf[4];
13601362

1363+
KASSERT(m0->m_pkthdr.len > sizeof(pktbuf));
13611364
m_copydata(m0, off, sizeof(pktbuf), pktbuf);
13621365
cp = pktbuf;
13631366

@@ -1621,6 +1624,13 @@ pipex_pptp_lookup_session(struct mbuf *m0)
16211624
goto not_ours;
16221625
}
16231626

1627+
/* flag check */
1628+
if ((flags & PIPEX_GRE_UNUSEDFLAGS) != 0) {
1629+
PIPEX_DBG((NULL, LOG_DEBUG,
1630+
"<%s> gre header has unused flags at pptp.", __func__));
1631+
goto not_ours;
1632+
}
1633+
16241634
/* lookup pipex session table */
16251635
id = ntohs(gre.call_id);
16261636
session = pipex_lookup_by_session_id(PIPEX_PROTO_PPTP, id);
@@ -2575,6 +2585,8 @@ pipex_mppe_input(struct mbuf *m0, struct pipex_session *session)
25752585
mppe->coher_cnt++;
25762586
mppe->coher_cnt &= PIPEX_COHERENCY_CNT_MASK;
25772587
}
2588+
if (m0->m_pkthdr.len < PIPEX_PPPMINLEN)
2589+
goto drop;
25782590

25792591
pipex_ppp_input(m0, session, 1);
25802592

sys/net/pipex_local.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: pipex_local.h,v 1.19 2013/04/20 07:54:28 yasuoka Exp $ */
1+
/* $OpenBSD: pipex_local.h,v 1.19.8.1 2014/12/01 06:57:33 yasuoka Exp $ */
22

33
/*
44
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -217,7 +217,8 @@ struct pipex_gre_header {
217217
#define PIPEX_GRE_SFLAG 0x1000 /* seq present */
218218
#define PIPEX_GRE_AFLAG 0x0080 /* ack present */
219219
#define PIPEX_GRE_VER 0x0001 /* gre version code */
220-
#define PIPEX_GRE_VERMASK 0x0003 /* gre version mask */
220+
#define PIPEX_GRE_VERMASK 0x0007 /* gre version mask */
221+
#define PIPEX_GRE_UNUSEDFLAGS 0xcf78 /* unused at pptp. set 0 in rfc2637 */
221222

222223
uint16_t type;
223224
#define PIPEX_GRE_PROTO_PPP 0x880b /* gre/ppp */

0 commit comments

Comments
 (0)