2019-10-10 04:57:16

by Yizhuo Zhai

[permalink] [raw]
Subject: Potential NULL pointer deference in mm/memcontrol.c

Hi All:
mm/memcontrol.c:
The function mem_cgroup_from_css() could return NULL, but some callers
in this file
checks the return value but directly dereference it, which seems
potentially unsafe.
Such callers include mem_cgroup_hierarchy_read(),
mem_cgroup_hierarchy_write(), mem_cgroup_read_u64(),
mem_cgroup_reset(), etc.
--
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


2019-10-10 07:39:34

by Michal Hocko

[permalink] [raw]
Subject: Re: Potential NULL pointer deference in mm/memcontrol.c

On Wed 09-10-19 21:56:04, Yizhuo Zhai wrote:
> Hi All:
> mm/memcontrol.c:
> The function mem_cgroup_from_css() could return NULL, but some callers

This is the case only when the memory cgroup controller is disabled
which is a boot time option.

> in this file
> checks the return value but directly dereference it, which seems
> potentially unsafe.
> Such callers include mem_cgroup_hierarchy_read(),
> mem_cgroup_hierarchy_write(), mem_cgroup_read_u64(),
> mem_cgroup_reset(), etc.

And none of those should be ever called under that condition AFAICS.

Thanks!
--
Michal Hocko
SUSE Labs