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]
Date:	Thu, 21 Jun 2012 14:53:57 +0800
From:	Li Yu <raise.sail@...il.com>
To:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [PATCH] fix potential 32bits truncation for result of timespec/timeval_compare()


The tv_nsec field of timespec struct and tv_usec field of timeval
struct are defined as long type, but two comparison API return int
type of result value, this may result in wrong result.

This simple patch fixed it, thanks

Signed-off-by: Li Yu <bingtian.ly@...bao.com>

diff --git a/include/linux/time.h b/include/linux/time.h
index 179f4d6..be381f6 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -53,7 +53,7 @@ static inline int timespec_equal(const struct timespec *a,
  * lhs == rhs: return 0
  * lhs > rhs:  return >0
  */
-static inline int timespec_compare(const struct timespec *lhs, const
struct timespec *rhs)
+static inline long timespec_compare(const struct timespec *lhs, const
struct timespec *rhs)
 {
 	if (lhs->tv_sec < rhs->tv_sec)
 		return -1;
@@ -62,7 +62,7 @@ static inline int timespec_compare(const struct
timespec *lhs, const struct time
 	return lhs->tv_nsec - rhs->tv_nsec;
 }

-static inline int timeval_compare(const struct timeval *lhs, const
struct timeval *rhs)
+static inline long timeval_compare(const struct timeval *lhs, const
struct timeval *rhs)
 {
 	if (lhs->tv_sec < rhs->tv_sec)
 		return -1;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ