From nobody Thu Apr 21 16:16:28 2022 X-Original-To: dev-commits-src-main@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 B98F211D2047; Thu, 21 Apr 2022 16:16:29 +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 4KkjMx1yMmz3kgR; Thu, 21 Apr 2022 16:16:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650557789; 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=801FiCqma6LMxKBtKnefeT3xn3mZz18dJkhaeP/e8Ic=; b=meqQtOw/fs1eIdNmqaS4pko7+D16BzIqiFlHevbh0txqOdOvEp2WgacR4jEeSdDiG3TabB Yqhiz45qHC6JDfaM1rErAni04zCis5xUSJm5ZwEVWIhruSMeytU0QBylk+K7S0wMDMzGig +DcL6K8tOV2uARpuPmzSAYLJn7wECdQCZaW/bbJv6h90rGtTDKkPA93W4aF0SX4oKD5SFI N65FL7x0zfSLL8axGQTYeIPVmwd8udNeoqRTOme8zoe3NVZg2Eze0sLhiLl4qwFDcegScV 8CCAIC9NNzOMtRFnnYQw/DNvdyVLOMNS8G9nbVaqr2xdmKxcJSlWRUDEvdGT6g== 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 EA01A3AD8; Thu, 21 Apr 2022 16:16:28 +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 23LGGSF2004071; Thu, 21 Apr 2022 16:16:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23LGGSNa004070; Thu, 21 Apr 2022 16:16:28 GMT (envelope-from git) Date: Thu, 21 Apr 2022 16:16:28 GMT Message-Id: <202204211616.23LGGSNa004070@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: efc64d02a62f - main - pf: counter argument to pfr_pool_get() may never be NULL List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: efc64d02a62f3254ecc0b22fcbcb8f73a079669f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650557789; 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=801FiCqma6LMxKBtKnefeT3xn3mZz18dJkhaeP/e8Ic=; b=gHuJCAhw6OQYvohZE+YtjL5rQW2nQeKVi1Z4784cg33Rqhd4anF+87GZvDELvHaC2/Mfrc SRlvA/A0B2kHozCq73Q0+WKhBtmhCpc2TEnLV1Yx2atgM+toA6wViI5lCZHwyO/zDp5F6+ ogzZq9xjta97u6zfWrE18hrb9bTjNDtBlRGfJCxhKkxHyYiqjAiJ5psQBhEFLWdUQX4OSY Y6u7P8VSO/kdlwNBR1Glni/7aOraQi/aHG4swaEj5/wyvNl2DLelcNNJdWHVepj/JyLg3R uLJtLG8niu2xQzxkI3PSKrvphpq8vTGkcotn2FAH/yO7imSLPZX/8wBmQJTv8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650557789; a=rsa-sha256; cv=none; b=EVRaK0/syVgkXPNJkLLw1GqvGlRD+dtl4PJef3BSOkVi/MFUt3b4Z650Vm+o50zXzSrBE8 w7sDMRum4Xsc9+QkNAig/Io3+3GcRDH56qy+E05KB6RF8W99hsiixV94ZC4Unqo+Qi/r/3 5GMM1Ex71VRla1oTpSUnqNhnewE66xyGaiF8Iu4BkxCqVxG6cudhDKTe1UcHbFzpSa4XC0 vhLeJKnPn4zN5WTXP239Dceprgp0GBDFcmVsYzKuzlaaff+YLI+dQz/d1nANEOeAb21UIt yStz4b+M32U2LyJqF2lnJcwfpNrMTi9+ONtgbO+9hLMZf72WaKvkYm2vYUmw1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=efc64d02a62f3254ecc0b22fcbcb8f73a079669f commit efc64d02a62f3254ecc0b22fcbcb8f73a079669f Author: Kristof Provost AuthorDate: 2022-04-21 12:53:05 +0000 Commit: Kristof Provost CommitDate: 2022-04-21 15:59:45 +0000 pf: counter argument to pfr_pool_get() may never be NULL Coverity points out that if counter was NULL when passed to pfr_pool_get() we could potentially end up dereferencing it. Happily all users of the function pass a non-NULL pointer. Enforce this by assertion and remove the pointless NULL check. Reported by: Coverity (CID 273309) MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf_table.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/pf/pf_table.c b/sys/netpfil/pf/pf_table.c index 9b048d899810..ea37b077c651 100644 --- a/sys/netpfil/pf/pf_table.c +++ b/sys/netpfil/pf/pf_table.c @@ -2249,6 +2249,7 @@ pfr_pool_get(struct pfr_ktable *kt, int *pidx, struct pf_addr *counter, int idx = -1, use_counter = 0; MPASS(pidx != NULL); + MPASS(counter != NULL); switch (af) { case AF_INET: @@ -2268,7 +2269,7 @@ pfr_pool_get(struct pfr_ktable *kt, int *pidx, struct pf_addr *counter, return (-1); idx = *pidx; - if (counter != NULL && idx >= 0) + if (idx >= 0) use_counter = 1; if (idx < 0) idx = 0;