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 */
|
2015-04-29 17:11:00 +00:00
|
|
|
|
|
|
|
#undef TRACE_SYSTEM_VAR
|
|
|
|
|
|
|
|
#ifdef CONFIG_PERF_EVENTS
|
|
|
|
|
|
|
|
#undef __entry
|
|
|
|
#define __entry entry
|
|
|
|
|
|
|
|
#undef __get_dynamic_array
|
|
|
|
#define __get_dynamic_array(field) \
|
|
|
|
((void *)__entry + (__entry->__data_loc_##field & 0xffff))
|
|
|
|
|
|
|
|
#undef __get_dynamic_array_len
|
|
|
|
#define __get_dynamic_array_len(field) \
|
|
|
|
((__entry->__data_loc_##field >> 16) & 0xffff)
|
|
|
|
|
|
|
|
#undef __get_str
|
2016-07-01 23:44:34 +00:00
|
|
|
#define __get_str(field) ((char *)__get_dynamic_array(field))
|
2015-04-29 17:11:00 +00:00
|
|
|
|
|
|
|
#undef __get_bitmask
|
|
|
|
#define __get_bitmask(field) (char *)__get_dynamic_array(field)
|
|
|
|
|
2022-01-11 17:43:55 +00:00
|
|
|
#undef __get_sockaddr
|
|
|
|
#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
|
|
|
|
|
2021-11-22 09:30:21 +00:00
|
|
|
#undef __get_rel_dynamic_array
|
|
|
|
#define __get_rel_dynamic_array(field) \
|
tracing/perf: Avoid -Warray-bounds warning for __rel_loc macro
As done for trace_events.h, also fix the __rel_loc macro in perf.h,
which silences the -Warray-bounds warning:
In file included from ./include/linux/string.h:253,
from ./include/linux/bitmap.h:11,
from ./include/linux/cpumask.h:12,
from ./include/linux/mm_types_task.h:14,
from ./include/linux/mm_types.h:5,
from ./include/linux/buildid.h:5,
from ./include/linux/module.h:14,
from samples/trace_events/trace-events-sample.c:2:
In function '__fortify_strcpy',
inlined from 'perf_trace_foo_rel_loc' at samples/trace_events/./trace-events-sample.h:519:1:
./include/linux/fortify-string.h:47:33: warning: '__builtin_strcpy' offset 12 is out of the bounds [
0, 4] [-Warray-bounds]
47 | #define __underlying_strcpy __builtin_strcpy
| ^
./include/linux/fortify-string.h:445:24: note: in expansion of macro '__underlying_strcpy'
445 | return __underlying_strcpy(p, q);
| ^~~~~~~~~~~~~~~~~~~
Also make __data struct member a proper flexible array to avoid future
problems.
Link: https://lkml.kernel.org/r/20220125220037.2738923-1-keescook@chromium.org
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: 55de2c0b5610c ("tracing: Add '__rel_loc' using trace event macros")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2022-01-25 22:00:37 +00:00
|
|
|
((void *)__entry + \
|
|
|
|
offsetof(typeof(*__entry), __rel_loc_##field) + \
|
|
|
|
sizeof(__entry->__rel_loc_##field) + \
|
2021-11-22 09:30:21 +00:00
|
|
|
(__entry->__rel_loc_##field & 0xffff))
|
|
|
|
|
|
|
|
#undef __get_rel_dynamic_array_len
|
|
|
|
#define __get_rel_dynamic_array_len(field) \
|
|
|
|
((__entry->__rel_loc_##field >> 16) & 0xffff)
|
|
|
|
|
|
|
|
#undef __get_rel_str
|
|
|
|
#define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field))
|
|
|
|
|
|
|
|
#undef __get_rel_bitmask
|
|
|
|
#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
|
|
|
|
|
2022-01-11 17:43:55 +00:00
|
|
|
#undef __get_rel_sockaddr
|
|
|
|
#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
|
|
|
|
|
2015-04-29 17:11:00 +00:00
|
|
|
#undef __perf_count
|
|
|
|
#define __perf_count(c) (__count = (c))
|
|
|
|
|
|
|
|
#undef __perf_task
|
|
|
|
#define __perf_task(t) (__task = (t))
|
|
|
|
|
|
|
|
#undef DECLARE_EVENT_CLASS
|
|
|
|
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
|
|
|
static notrace void \
|
|
|
|
perf_trace_##call(void *__data, proto) \
|
|
|
|
{ \
|
2015-05-05 15:45:27 +00:00
|
|
|
struct trace_event_call *event_call = __data; \
|
2015-05-13 19:33:52 +00:00
|
|
|
struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
|
2015-05-13 19:27:47 +00:00
|
|
|
struct trace_event_raw_##call *entry; \
|
2015-04-29 17:11:00 +00:00
|
|
|
struct pt_regs *__regs; \
|
2016-04-07 01:43:23 +00:00
|
|
|
u64 __count = 1; \
|
2015-04-29 17:11:00 +00:00
|
|
|
struct task_struct *__task = NULL; \
|
|
|
|
struct hlist_head *head; \
|
|
|
|
int __entry_size; \
|
|
|
|
int __data_size; \
|
|
|
|
int rctx; \
|
|
|
|
\
|
2015-05-13 19:40:23 +00:00
|
|
|
__data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
|
2015-04-29 17:11:00 +00:00
|
|
|
\
|
|
|
|
head = this_cpu_ptr(event_call->perf_events); \
|
2017-10-24 06:53:08 +00:00
|
|
|
if (!bpf_prog_array_valid(event_call) && \
|
|
|
|
__builtin_constant_p(!__task) && !__task && \
|
|
|
|
hlist_empty(head)) \
|
2015-04-29 17:11:00 +00:00
|
|
|
return; \
|
|
|
|
\
|
|
|
|
__entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
|
|
|
|
sizeof(u64)); \
|
|
|
|
__entry_size -= sizeof(u32); \
|
|
|
|
\
|
2016-04-07 01:43:24 +00:00
|
|
|
entry = perf_trace_buf_alloc(__entry_size, &__regs, &rctx); \
|
2015-04-29 17:11:00 +00:00
|
|
|
if (!entry) \
|
|
|
|
return; \
|
|
|
|
\
|
|
|
|
perf_fetch_caller_regs(__regs); \
|
|
|
|
\
|
|
|
|
tstruct \
|
|
|
|
\
|
|
|
|
{ assign; } \
|
|
|
|
\
|
2016-04-19 03:11:50 +00:00
|
|
|
perf_trace_run_bpf_submit(entry, __entry_size, rctx, \
|
|
|
|
event_call, __count, __regs, \
|
|
|
|
head, __task); \
|
2015-04-29 17:11:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This part is compiled out, it is only here as a build time check
|
|
|
|
* to make sure that if the tracepoint handling changes, the
|
|
|
|
* perf probe will fail to compile unless it too is updated.
|
|
|
|
*/
|
|
|
|
#undef DEFINE_EVENT
|
|
|
|
#define DEFINE_EVENT(template, call, proto, args) \
|
|
|
|
static inline void perf_test_probe_##call(void) \
|
|
|
|
{ \
|
|
|
|
check_trace_callback_type_##call(perf_trace_##template); \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#undef DEFINE_EVENT_PRINT
|
|
|
|
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
|
|
|
|
DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
|
|
|
|
|
|
|
|
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
|
|
|
|
#endif /* CONFIG_PERF_EVENTS */
|