From 5b40c9b90b44ddd0b042c12c10c65c9965a9856f Mon Sep 17 00:00:00 2001 From: Yang Sheng Date: Fri, 8 Nov 2019 02:48:43 +0800 Subject: [PATCH] LU-12928 gss: crash in sec2target_str() The timer_setup() API has being used since 3.10.0-957.x kernel. So change gck_timer to a embedded struct to avoid crashed on new timer API. Signed-off-by: Yang Sheng Change-Id: Ie12e21bca4169746016c8ac0e3ee4a125893ebf6 Reviewed-on: https://review.whamcloud.com/36708 Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: Li Dongyang Reviewed-by: Sebastien Buisson Tested-by: Sebastien Buisson Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/ptlrpc/gss/gss_internal.h | 6 +++--- lustre/ptlrpc/gss/gss_keyring.c | 22 ++++------------------ 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lustre/ptlrpc/gss/gss_internal.h b/lustre/ptlrpc/gss/gss_internal.h index a55d782..39c2e8d 100644 --- a/lustre/ptlrpc/gss/gss_internal.h +++ b/lustre/ptlrpc/gss/gss_internal.h @@ -287,9 +287,9 @@ struct gss_cli_ctx { }; struct gss_cli_ctx_keyring { - struct gss_cli_ctx gck_base; - struct key *gck_key; - struct timer_list *gck_timer; + struct gss_cli_ctx gck_base; + struct key *gck_key; + struct timer_list gck_timer; }; struct gss_sec { diff --git a/lustre/ptlrpc/gss/gss_keyring.c b/lustre/ptlrpc/gss/gss_keyring.c index 3d37bc6..cd9dc89 100644 --- a/lustre/ptlrpc/gss/gss_keyring.c +++ b/lustre/ptlrpc/gss/gss_keyring.c @@ -143,7 +143,7 @@ static inline void key_revoke_locked(struct key *key) static void ctx_upcall_timeout_kr(cfs_timer_cb_arg_t data) { struct gss_cli_ctx_keyring *gctx_kr = cfs_from_timer(gctx_kr, - &data, gck_timer); + data, gck_timer); struct ptlrpc_cli_ctx *ctx = &(gctx_kr->gck_base.gc_base); struct key *key = gctx_kr->gck_key; @@ -158,7 +158,7 @@ static void ctx_upcall_timeout_kr(cfs_timer_cb_arg_t data) static void ctx_start_timer_kr(struct ptlrpc_cli_ctx *ctx, time64_t timeout) { struct gss_cli_ctx_keyring *gctx_kr = ctx2gctx_keyring(ctx); - struct timer_list *timer = gctx_kr->gck_timer; + struct timer_list *timer = &gctx_kr->gck_timer; LASSERT(timer); @@ -177,18 +177,11 @@ static void ctx_clear_timer_kr(struct ptlrpc_cli_ctx *ctx) { struct gss_cli_ctx_keyring *gctx_kr = ctx2gctx_keyring(ctx); - struct timer_list *timer = gctx_kr->gck_timer; - - if (timer == NULL) - return; + struct timer_list *timer = &gctx_kr->gck_timer; CDEBUG(D_SEC, "ctx %p, key %p\n", ctx, gctx_kr->gck_key); - gctx_kr->gck_timer = NULL; - del_singleshot_timer_sync(timer); - - OBD_FREE_PTR(timer); } static @@ -202,17 +195,11 @@ struct ptlrpc_cli_ctx *ctx_create_kr(struct ptlrpc_sec *sec, if (gctx_kr == NULL) return NULL; - OBD_ALLOC_PTR(gctx_kr->gck_timer); - if (gctx_kr->gck_timer == NULL) { - OBD_FREE_PTR(gctx_kr); - return NULL; - } - cfs_timer_setup(gctx_kr->gck_timer, NULL, 0, 0); + cfs_timer_setup(&gctx_kr->gck_timer, NULL, 0, 0); ctx = &gctx_kr->gck_base.gc_base; if (gss_cli_ctx_init_common(sec, ctx, &gss_keyring_ctxops, vcred)) { - OBD_FREE_PTR(gctx_kr->gck_timer); OBD_FREE_PTR(gctx_kr); return NULL; } @@ -239,7 +226,6 @@ static void ctx_destroy_kr(struct ptlrpc_cli_ctx *ctx) LASSERT(gctx_kr->gck_key == NULL); ctx_clear_timer_kr(ctx); - LASSERT(gctx_kr->gck_timer == NULL); if (gss_cli_ctx_fini_common(sec, ctx)) return; -- 1.8.3.1