Skip to content

Commit 4219b2d

Browse files
lizf-oshtejun
authored andcommitted
memcg: fail to create cgroup if the cgroup id is too big
memcg requires the cgroup id to be smaller than 65536. This is a preparation to kill css id. Signed-off-by: Li Zefan <lizefan@huawei.com> Acked-by: Michal Hocko <mhocko@suse.cz> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 34c00c3 commit 4219b2d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎mm/memcontrol.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,12 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg)
488488
return (memcg == root_mem_cgroup);
489489
}
490490

491+
/*
492+
* We restrict the id in the range of [1, 65535], so it can fit into
493+
* an unsigned short.
494+
*/
495+
#define MEM_CGROUP_ID_MAX USHRT_MAX
496+
491497
static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg)
492498
{
493499
/*
@@ -6059,6 +6065,9 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css)
60596065
struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(css));
60606066
int error = 0;
60616067

6068+
if (css->cgroup->id > MEM_CGROUP_ID_MAX)
6069+
return -ENOSPC;
6070+
60626071
if (!parent)
60636072
return 0;
60646073

0 commit comments

Comments
 (0)