linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-arch@vger.kernel.org,
	"Joseph S. Myers" <joseph@codesourcery.com>,
	John Stultz <john.stultz@linaro.org>,
	Christoph Hellwig <hch@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	lftan@altera.com, "H. Peter Anvin" <hpa@zytor.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>
Subject: Re: [RFC 09/32] fs/pstore: convert to struct inode_time
Date: Fri, 30 May 2014 14:14:39 -0700	[thread overview]
Message-ID: <CAGXu5jLwmhLEqBDToE886=9c70AH7J6_aVqKTcH-KUX2ywzRbQ@mail.gmail.com> (raw)
In-Reply-To: <1401480116-1973111-10-git-send-email-arnd@arndb.de>

On Fri, May 30, 2014 at 1:01 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> pstore uses timestamps encoded in a string as seconds, but on 32-bit systems
> cannot go beyond year 2038 because of the limits of struct timespec.
>
> This converts the pstore code to use the new struct inode_time for timestamps.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Anton Vorontsov <anton@enomsg.org>
> Cc: Colin Cross <ccross@android.com>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Tony Luck <tony.luck@intel.com>

I don't see why you don't want to support making Linux work as a time
machine to visit the 70s! ;)

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  drivers/firmware/efi/efi-pstore.c | 28 ++++++++++++++--------------
>  fs/pstore/inode.c                 |  2 +-
>  fs/pstore/internal.h              |  2 +-
>  fs/pstore/platform.c              |  2 +-
>  fs/pstore/ram.c                   | 18 ++++++++++--------
>  include/linux/pstore.h            |  4 ++--
>  6 files changed, 29 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
> index 4b9dc83..a1e4153 100644
> --- a/drivers/firmware/efi/efi-pstore.c
> +++ b/drivers/firmware/efi/efi-pstore.c
> @@ -32,7 +32,7 @@ struct pstore_read_data {
>         u64 *id;
>         enum pstore_type_id *type;
>         int *count;
> -       struct timespec *timespec;
> +       struct inode_time *inode_time;
>         bool *compressed;
>         char **buf;
>  };
> @@ -63,8 +63,8 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
>                    cb_data->type, &part, &cnt, &time, &data_type) == 5) {
>                 *cb_data->id = generic_id(time, part, cnt);
>                 *cb_data->count = cnt;
> -               cb_data->timespec->tv_sec = time;
> -               cb_data->timespec->tv_nsec = 0;
> +               cb_data->inode_time->tv_sec = time;
> +               cb_data->inode_time->tv_nsec = 0;
>                 if (data_type == 'C')
>                         *cb_data->compressed = true;
>                 else
> @@ -73,8 +73,8 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
>                    cb_data->type, &part, &cnt, &time) == 4) {
>                 *cb_data->id = generic_id(time, part, cnt);
>                 *cb_data->count = cnt;
> -               cb_data->timespec->tv_sec = time;
> -               cb_data->timespec->tv_nsec = 0;
> +               cb_data->inode_time->tv_sec = time;
> +               cb_data->inode_time->tv_nsec = 0;
>                 *cb_data->compressed = false;
>         } else if (sscanf(name, "dump-type%u-%u-%lu",
>                           cb_data->type, &part, &time) == 3) {
> @@ -85,8 +85,8 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
>                  */
>                 *cb_data->id = generic_id(time, part, 0);
>                 *cb_data->count = 0;
> -               cb_data->timespec->tv_sec = time;
> -               cb_data->timespec->tv_nsec = 0;
> +               cb_data->inode_time->tv_sec = time;
> +               cb_data->inode_time->tv_nsec = 0;
>                 *cb_data->compressed = false;
>         } else
>                 return 0;
> @@ -208,7 +208,7 @@ static int efi_pstore_sysfs_entry_iter(void *data, struct efivar_entry **pos)
>   *           and pstore will stop reading entry.
>   */
>  static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
> -                              int *count, struct timespec *timespec,
> +                              int *count, struct inode_time *inode_time,
>                                char **buf, bool *compressed,
>                                struct pstore_info *psi)
>  {
> @@ -218,7 +218,7 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
>         data.id = id;
>         data.type = type;
>         data.count = count;
> -       data.timespec = timespec;
> +       data.inode_time = inode_time;
>         data.compressed = compressed;
>         data.buf = buf;
>
> @@ -266,7 +266,7 @@ struct pstore_erase_data {
>         u64 id;
>         enum pstore_type_id type;
>         int count;
> -       struct timespec time;
> +       struct inode_time time;
>         efi_char16_t *name;
>  };
>
> @@ -292,8 +292,8 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data)
>                  * Check if an old format, which doesn't support
>                  * holding multiple logs, remains.
>                  */
> -               sprintf(name_old, "dump-type%u-%u-%lu", ed->type,
> -                       (unsigned int)ed->id, ed->time.tv_sec);
> +               sprintf(name_old, "dump-type%u-%u-%llu", ed->type,
> +                       (unsigned int)ed->id, (u64)ed->time.tv_sec);
>
>                 for (i = 0; i < DUMP_NAME_LEN; i++)
>                         efi_name_old[i] = name_old[i];
> @@ -319,7 +319,7 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data)
>  }
>
>  static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
> -                           struct timespec time, struct pstore_info *psi)
> +                           struct inode_time time, struct pstore_info *psi)
>  {
>         struct pstore_erase_data edata;
>         struct efivar_entry *entry = NULL;
> @@ -330,7 +330,7 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
>
>         do_div(id, 1000);
>         part = do_div(id, 100);
> -       sprintf(name, "dump-type%u-%u-%d-%lu", type, part, count, time.tv_sec);
> +       sprintf(name, "dump-type%u-%u-%d-%llu", type, part, count, (u64)time.tv_sec);
>
>         for (i = 0; i < DUMP_NAME_LEN; i++)
>                 efi_name[i] = name[i];
> diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
> index 192297b..6f3925f 100644
> --- a/fs/pstore/inode.c
> +++ b/fs/pstore/inode.c
> @@ -277,7 +277,7 @@ int pstore_is_mounted(void)
>   */
>  int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
>                   char *data, bool compressed, size_t size,
> -                 struct timespec time, struct pstore_info *psi)
> +                 struct inode_time time, struct pstore_info *psi)
>  {
>         struct dentry           *root = pstore_sb->s_root;
>         struct dentry           *dentry;
> diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
> index 3b3d305..eb9c4eb 100644
> --- a/fs/pstore/internal.h
> +++ b/fs/pstore/internal.h
> @@ -51,7 +51,7 @@ extern void   pstore_set_kmsg_bytes(int);
>  extern void    pstore_get_records(int);
>  extern int     pstore_mkfile(enum pstore_type_id, char *psname, u64 id,
>                               int count, char *data, bool compressed,
> -                             size_t size, struct timespec time,
> +                             size_t size, struct inode_time time,
>                               struct pstore_info *psi);
>  extern int     pstore_is_mounted(void);
>
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index 0a9b72c..06f2628 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -475,7 +475,7 @@ void pstore_get_records(int quiet)
>         u64                     id;
>         int                     count;
>         enum pstore_type_id     type;
> -       struct timespec         time;
> +       struct inode_time       time;
>         int                     failed = 0, rc;
>         bool                    compressed;
>         int                     unzipped_len = -1;
> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> index 3b57443..50d7298 100644
> --- a/fs/pstore/ram.c
> +++ b/fs/pstore/ram.c
> @@ -135,29 +135,31 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
>         return prz;
>  }
>
> -static void ramoops_read_kmsg_hdr(char *buffer, struct timespec *time,
> +static void ramoops_read_kmsg_hdr(char *buffer, struct inode_time *time,
>                                   bool *compressed)
>  {
>         char data_type;
> +       u64 seconds;
>
> -       if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lu.%lu-%c\n",
> -                       &time->tv_sec, &time->tv_nsec, &data_type) == 3) {
> +       if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%llu.%lu-%c\n",
> +                       &seconds, &time->tv_nsec, &data_type) == 3) {
>                 if (data_type == 'C')
>                         *compressed = true;
>                 else
>                         *compressed = false;
> -       } else if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lu.%lu\n",
> -                       &time->tv_sec, &time->tv_nsec) == 2) {
> +       } else if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%llu.%lu\n",
> +                       &seconds, &time->tv_nsec) == 2) {
>                         *compressed = false;
>         } else {
> -               time->tv_sec = 0;
> +               seconds = 0;
>                 time->tv_nsec = 0;
>                 *compressed = false;
>         }
> +       time->tv_sec = seconds;
>  }
>
>  static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
> -                                  int *count, struct timespec *time,
> +                                  int *count, struct inode_time *time,
>                                    char **buf, bool *compressed,
>                                    struct pstore_info *psi)
>  {
> @@ -278,7 +280,7 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
>  }
>
>  static int ramoops_pstore_erase(enum pstore_type_id type, u64 id, int count,
> -                               struct timespec time, struct pstore_info *psi)
> +                               struct inode_time time, struct pstore_info *psi)
>  {
>         struct ramoops_context *cxt = psi->data;
>         struct persistent_ram_zone *prz;
> diff --git a/include/linux/pstore.h b/include/linux/pstore.h
> index ece0c6b..f293905 100644
> --- a/include/linux/pstore.h
> +++ b/include/linux/pstore.h
> @@ -55,7 +55,7 @@ struct pstore_info {
>         int             (*open)(struct pstore_info *psi);
>         int             (*close)(struct pstore_info *psi);
>         ssize_t         (*read)(u64 *id, enum pstore_type_id *type,
> -                       int *count, struct timespec *time, char **buf,
> +                       int *count, struct inode_time *time, char **buf,
>                         bool *compressed, struct pstore_info *psi);
>         int             (*write)(enum pstore_type_id type,
>                         enum kmsg_dump_reason reason, u64 *id,
> @@ -66,7 +66,7 @@ struct pstore_info {
>                         unsigned int part, const char *buf, bool compressed,
>                         size_t size, struct pstore_info *psi);
>         int             (*erase)(enum pstore_type_id type, u64 id,
> -                       int count, struct timespec time,
> +                       int count, struct inode_time time,
>                         struct pstore_info *psi);
>         void            *data;
>  };
> --
> 1.8.3.2
>



-- 
Kees Cook
Chrome OS Security

  reply	other threads:[~2014-05-30 21:14 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30 20:01 [RFC 00/32] making inode time stamps y2038 ready Arnd Bergmann
2014-05-30 20:01 ` [RFC 01/32] fs: introduce new 'struct inode_time' Arnd Bergmann
2014-05-31  7:56   ` Geert Uytterhoeven
2014-05-31  8:39     ` Andreas Schwab
2014-05-31 13:19       ` Geert Uytterhoeven
2014-05-31 13:46         ` Andreas Schwab
2014-05-31 14:54       ` Arnd Bergmann
2014-05-31 16:15         ` Geert Uytterhoeven
2014-05-31  9:03   ` H. Peter Anvin
2014-05-31 14:53     ` Arnd Bergmann
2014-05-31 14:55       ` H. Peter Anvin
2014-05-30 20:01 ` [RFC 02/32] uapi: add struct __kernel_timespec{32,64} Arnd Bergmann
2014-05-30 20:18   ` H. Peter Anvin
2014-05-31 15:09     ` Arnd Bergmann
2014-05-30 20:01 ` [RFC 03/32] fs: introduce sys_utimens64at Arnd Bergmann
2014-05-31  9:22   ` Andreas Schwab
2014-05-31 14:55     ` Arnd Bergmann
2014-05-30 20:01 ` [RFC 04/32] fs: introduce sys_newfstat64/sys_newfstatat64 Arnd Bergmann
2014-05-30 20:01 ` [RFC 05/32] arch: hook up new stat and utimes syscalls Arnd Bergmann
2014-05-30 20:01 ` [RFC 06/32] isofs: fix timestamps beyond 2027 Arnd Bergmann
2014-05-31  7:59   ` Geert Uytterhoeven
2014-05-31  8:47     ` H. Peter Anvin
2014-05-30 20:01 ` [RFC 07/32] fs/nfs: convert to struct inode_time Arnd Bergmann
2014-05-30 20:01 ` [RFC 08/32] fs/ceph: convert to 'struct inode_time' Arnd Bergmann
2014-05-30 20:01 ` [RFC 09/32] fs/pstore: convert to struct inode_time Arnd Bergmann
2014-05-30 21:14   ` Kees Cook [this message]
2014-05-30 20:01 ` [RFC 10/32] fs/coda: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 11/32] xfs: " Arnd Bergmann
2014-05-31  0:37   ` Dave Chinner
2014-05-31  0:41     ` H. Peter Anvin
2014-05-31  1:14       ` Dave Chinner
2014-05-31  1:22         ` H. Peter Anvin
2014-05-31  5:54           ` Dave Chinner
2014-05-31  8:41             ` H. Peter Anvin
2014-05-31 15:46               ` Nicolas Pitre
2014-06-01 19:56                 ` Arnd Bergmann
2014-06-01 20:26                   ` H. Peter Anvin
2014-06-02 11:02                     ` Arnd Bergmann
2014-06-02  1:36                   ` Nicolas Pitre
2014-06-02  2:22                     ` Dave Chinner
2014-06-02  7:09                       ` Geert Uytterhoeven
2014-06-02 10:56                     ` Arnd Bergmann
2014-06-02 11:57                       ` Theodore Ts'o
2014-06-02 12:38                         ` Arnd Bergmann
2014-06-02 13:15                           ` Theodore Ts'o
2014-06-02 12:52                         ` Arnd Bergmann
2014-06-02 13:07                           ` Theodore Ts'o
2014-06-02 15:01                             ` Arnd Bergmann
2014-06-02 14:52                         ` H. Peter Anvin
2014-06-02 15:04                       ` Chuck Lever
2014-06-02 15:31                         ` Theodore Ts'o
2014-06-02 17:12                           ` H. Peter Anvin
2014-06-02 18:50                             ` Arnd Bergmann
2014-06-02 22:29                             ` Theodore Ts'o
2014-06-02 22:32                               ` H. Peter Anvin
2014-06-02 23:32                                 ` Theodore Ts'o
2014-06-02 23:33                                   ` H. Peter Anvin
2014-06-03 13:09                                   ` Roger Willcocks
2014-06-02 18:52                         ` Arnd Bergmann
2014-06-02 18:58                         ` Roger Willcocks
2014-06-02 19:04                           ` Chuck Lever
2014-06-02 19:10                             ` Arnd Bergmann
2014-06-01  0:39               ` Dave Chinner
2014-06-02 14:00             ` Joseph S. Myers
2014-05-31 15:37         ` Arnd Bergmann
2014-06-01  0:24           ` Dave Chinner
2014-06-02  0:28             ` Dave Chinner
2014-06-02 11:35               ` Roger Willcocks
2014-06-02 11:43               ` Arnd Bergmann
2014-06-03  0:32                 ` Dave Chinner
2014-06-03  7:33                   ` Arnd Bergmann
2014-06-03  8:41                     ` Dave Chinner
2014-06-03  9:16                       ` Arnd Bergmann
2014-05-30 20:01 ` [RFC 12/32] btrfs: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 13/32] ext3: " Arnd Bergmann
2014-05-31  9:10   ` H. Peter Anvin
2014-05-31 14:32     ` Arnd Bergmann
2014-05-30 20:01 ` [RFC 14/32] ext4: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 15/32] cifs: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 16/32] ntfs: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 17/32] ubifs: " Arnd Bergmann
2014-06-02  7:54   ` Artem Bityutskiy
2014-05-30 20:01 ` [RFC 18/32] ocfs2: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 19/32] fs/fat: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 20/32] afs: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 21/32] udf: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 22/32] fs: convert simple fs to inode_time Arnd Bergmann
2014-05-30 23:06   ` Greg Kroah-Hartman
2014-05-30 20:01 ` [RFC 23/32] logfs: convert to struct inode_time Arnd Bergmann
2014-05-30 20:01 ` [RFC 24/32] hfs, hfsplus: " Arnd Bergmann
2014-05-31 14:23   ` Vyacheslav Dubeyko
2014-05-30 20:01 ` [RFC 25/32] gfs2: " Arnd Bergmann
2014-06-02  9:52   ` Steven Whitehouse
2014-05-30 20:01 ` [RFC 26/32] reiserfs: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 27/32] jffs2: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 28/32] adfs: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 29/32] f2fs: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 30/32] fuse: " Arnd Bergmann
2014-05-30 20:01 ` [RFC 31/32] scsi: fnic: use current_kernel_time() for timestamp Arnd Bergmann
2014-05-30 20:01 ` [RFC 32/32] fs: use new inode_time definition unconditionally Arnd Bergmann
2014-05-31 14:30 ` [RFC 00/32] making inode time stamps y2038 ready Vyacheslav Dubeyko
2014-06-03 12:21   ` Arnd Bergmann
2014-05-31 14:51 ` Richard Cochran
2014-05-31 15:23   ` Arnd Bergmann
2014-05-31 18:22     ` Richard Cochran
2014-05-31 19:34       ` H. Peter Anvin
2014-06-01  4:46         ` Richard Cochran
2014-06-01  4:44     ` Richard Cochran
2014-06-02 13:52 ` Joseph S. Myers
2014-06-02 19:19   ` Arnd Bergmann
2014-06-02 19:26     ` H. Peter Anvin
2014-06-02 19:55       ` Arnd Bergmann
2014-06-02 21:57         ` H. Peter Anvin
2014-06-03 14:22           ` Arnd Bergmann
2014-06-03 14:33             ` Joseph S. Myers
2014-06-03 14:37               ` Arnd Bergmann
2014-06-03 21:38             ` Dave Chinner
2014-06-04 15:03               ` Arnd Bergmann
2014-06-04 17:30                 ` Nicolas Pitre
2014-06-04 19:24                   ` Arnd Bergmann
2014-06-05  0:10                     ` H. Peter Anvin
2014-06-10  9:54                       ` Arnd Bergmann
2014-06-02 21:02     ` Joseph S. Myers
2014-06-04 15:05       ` Arnd Bergmann

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='CAGXu5jLwmhLEqBDToE886=9c70AH7J6_aVqKTcH-KUX2ywzRbQ@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=anton@enomsg.org \
    --cc=arnd@arndb.de \
    --cc=ccross@android.com \
    --cc=geert@linux-m68k.org \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=john.stultz@linaro.org \
    --cc=joseph@codesourcery.com \
    --cc=lftan@altera.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.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 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).