kaslr.c (9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e) kaslr.c (8339f7d8e178d9c933f437d14be0a5fd1359f53d)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2016 Linaro Ltd <ard.biesheuvel@linaro.org>
4 */
5
6#include <linux/cache.h>
7#include <linux/crc32.h>
8#include <linux/init.h>

--- 34 unchanged lines hidden (view full) ---

43
44 if (!kaslr_enabled()) {
45 pr_warn("KASLR disabled due to lack of seed\n");
46 return 0;
47 }
48
49 pr_info("KASLR enabled\n");
50
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2016 Linaro Ltd <ard.biesheuvel@linaro.org>
4 */
5
6#include <linux/cache.h>
7#include <linux/crc32.h>
8#include <linux/init.h>

--- 34 unchanged lines hidden (view full) ---

43
44 if (!kaslr_enabled()) {
45 pr_warn("KASLR disabled due to lack of seed\n");
46 return 0;
47 }
48
49 pr_info("KASLR enabled\n");
50
51 /*
52 * KASAN without KASAN_VMALLOC does not expect the module region to
53 * intersect the vmalloc region, since shadow memory is allocated for
54 * each module at load time, whereas the vmalloc region will already be
55 * shadowed by KASAN zero pages.
56 */
57 BUILD_BUG_ON((IS_ENABLED(CONFIG_KASAN_GENERIC) ||
58 IS_ENABLED(CONFIG_KASAN_SW_TAGS)) &&
59 !IS_ENABLED(CONFIG_KASAN_VMALLOC));
60
61 seed = get_random_u32();
62
63 if (IS_ENABLED(CONFIG_RANDOMIZE_MODULE_REGION_FULL)) {
64 /*
65 * Randomize the module region over a 2 GB window covering the
66 * kernel. This reduces the risk of modules leaking information
67 * about the address of the kernel itself, but results in
68 * branches between modules and the core kernel that are

--- 25 unchanged lines hidden ---
51 seed = get_random_u32();
52
53 if (IS_ENABLED(CONFIG_RANDOMIZE_MODULE_REGION_FULL)) {
54 /*
55 * Randomize the module region over a 2 GB window covering the
56 * kernel. This reduces the risk of modules leaking information
57 * about the address of the kernel itself, but results in
58 * branches between modules and the core kernel that are

--- 25 unchanged lines hidden ---