From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 4 19:20:09 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C53C4106567A for ; Mon, 4 Apr 2011 19:20:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A34628FC17 for ; Mon, 4 Apr 2011 19:20:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p34JK9hQ078545 for ; Mon, 4 Apr 2011 19:20:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p34JK9Vo078544; Mon, 4 Apr 2011 19:20:09 GMT (envelope-from gnats) Resent-Date: Mon, 4 Apr 2011 19:20:09 GMT Resent-Message-Id: <201104041920.p34JK9Vo078544@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Karim Fodil-Lemelin Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B229106564A for ; Mon, 4 Apr 2011 19:16:45 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 3B5528FC17 for ; Mon, 4 Apr 2011 19:16:45 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p34JGjNY053758 for ; Mon, 4 Apr 2011 19:16:45 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p34JGiXe053757; Mon, 4 Apr 2011 19:16:44 GMT (envelope-from nobody) Message-Id: <201104041916.p34JGiXe053757@red.freebsd.org> Date: Mon, 4 Apr 2011 19:16:44 GMT From: Karim Fodil-Lemelin To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/156180: ipfw checks TCP options on non-contiguous header X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Apr 2011 19:20:09 -0000 >Number: 156180 >Category: kern >Synopsis: ipfw checks TCP options on non-contiguous header >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 04 19:20:09 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Karim Fodil-Lemelin >Release: CURRENT >Organization: >Environment: >Description: When using tcpopt_match in ipfw there is no guarantee that the TCP option space matched is not bogus. This is because the case IPPROTO_TCP does not do an m_pullup on the entire IP+TCP+TCP option header. >How-To-Repeat: >Fix: The attached patch will call m_pullup on the TCP option space if it wasn't done already. Patch attached with submission follows: Index: netinet/ipfw/ip_fw2.c =================================================================== --- netinet/ipfw/ip_fw2.c (revision 219967) +++ netinet/ipfw/ip_fw2.c (working copy) @@ -949,6 +949,11 @@ case IPPROTO_TCP: PULLUP_TO(hlen, ulp, struct tcphdr); + /* kfl: check 'contiguousity' of the option space */ + if (m->m_len < (hlen + (TCP(ulp)->th_off << 2))) { + if ((m = m_pullup(m, hlen+(TCP(ulp)->th_off << 2))) == NULL) + goto pullup_failed; + } dst_port = TCP(ulp)->th_dport; src_port = TCP(ulp)->th_sport; /* save flags for dynamic rules */ @@ -1117,6 +1122,11 @@ switch (proto) { case IPPROTO_TCP: PULLUP_TO(hlen, ulp, struct tcphdr); + /* kfl: check 'contiguousity' of the option space */ + if (m->m_len < (hlen + (TCP(ulp)->th_off << 2))) { + if ((m = m_pullup(m, hlen+(TCP(ulp)->th_off << 2))) == NULL) + goto pullup_failed; + } dst_port = TCP(ulp)->th_dport; src_port = TCP(ulp)->th_sport; /* save flags for dynamic rules */ >Release-Note: >Audit-Trail: >Unformatted: