Tests: Validate unmapping 0x0 doesn't crash the Kernel

Previously unmapping any offset starting at 0x0 would assert in the
kernel, add a regression test to validate the fix.

Co-authored-by: Federico Guerinoni <guerinoni.federico@gmail.com>
This commit is contained in:
Brian Gianforcaro 2021-07-30 02:05:15 -07:00 committed by Andreas Kling
parent 0fcb9efd86
commit c9395d7e9a
Notes: sideshowbarker 2024-07-18 07:45:07 +09:00

View file

@ -0,0 +1,17 @@
/*
* Copyright (c) 2021, Brian Gianforcaro <bgianf@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibTest/TestCase.h>
#include <errno.h>
#include <sys/mman.h>
TEST_CASE(munmap_zero_page)
{
// munmap of the unmapped zero page should always fail.
auto res = munmap(0x0, 0xF);
EXPECT_EQ(res, -1);
EXPECT_EQ(errno, EINVAL);
}