From owner-svn-src-stable@freebsd.org Sun Mar 5 13:14:19 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B0AB9CF8F6F; Sun, 5 Mar 2017 13:14:19 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 800C0141E; Sun, 5 Mar 2017 13:14:19 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v25DEIsg076075; Sun, 5 Mar 2017 13:14:18 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v25DEIj6076074; Sun, 5 Mar 2017 13:14:18 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201703051314.v25DEIj6076074@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 5 Mar 2017 13:14:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r314702 - stable/11/sys/netpfil/pf X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Mar 2017 13:14:19 -0000 Author: kp Date: Sun Mar 5 13:14:18 2017 New Revision: 314702 URL: https://svnweb.freebsd.org/changeset/base/314702 Log: pf: Fix a crash in low-memory situations If the call to pf_state_key_clone() in pf_get_translation() fails (i.e. there's no more memory for it) it frees skp. This is wrong, because skp is a pf_state_key **, so we need to free *skp, as is done later in the function. Getting it wrong means we try to free a stack variable of the calling pf_test_rule() function, and we panic. Modified: stable/11/sys/netpfil/pf/pf_lb.c Modified: stable/11/sys/netpfil/pf/pf_lb.c ============================================================================== --- stable/11/sys/netpfil/pf/pf_lb.c Sun Mar 5 12:06:45 2017 (r314701) +++ stable/11/sys/netpfil/pf/pf_lb.c Sun Mar 5 13:14:18 2017 (r314702) @@ -553,7 +553,7 @@ pf_get_translation(struct pf_pdesc *pd, return (NULL); *nkp = pf_state_key_clone(*skp); if (*nkp == NULL) { - uma_zfree(V_pf_state_key_z, skp); + uma_zfree(V_pf_state_key_z, *skp); *skp = NULL; return (NULL); }