License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* misc.c
|
2008-01-30 15:33:38 +03:00
|
|
|
*
|
2016-04-18 19:42:13 +03:00
|
|
|
* This is a collection of several routines used to extract the kernel
|
|
|
|
* which includes KASLR relocation, decompression, ELF parsing, and
|
|
|
|
* relocation processing. Additionally included are the screen and serial
|
|
|
|
* output functions and related debugging support functions.
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
* malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
|
|
|
|
* puts by Nick Holloway 1993, better puts by Martin Mares 1995
|
|
|
|
* High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
|
|
|
|
*/
|
|
|
|
|
2010-08-03 03:21:22 +04:00
|
|
|
#include "misc.h"
|
2016-05-03 01:51:00 +03:00
|
|
|
#include "error.h"
|
2018-02-26 21:04:48 +03:00
|
|
|
#include "pgtable.h"
|
2014-03-18 23:26:38 +04:00
|
|
|
#include "../string.h"
|
x86/boot: Fix "run_size" calculation
Currently, the "run_size" variable holds the total kernel size
(size of code plus brk and bss) and is calculated via the shell script
arch/x86/tools/calc_run_size.sh. It gets the file offset and mem size
of the .bss and .brk sections from the vmlinux, and adds them as follows:
run_size = $(( $offsetA + $sizeA + $sizeB ))
However, this is not correct (it is too large). To illustrate, here's
a walk-through of the script's calculation, compared to the correct way
to find it.
First, offsetA is found as the starting address of the first .bss or
.brk section seen in the ELF file. The sizeA and sizeB values are the
respective section sizes.
[bhe@x1 linux]$ objdump -h vmlinux
vmlinux: file format elf64-x86-64
Sections:
Idx Name Size VMA LMA File off Algn
27 .bss 00170000 ffffffff81ec8000 0000000001ec8000 012c8000 2**12
ALLOC
28 .brk 00027000 ffffffff82038000 0000000002038000 012c8000 2**0
ALLOC
Here, offsetA is 0x012c8000, with sizeA at 0x00170000 and sizeB at
0x00027000. The resulting run_size is 0x145f000:
0x012c8000 + 0x00170000 + 0x00027000 = 0x145f000
However, if we instead examine the ELF LOAD program headers, we see a
different picture.
[bhe@x1 linux]$ readelf -l vmlinux
Elf file type is EXEC (Executable file)
Entry point 0x1000000
There are 5 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000200000 0xffffffff81000000 0x0000000001000000
0x0000000000b5e000 0x0000000000b5e000 R E 200000
LOAD 0x0000000000e00000 0xffffffff81c00000 0x0000000001c00000
0x0000000000145000 0x0000000000145000 RW 200000
LOAD 0x0000000001000000 0x0000000000000000 0x0000000001d45000
0x0000000000018158 0x0000000000018158 RW 200000
LOAD 0x000000000115e000 0xffffffff81d5e000 0x0000000001d5e000
0x000000000016a000 0x0000000000301000 RWE 200000
NOTE 0x000000000099bcac 0xffffffff8179bcac 0x000000000179bcac
0x00000000000001bc 0x00000000000001bc 4
Section to Segment mapping:
Segment Sections...
00 .text .notes __ex_table .rodata __bug_table .pci_fixup .tracedata
__ksymtab __ksymtab_gpl __ksymtab_strings __init_rodata __param
__modver
01 .data .vvar
02 .data..percpu
03 .init.text .init.data .x86_cpu_dev.init .parainstructions
.altinstructions .altinstr_replacement .iommu_table .apicdrivers
.exit.text .smp_locks .bss .brk
04 .notes
As mentioned, run_size needs to be the size of the running kernel
including .bss and .brk. We can see from the Section/Segment mapping
above that .bss and .brk are included in segment 03 (which corresponds
to the final LOAD program header). To find the run_size, we calculate
the end of the LOAD segment from its PhysAddr start (0x0000000001d5e000)
and its MemSiz (0x0000000000301000), minus the physical load address of
the kernel (the first LOAD segment's PhysAddr: 0x0000000001000000). The
resulting run_size is 0x105f000:
0x0000000001d5e000 + 0x0000000000301000 - 0x0000000001000000 = 0x105f000
So, from this we can see that the existing run_size calculation is
0x400000 too high. And, as it turns out, the correct run_size is
actually equal to VO_end - VO_text, which is certainly easier to calculate.
_end: 0xffffffff8205f000
_text:0xffffffff81000000
0xffffffff8205f000 - 0xffffffff81000000 = 0x105f000
As a result, run_size is a simple constant, so we don't need to pass it
around; we already have voffset.h for such things. We can share voffset.h
between misc.c and header.S instead of getting run_size in other ways.
This patch moves voffset.h creation code to boot/compressed/Makefile,
and switches misc.c to use the VO_end - VO_text calculation for run_size.
Dependence before:
boot/header.S ==> boot/voffset.h ==> vmlinux
boot/header.S ==> compressed/vmlinux ==> compressed/misc.c
Dependence after:
boot/header.S ==> compressed/vmlinux ==> compressed/misc.c ==> boot/voffset.h ==> vmlinux
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Baoquan He <bhe@redhat.com>
[ Rewrote the changelog. ]
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Junjie Mao <eternal.n08@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: lasse.collin@tukaani.org
Fixes: e6023367d779 ("x86, kaslr: Prevent .bss from overlaping initrd")
Link: http://lkml.kernel.org/r/1461888548-32439-5-git-send-email-keescook@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-04-29 03:09:06 +03:00
|
|
|
#include "../voffset.h"
|
2006-12-07 04:14:04 +03:00
|
|
|
|
|
|
|
/*
|
x86/KASLR: Update description for decompressor worst case size
The comment that describes the analysis for the size of the decompressor
code only took gzip into account (there are currently 6 other decompressors
that could be used). The actual z_extract_offset calculation in code was
already handling the correct maximum size, but this documentation hadn't
been updated. This updates the documentation, fixes several typos, moves
the comment to header.S, updates references, and adds a note at the end
of the decompressor include list to remind us about updating the comment
in the future.
(Instead of moving the comment to mkpiggy.c, where the calculation
is currently happening, it is being moved to header.S because
the calculations in mkpiggy.c will be removed in favor of header.S
calculations in a following patch, and it seemed like overkill to move
the giant comment twice, especially when there's already reference to
z_extract_offset in header.S.)
Signed-off-by: Baoquan He <bhe@redhat.com>
[ Rewrote changelog, cleaned up comment style, moved comments around. ]
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: H.J. Lu <hjl.tools@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1461185746-8017-2-git-send-email-keescook@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-04-20 23:55:42 +03:00
|
|
|
* WARNING!!
|
|
|
|
* This code is compiled with -fPIC and it is relocated dynamically at
|
|
|
|
* run time, but no relocation processing is performed. This means that
|
|
|
|
* it is not safe to place pointers in static structures.
|
2006-12-07 04:14:04 +03:00
|
|
|
*/
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-04-20 23:55:44 +03:00
|
|
|
/* Macros used by the included decompressor code below. */
|
2008-02-21 07:03:48 +03:00
|
|
|
#define STATIC static
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2014-03-18 23:26:40 +04:00
|
|
|
/*
|
2016-04-20 23:55:44 +03:00
|
|
|
* Use normal definitions of mem*() from string.c. There are already
|
2014-03-18 23:26:40 +04:00
|
|
|
* included header files which expect a definition of memset() and by
|
|
|
|
* the time we define memset macro, it is too late.
|
|
|
|
*/
|
2016-04-20 23:55:44 +03:00
|
|
|
#undef memcpy
|
2014-03-18 23:26:40 +04:00
|
|
|
#undef memset
|
2008-02-21 07:03:48 +03:00
|
|
|
#define memzero(s, n) memset((s), 0, (n))
|
2016-04-27 00:46:06 +03:00
|
|
|
#define memmove memmove
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-04-20 23:55:44 +03:00
|
|
|
/* Functions used by the included decompressor code below. */
|
2016-04-27 00:46:06 +03:00
|
|
|
void *memmove(void *dest, const void *src, size_t n);
|
2008-02-21 02:19:10 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* This is set up by the setup-routine at boot-time
|
|
|
|
*/
|
2016-04-18 19:42:12 +03:00
|
|
|
struct boot_params *boot_params;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2013-10-11 04:18:16 +04:00
|
|
|
memptr free_mem_ptr;
|
|
|
|
memptr free_mem_end_ptr;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-04-06 16:47:00 +04:00
|
|
|
static char *vidmem;
|
2005-04-17 02:20:36 +04:00
|
|
|
static int vidport;
|
|
|
|
static int lines, cols;
|
|
|
|
|
2009-01-05 00:46:17 +03:00
|
|
|
#ifdef CONFIG_KERNEL_GZIP
|
|
|
|
#include "../../../../lib/decompress_inflate.c"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_KERNEL_BZIP2
|
|
|
|
#include "../../../../lib/decompress_bunzip2.c"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_KERNEL_LZMA
|
|
|
|
#include "../../../../lib/decompress_unlzma.c"
|
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-01-13 04:01:24 +03:00
|
|
|
#ifdef CONFIG_KERNEL_XZ
|
|
|
|
#include "../../../../lib/decompress_unxz.c"
|
|
|
|
#endif
|
|
|
|
|
2010-01-09 01:42:45 +03:00
|
|
|
#ifdef CONFIG_KERNEL_LZO
|
|
|
|
#include "../../../../lib/decompress_unlzo.c"
|
|
|
|
#endif
|
|
|
|
|
2013-07-09 03:01:48 +04:00
|
|
|
#ifdef CONFIG_KERNEL_LZ4
|
|
|
|
#include "../../../../lib/decompress_unlz4.c"
|
|
|
|
#endif
|
x86/KASLR: Update description for decompressor worst case size
The comment that describes the analysis for the size of the decompressor
code only took gzip into account (there are currently 6 other decompressors
that could be used). The actual z_extract_offset calculation in code was
already handling the correct maximum size, but this documentation hadn't
been updated. This updates the documentation, fixes several typos, moves
the comment to header.S, updates references, and adds a note at the end
of the decompressor include list to remind us about updating the comment
in the future.
(Instead of moving the comment to mkpiggy.c, where the calculation
is currently happening, it is being moved to header.S because
the calculations in mkpiggy.c will be removed in favor of header.S
calculations in a following patch, and it seemed like overkill to move
the giant comment twice, especially when there's already reference to
z_extract_offset in header.S.)
Signed-off-by: Baoquan He <bhe@redhat.com>
[ Rewrote changelog, cleaned up comment style, moved comments around. ]
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: H.J. Lu <hjl.tools@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1461185746-8017-2-git-send-email-keescook@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-04-20 23:55:42 +03:00
|
|
|
/*
|
|
|
|
* NOTE: When adding a new decompressor, please update the analysis in
|
|
|
|
* ../header.S.
|
|
|
|
*/
|
2013-07-09 03:01:48 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static void scroll(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2016-04-27 00:46:06 +03:00
|
|
|
memmove(vidmem, vidmem + cols * 2, (lines - 1) * cols * 2);
|
2008-02-21 02:19:10 +03:00
|
|
|
for (i = (lines - 1) * cols * 2; i < lines * cols * 2; i += 2)
|
2005-04-17 02:20:36 +04:00
|
|
|
vidmem[i] = ' ';
|
|
|
|
}
|
|
|
|
|
2010-08-03 03:21:22 +04:00
|
|
|
#define XMTRDY 0x20
|
|
|
|
|
|
|
|
#define TXR 0 /* Transmit register (WRITE) */
|
|
|
|
#define LSR 5 /* Line Status */
|
|
|
|
static void serial_putchar(int ch)
|
|
|
|
{
|
|
|
|
unsigned timeout = 0xffff;
|
|
|
|
|
|
|
|
while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
|
|
|
|
cpu_relax();
|
|
|
|
|
|
|
|
outb(ch, early_serial_base + TXR);
|
|
|
|
}
|
|
|
|
|
2012-07-20 05:04:39 +04:00
|
|
|
void __putstr(const char *s)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-02-21 02:19:10 +03:00
|
|
|
int x, y, pos;
|
2005-04-17 02:20:36 +04:00
|
|
|
char c;
|
|
|
|
|
2010-08-03 03:21:22 +04:00
|
|
|
if (early_serial_base) {
|
|
|
|
const char *str = s;
|
|
|
|
while (*str) {
|
|
|
|
if (*str == '\n')
|
|
|
|
serial_putchar('\r');
|
|
|
|
serial_putchar(*str++);
|
|
|
|
}
|
|
|
|
}
|
2008-06-18 22:04:35 +04:00
|
|
|
|
2017-08-27 21:23:43 +03:00
|
|
|
if (lines == 0 || cols == 0)
|
2007-10-22 03:41:35 +04:00
|
|
|
return;
|
|
|
|
|
2016-04-18 19:42:12 +03:00
|
|
|
x = boot_params->screen_info.orig_x;
|
|
|
|
y = boot_params->screen_info.orig_y;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-02-21 02:19:10 +03:00
|
|
|
while ((c = *s++) != '\0') {
|
|
|
|
if (c == '\n') {
|
2005-04-17 02:20:36 +04:00
|
|
|
x = 0;
|
2008-02-21 02:19:10 +03:00
|
|
|
if (++y >= lines) {
|
2005-04-17 02:20:36 +04:00
|
|
|
scroll();
|
|
|
|
y--;
|
|
|
|
}
|
|
|
|
} else {
|
2008-08-02 23:23:36 +04:00
|
|
|
vidmem[(x + cols * y) * 2] = c;
|
2008-02-21 02:19:10 +03:00
|
|
|
if (++x >= cols) {
|
2005-04-17 02:20:36 +04:00
|
|
|
x = 0;
|
2008-02-21 02:19:10 +03:00
|
|
|
if (++y >= lines) {
|
2005-04-17 02:20:36 +04:00
|
|
|
scroll();
|
|
|
|
y--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-18 19:42:12 +03:00
|
|
|
boot_params->screen_info.orig_x = x;
|
|
|
|
boot_params->screen_info.orig_y = y;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
pos = (x + cols * y) * 2; /* Update cursor position */
|
2008-01-30 15:30:05 +03:00
|
|
|
outb(14, vidport);
|
|
|
|
outb(0xff & (pos >> 9), vidport+1);
|
|
|
|
outb(15, vidport);
|
|
|
|
outb(0xff & (pos >> 1), vidport+1);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2015-07-07 02:06:20 +03:00
|
|
|
void __puthex(unsigned long value)
|
|
|
|
{
|
|
|
|
char alpha[2] = "0";
|
|
|
|
int bits;
|
|
|
|
|
|
|
|
for (bits = sizeof(value) * 8 - 4; bits >= 0; bits -= 4) {
|
|
|
|
unsigned long digit = (value >> bits) & 0xf;
|
|
|
|
|
|
|
|
if (digit < 0xA)
|
|
|
|
alpha[0] = '0' + digit;
|
|
|
|
else
|
|
|
|
alpha[0] = 'a' + (digit - 0xA);
|
|
|
|
|
|
|
|
__putstr(alpha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-08 20:15:17 +04:00
|
|
|
#if CONFIG_X86_NEED_RELOCS
|
2016-05-26 01:45:32 +03:00
|
|
|
static void handle_relocations(void *output, unsigned long output_len,
|
|
|
|
unsigned long virt_addr)
|
2013-07-08 20:15:17 +04:00
|
|
|
{
|
|
|
|
int *reloc;
|
|
|
|
unsigned long delta, map, ptr;
|
|
|
|
unsigned long min_addr = (unsigned long)output;
|
2016-04-29 03:09:08 +03:00
|
|
|
unsigned long max_addr = min_addr + (VO___bss_start - VO__text);
|
2013-07-08 20:15:17 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the delta between where vmlinux was linked to load
|
|
|
|
* and where it was actually loaded.
|
|
|
|
*/
|
|
|
|
delta = min_addr - LOAD_PHYSICAL_ADDR;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The kernel contains a table of relocation addresses. Those
|
|
|
|
* addresses have the final load address of the kernel in virtual
|
|
|
|
* memory. We are currently working in the self map. So we need to
|
|
|
|
* create an adjustment for kernel memory addresses to the self map.
|
|
|
|
* This will involve subtracting out the base address of the kernel.
|
|
|
|
*/
|
|
|
|
map = delta - __START_KERNEL_map;
|
|
|
|
|
2016-05-26 01:45:32 +03:00
|
|
|
/*
|
|
|
|
* 32-bit always performs relocations. 64-bit relocations are only
|
|
|
|
* needed if KASLR has chosen a different starting address offset
|
|
|
|
* from __START_KERNEL_map.
|
|
|
|
*/
|
|
|
|
if (IS_ENABLED(CONFIG_X86_64))
|
|
|
|
delta = virt_addr - LOAD_PHYSICAL_ADDR;
|
|
|
|
|
|
|
|
if (!delta) {
|
|
|
|
debug_putstr("No relocation needed... ");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
debug_putstr("Performing relocations... ");
|
|
|
|
|
2013-07-08 20:15:17 +04:00
|
|
|
/*
|
|
|
|
* Process relocations: 32 bit relocations first then 64 bit after.
|
2014-11-04 11:50:18 +03:00
|
|
|
* Three sets of binary relocations are added to the end of the kernel
|
2013-07-08 20:15:17 +04:00
|
|
|
* before compression. Each relocation table entry is the kernel
|
|
|
|
* address of the location which needs to be updated stored as a
|
|
|
|
* 32-bit value which is sign extended to 64 bits.
|
|
|
|
*
|
|
|
|
* Format is:
|
|
|
|
*
|
|
|
|
* kernel bits...
|
|
|
|
* 0 - zero terminator for 64 bit relocations
|
|
|
|
* 64 bit relocation repeated
|
2014-11-04 11:50:18 +03:00
|
|
|
* 0 - zero terminator for inverse 32 bit relocations
|
|
|
|
* 32 bit inverse relocation repeated
|
2013-07-08 20:15:17 +04:00
|
|
|
* 0 - zero terminator for 32 bit relocations
|
|
|
|
* 32 bit relocation repeated
|
|
|
|
*
|
|
|
|
* So we work backwards from the end of the decompressed image.
|
|
|
|
*/
|
|
|
|
for (reloc = output + output_len - sizeof(*reloc); *reloc; reloc--) {
|
2016-04-29 03:09:03 +03:00
|
|
|
long extended = *reloc;
|
2013-07-08 20:15:17 +04:00
|
|
|
extended += map;
|
|
|
|
|
|
|
|
ptr = (unsigned long)extended;
|
|
|
|
if (ptr < min_addr || ptr > max_addr)
|
|
|
|
error("32-bit relocation outside of kernel!\n");
|
|
|
|
|
|
|
|
*(uint32_t *)ptr += delta;
|
|
|
|
}
|
|
|
|
#ifdef CONFIG_X86_64
|
2014-11-04 11:50:18 +03:00
|
|
|
while (*--reloc) {
|
|
|
|
long extended = *reloc;
|
|
|
|
extended += map;
|
|
|
|
|
|
|
|
ptr = (unsigned long)extended;
|
|
|
|
if (ptr < min_addr || ptr > max_addr)
|
|
|
|
error("inverse 32-bit relocation outside of kernel!\n");
|
|
|
|
|
|
|
|
*(int32_t *)ptr -= delta;
|
|
|
|
}
|
2013-07-08 20:15:17 +04:00
|
|
|
for (reloc--; *reloc; reloc--) {
|
|
|
|
long extended = *reloc;
|
|
|
|
extended += map;
|
|
|
|
|
|
|
|
ptr = (unsigned long)extended;
|
|
|
|
if (ptr < min_addr || ptr > max_addr)
|
|
|
|
error("64-bit relocation outside of kernel!\n");
|
|
|
|
|
|
|
|
*(uint64_t *)ptr += delta;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#else
|
2016-05-26 01:45:32 +03:00
|
|
|
static inline void handle_relocations(void *output, unsigned long output_len,
|
|
|
|
unsigned long virt_addr)
|
2013-07-08 20:15:17 +04:00
|
|
|
{ }
|
|
|
|
#endif
|
|
|
|
|
2008-02-13 23:54:58 +03:00
|
|
|
static void parse_elf(void *output)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
Elf64_Ehdr ehdr;
|
|
|
|
Elf64_Phdr *phdrs, *phdr;
|
|
|
|
#else
|
|
|
|
Elf32_Ehdr ehdr;
|
|
|
|
Elf32_Phdr *phdrs, *phdr;
|
|
|
|
#endif
|
|
|
|
void *dest;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memcpy(&ehdr, output, sizeof(ehdr));
|
2008-02-21 02:19:10 +03:00
|
|
|
if (ehdr.e_ident[EI_MAG0] != ELFMAG0 ||
|
2008-02-13 23:54:58 +03:00
|
|
|
ehdr.e_ident[EI_MAG1] != ELFMAG1 ||
|
|
|
|
ehdr.e_ident[EI_MAG2] != ELFMAG2 ||
|
2008-02-21 02:19:10 +03:00
|
|
|
ehdr.e_ident[EI_MAG3] != ELFMAG3) {
|
2008-02-13 23:54:58 +03:00
|
|
|
error("Kernel is not a valid ELF file");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-20 05:04:37 +04:00
|
|
|
debug_putstr("Parsing ELF... ");
|
2008-02-13 23:54:58 +03:00
|
|
|
|
|
|
|
phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
|
|
|
|
if (!phdrs)
|
|
|
|
error("Failed to allocate space for phdrs");
|
|
|
|
|
|
|
|
memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum);
|
|
|
|
|
2008-02-21 02:19:10 +03:00
|
|
|
for (i = 0; i < ehdr.e_phnum; i++) {
|
2008-02-13 23:54:58 +03:00
|
|
|
phdr = &phdrs[i];
|
|
|
|
|
|
|
|
switch (phdr->p_type) {
|
|
|
|
case PT_LOAD:
|
2018-03-20 00:08:11 +03:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
if ((phdr->p_align % 0x200000) != 0)
|
|
|
|
error("Alignment of LOAD segment isn't multiple of 2MB");
|
|
|
|
#endif
|
2008-02-13 23:54:58 +03:00
|
|
|
#ifdef CONFIG_RELOCATABLE
|
|
|
|
dest = output;
|
|
|
|
dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
|
|
|
|
#else
|
2008-02-21 02:19:10 +03:00
|
|
|
dest = (void *)(phdr->p_paddr);
|
2008-02-13 23:54:58 +03:00
|
|
|
#endif
|
2016-04-27 00:46:06 +03:00
|
|
|
memmove(dest, output + phdr->p_offset, phdr->p_filesz);
|
2008-02-13 23:54:58 +03:00
|
|
|
break;
|
|
|
|
default: /* Ignore other PT_* */ break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-24 02:34:59 +04:00
|
|
|
|
|
|
|
free(phdrs);
|
2008-02-13 23:54:58 +03:00
|
|
|
}
|
|
|
|
|
x86/boot: Move compressed kernel to the end of the decompression buffer
This change makes later calculations about where the kernel is located
easier to reason about. To better understand this change, we must first
clarify what 'VO' and 'ZO' are. These values were introduced in commits
by hpa:
77d1a4999502 ("x86, boot: make symbols from the main vmlinux available")
37ba7ab5e33c ("x86, boot: make kernel_alignment adjustable; new bzImage fields")
Specifically:
All names prefixed with 'VO_':
- relate to the uncompressed kernel image
- the size of the VO image is: VO__end-VO__text ("VO_INIT_SIZE" define)
All names prefixed with 'ZO_':
- relate to the bootable compressed kernel image (boot/compressed/vmlinux),
which is composed of the following memory areas:
- head text
- compressed kernel (VO image and relocs table)
- decompressor code
- the size of the ZO image is: ZO__end - ZO_startup_32 ("ZO_INIT_SIZE" define, though see below)
The 'INIT_SIZE' value is used to find the larger of the two image sizes:
#define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
#define VO_INIT_SIZE (VO__end - VO__text)
#if ZO_INIT_SIZE > VO_INIT_SIZE
# define INIT_SIZE ZO_INIT_SIZE
#else
# define INIT_SIZE VO_INIT_SIZE
#endif
The current code uses extract_offset to decide where to position the
copied ZO (i.e. ZO starts at extract_offset). (This is why ZO_INIT_SIZE
currently includes the extract_offset.)
Why does z_extract_offset exist? It's needed because we are trying to minimize
the amount of RAM used for the whole act of creating an uncompressed, executable,
properly relocation-linked kernel image in system memory. We do this so that
kernels can be booted on even very small systems.
To achieve the goal of minimal memory consumption we have implemented an in-place
decompression strategy: instead of cleanly separating the VO and ZO images and
also allocating some memory for the decompression code's runtime needs, we instead
create this elaborate layout of memory buffers where the output (decompressed)
stream, as it progresses, overlaps with and destroys the input (compressed)
stream. This can only be done safely if the ZO image is placed to the end of the
VO range, plus a certain amount of safety distance to make sure that when the last
bytes of the VO range are decompressed, the compressed stream pointer is safely
beyond the end of the VO range.
z_extract_offset is calculated in arch/x86/boot/compressed/mkpiggy.c during
the build process, at a point when we know the exact compressed and
uncompressed size of the kernel images and can calculate this safe minimum
offset value. (Note that the mkpiggy.c calculation is not perfect, because
we don't know the decompressor used at that stage, so the z_extract_offset
calculation is necessarily imprecise and is mostly based on gzip internals -
we'll improve that in the next patch.)
When INIT_SIZE is bigger than VO_INIT_SIZE (uncommon but possible),
the copied ZO occupies the memory from extract_offset to the end of
decompression buffer. It overlaps with the soon-to-be-uncompressed kernel
like this:
|-----compressed kernel image------|
V V
0 extract_offset +INIT_SIZE
|-----------|---------------|-------------------------|--------|
| | | |
VO__text startup_32 of ZO VO__end ZO__end
^ ^
|-------uncompressed kernel image---------|
When INIT_SIZE is equal to VO_INIT_SIZE (likely) there's still space
left from end of ZO to the end of decompressing buffer, like below.
|-compressed kernel image-|
V V
0 extract_offset +INIT_SIZE
|-----------|---------------|-------------------------|--------|
| | | |
VO__text startup_32 of ZO ZO__end VO__end
^ ^
|------------uncompressed kernel image-------------|
To simplify calculations and avoid special cases, it is cleaner to
always place the compressed kernel image in memory so that ZO__end
is at the end of the decompression buffer, instead of placing t at
the start of extract_offset as is currently done.
This patch adds BP_init_size (which is the INIT_SIZE as passed in from
the boot_params) into asm-offsets.c to make it visible to the assembly
code.
Then when moving the ZO, it calculates the starting position of
the copied ZO (via BP_init_size and the ZO run size) so that the VO__end
will be at the end of the decompression buffer. To make the position
calculation safe, the end of ZO is page aligned (and a comment is added
to the existing VO alignment for good measure).
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
[ Rewrote changelog and comments. ]
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: lasse.collin@tukaani.org
Link: http://lkml.kernel.org/r/1461888548-32439-3-git-send-email-keescook@chromium.org
[ Rewrote the changelog some more. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-04-29 03:09:04 +03:00
|
|
|
/*
|
|
|
|
* The compressed kernel image (ZO), has been moved so that its position
|
|
|
|
* is against the end of the buffer used to hold the uncompressed kernel
|
|
|
|
* image (VO) and the execution environment (.bss, .brk), which makes sure
|
|
|
|
* there is room to do the in-place decompression. (See header.S for the
|
|
|
|
* calculations.)
|
|
|
|
*
|
|
|
|
* |-----compressed kernel image------|
|
|
|
|
* V V
|
|
|
|
* 0 extract_offset +INIT_SIZE
|
|
|
|
* |-----------|---------------|-------------------------|--------|
|
|
|
|
* | | | |
|
|
|
|
* VO__text startup_32 of ZO VO__end ZO__end
|
|
|
|
* ^ ^
|
|
|
|
* |-------uncompressed kernel image---------|
|
|
|
|
*
|
|
|
|
*/
|
2016-04-18 19:42:13 +03:00
|
|
|
asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
|
2008-02-21 07:03:48 +03:00
|
|
|
unsigned char *input_data,
|
|
|
|
unsigned long input_len,
|
2013-07-08 20:15:17 +04:00
|
|
|
unsigned char *output,
|
2016-04-29 03:09:07 +03:00
|
|
|
unsigned long output_len)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2016-04-29 03:09:07 +03:00
|
|
|
const unsigned long kernel_total_size = VO__end - VO__text;
|
2017-06-27 15:39:06 +03:00
|
|
|
unsigned long virt_addr = LOAD_PHYSICAL_ADDR;
|
2015-01-16 03:51:46 +03:00
|
|
|
|
2016-04-18 19:42:12 +03:00
|
|
|
/* Retain x86 boot parameters pointer passed from startup_32/64. */
|
|
|
|
boot_params = rmode;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-04-18 19:42:12 +03:00
|
|
|
/* Clear flags intended for solely in-kernel use. */
|
|
|
|
boot_params->hdr.loadflags &= ~KASLR_FLAG;
|
2015-04-01 13:49:52 +03:00
|
|
|
|
2016-04-18 19:42:12 +03:00
|
|
|
sanitize_boot_params(boot_params);
|
2013-01-29 13:05:24 +04:00
|
|
|
|
2016-04-18 19:42:12 +03:00
|
|
|
if (boot_params->screen_info.orig_video_mode == 7) {
|
2005-04-17 02:20:36 +04:00
|
|
|
vidmem = (char *) 0xb0000;
|
|
|
|
vidport = 0x3b4;
|
|
|
|
} else {
|
|
|
|
vidmem = (char *) 0xb8000;
|
|
|
|
vidport = 0x3d4;
|
|
|
|
}
|
|
|
|
|
2016-04-18 19:42:12 +03:00
|
|
|
lines = boot_params->screen_info.orig_video_lines;
|
|
|
|
cols = boot_params->screen_info.orig_video_cols;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-08-03 03:21:22 +04:00
|
|
|
console_init();
|
2016-04-18 19:42:13 +03:00
|
|
|
debug_putstr("early console in extract_kernel\n");
|
2010-08-03 03:21:22 +04:00
|
|
|
|
2008-01-30 15:33:38 +03:00
|
|
|
free_mem_ptr = heap; /* Heap */
|
2008-04-08 14:54:30 +04:00
|
|
|
free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
|
2006-12-07 04:14:04 +03:00
|
|
|
|
2015-07-07 02:06:20 +03:00
|
|
|
/* Report initial kernel position details. */
|
|
|
|
debug_putaddr(input_data);
|
|
|
|
debug_putaddr(input_len);
|
|
|
|
debug_putaddr(output);
|
|
|
|
debug_putaddr(output_len);
|
2016-04-29 03:09:07 +03:00
|
|
|
debug_putaddr(kernel_total_size);
|
2015-07-07 02:06:20 +03:00
|
|
|
|
2018-02-26 21:04:48 +03:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
/* Report address of 32-bit trampoline */
|
|
|
|
debug_putaddr(trampoline_32bit);
|
|
|
|
#endif
|
|
|
|
|
2014-10-31 16:40:38 +03:00
|
|
|
/*
|
|
|
|
* The memory hole needed for the kernel is the larger of either
|
|
|
|
* the entire decompressed kernel plus relocation table, or the
|
|
|
|
* entire decompressed kernel plus .bss and .brk sections.
|
|
|
|
*/
|
2016-05-26 01:45:32 +03:00
|
|
|
choose_random_location((unsigned long)input_data, input_len,
|
|
|
|
(unsigned long *)&output,
|
|
|
|
max(output_len, kernel_total_size),
|
|
|
|
&virt_addr);
|
2013-10-11 04:18:14 +04:00
|
|
|
|
|
|
|
/* Validate memory location choices. */
|
2009-05-12 22:33:08 +04:00
|
|
|
if ((unsigned long)output & (MIN_KERNEL_ALIGN - 1))
|
2016-05-26 01:45:32 +03:00
|
|
|
error("Destination physical address inappropriately aligned");
|
|
|
|
if (virt_addr & (MIN_KERNEL_ALIGN - 1))
|
|
|
|
error("Destination virtual address inappropriately aligned");
|
2008-01-30 15:33:38 +03:00
|
|
|
#ifdef CONFIG_X86_64
|
2009-05-12 22:33:08 +04:00
|
|
|
if (heap > 0x3fffffffffffUL)
|
2008-01-30 15:33:38 +03:00
|
|
|
error("Destination address too large");
|
2017-06-27 15:39:05 +03:00
|
|
|
if (virt_addr + max(output_len, kernel_total_size) > KERNEL_IMAGE_SIZE)
|
|
|
|
error("Destination virtual address is beyond the kernel mapping area");
|
2008-01-30 15:33:38 +03:00
|
|
|
#else
|
2010-12-17 06:11:09 +03:00
|
|
|
if (heap > ((-__PAGE_OFFSET-(128<<20)-1) & 0x7fffffff))
|
2006-12-07 04:14:04 +03:00
|
|
|
error("Destination address too large");
|
2009-05-12 22:33:08 +04:00
|
|
|
#endif
|
2006-12-07 04:14:04 +03:00
|
|
|
#ifndef CONFIG_RELOCATABLE
|
2009-05-12 22:33:08 +04:00
|
|
|
if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
|
2016-05-26 01:45:32 +03:00
|
|
|
error("Destination address does not match LOAD_PHYSICAL_ADDR");
|
2017-06-27 15:39:06 +03:00
|
|
|
if (virt_addr != LOAD_PHYSICAL_ADDR)
|
2016-05-26 01:45:32 +03:00
|
|
|
error("Destination virtual address changed when not relocatable");
|
2006-12-07 04:14:04 +03:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-07-20 05:04:37 +04:00
|
|
|
debug_putstr("\nDecompressing Linux... ");
|
2015-09-10 01:39:12 +03:00
|
|
|
__decompress(input_data, input_len, NULL, NULL, output, output_len,
|
|
|
|
NULL, error);
|
2008-02-13 23:54:58 +03:00
|
|
|
parse_elf(output);
|
2016-05-26 01:45:32 +03:00
|
|
|
handle_relocations(output, output_len, virt_addr);
|
2012-07-20 05:04:37 +04:00
|
|
|
debug_putstr("done.\nBooting the kernel.\n");
|
2013-10-11 04:18:14 +04:00
|
|
|
return output;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
include/linux/string.h: add the option of fortified string.h functions
This adds support for compiling with a rough equivalent to the glibc
_FORTIFY_SOURCE=1 feature, providing compile-time and runtime buffer
overflow checks for string.h functions when the compiler determines the
size of the source or destination buffer at compile-time. Unlike glibc,
it covers buffer reads in addition to writes.
GNU C __builtin_*_chk intrinsics are avoided because they would force a
much more complex implementation. They aren't designed to detect read
overflows and offer no real benefit when using an implementation based
on inline checks. Inline checks don't add up to much code size and
allow full use of the regular string intrinsics while avoiding the need
for a bunch of _chk functions and per-arch assembly to avoid wrapper
overhead.
This detects various overflows at compile-time in various drivers and
some non-x86 core kernel code. There will likely be issues caught in
regular use at runtime too.
Future improvements left out of initial implementation for simplicity,
as it's all quite optional and can be done incrementally:
* Some of the fortified string functions (strncpy, strcat), don't yet
place a limit on reads from the source based on __builtin_object_size of
the source buffer.
* Extending coverage to more string functions like strlcat.
* It should be possible to optionally use __builtin_object_size(x, 1) for
some functions (C strings) to detect intra-object overflows (like
glibc's _FORTIFY_SOURCE=2), but for now this takes the conservative
approach to avoid likely compatibility issues.
* The compile-time checks should be made available via a separate config
option which can be enabled by default (or always enabled) once enough
time has passed to get the issues it catches fixed.
Kees said:
"This is great to have. While it was out-of-tree code, it would have
blocked at least CVE-2016-3858 from being exploitable (improper size
argument to strlcpy()). I've sent a number of fixes for
out-of-bounds-reads that this detected upstream already"
[arnd@arndb.de: x86: fix fortified memcpy]
Link: http://lkml.kernel.org/r/20170627150047.660360-1-arnd@arndb.de
[keescook@chromium.org: avoid panic() in favor of BUG()]
Link: http://lkml.kernel.org/r/20170626235122.GA25261@beast
[keescook@chromium.org: move from -mm, add ARCH_HAS_FORTIFY_SOURCE, tweak Kconfig help]
Link: http://lkml.kernel.org/r/20170526095404.20439-1-danielmicay@gmail.com
Link: http://lkml.kernel.org/r/1497903987-21002-8-git-send-email-keescook@chromium.org
Signed-off-by: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Daniel Axtens <dja@axtens.net>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-13 00:36:10 +03:00
|
|
|
|
|
|
|
void fortify_panic(const char *name)
|
|
|
|
{
|
|
|
|
error("detected buffer overflow");
|
|
|
|
}
|