From: Wei Li liwei391@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4T1NF CVE: NA
-------------------------------------------------
When CONFIG_KABI_RESERVE=n && CONFIG_KABI_SIZE_ALIGN_CHECKS=y, with kabi reserved padding replaced by KABI_USE(), we will get the build error:
include/linux/kabi.h:383:3: error: static assertion failed: \ "include/linux/fs.h:2306: long aaa is larger than . \ Disable CONFIG_KABI_SIZE_ALIGN_CHECKS if debugging." _Static_assert(sizeof(struct{_new;}) <= sizeof(struct{_orig;}), \ ^~~~~~~~~~~~~~
In fact, the result of KABI_USE() when CONFIG_KABI_RESERVE=n is weird, update _KABI_REPLACE() to fix this.
Signed-off-by: Wei Li liwei391@huawei.com Reviewed-by: Xie XiuQi xiexiuqi@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- include/linux/kabi.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/kabi.h b/include/linux/kabi.h index 0bc7ca2483f4..a52d9fa72cfa 100644 --- a/include/linux/kabi.h +++ b/include/linux/kabi.h @@ -396,6 +396,7 @@ # define _KABI_DEPRECATE(_type, _orig) _type kabi_reserved_##_orig # define _KABI_DEPRECATE_FN(_type, _orig, _args...) \ _type (* kabi_reserved_##_orig)(_args) +#ifdef CONFIG_KABI_RESERVE # define _KABI_REPLACE(_orig, _new) \ union { \ _new; \ @@ -404,6 +405,9 @@ } __UNIQUE_ID(kabi_hide); \ __KABI_CHECK_SIZE_ALIGN(_orig, _new); \ } +#else +# define _KABI_REPLACE(_orig, _new) KABI_BROKEN_REPLACE(_orig, _new) +#endif
# define _KABI_EXCLUDE(_elem) _elem
@@ -426,9 +430,9 @@ * code. */ #ifdef CONFIG_KABI_RESERVE - # define _KABI_RESERVE(n) u64 kabi_reserved##n +# define _KABI_RESERVE(n) u64 kabi_reserved##n #else - # define _KABI_RESERVE(n) +# define _KABI_RESERVE(n) #endif # define KABI_RESERVE(n) _KABI_RESERVE(n); /*