lib/test_overflow.c: avoid tainting the kernel and fix wrap size
authorKees Cook <keescook@chromium.org>
Tue, 16 Jul 2019 23:27:24 +0000 (16:27 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 6 Aug 2019 17:06:51 +0000 (19:06 +0200)
commit8e087a2abaf8a1d11bba8770c7e4e73572b52eff
tree3e6be7fd6557a78ef7af9af6205c22fe9a6064b5
parent439c79ed7718ee509421ca201a1f1a009bc403d0
lib/test_overflow.c: avoid tainting the kernel and fix wrap size

[ Upstream commit 8e060c21ae2c265a2b596e9e7f9f97ec274151a4 ]

This adds __GFP_NOWARN to the kmalloc()-portions of the overflow test to
avoid tainting the kernel.  Additionally fixes up the math on wrap size
to be architecture and page size agnostic.

Link: http://lkml.kernel.org/r/201905282012.0A8767E24@keescook
Fixes: ca90800a91ba ("test_overflow: Add memory allocation overflow tests")
Signed-off-by: Kees Cook <keescook@chromium.org>
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
lib/test_overflow.c