# SPDX-License-Identifier: GPL-2.0-only # # Copyright (C) 2006-2014 OpenWrt.org config KERNEL_BUILD_USER string "Custom Kernel Build User Name" default "builder" if BUILDBOT default "" help Sets the Kernel build user string, which for example will be returned by 'uname -a' on running systems. If not set, uses system user at build time. config KERNEL_BUILD_DOMAIN string "Custom Kernel Build Domain Name" default "buildhost" if BUILDBOT default "" help Sets the Kernel build domain string, which for example will be returned by 'uname -a' on running systems. If not set, uses system hostname at build time. config KERNEL_PRINTK bool "Enable support for printk" default y config KERNEL_CRASHLOG bool "Crash logging" depends on !(arm || powerpc || sparc || TARGET_uml || i386 || x86_64) default y config KERNEL_SWAP bool "Support for paging of anonymous memory (swap)" default y if !SMALL_FLASH config KERNEL_PROC_STRIPPED bool "Strip non-essential /proc functionality to reduce code size" default y if SMALL_FLASH config KERNEL_DEBUG_FS bool "Compile the kernel with debug filesystem enabled" default y help debugfs is a virtual file system that kernel developers use to put debugging files into. Enable this option to be able to read and write to these files. Many common debugging facilities, such as ftrace, require the existence of debugfs. config KERNEL_MIPS_FP_SUPPORT bool default y if TARGET_pistachio config KERNEL_ARM_PMU bool default n depends on (arm || aarch64) config KERNEL_X86_VSYSCALL_EMULATION bool "Enable vsyscall emulation" default n depends on x86_64 help This enables emulation of the legacy vsyscall page. Disabling it is roughly equivalent to booting with vsyscall=none, except that it will also disable the helpful warning if a program tries to use a vsyscall. With this option set to N, offending programs will just segfault, citing addresses of the form 0xffffffffff600?00. This option is required by many programs built before 2013, and care should be used even with newer programs if set to N. Disabling this option saves about 7K of kernel size and possibly 4K of additional runtime pagetable memory. config KERNEL_PERF_EVENTS bool "Compile the kernel with performance events and counters" default n select KERNEL_ARM_PMU if (arm || aarch64) config KERNEL_PROFILING bool "Compile the kernel with profiling enabled" default n select KERNEL_PERF_EVENTS help Enable the extended profiling support mechanisms used by profilers such as OProfile. config KERNEL_UBSAN bool "Compile the kernel with undefined behaviour sanity checker" help This option enables undefined behaviour sanity checker Compile-time instrumentation is used to detect various undefined behaviours in runtime. Various types of checks may be enabled via boot parameter ubsan_handle (see: Documentation/dev-tools/ubsan.rst). config KERNEL_UBSAN_SANITIZE_ALL bool "Enable instrumentation for the entire kernel" depends on KERNEL_UBSAN default y help This option activates instrumentation for the entire kernel. If you don't enable this option, you have to explicitly specify UBSAN_SANITIZE := y for the files/directories you want to check for UB. Enabling this option will get kernel image size increased significantly. config KERNEL_UBSAN_ALIGNMENT bool "Enable checking of pointers alignment" depends on KERNEL_UBSAN help This option enables detection of unaligned memory accesses. Enabling this option on architectures that support unaligned accesses may produce a lot of false positives. config KERNEL_UBSAN_NULL bool "Enable checking of null pointers" depends on KERNEL_UBSAN help This option enables detection of memory accesses via a null pointer. config KERNEL_KASAN bool "Compile the kernel with KASan: runtime memory debugger" select KERNEL_SLUB_DEBUG depends on (x86_64 || aarch64) help Enables kernel address sanitizer - runtime memory debugger, designed to find out-of-bounds accesses and use-after-free bugs. This is strictly a debugging feature and it requires a gcc version of 4.9.2 or later. Detection of out of bounds accesses to stack or global variables requires gcc 5.0 or later. This feature consumes about 1/8 of available memory and brings about ~x3 performance slowdown. For better error detection enable CONFIG_STACKTRACE. Currently CONFIG_KASAN doesn't work with CONFIG_DEBUG_SLAB (the resulting kernel does not boot). config KERNEL_KASAN_EXTRA bool "KAsan: extra checks" depends on KERNEL_KASAN && KERNEL_DEBUG_KERNEL help This enables further checks in the kernel address sanitizer, for now it only includes the address-use-after-scope check that can lead to excessive kernel stack usage, frame size warnings and longer compile time. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 has more choice prompt "Instrumentation type" depends on KERNEL_KASAN default KERNEL_KASAN_OUTLINE config KERNEL_KASAN_OUTLINE bool "Outline instrumentation" help Before every memory access compiler insert function call __asan_load*/__asan_store*. These functions performs check of shadow memory. This is slower than inline instrumentation, however it doesn't bloat size of kernel's .text section so much as inline does. config KERNEL_KASAN_INLINE bool "Inline instrumentation" help Compiler directly inserts code checking shadow memory before memory accesses. This is faster than outline (in some workloads it gives about x2 boost over outline instrumentation), but make kernel's .text size much bigger. This requires a gcc version of 5.0 or later. endchoice config KERNEL_KCOV bool "Compile the kernel with code coverage for fuzzing" select KERNEL_DEBUG_FS help KCOV exposes kernel code coverage information in a form suitable for coverage-guided fuzzing (randomized testing). If RANDOMIZE_BASE is enabled, PC values will not be stable across different machines and across reboots. If you need stable PC values, disable RANDOMIZE_BASE. For more details, see Documentation/kcov.txt. config KERNEL_KCOV_ENABLE_COMPARISONS bool "Enable comparison operands collection by KCOV" depends on KERNEL_KCOV help KCOV also exposes operands of every comparison in the instrumented code along with operand sizes and PCs of the comparison instructions. These operands can be used by fuzzing engines to improve the quality of fuzzing coverage. config KERNEL_KCOV_INSTRUMENT_ALL bool "Instrument all code by default" depends on KERNEL_KCOV default y if KERNEL_KCOV help If you are doing generic system call fuzzing (like e.g. syzkaller), then you will want to instrument the whole kernel and you should say y here. If you are doing more targeted fuzzing (like e.g. filesystem fuzzing with AFL) then you will want to enable coverage for more specific subsets of files, and should say n here. config KERNEL_TASKSTATS bool "Compile the kernel with task resource/io statistics and accounting" default n help Enable the collection and publishing of task/io statistics and accounting. Enable this option to enable i/o monitoring
#!/usr/bin/env perl
#
# Script for generating redboot configs, based on brcmImage.pl
#
# Copyright (C) 2015 Álvaro Fernández Rojas <noltari@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

use strict;
use Getopt::Std;
use File::stat;

my $version = "0.1";
my %arg = (
	o => 'redboot.script',
	s => 0x1000,
	f => 0xbe430000,
	a => 0x80010000,
	l => 0x7c0000,
	t => 20,
);
my $prog = $0;
$prog =~ s/^.*\///;
getopts("r:k:o:s:f:a:l:t:vh", \%arg);

die "usage: $prog ~opts~

  -r <file>	: input rootfs file
  -k <file>	: input kernel file
  -o <file>	: output image file, default $arg{o}
  -s <size_kb>	: redboot script size, default ".sprintf('%d', parse_num($arg{s}))."
  -f <baseaddr>	: flash base, default ".sprintf('0x%x', parse_num($arg{f}))."
  -a <loadaddr>	: Kernel load address, default ".sprintf('0x%x', parse_num($arg{a}))."
  -l <linux_kb>	: linux partition size, default ".sprintf('0x%x', parse_num($arg{l}))."
  -t <timeout> 	: redboot script timeout, default ".sprintf('%d', parse_num($arg{t}))."
  -v		: be more verbose
  -h		: help, version $version

EXAMPLES:
    $prog -k kern -r rootfs
" if $arg{h} || !$arg{k} || !$arg{r};

sub parse_num
{
	my $num = @_[0];
	if (index(lc($num), lc("0x")) == 0) {
		return hex($num);
	} else {
		return $num + 0;
	}
}

sub gen_script
{
	my $kernel_off = parse_num($arg{s});
	my $kernel_addr = parse_num($arg{f});
	my $kernel_len = stat($arg{k})->size;

	my $rootfs_off = $kernel_off + $kernel_len;
	my $rootfs_addr = $kernel_addr + $kernel_len;
	my $rootfs_len = parse_num($arg{l}) - $kernel_len;
	my $rootfs_size = stat($arg{r})->size;

	my $load_addr = parse_num($arg{a});

	my $timeout = parse_num($arg{t});

	if ($arg{v}) {
		printf "kernel_off: 0x%x(%u)\n", $kernel_off, $kernel_off;
		printf "kernel_addr: 0x%x(%u)\n", $kernel_addr, $kernel_addr;
		printf "kernel_len: 0x%x(%u)\n", $kernel_len, $kernel_len;

		printf "rootfs_off: 0x%x(%u)\n", $rootfs_off, $rootfs_off;
		printf "rootfs_addr: 0x%x(%u)\n", $rootfs_addr, $rootfs_addr;
		printf "rootfs_len: 0x%x(%u)\n", $rootfs_len, $rootfs_len;
		printf "rootfs_size: 0x%x(%u)\n", $rootfs_size, $rootfs_size;
	}

	open(FO, ">$arg{o}");
	printf FO "fis init -f\n";
	printf FO "\n";
	printf FO "fconfig boot_script true\n";
	printf FO "fconfig boot_script_data\n";
	printf FO "fis load -b 0x%x -d kernel\n", $load_addr;
	printf FO "exec -c \"noinitrd\" 0x%x\n", $load_addr;
	printf FO "\n";
	printf FO "fconfig boot_script_timeout %d\n", $timeout;
	printf FO "\n";
	printf FO "fis create -o 0x%x -f 0x%x -l 0x%x kernel\n", $kernel_off, $kernel_addr, $kernel_len;
	printf FO "\n";
	printf FO "fis create -o 0x%x -s 0x%x -f 0x%x -l 0x%x rootfs\n", $rootfs_off, $rootfs_size, $rootfs_addr, $rootfs_len;
	printf FO "\n";
	printf FO "reset\n";
	close FO;
}

# MAIN
gen_script();
nds on KERNEL_SECURITY_SELINUX config KERNEL_EXT4_FS_SECURITY bool "Ext4 Security Labels" config KERNEL_F2FS_FS_SECURITY bool "F2FS Security Labels" config KERNEL_UBIFS_FS_SECURITY bool "UBIFS Security Labels" config KERNEL_JFFS2_FS_SECURITY bool "JFFS2 Security Labels"