]> git.baikalelectronics.ru Git - kernel.git/commit
mm/page_alloc: __alloc_pages_bulk(): do bounds check before accessing array
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Fri, 25 Jun 2021 01:40:04 +0000 (18:40 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 25 Jun 2021 02:40:54 +0000 (19:40 -0700)
commit5a53c44c74d4ce12ef8ee3f0f18fce5a5fd835b5
tree2e3cb23ccd9b949e687584e7c3f581ca06feb318
parent392bf74ed54fa67a6b22890af1a073f6d9527206
mm/page_alloc: __alloc_pages_bulk(): do bounds check before accessing array

In the event that somebody would call this with an already fully
populated page_array, the last loop iteration would do an access beyond
the end of page_array.

It's of course extremely unlikely that would ever be done, but this
triggers my internal static analyzer.  Also, if it really is not
supposed to be invoked this way (i.e., with no NULL entries in
page_array), the nr_populated<nr_pages check could simply be removed
instead.

Link: https://lkml.kernel.org/r/20210507064504.1712559-1-linux@rasmusvillemoes.dk
Fixes: 9b30cb2ee69a ("mm/page_alloc: add an array-based interface to the bulk page allocator")
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/page_alloc.c