From: "GONG, Ruiqi" gongruiqi1@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4MYYH CVE: N/A
-----------------------
Reserve space in struct cred and struct user_namespace in advance to prepare for merging a promising new feature [1] from kernel 5.14 and some others in the future.
[1]: https://lkml.kernel.org/r/94d1dbecab060a6b116b0a2d1accd8ca1bbb4f5f.161909442...
Signed-off-by: GONG, Ruiqi gongruiqi1@huawei.com Reviewed-by: Xiu Jianfeng xiujianfeng@huawei.com Reviewed-by: weiyang wang wangweiyang2@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- include/linux/cred.h | 2 ++ include/linux/user_namespace.h | 20 ++++++++++++++++++++ kernel/ucount.c | 16 ++++++++++++++++ 3 files changed, 38 insertions(+)
diff --git a/include/linux/cred.h b/include/linux/cred.h index 18639c069263..280e86c4d768 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -15,6 +15,7 @@ #include <linux/uidgid.h> #include <linux/sched.h> #include <linux/sched/user.h> +#include <linux/kabi.h>
struct cred; struct inode; @@ -150,6 +151,7 @@ struct cred { int non_rcu; /* Can we skip RCU deletion? */ struct rcu_head rcu; /* RCU deletion hook */ }; + KABI_RESERVE(1) /* reserved for ucounts */ } __randomize_layout;
extern void __put_cred(struct cred *); diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index ea2f4dc95445..d7d02654a49e 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h @@ -50,6 +50,26 @@ enum ucount_type { UCOUNT_INOTIFY_INSTANCES, UCOUNT_INOTIFY_WATCHES, #endif + /* These 15 members are reserved (with extra margin) for the future + * enlargement of enum ucount_type, as how RH8.1 did it. This number + * should be enough, as 6 of them are very likely to be used in the near + * future. + */ + UCOUNT_KABI_RESERVE1, + UCOUNT_KABI_RESERVE2, + UCOUNT_KABI_RESERVE3, + UCOUNT_KABI_RESERVE4, + UCOUNT_KABI_RESERVE5, + UCOUNT_KABI_RESERVE6, + UCOUNT_KABI_RESERVE7, + UCOUNT_KABI_RESERVE8, + UCOUNT_KABI_RESERVE9, + UCOUNT_KABI_RESERVE10, + UCOUNT_KABI_RESERVE11, + UCOUNT_KABI_RESERVE12, + UCOUNT_KABI_RESERVE13, + UCOUNT_KABI_RESERVE14, + UCOUNT_KABI_RESERVE15, UCOUNT_COUNTS, };
diff --git a/kernel/ucount.c b/kernel/ucount.c index 04c561751af1..dff1d9b739d2 100644 --- a/kernel/ucount.c +++ b/kernel/ucount.c @@ -74,6 +74,22 @@ static struct ctl_table user_table[] = { UCOUNT_ENTRY("max_inotify_instances"), UCOUNT_ENTRY("max_inotify_watches"), #endif + /* These corresponds to the reservation in enum ucount_type */ + { }, // UCOUNT_KABI_RESERVE1 + { }, // UCOUNT_KABI_RESERVE2 + { }, // UCOUNT_KABI_RESERVE3 + { }, // UCOUNT_KABI_RESERVE4 + { }, // UCOUNT_KABI_RESERVE5 + { }, // UCOUNT_KABI_RESERVE6 + { }, // UCOUNT_KABI_RESERVE7 + { }, // UCOUNT_KABI_RESERVE8 + { }, // UCOUNT_KABI_RESERVE9 + { }, // UCOUNT_KABI_RESERVE10 + { }, // UCOUNT_KABI_RESERVE11 + { }, // UCOUNT_KABI_RESERVE12 + { }, // UCOUNT_KABI_RESERVE13 + { }, // UCOUNT_KABI_RESERVE14 + { }, // UCOUNT_KABI_RESERVE15 { } }; #endif /* CONFIG_SYSCTL */