From patchwork Thu Feb 25 07:07:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 587939 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7C840140328 for ; Thu, 25 Feb 2016 18:09:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=T9DHhCjd; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759389AbcBYHJW (ORCPT ); Thu, 25 Feb 2016 02:09:22 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35710 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759377AbcBYHJU (ORCPT ); Thu, 25 Feb 2016 02:09:20 -0500 Received: by mail-pf0-f194.google.com with SMTP id w128so2336199pfb.2 for ; Wed, 24 Feb 2016 23:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dBR+iOhYJJxqmrjuqal/mV5/58vBZsCUPv4rEHQIqYw=; b=T9DHhCjdH3UuRHFPXPXLgi6kG5AQ3pCuTW0ZDLDHfCq4xJoNV+Oebjh+Y8ldWjeH75 WNPjcLPhkgIeZO7ayKr8iw+qyCp5/eTNFw/9b35QMq8prh6O8QhyVQUggDYqfyaPCo+O +HT3ZZw7jZ9WZ1g3Lio+DbLtuIB2Gzowe1w0HP9IcAELGX+s7KSO6QP9LO3oQxrT4rUg yQm2iGe+isKiJqXia0PnzdToWIm3aGSRCfEAmRvBEhwNOnoCWEVYxyHUYBktXVV4OQ8c qVpqesTFW9OT0qDPzDGUMcZsehlRtkcXN9Irx7PcTNS4In0J/SkEyDN5Ff5dCKRFfz18 +EqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dBR+iOhYJJxqmrjuqal/mV5/58vBZsCUPv4rEHQIqYw=; b=bJEhhNUe+my9PEUVBw3UUwqHiE5mP1OR2yUZKm1vrj0y/p42JSkaYqKCajn8DHBmlG dkAzF96f6QVp8eicRu0NTfdPPdO6cqvAzQGvChABh/hoVx0p51IkxhYCPJw8KRrc3Gy9 wob6+T0Ep3Gc1hXk52Hl+R/YUPyz/mM2o8jnaM0Gx2AtjHSFfbADAN2sVz6WdopMSzpc S1guKAnYeAmF2CqrLgbck4fjcB+VnO6PJ+p54jy1zD6889YZ6Qs5u2a0JRybSQ5M2yZa gpqXTcAc68NCKD8GPkA+2zQbxm8oJOs9u+vl+MffU22igRXUNXZ5g61a4e5Ka/tg+Foy aIlA== X-Gm-Message-State: AG10YOSW6ScD2ibGetreSU5grfa3PvvmvEouAyjiyqSiwLdgojbgaCD8Tbia3tClEtEUxQ== X-Received: by 10.98.76.194 with SMTP id e63mr60874718pfj.9.1456384159773; Wed, 24 Feb 2016 23:09:19 -0800 (PST) Received: from localhost.localdomain ([106.51.31.207]) by smtp.gmail.com with ESMTPSA id 19sm9536062pfb.64.2016.02.24.23.08.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Feb 2016 23:09:19 -0800 (PST) From: Deepa Dinamani To: netdev@vger.kernel.org, y2038@lists.linaro.org Cc: arnd@arndb.de, "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy Subject: [PATCH 2/4] net: ipv4: Use y2038 safe functions and data structures Date: Wed, 24 Feb 2016 23:07:09 -0800 Message-Id: <1456384031-29244-3-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456384031-29244-1-git-send-email-deepa.kernel@gmail.com> References: <1456384031-29244-1-git-send-email-deepa.kernel@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ICMP timestamp messages and IP source route options require timestamps to be in milliseconds modulo 24 hours from midnight UT format. Timestamps are calculated from realtime by making a call to getnstimeofday() which uses struct timespec. timespec is not y2038 safe. Replace the above calls with y2038 safe current_nw_time() to obtain network timestamps which uses y2038 safe struct timespec64. Signed-off-by: Deepa Dinamani Cc: "David S. Miller" Cc: Alexey Kuznetsov Cc: James Morris Cc: Hideaki YOSHIFUJI Cc: Patrick McHardy Reviewed-by: Arnd Bergmann --- net/ipv4/icmp.c | 5 +---- net/ipv4/ip_options.c | 13 +++++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 36e2697..e43dfa3 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -931,7 +931,6 @@ static bool icmp_echo(struct sk_buff *skb) */ static bool icmp_timestamp(struct sk_buff *skb) { - struct timespec tv; struct icmp_bxm icmp_param; /* * Too short. @@ -942,9 +941,7 @@ static bool icmp_timestamp(struct sk_buff *skb) /* * Fill in the current time as ms since midnight UT: */ - getnstimeofday(&tv); - icmp_param.data.times[1] = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + - tv.tv_nsec / NSEC_PER_MSEC); + icmp_param.data.times[1] = current_nw_timestamp(); icmp_param.data.times[2] = icmp_param.data.times[1]; if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4)) BUG(); diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index bd24679..6958e7c 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -58,10 +58,8 @@ void ip_options_build(struct sk_buff *skb, struct ip_options *opt, if (opt->ts_needaddr) ip_rt_get_source(iph+opt->ts+iph[opt->ts+2]-9, skb, rt); if (opt->ts_needtime) { - struct timespec tv; __be32 midtime; - getnstimeofday(&tv); - midtime = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC); + midtime = current_nw_timestamp(); memcpy(iph+opt->ts+iph[opt->ts+2]-5, &midtime, 4); } return; @@ -415,11 +413,10 @@ int ip_options_compile(struct net *net, break; } if (timeptr) { - struct timespec tv; - u32 midtime; - getnstimeofday(&tv); - midtime = (tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC; - put_unaligned_be32(midtime, timeptr); + __be32 midtime; + + midtime = current_nw_timestamp(); + memcpy(timeptr, &midtime, 4); opt->is_changed = 1; } } else if ((optptr[3]&0xF) != IPOPT_TS_PRESPEC) {