From: Chen Zhou chenzhou10@huawei.com
hulk inclusion category: bugfix bugzilla: NA CVE: NA
-------------------------------------------------
Commit 354e249da4b0 ("cgroup: fix cgroup_sk_alloc() for sk_clone_lock()") modifies struct sock_cgroup_data, which made the KABI broken.
Use is_data to save the val of is_data and no_refcnt, bit 0 of is_data : is_data, bit 1 of is_data: no_refcnt.
Signed-off-by: Chen Zhou chenzhou10@huawei.com Reviewed-by: Xie XiuQi xiexiuqi@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- include/linux/cgroup-defs.h | 11 +++++++---- kernel/cgroup/cgroup.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 56b073368374..cad1a82ca7d7 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -753,10 +753,14 @@ static inline void cgroup_threadgroup_change_end(struct task_struct *tsk) {} */ struct sock_cgroup_data { union { + /* + * Field is_data is the combination of is_data and no_refcnt, + * bit 0: is_data, + * bit 1: no_refcnt. + */ #ifdef __LITTLE_ENDIAN struct { - u8 is_data : 1; - u8 no_refcnt : 1; + u8 is_data; u8 padding; u16 prioidx; u32 classid; @@ -766,8 +770,7 @@ struct sock_cgroup_data { u32 classid; u16 prioidx; u8 padding; - u8 no_refcnt : 1; - u8 is_data : 1; + u8 is_data; } __packed; #endif u64 val; diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 69a0b985af8e..258331394bfe 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -5915,7 +5915,7 @@ void cgroup_sk_alloc_disable(void) void cgroup_sk_alloc(struct sock_cgroup_data *skcd) { if (cgroup_sk_alloc_disabled) { - skcd->no_refcnt = 1; + skcd->is_data |= 2; return; }
@@ -5954,7 +5954,7 @@ void cgroup_sk_clone(struct sock_cgroup_data *skcd)
void cgroup_sk_free(struct sock_cgroup_data *skcd) { - if (skcd->no_refcnt) + if (skcd->is_data & 2) return;
cgroup_put(sock_cgroup_ptr(skcd));