linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: Qiang Huang <h.huangqiang@huawei.com>
Cc: cgroups@vger.kernel.org, linux-mm@kvack.org,
	handai.szj@taobao.com, lizefan@huawei.com,
	nishimura@mxp.nes.nec.co.jp, akpm@linux-foundation.org,
	jeff.liu@oracle.com
Subject: Re: [PATCH 3/4] memcg: avoid overflow caused by PAGE_ALIGN
Date: Wed, 31 Jul 2013 10:14:41 +0200	[thread overview]
Message-ID: <20130731081441.GG30514@dhcp22.suse.cz> (raw)
In-Reply-To: <1375255885-10648-4-git-send-email-h.huangqiang@huawei.com>

On Wed 31-07-13 15:31:24, Qiang Huang wrote:
> Since PAGE_ALIGN is aligning up(the next page boundary), so after PAGE_ALIGN,
> the value might be overflow, such as write the MAX value to *.limit_in_bytes.
> 
> $ cat /cgroup/memory/memory.limit_in_bytes
> 18446744073709551615
> 
> # echo 18446744073709551615 > /cgroup/memory/memory.limit_in_bytes
> bash: echo: write error: Invalid argument
> 
> Some user programs might depend on such behaviours(like libcg, we read the
> value in snapshot, then use the value to reset cgroup later), and that
> will cause confusion. So we need to fix it.
> 
> Signed-off-by: Sha Zhengju <handai.szj@taobao.com>
> Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>

Reviewed-by: Michal Hocko <mhocko@suse.cz>

> ---
>  kernel/res_counter.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/res_counter.c b/kernel/res_counter.c
> index 3f0417f..085d3ae 100644
> --- a/kernel/res_counter.c
> +++ b/kernel/res_counter.c
> @@ -195,6 +195,10 @@ int res_counter_memparse_write_strategy(const char *buf,
>  	if (*end != '\0')
>  		return -EINVAL;
>  
> -	*res = PAGE_ALIGN(*res);
> +	if (PAGE_ALIGN(*res) >= *res)
> +		*res = PAGE_ALIGN(*res);
> +	else
> +		*res = RES_COUNTER_MAX;
> +
>  	return 0;
>  }
> -- 
> 1.8.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe cgroups" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Michal Hocko
SUSE Labs

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2013-07-31  8:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-31  7:31 [PATCH 0/4] memcg: fix memcg resource limit overflow issues Qiang Huang
2013-07-31  7:31 ` [PATCH 1/4] memcg: correct RESOURCE_MAX to ULLONG_MAX Qiang Huang
2013-07-31  8:00   ` Michal Hocko
2013-07-31  7:31 ` [PATCH 2/4] memcg: rename RESOURCE_MAX to RES_COUNTER_MAX Qiang Huang
2013-07-31  8:02   ` Michal Hocko
2013-07-31  7:31 ` [PATCH 3/4] memcg: avoid overflow caused by PAGE_ALIGN Qiang Huang
2013-07-31  8:14   ` Michal Hocko [this message]
2013-07-31  7:31 ` [PATCH 4/4] memcg: reduce function dereference Qiang Huang
2013-07-31  8:20   ` Michal Hocko
2013-07-31  8:23 ` [PATCH 0/4] memcg: fix memcg resource limit overflow issues Sha Zhengju
2013-07-31  8:51   ` Qiang Huang
2013-07-31  8:54     ` Li Zefan
2013-07-31  9:02       ` Qiang Huang
2013-07-31  9:34       ` Jeff Liu
2013-07-31  9:51         ` Li Zefan
2013-07-31  9:39       ` Sha Zhengju
2013-07-31  9:50         ` Michal Hocko
2013-07-31 10:04           ` Sha Zhengju
2013-07-31  9:51         ` Qiang Huang
2013-07-31  9:28     ` Sha Zhengju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130731081441.GG30514@dhcp22.suse.cz \
    --to=mhocko@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=h.huangqiang@huawei.com \
    --cc=handai.szj@taobao.com \
    --cc=jeff.liu@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=lizefan@huawei.com \
    --cc=nishimura@mxp.nes.nec.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).