Updates the struct key_preparsed_payload to use time64_t instead of time_t. In addition, several variables in the security/keys have been converted to time64_t and to use the S64_MAX macro instead of LONG_MAX. This is to handle the y2038 problem where time_t will overflow in 2038.
Signed-off-by: Arnd Bergmann arnd@arndb.de Signed-off-by: Aya Mahfouz mahfouz.saif.elyazal@gmail.com --- include/linux/key-type.h | 2 +- security/keys/gc.c | 12 ++++++------ security/keys/key.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/linux/key-type.h b/include/linux/key-type.h index 7463355..2c844ae 100644 --- a/include/linux/key-type.h +++ b/include/linux/key-type.h @@ -44,7 +44,7 @@ struct key_preparsed_payload { const void *data; /* Raw data */ size_t datalen; /* Raw datalen */ size_t quotalen; /* Quota length for proposed payload */ - time_t expiry; /* Expiry time of key */ + time64_t expiry; /* Expiry time of key */ bool trusted; /* True if key is trusted */ };
diff --git a/security/keys/gc.c b/security/keys/gc.c index fffc097..19b0760 100644 --- a/security/keys/gc.c +++ b/security/keys/gc.c @@ -32,7 +32,7 @@ DECLARE_WORK(key_gc_work, key_garbage_collector); static void key_gc_timer_func(unsigned long); static DEFINE_TIMER(key_gc_timer, key_gc_timer_func, 0, 0);
-static time_t key_gc_next_run = LONG_MAX; +static time64_t key_gc_next_run = S64_MAX; static struct key_type *key_gc_dead_keytype;
static unsigned long key_gc_flags; @@ -87,7 +87,7 @@ void key_schedule_gc_links(void) static void key_gc_timer_func(unsigned long data) { kenter(""); - key_gc_next_run = LONG_MAX; + key_gc_next_run = S64_MAX; key_schedule_gc_links(); }
@@ -186,11 +186,11 @@ static void key_garbage_collector(struct work_struct *work)
struct rb_node *cursor; struct key *key; - time_t new_timer, limit; + time64_t new_timer, limit;
kenter("[%lx,%x]", key_gc_flags, gc_state);
- limit = current_kernel_time().tv_sec; + limit = ktime_get_real_seconds(); if (limit > key_gc_delay) limit -= key_gc_delay; else @@ -206,7 +206,7 @@ static void key_garbage_collector(struct work_struct *work) gc_state |= KEY_GC_REAPING_DEAD_1; kdebug("new pass %x", gc_state);
- new_timer = LONG_MAX; + new_timer = S64_MAX;
/* As only this function is permitted to remove things from the key * serial tree, if cursor is non-NULL then it will always point to a @@ -275,7 +275,7 @@ maybe_resched: */ kdebug("pass complete");
- if (gc_state & KEY_GC_SET_TIMER && new_timer != (time_t)LONG_MAX) { + if (gc_state & KEY_GC_SET_TIMER && new_timer != (time64_t)S64_MAX) { new_timer += key_gc_delay; key_schedule_gc(new_timer); } diff --git a/security/keys/key.c b/security/keys/key.c index a7bc935..85d3ae7 100644 --- a/security/keys/key.c +++ b/security/keys/key.c @@ -436,7 +436,7 @@ static int __key_instantiate_and_link(struct key *key, if (authkey) key_revoke(authkey);
- if (prep->expiry != TIME_T_MAX) { + if (prep->expiry != S64_MAX) { key->expiry = prep->expiry; key_schedule_gc(prep->expiry + key_gc_delay); } @@ -482,7 +482,7 @@ int key_instantiate_and_link(struct key *key, prep.data = data; prep.datalen = datalen; prep.quotalen = key->type->def_datalen; - prep.expiry = TIME_T_MAX; + prep.expiry = S64_MAX; if (key->type->preparse) { ret = key->type->preparse(&prep); if (ret < 0)