From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=aZZrwi0u; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id CB04A5A026E for ; Thu, 07 May 2026 01:55:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1778111697; bh=J6cKRmjsk7/FVb7rFliW0y8a2YbPKcTQemTGM+q6tYw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aZZrwi0uRS17UXc3cjqbkKA3S2Yj/cTXsSA4oCPwA9vpKGt65wqMltrfWYQS5VGpr ERWU+2sdZ5oKJHCJiUZ39++fwwa22EmT43LXP3mlSsW3Q3DPnqFWuxHbWZOAqNQNiF BmuWlrg4G2AzY+WBnSbZjT1bTCmJEAwOnstMuazFbXZ07iyo1zLAzFAbqmsRS/SrXE Bcl2T5qySMn4nzKcrYh4KyCSXrt9HAodUxqwYMeT6rf+y3UtH3W0WP8aSlGbMhS/dp NBrZtIeKfLQk9zEonrHCO568DBRdLph1MwJdQLuSaZvuLLhHqmfTag/oPUbXpHCkO3 it9UUV+piXz6Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4g9sgj0pF3z4wHs; Thu, 07 May 2026 09:54:57 +1000 (AEST) Date: Thu, 7 May 2026 09:28:21 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v9 18/23] fwd_rule: Fix static checkers warnings in fwd_rule_add() Message-ID: References: <20260506092241.1607480-1-sbrivio@redhat.com> <20260506092241.1607480-19-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="qiL35NRD0vFdcCSR" Content-Disposition: inline In-Reply-To: <20260506092241.1607480-19-sbrivio@redhat.com> Message-ID-Hash: XSVGO5O5IDNMMFWCZILUNIMYGEWEE4I3 X-Message-ID-Hash: XSVGO5O5IDNMMFWCZILUNIMYGEWEE4I3 X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Jon Maloy , Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --qiL35NRD0vFdcCSR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 06, 2026 at 11:22:36AM +0200, Stefano Brivio wrote: > The new checks are actually sufficient but not enough for Coverity > Scan. Now that fwd->sock_count and new->last are affected or supplied > by clients, we need explicit (albeit redundant) checks on them. >=20 > Signed-off-by: Stefano Brivio Thanks for the extra details. I still think this can probably be done more neatly. but it's good enough for the time being. Reviewed-by: David Gibson > --- > fwd_rule.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) >=20 > diff --git a/fwd_rule.c b/fwd_rule.c > index b55e4df..200f4b5 100644 > --- a/fwd_rule.c > +++ b/fwd_rule.c > @@ -271,13 +271,24 @@ int fwd_rule_add(struct fwd_table *fwd, const struc= t fwd_rule *new) > warn("Too many rules (maximum %d)", ARRAY_SIZE(fwd->rules)); > return -ENOSPC; > } > + > if ((fwd->sock_count + num) > ARRAY_SIZE(fwd->socks)) { > warn("Rules require too many listening sockets (maximum %d)", > ARRAY_SIZE(fwd->socks)); > return -ENOSPC; > } > + /* Redundant (see check just above), to make static checkers happy */ > + if (fwd->sock_count > ARRAY_SIZE(fwd->socks)) > + return -ENOSPC; > =20 > fwd->rulesocks[fwd->count] =3D &fwd->socks[fwd->sock_count]; > + > + /* Redundant, but not for static checkers, that might be missing that > + * due to the check on 'num' above against ARRAY_SIZE(fwd->socks), we > + * have a proper upper bound for new->last in the loop below. > + */ > + if (new->last > ARRAY_SIZE(fwd->socks) + new->first) > + return -ENOSPC; > for (port =3D new->first; port <=3D new->last; port++) > fwd->rulesocks[fwd->count][port - new->first] =3D -1; > =20 > --=20 > 2.43.0 >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --qiL35NRD0vFdcCSR Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmn7zo4ACgkQzQJF27ox 2GcWjxAAgFvaq62nNTXvgDrtttOlTMvgTroso0ox1iiHUoPpfKENkzF1KD5wLia0 +ANv31ALAeqT5MV0a7OXqvFVdegcDj/taHgsnLNZ113vqJgso8lP8dCBrUyczQWb CqgkxjBbKXKr1W4jpaSwxVhrAVY1wLETGtlCTILTqQPZH5kIa/hpgLp1DtAS25fx BvsY9+9lIDDgSbWEuIfEUmWmD1ZYJh3cB/3SZr3sl4UemNIO5/WBIyQZf5wZLfdT rWt/Dbrmo1Gr7HtCV0mPdOPzqU+VL6i1BJPFPz6W+4bZs5dwGe/lGfmT7q6/cc/o +/CTfwaYFCpNmB0IRmpGchxdpEI9dQTJ6xW6Jb24B0PrAxgtTVKJ/LU7B5yB47UZ JwdBnopnbTwWC7nvybQCuisir0ytnR3GMg+Jz2N/mkjznr9hx3Qa9RZ3RXyNe4kZ KHGgdCa+q2L6klMOfrp0WBJLNIeWxhpvjOVpSHfCr8UIUS/9DnTfDdku76B6wF03 3ZrbgqslEmIpPDgZrq0kbjW0zGvWWONwqk4HYsSf5dEvajEpzbm9FoJnLyWd1VMO KQvi3i0RZATi1K7oWgwsm4mLoK0D4mZzQ/OwkPyMuOuKIa8uSLW/Epv2RNRKB0BP 0LJVssY006iEH0RQRaOL3nT/Ja4vbNPuFbSD5n1P7Vvah+YVnD4= =eAaI -----END PGP SIGNATURE----- --qiL35NRD0vFdcCSR--