All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <johnstul@us.ibm.com>
To: Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org,
	Anton Vorontsov <cbouatmailru@gmail.com>,
	Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2] pstore/ram: no timekeeping calls when unavailable
Date: Fri, 09 Nov 2012 16:56:30 -0800	[thread overview]
Message-ID: <509DA63E.7070500@us.ibm.com> (raw)
In-Reply-To: <20121105220059.GA6379@www.outflux.net>

On 11/05/2012 02:00 PM, Kees Cook wrote:
> We must not call timekeeping functions unless they are available. If we dump
> before they have resumed, avoid a WARN_ON by setting the timestamp to 0.
>
> Since the "ram" pstore driver can be a module, we must have
> timekeeping_suspended exported.
>
> Reported-by: Doug Anderson <dianders@chromium.org>
> Cc: Anton Vorontsov <cbouatmailru@gmail.com>
> Cc: John Stultz <johnstul@us.ibm.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> v2:
>   - export needed for timekeeping_suspended (thanks to Fengguang Wu).
> ---
>   fs/pstore/ram.c           |    8 +++++++-
>   kernel/time/timekeeping.c |    1 +
>   2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> index 1a4f6da..6d014e0 100644
> --- a/fs/pstore/ram.c
> +++ b/fs/pstore/ram.c
> @@ -171,7 +171,13 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
>   	struct timeval timestamp;
>   	size_t len;
>
> -	do_gettimeofday(&timestamp);
> +	/* Handle dumping before timekeeping has resumed. */
> +	if (unlikely(timekeeping_suspended)) {
> +		timestamp.tv_sec = 0;
> +		timestamp.tv_usec = 0;
> +	} else
> +		do_gettimeofday(&timestamp);
> +
Would nulling out the timestamp be better done in do_gettimeofday()?  
That way we don't have to export timekeeping internals and users would 
get something more sane for this corner case.

thanks
-john



  reply	other threads:[~2012-11-10  2:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05 22:00 [PATCH v2] pstore/ram: no timekeeping calls when unavailable Kees Cook
2012-11-10  0:56 ` John Stultz [this message]
2012-11-10  1:26   ` Kees Cook
2012-11-17  2:53     ` Anton Vorontsov
2012-11-17  3:16       ` John Stultz
2012-11-18 20:09         ` Kees Cook
2012-11-19 17:23           ` John Stultz
2012-11-19 17:45             ` Kees Cook
2012-11-19 18:57               ` John Stultz
2012-11-19 21:42                 ` Kees Cook

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=509DA63E.7070500@us.ibm.com \
    --to=johnstul@us.ibm.com \
    --cc=cbouatmailru@gmail.com \
    --cc=ccross@android.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.