From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NkBkprLA; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id C25825A0279 for ; Thu, 11 Sep 2025 02:13:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757549588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U6E7HTeNGPMa4b8bwvIi6+p4OoQjtVMsoLzbaSvg2zI=; b=NkBkprLASgrW6P2ap+5Ecz+Ma1H4FrIGh658F+XVHrvuxWWzrYCnnmpdoTSh445uGilb6E iufjqLpIFLXPfRd4X5F8pyMAF/z1Zy7iV+h9/E8MlkqJvZTVQkUvu1YNSSqHqWSmCIi0TP TY9ehZGgOrkpholxKnhK5CUMeBdanyQ= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-183-b8j1ov0fNTy-wNyvGuBTrA-1; Wed, 10 Sep 2025 20:13:07 -0400 X-MC-Unique: b8j1ov0fNTy-wNyvGuBTrA-1 X-Mimecast-MFC-AGG-ID: b8j1ov0fNTy-wNyvGuBTrA_1757549587 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-81b8e3e2a08so13331085a.3 for ; Wed, 10 Sep 2025 17:13:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757549586; x=1758154386; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U6E7HTeNGPMa4b8bwvIi6+p4OoQjtVMsoLzbaSvg2zI=; b=Y1Kkhp236SqRQ7vEITr9G4dToVokwD/ijP4kWRms6ePYtxNTJ8UZTYE3XAkX79nm/K P8MS8tiIMOdy4bwlhMe7mIb/eiqJPebpE7C0oKb65j9/5fxZoBE/C9SNbDjhe9n7RIxz ZvzDDWEairEqMtafsxaA7tKasAHtZsdEB9T3iMAc2xmakgKiK+fCml67Pf/DgqUvdKRm EWsc6KhhdsxXSlrnpOCvXoYbHSxLdwTimpNtZyvsWEy5iTRIrrIuqQ1L5XnRxiWYya4B jqSBO1bYrrBlh7HRao0075Uki8BjZvpLRSAjvLzx7HVi/+4Gsm9Wchbnztke4Mcknck5 12kg== X-Forwarded-Encrypted: i=1; AJvYcCXBLiJynneISvbtMdZigycjJ4hSzIT2/VUpzxEnoNUiuHsHgaBUouY0t5r8fa0Cgp6VnBDPuM85mUc=@passt.top X-Gm-Message-State: AOJu0Yz7c0+wfs6owOpba+R6jqF3O77KYC0wXOwF5gwk4uMIt4kkTiN1 YlHf/wRjoZa0zLETIhKGLYI2nwE2aCNhmSffAj+0/Efhqq2zLUr8QzGfmSmkmbsOs7opc2M7AMB ZH1bJTsVNjFWyAk92qwgVXqbQ2Nc5ffBr6PFHyke5AH7BrhW5sAG07w== X-Gm-Gg: ASbGncuRNOJ8JfquYnMJEtEqXDVNAba/wklRlIuBG6Li1CF1wEbWIJQYzO3ZZ73Vf+k HqT5S8a9SG1bZayBz4pXwZpLRhCV7nSRq0WoWmmoS14XuYSu7KUZ/I5lfP0k8LbScBZm2uvusW1 RVxheOCW6/Ei+rGlUaIq44uab6q3yXQgZz2wQ2xA56KDIXQFksDETIl3m5KM2XO6bedBeiTWOaz XcyAsWCOQUWwv7Zbui1Oz03tRH73s5ewog2Mo7FQ4NqGKenus+gWBBSNPeAX11zTF8BCaHCc8lt 0sl97QVDWkYUFSlsyP/AG2kb9bfDnLI/gZ7vHNFdQn5ZYDc1STIh/R+qvXX3NOIaTxfdc/Bn3GY zjz0P3oABnQ== X-Received: by 2002:a05:620a:4455:b0:815:fa79:a979 with SMTP id af79cd13be357-815fa79a996mr1477539685a.2.1757549586691; Wed, 10 Sep 2025 17:13:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUfVsn9yHafkMLk0bkwQHswbOxf3ZrwT2A9LhQxeEJikmonaTLz7Wb0n1I+LRoWfyHWyz2iA== X-Received: by 2002:a05:620a:4455:b0:815:fa79:a979 with SMTP id af79cd13be357-815fa79a996mr1477537285a.2.1757549586341; Wed, 10 Sep 2025 17:13:06 -0700 (PDT) Received: from ?IPV6:2001:4958:2206:8901:6025:1483:4146:72dd? ([2001:4958:2206:8901:6025:1483:4146:72dd]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4b639dab3f3sm972151cf.34.2025.09.10.17.13.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Sep 2025 17:13:06 -0700 (PDT) Message-ID: <99606601-bd35-4cb0-a241-36128b11205b@redhat.com> Date: Wed, 10 Sep 2025 20:13:05 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 6/8] tcp: Cast operands of sequence comparison macros to uint32_t before using them To: Stefano Brivio , passt-dev@passt.top References: <20250909181655.2990223-1-sbrivio@redhat.com> <20250909181655.2990223-7-sbrivio@redhat.com> From: Jon Maloy In-Reply-To: <20250909181655.2990223-7-sbrivio@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: r3J-7sENwvXZyaMqSF1n2G6GdI4RDGgWU3HWHM7I-7g_1757549587 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: DBYBL4NGD7ALIKVKFDMH7Y66AVCA3DFQ X-Message-ID-Hash: DBYBL4NGD7ALIKVKFDMH7Y66AVCA3DFQ X-MailFrom: jmaloy@redhat.com 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: Paul Holzinger , David Gibson 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: On 2025-09-09 14:16, 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. > > The next patch introduces a ssize_t operand for SEQ_LE, illustrating > the issue. > > Signed-off-by: Stefano Brivio Reviewed-by: Jon Maloy > --- > tcp_internal.h | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/tcp_internal.h b/tcp_internal.h > index d0009f8..ce6fee2 100644 > --- a/tcp_internal.h > +++ b/tcp_internal.h > @@ -21,10 +21,14 @@ > sizeof(struct ipv6hdr), \ > sizeof(uint32_t)) > > -#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) > > #define FIN (1 << 0) > #define SYN (1 << 1)