From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Zefan Subject: [PATCH 6/8] memcg: fail to create cgroup if the cgroup id is too big Date: Mon, 8 Apr 2013 16:22:34 +0800 Message-ID: <51627E4A.6090807@huawei.com> References: <51627DA9.7020507@huawei.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <51627DA9.7020507-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Andrew Morton Cc: Tejun Heo , Glauber Costa , KAMEZAWA Hiroyuki , Michal Hocko , Johannes Weiner , LKML , Cgroups , linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org memcg requires the cgroup id to be smaller than 65536. Signed-off-by: Li Zefan --- mm/memcontrol.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c4e0173..947dff1 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -492,6 +492,12 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) return (memcg == root_mem_cgroup); } +/* + * We restrict the id in the range of [0, 65535], so it can fit into + * an unsigned short. + */ +#define MEM_CGROUP_ID_MAX (65535) + static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) { return memcg->css.cgroup->id; @@ -6125,6 +6131,9 @@ mem_cgroup_css_alloc(struct cgroup *cont) long error = -ENOMEM; int node; + if (cont->id > MEM_CGROUP_ID_MAX) + return ERR_PTR(-ENOSPC); + memcg = mem_cgroup_alloc(); if (!memcg) return ERR_PTR(error); -- 1.8.0.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx192.postini.com [74.125.245.192]) by kanga.kvack.org (Postfix) with SMTP id 58F326B0069 for ; Mon, 8 Apr 2013 04:24:24 -0400 (EDT) Message-ID: <51627E4A.6090807@huawei.com> Date: Mon, 8 Apr 2013 16:22:34 +0800 From: Li Zefan MIME-Version: 1.0 Subject: [PATCH 6/8] memcg: fail to create cgroup if the cgroup id is too big References: <51627DA9.7020507@huawei.com> In-Reply-To: <51627DA9.7020507@huawei.com> Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Tejun Heo , Glauber Costa , KAMEZAWA Hiroyuki , Michal Hocko , Johannes Weiner , LKML , Cgroups , linux-mm@kvack.org memcg requires the cgroup id to be smaller than 65536. Signed-off-by: Li Zefan --- mm/memcontrol.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c4e0173..947dff1 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -492,6 +492,12 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) return (memcg == root_mem_cgroup); } +/* + * We restrict the id in the range of [0, 65535], so it can fit into + * an unsigned short. + */ +#define MEM_CGROUP_ID_MAX (65535) + static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) { return memcg->css.cgroup->id; @@ -6125,6 +6131,9 @@ mem_cgroup_css_alloc(struct cgroup *cont) long error = -ENOMEM; int node; + if (cont->id > MEM_CGROUP_ID_MAX) + return ERR_PTR(-ENOSPC); + memcg = mem_cgroup_alloc(); if (!memcg) return ERR_PTR(error); -- 1.8.0.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934579Ab3DHIYA (ORCPT ); Mon, 8 Apr 2013 04:24:00 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:47296 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934322Ab3DHIX6 (ORCPT ); Mon, 8 Apr 2013 04:23:58 -0400 Message-ID: <51627E4A.6090807@huawei.com> Date: Mon, 8 Apr 2013 16:22:34 +0800 From: Li Zefan User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: Andrew Morton CC: Tejun Heo , Glauber Costa , KAMEZAWA Hiroyuki , Michal Hocko , Johannes Weiner , LKML , Cgroups , Subject: [PATCH 6/8] memcg: fail to create cgroup if the cgroup id is too big References: <51627DA9.7020507@huawei.com> In-Reply-To: <51627DA9.7020507@huawei.com> Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.135.68.215] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org memcg requires the cgroup id to be smaller than 65536. Signed-off-by: Li Zefan --- mm/memcontrol.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c4e0173..947dff1 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -492,6 +492,12 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) return (memcg == root_mem_cgroup); } +/* + * We restrict the id in the range of [0, 65535], so it can fit into + * an unsigned short. + */ +#define MEM_CGROUP_ID_MAX (65535) + static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) { return memcg->css.cgroup->id; @@ -6125,6 +6131,9 @@ mem_cgroup_css_alloc(struct cgroup *cont) long error = -ENOMEM; int node; + if (cont->id > MEM_CGROUP_ID_MAX) + return ERR_PTR(-ENOSPC); + memcg = mem_cgroup_alloc(); if (!memcg) return ERR_PTR(error); -- 1.8.0.2