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 7F9D21AAA8E2; 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 4KpJWW00KWz4dZc; 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=jkXwHcSDGFuuzH65JAAwkeIU27+rpB78R/RWUwGbKWE=; b=wzwF+Ic2FZHvcsWXAwwo1Jlr9c6uZoxvqQ3w+ln8A5YEBQFigrzF9AFnHSh3rbKJjDrNcB MaNxEoWhIhLX+TcAahgXMZ0RMbIzIcl5OaZ9orNx0U2rt+XGPXLhVkKRt0fj+bHp3IvvO/ lQ6mc9WjbW0+n5a2yK3Ur0L16auprgIxYsQFLFKqGtpY1mufGf/2FahTrPgT2MALQNhavd Hf4Bb80vN1/nHxVvHYLLadG0J1U0t9nFd1n+f7ZXXHJdRyxj43gqfp6klhCHfwDNbm2LXl dBl3f1rm4z9Fz88xu6XN1mJaCSlfBWSfDZlXeCif85VyA8CpBffaNmELSwhQEA== 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 9AF77241B7; 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 23RCoU9n011775; 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 23RCoUUB011774; Wed, 27 Apr 2022 12:50:30 GMT (envelope-from git) Date: Wed, 27 Apr 2022 12:50:30 GMT Message-Id: <202204271250.23RCoUUB011774@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: a99ef04e0659 - stable/13 - pf: counter argument to pfr_pool_get() may never be NULL 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/13 X-Git-Reftype: branch X-Git-Commit: a99ef04e0659db80bcf85074c4d37c029f292fe2 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=jkXwHcSDGFuuzH65JAAwkeIU27+rpB78R/RWUwGbKWE=; b=JbO2gctwQ8X0eNQqa7KrHZ/U3jCbAzDlIDEO/nVV6jd4JqqBODgk/U8guhbZ0N+P+4+fIs 2luDAP8Ef7JarfTGBw0dvMsQn08JX2jRTCqeskoLdVwB0KT6tGd/Gpek34Jy7cS4EswMKO qeDz6JbvoIqQz6y9GXU55uNCHSzh7Dhr3OIgbNYJ7chGojmZNSwSVuUZMsjgym02LJwQFP HQCLduSX4mu+JtYOJzcm5Voo9/CQt0YmLHaJqWfB92xiyLbqaF7iaiS42AbkhGY+OrxLbU B5LaQ1bvS4dZTecF8LEJ1brN8tcLTZevkO2t5cG+whvdjPShklEG/a54gzmWwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651063831; a=rsa-sha256; cv=none; b=IXmUY/JXbPNpl3W4YUTwX+twpI94usTQiwuZT/yyIn7b4kv8DDnGp3psjIERPxFblDWtQ8 t+Rf1jG4Hk2HPNfVTKABOuAOgkN0IIMcjBJwfsQCOk5lblfHPmuj8k4Tr9QwNrYb0Gwqjz k0zgtf1CquUpdvmOXBFm/YtN4kp9CdpWUlZOXRV0RY2vpf70gXMDqc6WG2Jk8XzItqeDxC o9d7OeLGlHOtwJ9qy6VTs4MyLgjBA4tKoH8WiK27+9L9GjcVQelP4k66/rs9E4A9WY+Ysq hwvlMVrumeWK6jWBsdjbnE0cVzuf+93w7VT6g2IpB+QDr0lLkKYuXTV+4WtE9w== 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=a99ef04e0659db80bcf85074c4d37c029f292fe2 commit a99ef04e0659db80bcf85074c4d37c029f292fe2 Author: Kristof Provost AuthorDate: 2022-04-21 12:53:05 +0000 Commit: Kristof Provost CommitDate: 2022-04-27 06:46:55 +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") (cherry picked from commit efc64d02a62f3254ecc0b22fcbcb8f73a079669f) --- 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 a2afd5c24cff..42cd633f8411 100644 --- a/sys/netpfil/pf/pf_table.c +++ b/sys/netpfil/pf/pf_table.c @@ -2211,6 +2211,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: @@ -2230,7 +2231,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;