From 997085ed60dbb68c214f97d871b2cb72b6bf6175 Mon Sep 17 00:00:00 2001 From: Yang Sheng Date: Mon, 12 Aug 2024 13:04:55 +0800 Subject: [PATCH] LU-17911 obdclass: fix faked flexible arrays in jobid To fix the crash caused by issue of faked flexible arrays in jobid. Signed-off-by: Yang Sheng Change-Id: Iba88582e20dfe38ec060ed9a05ba3d65ee3e31e1 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55995 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu --- lustre/obdclass/jobid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lustre/obdclass/jobid.c b/lustre/obdclass/jobid.c index 87b167f..ae1fcdb 100644 --- a/lustre/obdclass/jobid.c +++ b/lustre/obdclass/jobid.c @@ -80,7 +80,7 @@ struct session_jobid { struct pid *sj_session; struct rhash_head sj_linkage; struct rcu_head sj_rcu; - char sj_jobid[1]; + char sj_jobid[]; }; static const struct rhashtable_params jobid_params = { @@ -120,13 +120,13 @@ int jobid_set_current(char *jobid) int ret; int len = strlen(jobid); - sj = kmalloc(sizeof(*sj) + len, GFP_KERNEL); + sj = kmalloc(sizeof(*sj) + len + 1, GFP_KERNEL); if (!sj) return -ENOMEM; rcu_read_lock(); sid = task_session(current); sj->sj_session = get_pid(sid); - strncpy(sj->sj_jobid, jobid, len+1); + strncpy(sj->sj_jobid, jobid, len + 1); origsj = rhashtable_lookup_get_insert_fast(&session_jobids, &sj->sj_linkage, jobid_params); -- 1.8.3.1