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 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-06-22 19:55:10 +08:00
|
|
|
#include <linux/compat.h>
|
|
|
|
#include <linux/uaccess.h>
|
2016-09-05 21:33:08 +08:00
|
|
|
#include <linux/ptrace.h>
|
2015-06-22 19:55:10 +08:00
|
|
|
|
2016-06-09 01:25:34 +08:00
|
|
|
/*
|
|
|
|
* The compat_siginfo_t structure and handing code is very easy
|
|
|
|
* to break in several ways. It must always be updated when new
|
|
|
|
* updates are made to the main siginfo_t, and
|
|
|
|
* copy_siginfo_to_user32() must be updated when the
|
|
|
|
* (arch-independent) copy_siginfo_to_user() is updated.
|
|
|
|
*
|
|
|
|
* It is also easy to put a new member in the compat_siginfo_t
|
|
|
|
* which has implicit alignment which can move internal structure
|
|
|
|
* alignment around breaking the ABI. This can happen if you,
|
|
|
|
* for instance, put a plain 64-bit value in there.
|
|
|
|
*/
|
|
|
|
static inline void signal_compat_build_tests(void)
|
|
|
|
{
|
|
|
|
int _sifields_offset = offsetof(compat_siginfo_t, _sifields);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If adding a new si_code, there is probably new data in
|
|
|
|
* the siginfo. Make sure folks bumping the si_code
|
|
|
|
* limits also have to look at this code. Make sure any
|
|
|
|
* new fields are handled in copy_siginfo_to_user32()!
|
|
|
|
*/
|
|
|
|
BUILD_BUG_ON(NSIGILL != 8);
|
|
|
|
BUILD_BUG_ON(NSIGFPE != 8);
|
|
|
|
BUILD_BUG_ON(NSIGSEGV != 4);
|
|
|
|
BUILD_BUG_ON(NSIGBUS != 5);
|
|
|
|
BUILD_BUG_ON(NSIGTRAP != 4);
|
|
|
|
BUILD_BUG_ON(NSIGCHLD != 6);
|
|
|
|
BUILD_BUG_ON(NSIGSYS != 1);
|
|
|
|
|
|
|
|
/* This is part of the ABI and can never change in size: */
|
|
|
|
BUILD_BUG_ON(sizeof(compat_siginfo_t) != 128);
|
|
|
|
/*
|
|
|
|
* The offsets of all the (unioned) si_fields are fixed
|
|
|
|
* in the ABI, of course. Make sure none of them ever
|
|
|
|
* move and are always at the beginning:
|
|
|
|
*/
|
|
|
|
BUILD_BUG_ON(offsetof(compat_siginfo_t, _sifields) != 3 * sizeof(int));
|
|
|
|
#define CHECK_CSI_OFFSET(name) BUILD_BUG_ON(_sifields_offset != offsetof(compat_siginfo_t, _sifields.name))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure that the size of each si_field never changes.
|
|
|
|
* If it does, it is a sign that the
|
|
|
|
* copy_siginfo_to_user32() code below needs to updated
|
|
|
|
* along with the size in the CHECK_SI_SIZE().
|
|
|
|
*
|
|
|
|
* We repeat this check for both the generic and compat
|
|
|
|
* siginfos.
|
|
|
|
*
|
|
|
|
* Note: it is OK for these to grow as long as the whole
|
|
|
|
* structure stays within the padding size (checked
|
|
|
|
* above).
|
|
|
|
*/
|
|
|
|
#define CHECK_CSI_SIZE(name, size) BUILD_BUG_ON(size != sizeof(((compat_siginfo_t *)0)->_sifields.name))
|
|
|
|
#define CHECK_SI_SIZE(name, size) BUILD_BUG_ON(size != sizeof(((siginfo_t *)0)->_sifields.name))
|
|
|
|
|
|
|
|
CHECK_CSI_OFFSET(_kill);
|
|
|
|
CHECK_CSI_SIZE (_kill, 2*sizeof(int));
|
|
|
|
CHECK_SI_SIZE (_kill, 2*sizeof(int));
|
|
|
|
|
|
|
|
CHECK_CSI_OFFSET(_timer);
|
|
|
|
CHECK_CSI_SIZE (_timer, 5*sizeof(int));
|
|
|
|
CHECK_SI_SIZE (_timer, 6*sizeof(int));
|
|
|
|
|
|
|
|
CHECK_CSI_OFFSET(_rt);
|
|
|
|
CHECK_CSI_SIZE (_rt, 3*sizeof(int));
|
|
|
|
CHECK_SI_SIZE (_rt, 4*sizeof(int));
|
|
|
|
|
|
|
|
CHECK_CSI_OFFSET(_sigchld);
|
|
|
|
CHECK_CSI_SIZE (_sigchld, 5*sizeof(int));
|
|
|
|
CHECK_SI_SIZE (_sigchld, 8*sizeof(int));
|
|
|
|
|
|
|
|
CHECK_CSI_OFFSET(_sigchld_x32);
|
|
|
|
CHECK_CSI_SIZE (_sigchld_x32, 7*sizeof(int));
|
|
|
|
/* no _sigchld_x32 in the generic siginfo_t */
|
|
|
|
|
|
|
|
CHECK_CSI_OFFSET(_sigfault);
|
|
|
|
CHECK_CSI_SIZE (_sigfault, 4*sizeof(int));
|
|
|
|
CHECK_SI_SIZE (_sigfault, 8*sizeof(int));
|
|
|
|
|
|
|
|
CHECK_CSI_OFFSET(_sigpoll);
|
|
|
|
CHECK_CSI_SIZE (_sigpoll, 2*sizeof(int));
|
|
|
|
CHECK_SI_SIZE (_sigpoll, 4*sizeof(int));
|
|
|
|
|
|
|
|
CHECK_CSI_OFFSET(_sigsys);
|
|
|
|
CHECK_CSI_SIZE (_sigsys, 3*sizeof(int));
|
|
|
|
CHECK_SI_SIZE (_sigsys, 4*sizeof(int));
|
|
|
|
|
|
|
|
/* any new si_fields should be added here */
|
|
|
|
}
|
|
|
|
|
2016-09-05 21:33:08 +08:00
|
|
|
void sigaction_compat_abi(struct k_sigaction *act, struct k_sigaction *oact)
|
|
|
|
{
|
|
|
|
/* Don't leak in-kernel non-uapi flags to user-space */
|
|
|
|
if (oact)
|
|
|
|
oact->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI);
|
|
|
|
|
|
|
|
if (!act)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Don't let flags to be set from userspace */
|
|
|
|
act->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI);
|
|
|
|
|
|
|
|
if (in_ia32_syscall())
|
|
|
|
act->sa.sa_flags |= SA_IA32_ABI;
|
|
|
|
if (in_x32_syscall())
|
|
|
|
act->sa.sa_flags |= SA_X32_ABI;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from,
|
|
|
|
bool x32_ABI)
|
2015-06-22 19:55:10 +08:00
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
|
2016-06-09 01:25:34 +08:00
|
|
|
signal_compat_build_tests();
|
|
|
|
|
2015-06-22 19:55:10 +08:00
|
|
|
if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
put_user_try {
|
|
|
|
/* If you change siginfo_t structure, please make sure that
|
|
|
|
this code is fixed accordingly.
|
|
|
|
It should never copy any pad contained in the structure
|
|
|
|
to avoid security leaks, but must copy the generic
|
|
|
|
3 ints plus the relevant union member. */
|
|
|
|
put_user_ex(from->si_signo, &to->si_signo);
|
|
|
|
put_user_ex(from->si_errno, &to->si_errno);
|
2017-07-17 11:36:59 +08:00
|
|
|
put_user_ex(from->si_code, &to->si_code);
|
2015-06-22 19:55:10 +08:00
|
|
|
|
|
|
|
if (from->si_code < 0) {
|
|
|
|
put_user_ex(from->si_pid, &to->si_pid);
|
|
|
|
put_user_ex(from->si_uid, &to->si_uid);
|
|
|
|
put_user_ex(ptr_to_compat(from->si_ptr), &to->si_ptr);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* First 32bits of unions are always present:
|
|
|
|
* si_pid === si_band === si_tid === si_addr(LS half)
|
|
|
|
*/
|
|
|
|
put_user_ex(from->_sifields._pad[0],
|
|
|
|
&to->_sifields._pad[0]);
|
2017-07-17 11:36:59 +08:00
|
|
|
switch (siginfo_layout(from->si_signo, from->si_code)) {
|
|
|
|
case SIL_FAULT:
|
2016-06-09 01:25:33 +08:00
|
|
|
if (from->si_signo == SIGBUS &&
|
|
|
|
(from->si_code == BUS_MCEERR_AR ||
|
|
|
|
from->si_code == BUS_MCEERR_AO))
|
|
|
|
put_user_ex(from->si_addr_lsb, &to->si_addr_lsb);
|
|
|
|
|
|
|
|
if (from->si_signo == SIGSEGV) {
|
|
|
|
if (from->si_code == SEGV_BNDERR) {
|
2017-04-05 00:15:01 +08:00
|
|
|
compat_uptr_t lower = (unsigned long)from->si_lower;
|
|
|
|
compat_uptr_t upper = (unsigned long)from->si_upper;
|
2016-06-09 01:25:33 +08:00
|
|
|
put_user_ex(lower, &to->si_lower);
|
|
|
|
put_user_ex(upper, &to->si_upper);
|
|
|
|
}
|
|
|
|
if (from->si_code == SEGV_PKUERR)
|
|
|
|
put_user_ex(from->si_pkey, &to->si_pkey);
|
|
|
|
}
|
2015-06-22 19:55:10 +08:00
|
|
|
break;
|
2017-07-17 11:36:59 +08:00
|
|
|
case SIL_SYS:
|
2015-06-22 19:55:10 +08:00
|
|
|
put_user_ex(from->si_syscall, &to->si_syscall);
|
|
|
|
put_user_ex(from->si_arch, &to->si_arch);
|
|
|
|
break;
|
2017-07-17 11:36:59 +08:00
|
|
|
case SIL_CHLD:
|
2016-09-05 21:33:08 +08:00
|
|
|
if (!x32_ABI) {
|
2015-06-22 19:55:10 +08:00
|
|
|
put_user_ex(from->si_utime, &to->si_utime);
|
|
|
|
put_user_ex(from->si_stime, &to->si_stime);
|
|
|
|
} else {
|
|
|
|
put_user_ex(from->si_utime, &to->_sifields._sigchld_x32._utime);
|
|
|
|
put_user_ex(from->si_stime, &to->_sifields._sigchld_x32._stime);
|
|
|
|
}
|
|
|
|
put_user_ex(from->si_status, &to->si_status);
|
|
|
|
/* FALL THROUGH */
|
2017-07-17 11:36:59 +08:00
|
|
|
case SIL_KILL:
|
2015-06-22 19:55:10 +08:00
|
|
|
put_user_ex(from->si_uid, &to->si_uid);
|
|
|
|
break;
|
2017-07-17 11:36:59 +08:00
|
|
|
case SIL_POLL:
|
2015-06-22 19:55:10 +08:00
|
|
|
put_user_ex(from->si_fd, &to->si_fd);
|
|
|
|
break;
|
2017-07-17 11:36:59 +08:00
|
|
|
case SIL_TIMER:
|
2015-06-22 19:55:10 +08:00
|
|
|
put_user_ex(from->si_overrun, &to->si_overrun);
|
|
|
|
put_user_ex(ptr_to_compat(from->si_ptr),
|
|
|
|
&to->si_ptr);
|
|
|
|
break;
|
2017-07-17 11:36:59 +08:00
|
|
|
case SIL_RT:
|
2015-06-22 19:55:10 +08:00
|
|
|
put_user_ex(from->si_uid, &to->si_uid);
|
|
|
|
put_user_ex(from->si_int, &to->si_int);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} put_user_catch(err);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2016-09-05 21:33:08 +08:00
|
|
|
/* from syscall's path, where we know the ABI */
|
|
|
|
int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
|
|
|
|
{
|
|
|
|
return __copy_siginfo_to_user32(to, from, in_x32_syscall());
|
|
|
|
}
|
|
|
|
|
2015-06-22 19:55:10 +08:00
|
|
|
int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
|
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
u32 ptr32;
|
|
|
|
|
|
|
|
if (!access_ok(VERIFY_READ, from, sizeof(compat_siginfo_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
get_user_try {
|
|
|
|
get_user_ex(to->si_signo, &from->si_signo);
|
|
|
|
get_user_ex(to->si_errno, &from->si_errno);
|
|
|
|
get_user_ex(to->si_code, &from->si_code);
|
|
|
|
|
|
|
|
get_user_ex(to->si_pid, &from->si_pid);
|
|
|
|
get_user_ex(to->si_uid, &from->si_uid);
|
|
|
|
get_user_ex(ptr32, &from->si_ptr);
|
|
|
|
to->si_ptr = compat_ptr(ptr32);
|
|
|
|
} get_user_catch(err);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|