]> git.baikalelectronics.ru Git - kernel.git/commit
hugetlb_cgroup: fix illegal access to memory
authorMina Almasry <almasrymina@google.com>
Sun, 29 Mar 2020 02:17:22 +0000 (19:17 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 29 Mar 2020 16:47:05 +0000 (09:47 -0700)
commit3c74cabe535648700e1f07f4e8323effa7c66441
tree9801d33f07d79e84333f425495415a61e4838a01
parent5143f84508574ab2071e9c1691058ce688ad8358
hugetlb_cgroup: fix illegal access to memory

This appears to be a mistake in commit fa9793c7fc49a ("mm: hugetlb
controller for cgroups v2").

Essentially that commit does a hugetlb_cgroup_from_counter assuming that
page_counter_try_charge has initialized counter.

But if that has failed then it seems will not initialize counter, so
hugetlb_cgroup_from_counter(counter) ends up pointing to random memory,
causing kasan to complain.

The solution is to simply use 'h_cg', instead of
hugetlb_cgroup_from_counter(counter), since that is a reference to the
hugetlb_cgroup anyway.  After this change kasan ceases to complain.

Fixes: fa9793c7fc49a ("mm: hugetlb controller for cgroups v2")
Reported-by: syzbot+cac0c4e204952cf449b1@syzkaller.appspotmail.com
Signed-off-by: Mina Almasry <almasrymina@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Giuseppe Scrivano <gscrivan@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: David Rientjes <rientjes@google.com>
Link: http://lkml.kernel.org/r/20200313223920.124230-1-almasrymina@google.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/hugetlb_cgroup.c