From 60fa789d87ecf2b1e7e4771387abd1a21b34512c Mon Sep 17 00:00:00 2001 From: ChenJie Date: Fri, 27 May 2022 10:46:41 +0800 Subject: [PATCH 1/3] allow user memmgr add procs to memcg when hyperhold is on Signed-off-by: ChenJie --- include/linux/uidgid.h | 4 ++++ kernel/cgroup/cgroup-v1.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h index b0542cd11aeb..c92d96360ae7 100644 --- a/include/linux/uidgid.h +++ b/include/linux/uidgid.h @@ -55,6 +55,10 @@ static inline gid_t __kgid_val(kgid_t gid) #define GLOBAL_ROOT_UID KUIDT_INIT(0) #define GLOBAL_ROOT_GID KGIDT_INIT(0) +#ifdef CONFIG_HYPERHOLD +#define MEMMGR_UID KUIDT_INIT(1111) +#endif + #define INVALID_UID KUIDT_INIT(-1) #define INVALID_GID KGIDT_INIT(-1) diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index 9f5221653f80..f64ca70c729a 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -513,7 +513,12 @@ static ssize_t __cgroup1_procs_write(struct kernfs_open_file *of, tcred = get_task_cred(task); if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) && !uid_eq(cred->euid, tcred->uid) && +#ifdef CONFIG_HYPERHOLD + !uid_eq(cred->euid, tcred->suid) && + !uid_eq(cred->euid, MEMMGR_UID)) +#else !uid_eq(cred->euid, tcred->suid)) +#endif ret = -EACCES; put_cred(tcred); if (ret) -- Gitee From fc042b69be3d48af49bc4946f7a211b5cfb525f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=9D=B0?= Date: Fri, 27 May 2022 04:33:11 +0000 Subject: [PATCH 2/3] update kernel/cgroup/cgroup-v1.c. Signed-off-by: ChenJie --- kernel/cgroup/cgroup-v1.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index f64ca70c729a..e0fa0b1fffc7 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -511,14 +511,14 @@ static ssize_t __cgroup1_procs_write(struct kernfs_open_file *of, */ cred = of->file->f_cred; tcred = get_task_cred(task); - if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) && - !uid_eq(cred->euid, tcred->uid) && #ifdef CONFIG_HYPERHOLD - !uid_eq(cred->euid, tcred->suid) && - !uid_eq(cred->euid, MEMMGR_UID)) + if (!uid_eq(cred->euid, MEMMGR_UID)) && + !uid_eq(cred->euid, GLOBAL_ROOT_UID) && #else - !uid_eq(cred->euid, tcred->suid)) + if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) && #endif + !uid_eq(cred->euid, tcred->uid) && + !uid_eq(cred->euid, tcred->suid)) ret = -EACCES; put_cred(tcred); if (ret) -- Gitee From 8e1cb1cdad8757515826061d5cc80532be17fad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=9D=B0?= Date: Fri, 27 May 2022 04:34:42 +0000 Subject: [PATCH 3/3] update kernel/cgroup/cgroup-v1.c. --- kernel/cgroup/cgroup-v1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index e0fa0b1fffc7..4f973d851092 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -513,7 +513,7 @@ static ssize_t __cgroup1_procs_write(struct kernfs_open_file *of, tcred = get_task_cred(task); #ifdef CONFIG_HYPERHOLD if (!uid_eq(cred->euid, MEMMGR_UID)) && - !uid_eq(cred->euid, GLOBAL_ROOT_UID) && + !uid_eq(cred->euid, GLOBAL_ROOT_UID) && #else if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) && #endif -- Gitee