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: <CAAmzW4MGdj-jL_FJ2Nkoa4Hx8KUDCeVK6HFidYQLauu_0vHhCg@mail.gmail.com>
Date:	Tue, 30 Oct 2012 00:26:43 +0900
From:	JoonSoo Kim <js1304@...il.com>
To:	Glauber Costa <glommer@...allels.com>
Cc:	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	cgroups@...r.kernel.org, Mel Gorman <mgorman@...e.de>,
	Tejun Heo <tj@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Michal Hocko <mhocko@...e.cz>,
	Johannes Weiner <hannes@...xchg.org>,
	kamezawa.hiroyu@...fujitsu.com, Christoph Lameter <cl@...ux.com>,
	David Rientjes <rientjes@...gle.com>,
	Pekka Enberg <penberg@...nel.org>, devel@...nvz.org,
	Suleiman Souhlal <suleiman@...gle.com>,
	Pekka Enberg <penberg@...helsinki.fi>
Subject: Re: [PATCH v5 13/18] memcg/sl[au]b Track all the memcg children of a kmem_cache.

2012/10/19 Glauber Costa <glommer@...allels.com>:
> +void kmem_cache_destroy_memcg_children(struct kmem_cache *s)
> +{
> +       struct kmem_cache *c;
> +       int i;
> +
> +       if (!s->memcg_params)
> +               return;
> +       if (!s->memcg_params->is_root_cache)
> +               return;
> +
> +       /*
> +        * If the cache is being destroyed, we trust that there is no one else
> +        * requesting objects from it. Even if there are, the sanity checks in
> +        * kmem_cache_destroy should caught this ill-case.
> +        *
> +        * Still, we don't want anyone else freeing memcg_caches under our
> +        * noses, which can happen if a new memcg comes to life. As usual,
> +        * we'll take the set_limit_mutex to protect ourselves against this.
> +        */
> +       mutex_lock(&set_limit_mutex);
> +       for (i = 0; i < memcg_limited_groups_array_size; i++) {
> +               c = s->memcg_params->memcg_caches[i];
> +               if (c)
> +                       kmem_cache_destroy(c);
> +       }
> +       mutex_unlock(&set_limit_mutex);
> +}

It may cause NULL deref.
Look at the following scenario.

1. some memcg slab caches has remained object.
2. start to destroy memcg.
3. schedule_delayed_work(kmem_cache_destroy_work_func, @delay 60hz)
4. all remained object is freed.
5. start to destroy root cache.
6. kmem_cache_destroy makes 's->memcg_params->memcg_caches[i]" NULL!!
7. Start delayed work function.
8. cachep in kmem_cache_destroy_work_func() may be NULL

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ