From edfcf0c638fd4c7988e833989fca9167d079674e Mon Sep 17 00:00:00 2001 From: Michal Koutný Date: May 29 2023 13:51:35 +0000 Subject: cgroup: Homogenize cgroup_get_from_id() return value (bsc#1205650). --- diff --git a/patches.suse/cgroup-Homogenize-cgroup_get_from_id-return-value.patch b/patches.suse/cgroup-Homogenize-cgroup_get_from_id-return-value.patch new file mode 100644 index 0000000..b75a2e2 --- /dev/null +++ b/patches.suse/cgroup-Homogenize-cgroup_get_from_id-return-value.patch @@ -0,0 +1,80 @@ +From: =?utf-8?b?TWljaGFsIEtvdXRuw70gPG1rb3V0bnlAc3VzZS5jb20+?= +Date: Fri, 26 Aug 2022 18:52:37 +0200 +Subject: cgroup: Homogenize cgroup_get_from_id() return value +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Git-commit: fa7e439cf90ba23ea473d0b7d85efd02ae6ccf94 +Patch-mainline: v6.1-rc1 +References: bsc#1205650 + +Cgroup id is user provided datum hence extend its return domain to +include possible error reason (similar to cgroup_get_from_fd()). + +This change also fixes commit d4ccaf58a847 ("bpf: Introduce cgroup +iter") that would use NULL instead of proper error handling in +d4ccaf58a847 ("bpf: Introduce cgroup iter"). + +Additionally, neither of: fc_appid_store, bpf_iter_attach_cgroup, +mem_cgroup_get_from_ino (callers of cgroup_get_from_fd) is built without +CONFIG_CGROUPS (depends via CONFIG_BLK_CGROUP, direct, transitive +CONFIG_MEMCG respectively) transitive, so drop the singular definition +not needed with !CONFIG_CGROUPS. + +Fixes: d4ccaf58a847 ("bpf: Introduce cgroup iter") +Signed-off-by: Michal Koutný +Signed-off-by: Tejun Heo +[mkoutny: drop mem_cgroup_get_from_ino() hunk] +--- + block/blk-cgroup-fc-appid.c | 4 ++-- + include/linux/cgroup.h | 5 ----- + kernel/cgroup/cgroup.c | 4 ++-- + 3 files changed, 4 insertions(+), 9 deletions(-) + +--- a/block/blk-cgroup-fc-appid.c ++++ b/block/blk-cgroup-fc-appid.c +@@ -19,8 +19,8 @@ int blkcg_set_fc_appid(char *app_id, u64 + return -EINVAL; + + cgrp = cgroup_get_from_id(cgrp_id); +- if (!cgrp) +- return -ENOENT; ++ if (IS_ERR(cgrp)) ++ return PTR_ERR(cgrp); + css = cgroup_get_e_css(cgrp, &io_cgrp_subsys); + if (!css) { + ret = -ENOENT; +--- a/include/linux/cgroup.h ++++ b/include/linux/cgroup.h +@@ -751,11 +751,6 @@ static inline bool task_under_cgroup_hie + + static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen) + {} +- +-static inline struct cgroup *cgroup_get_from_id(u64 id) +-{ +- return NULL; +-} + #endif /* !CONFIG_CGROUPS */ + + #ifdef CONFIG_CGROUPS +--- a/kernel/cgroup/cgroup.c ++++ b/kernel/cgroup/cgroup.c +@@ -6002,7 +6002,7 @@ void cgroup_path_from_kernfs_id(u64 id, + /* + * cgroup_get_from_id : get the cgroup associated with cgroup id + * @id: cgroup id +- * On success return the cgrp, on failure return NULL ++ * On success return the cgrp or ERR_PTR on failure + * Only cgroups within current task's cgroup NS are valid. + */ + struct cgroup *cgroup_get_from_id(u64 id) +@@ -6038,7 +6038,7 @@ put: + cgrp = NULL; + } + out: +- return cgrp; ++ return cgrp ?: ERR_PTR(-ENOENT); + } + EXPORT_SYMBOL_GPL(cgroup_get_from_id); + diff --git a/series.conf b/series.conf index 6dc2ae9..30a9dd1 100644 --- a/series.conf +++ b/series.conf @@ -16708,6 +16708,7 @@ patches.suse/locking-rwsem-Disable-preemption-while-trying-for-rw.patch patches.suse/cgroup-Honor-caller-s-cgroup-NS-when-resolving-path.patch patches.suse/cgroup-cgroup-Honor-caller-s-cgroup-NS-when-resolving-cgroup-id.patch + patches.suse/cgroup-Homogenize-cgroup_get_from_id-return-value.patch patches.suse/cgroup-cpuset-Enable-update_tasks_cpumask-on-top_cpuset.patch patches.suse/livepatch-fix-race-between-fork-and-KLP-transition.patch patches.suse/livepatch-Add-a-missing-newline-character-in-klp_mod.patch