Skip to content

Commit

Permalink
initramfs: use time64_t timestamps
Browse files Browse the repository at this point in the history
The cpio format uses a 32-bit number to encode file timestamps, which
breaks initramfs support in 2038.  This reinterprets the timestamp as
unsigned, to give us another 68 years and avoids breaking until 2106.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnd Bergmann <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Deepa Dinamani <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Daniel Thompson <[email protected]>
Cc: Lokesh Vutla <[email protected]>
Cc: Stafford Horne <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
arndb authored and torvalds committed Nov 18, 2017
1 parent 44ea394 commit e35c4c6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static void __init free_hash(void)
}
}

static long __init do_utime(char *filename, time_t mtime)
static long __init do_utime(char *filename, time64_t mtime)
{
struct timespec64 t[2];

Expand All @@ -125,10 +125,10 @@ static __initdata LIST_HEAD(dir_list);
struct dir_entry {
struct list_head list;
char *name;
time_t mtime;
time64_t mtime;
};

static void __init dir_add(const char *name, time_t mtime)
static void __init dir_add(const char *name, time64_t mtime)
{
struct dir_entry *de = kmalloc(sizeof(struct dir_entry), GFP_KERNEL);
if (!de)
Expand All @@ -150,7 +150,7 @@ static void __init dir_utime(void)
}
}

static __initdata time_t mtime;
static __initdata time64_t mtime;

/* cpio header parsing */

Expand All @@ -177,7 +177,7 @@ static void __init parse_header(char *s)
uid = parsed[2];
gid = parsed[3];
nlink = parsed[4];
mtime = parsed[5];
mtime = parsed[5]; /* breaks in y2106 */
body_len = parsed[6];
major = parsed[7];
minor = parsed[8];
Expand Down

0 comments on commit e35c4c6

Please sign in to comment.