stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Harsh Shandilya <msfjarvis@gmail.com>
Cc: stable@vger.kernel.org, Wang YanQing <udknight@gmail.com>,
	Prarit Bhargava <prarit@redhat.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	John Stultz <john.stultz@linaro.org>
Subject: Re: [PATCH 1/1] time: Always make sure wall_to_monotonic isn't positive
Date: Mon, 27 Nov 2017 17:41:17 +0100	[thread overview]
Message-ID: <20171127164117.GA2998@kroah.com> (raw)
In-Reply-To: <20171126072511.7553-1-msfjarvis@gmail.com>

On Sun, Nov 26, 2017 at 12:55:11PM +0530, Harsh Shandilya wrote:
> From: Wang YanQing <udknight@gmail.com>
> 
> commit e1d7ba8735551ed79c7a0463a042353574b96da3 upstream.
> 
> Two issues were found on an IMX6 development board without an
> enabled RTC device(resulting in the boot time and monotonic
> time being initialized to 0).
> 
> Issue 1:exportfs -a generate:
>        "exportfs: /opt/nfs/arm does not support NFS export"
> Issue 2:cat /proc/stat:
>        "btime 4294967236"
> 
> The same issues can be reproduced on x86 after running the
> following code:
> 	int main(void)
> 	{
> 	    struct timeval val;
> 	    int ret;
> 
> 	    val.tv_sec = 0;
> 	    val.tv_usec = 0;
> 	    ret = settimeofday(&val, NULL);
> 	    return 0;
> 	}
> 
> Two issues are different symptoms of same problem:
> The reason is a positive wall_to_monotonic pushes boot time back
> to the time before Epoch, and getboottime will return negative
> value.
> 
> In symptom 1:
>           negative boot time cause get_expiry() to overflow time_t
>           when input expire time is 2147483647, then cache_flush()
>           always clears entries just added in ip_map_parse.
> In symptom 2:
>           show_stat() uses "unsigned long" to print negative btime
>           value returned by getboottime.
> 
> This patch fix the problem by prohibiting time from being set to a value which
> would cause a negative boot time. As a result one can't set the CLOCK_REALTIME
> time prior to (1970 + system uptime).
> 
> Change-Id: I19acf5df5cc34dd388de0dc633723fe73adc077e
> Cc: Prarit Bhargava <prarit@redhat.com>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Wang YanQing <udknight@gmail.com>
> [jstultz: reworded commit message]
> [msfjarvis: Backport to 3.18 as we are missing the do_settimeofday64
> function the upstream commit patches, so we apply the changes to
> do_settimeofday]
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
> ---
>  kernel/time/timekeeping.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)

Thanks for this, now queued up.

greg k-h

      reply	other threads:[~2017-11-27 16:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-26  7:25 [PATCH 1/1] time: Always make sure wall_to_monotonic isn't positive Harsh Shandilya
2017-11-27 16:41 ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171127164117.GA2998@kroah.com \
    --to=greg@kroah.com \
    --cc=john.stultz@linaro.org \
    --cc=mingo@kernel.org \
    --cc=msfjarvis@gmail.com \
    --cc=prarit@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=udknight@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).