Re: [PATCH] selftests/nolibc: avoid buffer underrun in space printing

From: Willy Tarreau
Date: Sat Jul 29 2023 - 03:29:52 EST


On Wed, Jul 26, 2023 at 08:08:13AM +0200, Thomas Weißschuh wrote:
> If the test description is longer than the status alignment the
> parameter 'n' to putcharn() would lead to a signed underflow that then
> gets converted to a very large unsigned value.
> This in turn leads out-of-bound writes in memset() crashing the
> application.
>
> The failure case of EXPECT_PTRER() used in "mmap_bad" exhibits this
> exact behavior.
>
> Fixes: 8a27526f49f9 ("selftests/nolibc: add EXPECT_PTREQ, EXPECT_PTRNE and EXPECT_PTRER")
> Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>

Applied, thank you Thomas!
Willy