From nobody Wed Apr 27 12:50:29 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 02E361AAAB0A; Wed, 27 Apr 2022 12:50:31 +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 4KpJWT6R0zz4dXN; Wed, 27 Apr 2022 12:50:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651063829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZQQqaPRbsFfCKJpWYQh0cRWm/Fo8ZokysMd4UlgAZT8=; b=GmWdolqWt3RN+99/u3gbkkKULy4RxufE3iRnezvQduOFe5tetJnoXX9e/fIjyLw+T5Ybm+ Q5yzR6JFBSTaP5tvOqUfF49stLg/9m7eS8b91RMRCABhRhyzL81uwQEkGMb72A86Ob78Ky IAW13TcZ6BN9DXQ2UoeM5dsBILN4aYEySvUeBYMArzWf19ppVQFCywmgarA2A3INbKHNg4 JnrJUqM3DcO9Jxo+to02n2Mp2SuqGVhKk6H1SIViWSXJlBmRJn7QdE5eypaPDhpiluQ/Pw pp46OVyhhoyerpwinpQ+fd3dcHh/AbFvJiwzU7TC56gr+87dCSqbcr06b5CMYw== 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 79CF423ECE; Wed, 27 Apr 2022 12:50:29 +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 23RCoTS6011720; Wed, 27 Apr 2022 12:50:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23RCoTYW011719; Wed, 27 Apr 2022 12:50:29 GMT (envelope-from git) Date: Wed, 27 Apr 2022 12:50:29 GMT Message-Id: <202204271250.23RCoTYW011719@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: 160e2dbfb48d - stable/13 - pfsync: NULL check before dereference List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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: 160e2dbfb48dcb1d92ef6c66bf106ee5e6d03d0a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651063829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZQQqaPRbsFfCKJpWYQh0cRWm/Fo8ZokysMd4UlgAZT8=; b=YPCspGZjYr+wxefW8XdZwAUXv/QI9OuNYeq79p5QNvx4J6KhykDUOGbI3ur7m89gdB4oTV pKRRSvMBPvTPYCcNhT5a6swo2UaCMfowXExWKtbd/j96WzidDTiPVwWt4UJQKYZPXu83+h uM99gtsYTxYp+57ZmutDpo+i1Go8IfAHDuWaBHZg0raplgULuxlmPnoEmPk1fFS7lodOHP 0qx9MIX7tbtWSgCGTbVZmyhhy6F3Op17SUkKbhZGHdNeWfVl+dgGS47OIqjqSv7hPU6lq2 gyKHt+5w0aXWnEOh+Lffc1ki7b8CFdRrql2CX7/WyECuZJ1/1FQkhmF/9A21CA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651063829; a=rsa-sha256; cv=none; b=WE+M53NCY55Y2sG20dDiAzeeY+CjI1KJSN78shVZS17Nwqlt02BrGjsqIzQAsY/M9JURqb 7sWFyVzW7xlIYvweQ/i1iazFdF7IfdzhzVVny4Qsq4So08SruXBf45KQzYELPSDrLwEQ4L zwWMeSU2zp4OULmyyvqDORrWnqMNMPeAnVf1zs4JAlWOEQxLU5VkJ1drS0TKhOu9hAUEl5 DMOgWThKRCXe+Rx5e4wQ5nVopom1t2VqQw83o4cXP5I2LVmgd/gIW0cjjIVRGtoJVb6YT1 y+eKtasNqT+q1j2nGiqntJSXLhWdX8fMx1bgNn5jxAK7NzDwe+Soh9SMTTmJPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=160e2dbfb48dcb1d92ef6c66bf106ee5e6d03d0a commit 160e2dbfb48dcb1d92ef6c66bf106ee5e6d03d0a Author: Kristof Provost AuthorDate: 2022-04-21 12:40:32 +0000 Commit: Kristof Provost CommitDate: 2022-04-27 06:46:52 +0000 pfsync: NULL check before dereference Move the use of 'sc' to after the NULL check. It's very unlikely that we'd actually hit this, but Coverity is correct that it's not a good idea to dereference the pointer and only then NULL check it. Reported by: Coverity (CID 1398362) MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 43020350635150eeb439c035f608ec9e78ddff8f) --- sys/netpfil/pf/if_pfsync.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index cc3c4ec0217b..11ac0f6951bd 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -1735,7 +1735,7 @@ pfsync_defer(struct pf_kstate *st, struct mbuf *m) { struct pfsync_softc *sc = V_pfsyncif; struct pfsync_deferral *pd; - struct pfsync_bucket *b = pfsync_get_bucket(sc, st); + struct pfsync_bucket *b; if (m->m_flags & (M_BCAST|M_MCAST)) return (0); @@ -1743,6 +1743,8 @@ pfsync_defer(struct pf_kstate *st, struct mbuf *m) if (sc == NULL) return (0); + b = pfsync_get_bucket(sc, st); + PFSYNC_LOCK(sc); if (!(sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) ||