From c9395d7e9a80c35adbd365794ef6b6c80977020b Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Fri, 30 Jul 2021 02:05:15 -0700 Subject: 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 --- Tests/Kernel/TestMunMap.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Tests/Kernel/TestMunMap.cpp (limited to 'Tests/Kernel/TestMunMap.cpp') diff --git a/Tests/Kernel/TestMunMap.cpp b/Tests/Kernel/TestMunMap.cpp new file mode 100644 index 0000000000..206c7c3556 --- /dev/null +++ b/Tests/Kernel/TestMunMap.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2021, Brian Gianforcaro + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include + +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); +} -- cgit v1.2.3