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 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2010-09-17 15:09:22 +00:00
|
|
|
/*
|
|
|
|
* jump label x86 support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jason Baron <jbaron@redhat.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/jump_label.h>
|
|
|
|
#include <linux/memory.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/jhash.h>
|
|
|
|
#include <linux/cpu.h>
|
|
|
|
#include <asm/kprobes.h>
|
|
|
|
#include <asm/alternative.h>
|
2016-04-26 19:23:24 +00:00
|
|
|
#include <asm/text-patching.h>
|
2021-05-06 19:34:01 +00:00
|
|
|
#include <asm/insn.h>
|
2010-09-17 15:09:22 +00:00
|
|
|
|
2021-05-06 19:33:58 +00:00
|
|
|
int arch_jump_entry_size(struct jump_entry *entry)
|
|
|
|
{
|
2021-05-06 19:34:01 +00:00
|
|
|
struct insn insn = {};
|
|
|
|
|
|
|
|
insn_decode_kernel(&insn, (void *)jump_entry_code(entry));
|
|
|
|
BUG_ON(insn.length != 2 && insn.length != 5);
|
|
|
|
|
|
|
|
return insn.length;
|
2021-05-06 19:33:58 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 19:33:59 +00:00
|
|
|
struct jump_label_patch {
|
|
|
|
const void *code;
|
|
|
|
int size;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct jump_label_patch
|
|
|
|
__jump_label_patch(struct jump_entry *entry, enum jump_label_type type)
|
2010-09-17 15:09:22 +00:00
|
|
|
{
|
2021-05-06 19:33:59 +00:00
|
|
|
const void *expect, *code, *nop;
|
2019-10-03 12:50:42 +00:00
|
|
|
const void *addr, *dest;
|
2021-05-06 19:33:59 +00:00
|
|
|
int size;
|
2018-09-19 06:51:40 +00:00
|
|
|
|
2019-10-03 12:50:42 +00:00
|
|
|
addr = (void *)jump_entry_code(entry);
|
|
|
|
dest = (void *)jump_entry_target(entry);
|
2019-08-26 11:38:58 +00:00
|
|
|
|
2021-05-06 19:33:59 +00:00
|
|
|
size = arch_jump_entry_size(entry);
|
|
|
|
switch (size) {
|
|
|
|
case JMP8_INSN_SIZE:
|
|
|
|
code = text_gen_insn(JMP8_INSN_OPCODE, addr, dest);
|
|
|
|
nop = x86_nops[size];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case JMP32_INSN_SIZE:
|
|
|
|
code = text_gen_insn(JMP32_INSN_OPCODE, addr, dest);
|
|
|
|
nop = x86_nops[size];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: BUG();
|
|
|
|
}
|
2012-01-26 23:38:07 +00:00
|
|
|
|
2021-05-06 19:33:57 +00:00
|
|
|
if (type == JUMP_LABEL_JMP)
|
2021-05-06 19:33:59 +00:00
|
|
|
expect = nop;
|
2021-05-06 19:33:57 +00:00
|
|
|
else
|
|
|
|
expect = code;
|
|
|
|
|
2021-05-06 19:33:59 +00:00
|
|
|
if (memcmp(addr, expect, size)) {
|
2021-05-06 19:33:57 +00:00
|
|
|
/*
|
|
|
|
* The location is not an op that we were expecting.
|
|
|
|
* Something went wrong. Crash the box, as something could be
|
|
|
|
* corrupting the kernel.
|
|
|
|
*/
|
2021-05-06 19:33:59 +00:00
|
|
|
pr_crit("jump_label: Fatal kernel bug, unexpected op at %pS [%p] (%5ph != %5ph)) size:%d type:%d\n",
|
|
|
|
addr, addr, addr, expect, size, type);
|
2021-05-06 19:33:57 +00:00
|
|
|
BUG();
|
2012-01-26 23:38:07 +00:00
|
|
|
}
|
2011-09-29 18:11:09 +00:00
|
|
|
|
2019-06-12 09:57:27 +00:00
|
|
|
if (type == JUMP_LABEL_NOP)
|
2021-05-06 19:33:59 +00:00
|
|
|
code = nop;
|
2019-08-26 11:38:58 +00:00
|
|
|
|
2021-05-06 19:33:59 +00:00
|
|
|
return (struct jump_label_patch){.code = code, .size = size};
|
2019-06-12 09:57:27 +00:00
|
|
|
}
|
|
|
|
|
2021-07-13 04:16:05 +00:00
|
|
|
static __always_inline void
|
|
|
|
__jump_label_transform(struct jump_entry *entry,
|
|
|
|
enum jump_label_type type,
|
|
|
|
int init)
|
2019-06-12 09:57:27 +00:00
|
|
|
{
|
2021-05-06 19:33:59 +00:00
|
|
|
const struct jump_label_patch jlp = __jump_label_patch(entry, type);
|
2019-06-12 09:57:27 +00:00
|
|
|
|
2013-07-12 09:22:09 +00:00
|
|
|
/*
|
2019-04-26 00:11:32 +00:00
|
|
|
* As long as only a single processor is running and the code is still
|
|
|
|
* not marked as RO, text_poke_early() can be used; Checking that
|
|
|
|
* system_state is SYSTEM_BOOTING guarantees it. It will be set to
|
|
|
|
* SYSTEM_SCHEDULING before other cores are awaken and before the
|
|
|
|
* code is write-protected.
|
2013-07-12 09:22:09 +00:00
|
|
|
*
|
|
|
|
* At the time the change is being done, just ignore whether we
|
|
|
|
* are doing nop -> jump or jump -> nop transition, and assume
|
|
|
|
* always nop being the 'currently valid' instruction
|
|
|
|
*/
|
2019-04-26 00:11:32 +00:00
|
|
|
if (init || system_state == SYSTEM_BOOTING) {
|
2021-05-06 19:33:59 +00:00
|
|
|
text_poke_early((void *)jump_entry_code(entry), jlp.code, jlp.size);
|
2018-09-19 06:51:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-06 19:33:59 +00:00
|
|
|
text_poke_bp((void *)jump_entry_code(entry), jlp.code, jlp.size, NULL);
|
2011-09-29 18:11:09 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 11:38:58 +00:00
|
|
|
static void __ref jump_label_transform(struct jump_entry *entry,
|
|
|
|
enum jump_label_type type,
|
|
|
|
int init)
|
2011-09-29 18:11:09 +00:00
|
|
|
{
|
2010-09-17 15:09:22 +00:00
|
|
|
mutex_lock(&text_mutex);
|
2019-08-26 11:38:58 +00:00
|
|
|
__jump_label_transform(entry, type, init);
|
2010-09-17 15:09:22 +00:00
|
|
|
mutex_unlock(&text_mutex);
|
|
|
|
}
|
|
|
|
|
2019-08-26 11:38:58 +00:00
|
|
|
void arch_jump_label_transform(struct jump_entry *entry,
|
|
|
|
enum jump_label_type type)
|
|
|
|
{
|
|
|
|
jump_label_transform(entry, type, 0);
|
|
|
|
}
|
x86/jump_label: Batch jump label updates
Currently, the jump label of a static key is transformed via the arch
specific function:
void arch_jump_label_transform(struct jump_entry *entry,
enum jump_label_type type)
The new approach (batch mode) uses two arch functions, the first has the
same arguments of the arch_jump_label_transform(), and is the function:
bool arch_jump_label_transform_queue(struct jump_entry *entry,
enum jump_label_type type)
Rather than transforming the code, it adds the jump_entry in a queue of
entries to be updated. This functions returns true in the case of a
successful enqueue of an entry. If it returns false, the caller must to
apply the queue and then try to queue again, for instance, because the
queue is full.
This function expects the caller to sort the entries by the address before
enqueueuing then. This is already done by the arch independent code, though.
After queuing all jump_entries, the function:
void arch_jump_label_transform_apply(void)
Applies the changes in the queue.
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Chris von Recklinghausen <crecklin@redhat.com>
Cc: Clark Williams <williams@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Scott Wood <swood@redhat.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/57b4caa654bad7e3b066301c9a9ae233dea065b5.1560325897.git.bristot@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-06-12 09:57:31 +00:00
|
|
|
|
|
|
|
bool arch_jump_label_transform_queue(struct jump_entry *entry,
|
|
|
|
enum jump_label_type type)
|
|
|
|
{
|
2021-05-06 19:33:59 +00:00
|
|
|
struct jump_label_patch jlp;
|
x86/jump_label: Batch jump label updates
Currently, the jump label of a static key is transformed via the arch
specific function:
void arch_jump_label_transform(struct jump_entry *entry,
enum jump_label_type type)
The new approach (batch mode) uses two arch functions, the first has the
same arguments of the arch_jump_label_transform(), and is the function:
bool arch_jump_label_transform_queue(struct jump_entry *entry,
enum jump_label_type type)
Rather than transforming the code, it adds the jump_entry in a queue of
entries to be updated. This functions returns true in the case of a
successful enqueue of an entry. If it returns false, the caller must to
apply the queue and then try to queue again, for instance, because the
queue is full.
This function expects the caller to sort the entries by the address before
enqueueuing then. This is already done by the arch independent code, though.
After queuing all jump_entries, the function:
void arch_jump_label_transform_apply(void)
Applies the changes in the queue.
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Chris von Recklinghausen <crecklin@redhat.com>
Cc: Clark Williams <williams@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Scott Wood <swood@redhat.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/57b4caa654bad7e3b066301c9a9ae233dea065b5.1560325897.git.bristot@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-06-12 09:57:31 +00:00
|
|
|
|
|
|
|
if (system_state == SYSTEM_BOOTING) {
|
|
|
|
/*
|
|
|
|
* Fallback to the non-batching mode.
|
|
|
|
*/
|
|
|
|
arch_jump_label_transform(entry, type);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-08-26 11:38:58 +00:00
|
|
|
mutex_lock(&text_mutex);
|
2021-05-06 19:33:59 +00:00
|
|
|
jlp = __jump_label_patch(entry, type);
|
|
|
|
text_poke_queue((void *)jump_entry_code(entry), jlp.code, jlp.size, NULL);
|
2019-08-26 11:38:58 +00:00
|
|
|
mutex_unlock(&text_mutex);
|
x86/jump_label: Batch jump label updates
Currently, the jump label of a static key is transformed via the arch
specific function:
void arch_jump_label_transform(struct jump_entry *entry,
enum jump_label_type type)
The new approach (batch mode) uses two arch functions, the first has the
same arguments of the arch_jump_label_transform(), and is the function:
bool arch_jump_label_transform_queue(struct jump_entry *entry,
enum jump_label_type type)
Rather than transforming the code, it adds the jump_entry in a queue of
entries to be updated. This functions returns true in the case of a
successful enqueue of an entry. If it returns false, the caller must to
apply the queue and then try to queue again, for instance, because the
queue is full.
This function expects the caller to sort the entries by the address before
enqueueuing then. This is already done by the arch independent code, though.
After queuing all jump_entries, the function:
void arch_jump_label_transform_apply(void)
Applies the changes in the queue.
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Chris von Recklinghausen <crecklin@redhat.com>
Cc: Clark Williams <williams@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Scott Wood <swood@redhat.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/57b4caa654bad7e3b066301c9a9ae233dea065b5.1560325897.git.bristot@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-06-12 09:57:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void arch_jump_label_transform_apply(void)
|
|
|
|
{
|
|
|
|
mutex_lock(&text_mutex);
|
2019-08-26 11:38:58 +00:00
|
|
|
text_poke_finish();
|
x86/jump_label: Batch jump label updates
Currently, the jump label of a static key is transformed via the arch
specific function:
void arch_jump_label_transform(struct jump_entry *entry,
enum jump_label_type type)
The new approach (batch mode) uses two arch functions, the first has the
same arguments of the arch_jump_label_transform(), and is the function:
bool arch_jump_label_transform_queue(struct jump_entry *entry,
enum jump_label_type type)
Rather than transforming the code, it adds the jump_entry in a queue of
entries to be updated. This functions returns true in the case of a
successful enqueue of an entry. If it returns false, the caller must to
apply the queue and then try to queue again, for instance, because the
queue is full.
This function expects the caller to sort the entries by the address before
enqueueuing then. This is already done by the arch independent code, though.
After queuing all jump_entries, the function:
void arch_jump_label_transform_apply(void)
Applies the changes in the queue.
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Chris von Recklinghausen <crecklin@redhat.com>
Cc: Clark Williams <williams@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Scott Wood <swood@redhat.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/57b4caa654bad7e3b066301c9a9ae233dea065b5.1560325897.git.bristot@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-06-12 09:57:31 +00:00
|
|
|
mutex_unlock(&text_mutex);
|
|
|
|
}
|
|
|
|
|
2012-01-26 23:16:15 +00:00
|
|
|
static enum {
|
|
|
|
JL_STATE_START,
|
|
|
|
JL_STATE_NO_UPDATE,
|
|
|
|
JL_STATE_UPDATE,
|
|
|
|
} jlstate __initdata_or_module = JL_STATE_START;
|
|
|
|
|
2011-12-06 16:27:29 +00:00
|
|
|
__init_or_module void arch_jump_label_transform_static(struct jump_entry *entry,
|
2011-09-29 18:11:09 +00:00
|
|
|
enum jump_label_type type)
|
|
|
|
{
|
2012-01-26 23:16:15 +00:00
|
|
|
if (jlstate == JL_STATE_UPDATE)
|
2019-08-26 11:38:58 +00:00
|
|
|
jump_label_transform(entry, type, 1);
|
2011-09-29 18:11:09 +00:00
|
|
|
}
|