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=202508 header.b=gZfMJTa4; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 82F8A5A0279 for ; Mon, 01 Sep 2025 06:31:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1756701105; bh=FeyEMrqEDjpjLyO/zXV7KexNNXJ36lL59PXDRmzc30Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gZfMJTa4RpLW8ZYy6FAq0gR++7OL54aiBdJ1yAlKZ82ILyOBOQ10erikthOYv9Q3K ZnOZZOQ7CDroIRA8oRXcMCZ4+59WbC8wVFO2nv/EVhbeCeIjqViF+nVEprojMa8JME 4lj9S5vqVt31hC9voNxcomQtZlu7p3b2P2y/28vMQHlaek1Fcn9PluSfy+8hCVykdk 5dNzfMiGNDubRpKSyXzw5Oco4ZjpBtpBpNDT/1YumkY4iKNMwf59RQis8Z/EEmfS+g xL+Zmdw5FjwUC+xLEVwvm1lPDbGtOtdKqpka08LuR6reiKVqolg6Ynx4xTxUQgsFwi LnhPdphrWMCdQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cFbYY6ppjz4w9b; Mon, 1 Sep 2025 14:31:45 +1000 (AEST) Date: Mon, 1 Sep 2025 14:29:29 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v3 6/7] tcp: Cast operands of sequence comparison macros to uint32_t before using them Message-ID: References: <20250829201132.1561650-1-sbrivio@redhat.com> <20250829201132.1561650-7-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="RAeVgBRWpWriupNa" Content-Disposition: inline In-Reply-To: <20250829201132.1561650-7-sbrivio@redhat.com> Message-ID-Hash: RS25QXHTUI67QNKD2OQS2TFHKGTLAE6B X-Message-ID-Hash: RS25QXHTUI67QNKD2OQS2TFHKGTLAE6B 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 , Paul Holzinger 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: --RAeVgBRWpWriupNa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 29, 2025 at 10:11:31PM +0200, Stefano Brivio wrote: > Otherwise, passing signed types causes automatic promotion of the > result of the subtractions as well, which is not what we want, as > these macros rely on unsigned 32-bit arithmetic. >=20 > The next patch introduces a ssize_t operand for SEQ_LE, illustrating > the issue. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tcp_internal.h | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) >=20 > diff --git a/tcp_internal.h b/tcp_internal.h > index 36c6533..c80ba40 100644 > --- a/tcp_internal.h > +++ b/tcp_internal.h > @@ -18,10 +18,14 @@ > sizeof(struct ipv6hdr), \ > sizeof(uint32_t)) > =20 > -#define SEQ_LE(a, b) ((b) - (a) < MAX_WINDOW) > -#define SEQ_LT(a, b) ((b) - (a) - 1 < MAX_WINDOW) > -#define SEQ_GE(a, b) ((a) - (b) < MAX_WINDOW) > -#define SEQ_GT(a, b) ((a) - (b) - 1 < MAX_WINDOW) > +#define SEQ_LE(a, b) \ > + ((uint32_t)(b) - (uint32_t)(a) < MAX_WINDOW) > +#define SEQ_LT(a, b) \ > + ((uint32_t)(b) - (uint32_t)(a) - 1 < MAX_WINDOW) > +#define SEQ_GE(a, b) \ > + ((uint32_t)(a) - (uint32_t)(b) < MAX_WINDOW) > +#define SEQ_GT(a, b) \ > + ((uint32_t)(a) - (uint32_t)(b) - 1 < MAX_WINDOW) > =20 > #define FIN (1 << 0) > #define SYN (1 << 1) > --=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 --RAeVgBRWpWriupNa Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmi1ISgACgkQzQJF27ox 2Geu/A/9HHrOCM16bXgILHSx519qEby8rJOVts9A0TCxlwGWZSKs1xUTcLtrBOyr 37Zi6UtXpLLHoMkXyoay5o6SaP/DBU4TwxzkriB9C97W03dnRyUqbs+9GGNrx5tX OiSbDKEuaoASc5AIlAcT0Aj4v/v9gw1WrozBrjEHg2+h2nzIw+0tHU9mHg3BvnrP eGjwAXOS5SjxIOaC9uYZrDfJBvStltiPTfU93PtwVpwjLP26mAy586rTxs9gktTc xUbVS1/RVY0tCSr1GdK+FbAOg4H8kNgiqujmMs6TarEP5thKE+Ancw1y1lAtWVlx tXbQsJK0HZJHZYLjXUXMO682qf3aF1VCPPSropb+hmCanN4hsfQnqUNCfR6RzlFl v0EyIfHWRrRRbpLg1RAseuuiiCOARd2HElsjRYGoRKalKUJ4BXmi5v8JDVF8GZPa fLuR9+QGjQSQJzUYfnYSZWMcmK96YJkCP9hvWiikSbNeXL/yCcFZ8GzqjCOGqi8E HxkFpqWqVkn94aYbpSbrB/qg/ybrN0tR8E8W48zvnLSgNAE0gRHMPRkTJIULZxd0 AoxXd42zkiHkB6OyRrv1xBHS8Fbd/k3Gdr0a/eFH9HD+nWCU6ZAPM/1XoxuFlN3q uML8a1yV+1fselp13BWLJbbDTLsbzTAWvRpohKTxvSfSCkVBUhU= =dfa0 -----END PGP SIGNATURE----- --RAeVgBRWpWriupNa--