* [PATCH RESEND] net: ipv4: Fix truncated timestamp returned by inet_current_timestamp()
@ 2016-03-22 1:21 Deepa Dinamani
2016-03-22 2:57 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Deepa Dinamani @ 2016-03-22 1:21 UTC (permalink / raw)
To: netdev, y2038
Cc: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
James Morris, Patrick McHardy, Arnd Bergmann
The millisecond timestamps returned by the function is
converted to network byte order by making a call to htons().
htons() only returns __be16 while __be32 is required here.
This was identified by the sparse warning from the buildbot:
net/ipv4/af_inet.c:1405:16: sparse: incorrect type in return
expression (different base types)
net/ipv4/af_inet.c:1405:16: expected restricted __be32
net/ipv4/af_inet.c:1405:16: got restricted __be16 [usertype] <noident>
Change the function to use htonl() to return the correct __be32 type
instead so that the millisecond value doesn't get truncated.
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: James Morris <jmorris@namei.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Fixes: 822c868532ca ("net: ipv4: Convert IP network timestamps to be y2038 safe")
Reported-by: Fengguang Wu <fengguang.wu@intel.com> [0-day test robot]
---
Fixed the y2038 list email address.
net/ipv4/af_inet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 0cc923f..5fab7e3 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1402,7 +1402,7 @@ __be32 inet_current_timestamp(void)
msecs += (u32)ts.tv_nsec / NSEC_PER_MSEC;
/* Convert to network byte order. */
- return htons(msecs);
+ return htonl(msecs);
}
EXPORT_SYMBOL(inet_current_timestamp);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH RESEND] net: ipv4: Fix truncated timestamp returned by inet_current_timestamp()
2016-03-22 1:21 [PATCH RESEND] net: ipv4: Fix truncated timestamp returned by inet_current_timestamp() Deepa Dinamani
@ 2016-03-22 2:57 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-03-22 2:57 UTC (permalink / raw)
To: deepa.kernel; +Cc: netdev, y2038, kuznet, yoshfuji, jmorris, kaber, arnd
From: Deepa Dinamani <deepa.kernel@gmail.com>
Date: Mon, 21 Mar 2016 18:21:26 -0700
> The millisecond timestamps returned by the function is
> converted to network byte order by making a call to htons().
> htons() only returns __be16 while __be32 is required here.
>
> This was identified by the sparse warning from the buildbot:
> net/ipv4/af_inet.c:1405:16: sparse: incorrect type in return
> expression (different base types)
> net/ipv4/af_inet.c:1405:16: expected restricted __be32
> net/ipv4/af_inet.c:1405:16: got restricted __be16 [usertype] <noident>
>
> Change the function to use htonl() to return the correct __be32 type
> instead so that the millisecond value doesn't get truncated.
>
> Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
> Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
> Cc: James Morris <jmorris@namei.org>
> Cc: Patrick McHardy <kaber@trash.net>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Fixes: 822c868532ca ("net: ipv4: Convert IP network timestamps to be y2038 safe")
> Reported-by: Fengguang Wu <fengguang.wu@intel.com> [0-day test robot]
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-22 2:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-22 1:21 [PATCH RESEND] net: ipv4: Fix truncated timestamp returned by inet_current_timestamp() Deepa Dinamani
2016-03-22 2:57 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).