diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-07-30 02:05:15 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-30 11:28:55 +0200 |
commit | c9395d7e9a80c35adbd365794ef6b6c80977020b (patch) | |
tree | 345a6377378d2af612730b675eb7c2bc6d07f1b6 | |
parent | 0fcb9efd86da4c15a1aee87503348c5bee875c51 (diff) | |
download | serenity-c9395d7e9a80c35adbd365794ef6b6c80977020b.zip |
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>
-rw-r--r-- | Tests/Kernel/TestMunMap.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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 <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); +} |