lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20071102202131.30769.8429.stgit@manray.1015granger.net>
Date:	Fri, 02 Nov 2007 16:21:31 -0400
From:	Chuck Lever <chuck.lever@...cle.com>
To:	netdev@...r.kernel.org
Subject: [PATCH] NET: Make ts_recent_stamp and tw_ts_recent_stamp unsigned long

The get_seconds() function now returns an unsigned long.  K&R states
that comparing a signed long with an unsigned long implicitly converts
the signed long to unsigned long [1].

Thus ts_recent_stamp and tw_ts_recent_stamp are already implicitly
converted to unsigned long in every comparison with get_seconds() or
other unsigned longs (such as tcp_ts_stamp).

Code review shows that ts_recent_stamp is compared only to get_seconds() or
zero.  It is set only to zero, the return value of get_seconds(), or the
value of tw_ts_recent_stamp.  Thus changing ts_recent_stamp to an unsigned
long does not change current behavior in any way, and eliminates implicit
type conversions in several places, including some comparisons.

Review shows that tw_ts_recent_stamp is set only to the return value of
get_seconds() or to the value of ts_recent_stamp.  It is compared to the
return value of get_seconds(), the value of tcp_ts_stamp (an unsigned
long), one, or zero.  Thus changing tw_ts_recent_stamp to an unsigned long
also does not change current behavior in any way.

It might improve matters even further if these open-coded timestamp
comparisons were replaced with something similar to the time_after_eq
macro from include/linux/jiffies.h.

[1] Kernighan & Ritchie, "The C Programming Language", 2nd. ed., appendix
A, sec. 6.5.

Signed-off-by: Chuck Lever <chuck.lever@...cle.com>
Cc: netdev@...r.kernel.org
---

 include/linux/tcp.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index bac17c5..0122374 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -206,7 +206,7 @@ struct tcp_sack_block {
 
 struct tcp_options_received {
 /*	PAWS/RTTM data	*/
-	long	ts_recent_stamp;/* Time we stored ts_recent (for aging) */
+	unsigned long ts_recent_stamp;/* Time we stored ts_recent (for aging) */
 	u32	ts_recent;	/* Time stamp to echo next		*/
 	u32	rcv_tsval;	/* Time stamp value             	*/
 	u32	rcv_tsecr;	/* Time stamp echo reply        	*/
@@ -419,7 +419,7 @@ struct tcp_timewait_sock {
 	u32			  tw_snd_nxt;
 	u32			  tw_rcv_wnd;
 	u32			  tw_ts_recent;
-	long			  tw_ts_recent_stamp;
+	unsigned long		  tw_ts_recent_stamp;
 #ifdef CONFIG_TCP_MD5SIG
 	u16			  tw_md5_keylen;
 	u8			  tw_md5_key[TCP_MD5SIG_MAXKEYLEN];

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ