From owner-freebsd-pf@FreeBSD.ORG Sun Apr 15 11:10:03 2012 Return-Path: Delivered-To: freebsd-pf@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4D584106564A for ; Sun, 15 Apr 2012 11:10:03 +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 316888FC0C for ; Sun, 15 Apr 2012 11:10:03 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q3FBA3c1034334 for ; Sun, 15 Apr 2012 11:10:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q3FBA3Fr034331; Sun, 15 Apr 2012 11:10:03 GMT (envelope-from gnats) Date: Sun, 15 Apr 2012 11:10:03 GMT Message-Id: <201204151110.q3FBA3Fr034331@freefall.freebsd.org> To: freebsd-pf@FreeBSD.org From: Gleb Smirnoff Cc: Subject: kern/164402: [pf] pf crashes with a particular set of rules when first matching packet arrives X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Gleb Smirnoff List-Id: "Technical discussion and general questions about packet filter \(pf\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Apr 2012 11:10:03 -0000 The following reply was made to PR kern/164402; it has been noted by GNATS. From: Gleb Smirnoff To: "Eugene M. Zheganin" Cc: bug-followup@FreeBSD.org Subject: kern/164402: [pf] pf crashes with a particular set of rules when first matching packet arrives Date: Sun, 15 Apr 2012 15:07:56 +0400 Hi, I have a vague suspicion on what is happening. Your description of the problem looks like if a packet processing in the kernel has entered an endless loop. Looking at pf_route() I see such possibility. From OpenBSD we have this protection against endless looping: if ((*m)->m_pkthdr.pf.routed++ > 3) { m0 = *m; *m = NULL; goto bad; } In our code this transforms to: if (pd->pf_mtag->routed++ > 3) { m0 = *m; *m = NULL; goto bad; } The root difference between storing the tag on mbuf and on pfdesc is that we lose pfdesc, and thus the tag, when we enter pf_test() recursively. And pf_route() does this recursion: if (oifp != ifp) { if (pf_test(PF_OUT, ifp, &m0, NULL) != PF_PASS) { goto bad; .... -- Totus tuus, Glebius.