From nobody Wed Apr 27 12:50:30 2022 X-Original-To: dev-commits-src-branches@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 0E8B41AAAB19; Wed, 27 Apr 2022 12:50:32 +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 4KpJWV5PZVz4djv; Wed, 27 Apr 2022 12:50:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651063831; 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=vDtX1ztcVLqGbXm4yZOCYL5Clz9TtNUzrYKLkUgzzrE=; b=F7a/CFDEfhnA8KBEX9YF4jRWhYAgJET4HitVHBrth2XHdhI5OaGMVfTmB57NHbjPDZNEla Yt2P5dR9oJFWXj15Zv8v2F1JwALxPzJH8osGH7oCSKL8rgaM8fjfBklqxF2a/gy610nz3v 6oX9wlWKzA7K+GA49Oqv6xeJM+D4lUriyM0Xb/O5cxx8yqZu1Uw19c9noW9qMlHoMaDlmM nXOyfO/I7Dap8oiE1o7Jvt4MgIESDMeUfZ3/g/BPaN6JQtbzqx19UlBZbihesrMmGF1Fmi Y3SJiqxFIQK8ZJw9BChQeHrcrzxXmuT1PU0CCT9lRiD37WlmaOnvu2PtglOw7Q== 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 723AA23D7B; Wed, 27 Apr 2022 12:50:30 +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 23RCoUpc011751; Wed, 27 Apr 2022 12:50:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23RCoUfn011750; Wed, 27 Apr 2022 12:50:30 GMT (envelope-from git) Date: Wed, 27 Apr 2022 12:50:30 GMT Message-Id: <202204271250.23RCoUfn011750@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: f3b722fed330 - stable/12 - pfsync: NULL check before dereference List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/12 X-Git-Reftype: branch X-Git-Commit: f3b722fed330ee3a08a21947d6b4cf2fb70cc562 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651063831; 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=vDtX1ztcVLqGbXm4yZOCYL5Clz9TtNUzrYKLkUgzzrE=; b=mYf2BslDru6wRXlnUiPue+tESRLuor1sWDFyVn+mqOmlCAFloXf/Au38+u5ARjL/74953J vhTdIgK11Ogyy+3VQ8PuQw1AhvSCSCzjjgoaQ2OWfo1nKxtT1TDetSvk9O5rlZCNaCTeTK 9Epi3Frmz0uwUNidy1yU+V+FhlWKWpSHmZsd03fPOmCEMq/z9pHdXHPBhA4E6XC79YxO9o aJAoTR+9z8vRhqDqfWbWO8kmuOMLECQ/x+q/QSh4RmK/td739ik8mr7bj9IQOKUqWX++D6 aqCG+It9Wl7yL56yvVy9BSwW7avO/sDuCLU9P7kUofQ+uu3K4ILHI6aojILAmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651063831; a=rsa-sha256; cv=none; b=fMOqdyk//BNzm4+uS1Dinj50TH3ohAtYinvm6KLcQpZBB3QJbgDIsX62FtNLRSulZ8Um7O okvQu0HjxQAG8rTVwUoERTYXQRQqMH/m65/ZnxkP4ILEB0IOJRkw/87Jg4BTUKW/4PgsCg NqWbWlUuTxn68k1yIM2nyJP1K9zhxLxNLEsSBR62VVWYPdKiEgsngrQFJvICooSdxk9N4H E2QjuwWLlVVcqrR+AmcZCY/gseExzcTd4DftpXdIy8+sjgRTRFFPITjHWBAUu5BTfvi3iV CzvAN0RWGAdnnRZCKRCsiS0tb6iqR+bBcuIF0CJhDLjwW5hLRNseeKmKTSnlVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f3b722fed330ee3a08a21947d6b4cf2fb70cc562 commit f3b722fed330ee3a08a21947d6b4cf2fb70cc562 Author: Kristof Provost AuthorDate: 2022-04-21 12:40:32 +0000 Commit: Kristof Provost CommitDate: 2022-04-27 06:49:25 +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 cc053b53204a..470c2f176328 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -1737,7 +1737,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); @@ -1745,6 +1745,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) ||