From owner-dev-commits-src-branches@freebsd.org Fri May 7 15:25:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4396E6314A8; Fri, 7 May 2021 15:25:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FcDmc4kYhz4k2V; Fri, 7 May 2021 15:25:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B107358F2; Fri, 7 May 2021 15:25:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 147FPnd5026477; Fri, 7 May 2021 15:25:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 147FPnRl026476; Fri, 7 May 2021 15:25:49 GMT (envelope-from git) Date: Fri, 7 May 2021 15:25:49 GMT Message-Id: <202105071525.147FPnRl026476@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 7b15ca116c1d - stable/13 - pf: Ensure that we don't use kif passed to pfi_kkif_attach() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7b15ca116c1d257f5c734b1c6f3b9c10ad80e7a8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2021 15:25:53 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=7b15ca116c1d257f5c734b1c6f3b9c10ad80e7a8 commit 7b15ca116c1d257f5c734b1c6f3b9c10ad80e7a8 Author: Kristof Provost AuthorDate: 2021-04-12 09:45:48 +0000 Commit: Kristof Provost CommitDate: 2021-05-07 08:15:42 +0000 pf: Ensure that we don't use kif passed to pfi_kkif_attach() Once a kif is passed to pfi_kkif_attach() we must ensure we never re-use it for anything else. Set the kif to NULL afterwards to guarantee this. Reported-by: syzbot+be5d4f4a7a4c295e659a@syzkaller.appspotmail.com MFC after: 4 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 5e98cae661f3a7e85df7f277660765b823454073) --- sys/netpfil/pf/pf_if.c | 1 + sys/netpfil/pf/pf_ioctl.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c index be290a1e1f2e..4630098221c8 100644 --- a/sys/netpfil/pf/pf_if.c +++ b/sys/netpfil/pf/pf_if.c @@ -486,6 +486,7 @@ pfi_dynaddr_setup(struct pf_addr_wrap *aw, sa_family_t af) dyn->pfid_kif = pfi_kkif_attach(kif, IFG_ALL); else dyn->pfid_kif = pfi_kkif_attach(kif, aw->v.ifname); + kif = NULL; pfi_kkif_ref(dyn->pfid_kif); dyn->pfid_net = pfi_unmask(&aw->v.a.mask); diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index cdff32916953..e6ab3ab5e91f 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2411,6 +2411,7 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, rule->nr = 0; if (rule->ifname[0]) { rule->kif = pfi_kkif_attach(kif, rule->ifname); + kif = NULL; pfi_kkif_ref(rule->kif); } else rule->kif = NULL; @@ -3028,6 +3029,7 @@ DIOCGETRULENV_error: if (newrule->ifname[0]) { newrule->kif = pfi_kkif_attach(kif, newrule->ifname); + kif = NULL; pfi_kkif_ref(newrule->kif); } else newrule->kif = NULL; @@ -3761,6 +3763,7 @@ DIOCGETSTATES_full: } if (pa->ifname[0]) { pa->kif = pfi_kkif_attach(kif, pa->ifname); + kif = NULL; pfi_kkif_ref(pa->kif); } else pa->kif = NULL;