lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALvZod7CJ6W5RGRVzyc8J=dWgOHeHGFT+43NWGQjATvEqRjkMg@mail.gmail.com>
Date:   Wed, 17 Jul 2019 11:02:24 -0700
From:   Shakeel Butt <shakeelb@...gle.com>
To:     Yang Shi <yang.shi@...ux.alibaba.com>
Cc:     Vladimir Davydov <vdavydov.dev@...il.com>,
        Johannes Weiner <hannes@...xchg.org>,
        Michal Hocko <mhocko@...e.com>,
        Kirill Tkhai <ktkhai@...tuozzo.com>,
        Roman Gushchin <guro@...com>, Hugh Dickins <hughd@...gle.com>,
        Qian Cai <cai@....pw>,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        stable@...r.kernel.org, Linux MM <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm: vmscan: check if mem cgroup is disabled or not before
 calling memcg slab shrinker

On Wed, Jul 17, 2019 at 10:45 AM Yang Shi <yang.shi@...ux.alibaba.com> wrote:
>
> Shakeel Butt reported premature oom on kernel with
> "cgroup_disable=memory" since mem_cgroup_is_root() returns false even
> though memcg is actually NULL.  The drop_caches is also broken.
>
> It is because commit aeed1d325d42 ("mm/vmscan.c: generalize shrink_slab()
> calls in shrink_node()") removed the !memcg check before
> !mem_cgroup_is_root().  And, surprisingly root memcg is allocated even
> though memory cgroup is disabled by kernel boot parameter.
>
> Add mem_cgroup_disabled() check to make reclaimer work as expected.
>
> Fixes: aeed1d325d42 ("mm/vmscan.c: generalize shrink_slab() calls in shrink_node()")
> Reported-by: Shakeel Butt <shakeelb@...gle.com>
> Cc: Vladimir Davydov <vdavydov.dev@...il.com>
> Cc: Johannes Weiner <hannes@...xchg.org>
> Cc: Michal Hocko <mhocko@...e.com>
> Cc: Kirill Tkhai <ktkhai@...tuozzo.com>
> Cc: Roman Gushchin <guro@...com>
> Cc: Hugh Dickins <hughd@...gle.com>
> Cc: Qian Cai <cai@....pw>
> Cc: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> Cc: stable@...r.kernel.org  4.19+
> Signed-off-by: Yang Shi <yang.shi@...ux.alibaba.com>

Reviewed-by: Shakeel Butt <shakeelb@...gle.com>

> ---
>  mm/vmscan.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index f8e3dcd..c10dc02 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -684,7 +684,14 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>         unsigned long ret, freed = 0;
>         struct shrinker *shrinker;
>
> -       if (!mem_cgroup_is_root(memcg))
> +       /*
> +        * The root memcg might be allocated even though memcg is disabled
> +        * via "cgroup_disable=memory" boot parameter.  This could make
> +        * mem_cgroup_is_root() return false, then just run memcg slab
> +        * shrink, but skip global shrink.  This may result in premature
> +        * oom.
> +        */
> +       if (!mem_cgroup_disabled() && !mem_cgroup_is_root(memcg))
>                 return shrink_slab_memcg(gfp_mask, nid, memcg, priority);
>
>         if (!down_read_trylock(&shrinker_rwsem))
> --
> 1.8.3.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ