File Index
Files and directories
Sign in
FILE

kaslr.c

File preview with syntax highlighting.

linux-6.19.14/arch/arm64/kernel/kaslr.c C
 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/init.h>
 8#include <linux/printk.h>
 9
10#include <asm/cpufeature.h>
11#include <asm/memory.h>
12
13bool __ro_after_init __kaslr_is_enabled = false;
14
15void __init kaslr_init(void)
16{
17	if (kaslr_disabled_cmdline()) {
18		pr_info("KASLR disabled on command line\n");
19		return;
20	}
21
22	/*
23	 * The KASLR offset modulo MIN_KIMG_ALIGN is taken from the physical
24	 * placement of the image rather than from the seed, so a displacement
25	 * of less than MIN_KIMG_ALIGN means that no seed was provided.
26	 */
27	if (kaslr_offset() < MIN_KIMG_ALIGN) {
28		pr_warn("KASLR disabled due to lack of seed\n");
29		return;
30	}
31
32	pr_info("KASLR enabled\n");
33	__kaslr_is_enabled = true;
34}
35
36static int __init parse_nokaslr(char *unused)
37{
38	/* nokaslr param handling is done by early cpufeature code */
39	return 0;
40}
41early_param("nokaslr", parse_nokaslr);
~/ Read-only file preview.