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 21:07:57 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-10-23 12:26:29 +07:00
|
|
|
#ifndef _ASM_X86_COMPAT_H
|
|
|
|
#define _ASM_X86_COMPAT_H
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Architecture specific compatibility types
|
|
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/sched.h>
|
2017-11-02 14:59:16 +07:00
|
|
|
#include <linux/sched/task_stack.h>
|
2012-02-20 01:06:34 +07:00
|
|
|
#include <asm/processor.h>
|
2007-10-20 01:35:02 +07:00
|
|
|
#include <asm/user32.h>
|
2012-02-19 22:56:26 +07:00
|
|
|
#include <asm/unistd.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2018-04-19 03:01:26 +07:00
|
|
|
#include <asm-generic/compat.h>
|
|
|
|
|
2010-03-11 06:21:19 +07:00
|
|
|
#define COMPAT_USER_HZ 100
|
|
|
|
#define COMPAT_UTS_MACHINE "i686\0\0"
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-07 05:16:40 +07:00
|
|
|
typedef u16 __compat_uid_t;
|
|
|
|
typedef u16 __compat_gid_t;
|
|
|
|
typedef u32 __compat_uid32_t;
|
|
|
|
typedef u32 __compat_gid32_t;
|
2005-04-17 05:20:36 +07:00
|
|
|
typedef u16 compat_mode_t;
|
|
|
|
typedef u16 compat_dev_t;
|
|
|
|
typedef u16 compat_nlink_t;
|
|
|
|
typedef u16 compat_ipc_pid_t;
|
|
|
|
typedef u32 compat_caddr_t;
|
|
|
|
typedef __kernel_fsid_t compat_fsid_t;
|
2007-07-16 13:41:11 +07:00
|
|
|
typedef s64 __attribute__((aligned(4))) compat_s64;
|
|
|
|
typedef u64 __attribute__((aligned(4))) compat_u64;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
struct compat_stat {
|
|
|
|
compat_dev_t st_dev;
|
|
|
|
u16 __pad1;
|
|
|
|
compat_ino_t st_ino;
|
|
|
|
compat_mode_t st_mode;
|
|
|
|
compat_nlink_t st_nlink;
|
2005-09-07 05:16:40 +07:00
|
|
|
__compat_uid_t st_uid;
|
|
|
|
__compat_gid_t st_gid;
|
2005-04-17 05:20:36 +07:00
|
|
|
compat_dev_t st_rdev;
|
|
|
|
u16 __pad2;
|
|
|
|
u32 st_size;
|
|
|
|
u32 st_blksize;
|
|
|
|
u32 st_blocks;
|
|
|
|
u32 st_atime;
|
|
|
|
u32 st_atime_nsec;
|
|
|
|
u32 st_mtime;
|
|
|
|
u32 st_mtime_nsec;
|
|
|
|
u32 st_ctime;
|
|
|
|
u32 st_ctime_nsec;
|
|
|
|
u32 __unused4;
|
|
|
|
u32 __unused5;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct compat_flock {
|
|
|
|
short l_type;
|
|
|
|
short l_whence;
|
|
|
|
compat_off_t l_start;
|
|
|
|
compat_off_t l_len;
|
|
|
|
compat_pid_t l_pid;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define F_GETLK64 12 /* using 'struct flock64' */
|
|
|
|
#define F_SETLK64 13
|
|
|
|
#define F_SETLKW64 14
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IA32 uses 4 byte alignment for 64 bit quantities,
|
|
|
|
* so we need to pack this structure.
|
|
|
|
*/
|
|
|
|
struct compat_flock64 {
|
|
|
|
short l_type;
|
|
|
|
short l_whence;
|
|
|
|
compat_loff_t l_start;
|
|
|
|
compat_loff_t l_len;
|
|
|
|
compat_pid_t l_pid;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct compat_statfs {
|
|
|
|
int f_type;
|
|
|
|
int f_bsize;
|
|
|
|
int f_blocks;
|
|
|
|
int f_bfree;
|
|
|
|
int f_bavail;
|
|
|
|
int f_files;
|
|
|
|
int f_ffree;
|
|
|
|
compat_fsid_t f_fsid;
|
|
|
|
int f_namelen; /* SunOS ignores this field. */
|
|
|
|
int f_frsize;
|
2011-10-18 03:40:02 +07:00
|
|
|
int f_flags;
|
|
|
|
int f_spare[4];
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define COMPAT_RLIM_INFINITY 0xffffffff
|
|
|
|
|
|
|
|
typedef u32 compat_old_sigset_t; /* at least 32 bits */
|
|
|
|
|
|
|
|
#define _COMPAT_NSIG 64
|
|
|
|
#define _COMPAT_NSIG_BPW 32
|
|
|
|
|
|
|
|
typedef u32 compat_sigset_word;
|
|
|
|
|
|
|
|
#define COMPAT_OFF_T_MAX 0x7fffffff
|
|
|
|
|
|
|
|
struct compat_ipc64_perm {
|
|
|
|
compat_key_t key;
|
2005-09-07 05:16:40 +07:00
|
|
|
__compat_uid32_t uid;
|
|
|
|
__compat_gid32_t gid;
|
|
|
|
__compat_uid32_t cuid;
|
|
|
|
__compat_gid32_t cgid;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned short mode;
|
|
|
|
unsigned short __pad1;
|
|
|
|
unsigned short seq;
|
|
|
|
unsigned short __pad2;
|
|
|
|
compat_ulong_t unused1;
|
|
|
|
compat_ulong_t unused2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct compat_semid64_ds {
|
|
|
|
struct compat_ipc64_perm sem_perm;
|
2015-05-06 04:05:19 +07:00
|
|
|
compat_ulong_t sem_otime;
|
|
|
|
compat_ulong_t sem_otime_high;
|
|
|
|
compat_ulong_t sem_ctime;
|
|
|
|
compat_ulong_t sem_ctime_high;
|
2005-04-17 05:20:36 +07:00
|
|
|
compat_ulong_t sem_nsems;
|
|
|
|
compat_ulong_t __unused3;
|
|
|
|
compat_ulong_t __unused4;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct compat_msqid64_ds {
|
|
|
|
struct compat_ipc64_perm msg_perm;
|
2015-05-06 04:05:19 +07:00
|
|
|
compat_ulong_t msg_stime;
|
|
|
|
compat_ulong_t msg_stime_high;
|
|
|
|
compat_ulong_t msg_rtime;
|
|
|
|
compat_ulong_t msg_rtime_high;
|
|
|
|
compat_ulong_t msg_ctime;
|
|
|
|
compat_ulong_t msg_ctime_high;
|
2005-04-17 05:20:36 +07:00
|
|
|
compat_ulong_t msg_cbytes;
|
|
|
|
compat_ulong_t msg_qnum;
|
|
|
|
compat_ulong_t msg_qbytes;
|
|
|
|
compat_pid_t msg_lspid;
|
|
|
|
compat_pid_t msg_lrpid;
|
|
|
|
compat_ulong_t __unused4;
|
|
|
|
compat_ulong_t __unused5;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct compat_shmid64_ds {
|
|
|
|
struct compat_ipc64_perm shm_perm;
|
|
|
|
compat_size_t shm_segsz;
|
2015-05-06 04:05:19 +07:00
|
|
|
compat_ulong_t shm_atime;
|
|
|
|
compat_ulong_t shm_atime_high;
|
|
|
|
compat_ulong_t shm_dtime;
|
|
|
|
compat_ulong_t shm_dtime_high;
|
|
|
|
compat_ulong_t shm_ctime;
|
|
|
|
compat_ulong_t shm_ctime_high;
|
2005-04-17 05:20:36 +07:00
|
|
|
compat_pid_t shm_cpid;
|
|
|
|
compat_pid_t shm_lpid;
|
|
|
|
compat_ulong_t shm_nattch;
|
|
|
|
compat_ulong_t __unused4;
|
|
|
|
compat_ulong_t __unused5;
|
|
|
|
};
|
|
|
|
|
2007-10-20 01:35:02 +07:00
|
|
|
/*
|
|
|
|
* The type of struct elf_prstatus.pr_reg in compatible core dumps.
|
|
|
|
*/
|
2012-02-20 01:06:34 +07:00
|
|
|
typedef struct user_regs_struct compat_elf_gregset_t;
|
|
|
|
|
2016-09-05 20:33:06 +07:00
|
|
|
/* Full regset -- prstatus on x32, otherwise on ia32 */
|
|
|
|
#define PRSTATUS_SIZE(S, R) (R != sizeof(S.pr_reg) ? 144 : 296)
|
|
|
|
#define SET_PR_FPVALID(S, V, R) \
|
|
|
|
do { *(int *) (((void *) &((S)->pr_reg)) + R) = (V); } \
|
2012-02-20 01:06:34 +07:00
|
|
|
while (0)
|
|
|
|
|
x86/coredump: Always use user_regs_struct for compat_elf_gregset_t
Commit:
90954e7b9407 ("x86/coredump: Use pr_reg size, rather that TIF_IA32 flag")
changed the coredumping code to construct the elf coredump file according
to register set size - and that's good: if binary crashes with 32-bit code
selector, generate 32-bit ELF core, otherwise - 64-bit core.
That was made for restoring 32-bit applications on x86_64: we want
32-bit application after restore to generate 32-bit ELF dump on crash.
All was quite good and recently I started reworking 32-bit applications
dumping part of CRIU: now it has two parasites (32 and 64) for seizing
compat/native tasks, after rework it'll have one parasite, working in
64-bit mode, to which 32-bit prologue long-jumps during infection.
And while it has worked for my work machine, in VM with
!CONFIG_X86_X32_ABI during reworking I faced that segfault in 32-bit
binary, that has long-jumped to 64-bit mode results in dereference
of garbage:
32-victim[19266]: segfault at f775ef65 ip 00000000f775ef65 sp 00000000f776aa50 error 14
BUG: unable to handle kernel paging request at ffffffffffffffff
IP: [<ffffffff81332ce0>] strlen+0x0/0x20
[...]
Call Trace:
[] elf_core_dump+0x11a9/0x1480
[] do_coredump+0xa6b/0xe60
[] get_signal+0x1a8/0x5c0
[] do_signal+0x23/0x660
[] exit_to_usermode_loop+0x34/0x65
[] prepare_exit_to_usermode+0x2f/0x40
[] retint_user+0x8/0x10
That's because we have 64-bit registers set (with according total size)
and we're writing it to elf_thread_core_info which has smaller size
on !CONFIG_X86_X32_ABI. That lead to overwriting ELF notes part.
Tested on 32-, 64-bit ELF crashes and on 32-bit binaries that have
jumped with 64-bit code selector - all is readable with gdb.
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.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: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Fixes: 90954e7b9407 ("x86/coredump: Use pr_reg size, rather that TIF_IA32 flag")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-11-24 01:13:30 +07:00
|
|
|
#ifdef CONFIG_X86_X32_ABI
|
2012-02-20 01:06:34 +07:00
|
|
|
#define COMPAT_USE_64BIT_TIME \
|
|
|
|
(!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
|
|
|
|
#endif
|
2007-10-20 01:35:02 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* A pointer passed in from user mode. This should not
|
|
|
|
* be used for syscall parameters, just declare them
|
|
|
|
* as pointers because the syscall entry code will have
|
2008-02-03 21:32:51 +07:00
|
|
|
* appropriately converted them already.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void __user *compat_ptr(compat_uptr_t uptr)
|
|
|
|
{
|
|
|
|
return (void __user *)(unsigned long)uptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
|
|
|
|
{
|
|
|
|
return (u32)(unsigned long)uptr;
|
|
|
|
}
|
|
|
|
|
2010-09-08 06:16:18 +07:00
|
|
|
static inline void __user *arch_compat_alloc_user_space(long len)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2012-02-20 01:06:34 +07:00
|
|
|
compat_uptr_t sp;
|
|
|
|
|
|
|
|
if (test_thread_flag(TIF_IA32)) {
|
|
|
|
sp = task_pt_regs(current)->sp;
|
|
|
|
} else {
|
|
|
|
/* -128 for the x32 ABI redzone */
|
2015-03-10 01:39:23 +07:00
|
|
|
sp = task_pt_regs(current)->sp - 128;
|
2012-02-20 01:06:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
return (void __user *)round_down(sp - len, 16);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2016-04-18 20:43:43 +07:00
|
|
|
static inline bool in_x32_syscall(void)
|
2012-03-06 04:39:29 +07:00
|
|
|
{
|
2012-02-19 22:56:26 +07:00
|
|
|
#ifdef CONFIG_X86_X32_ABI
|
|
|
|
if (task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
return false;
|
2006-01-12 04:44:06 +07:00
|
|
|
}
|
|
|
|
|
2018-10-12 20:42:52 +07:00
|
|
|
static inline bool in_32bit_syscall(void)
|
2012-03-06 04:39:29 +07:00
|
|
|
{
|
2016-04-18 20:43:43 +07:00
|
|
|
return in_ia32_syscall() || in_x32_syscall();
|
2012-03-06 04:39:29 +07:00
|
|
|
}
|
2018-10-12 20:42:52 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
static inline bool in_compat_syscall(void)
|
|
|
|
{
|
|
|
|
return in_32bit_syscall();
|
|
|
|
}
|
2016-03-23 04:25:27 +07:00
|
|
|
#define in_compat_syscall in_compat_syscall /* override the generic impl */
|
2018-10-12 20:42:52 +07:00
|
|
|
#endif
|
2012-03-06 04:39:29 +07:00
|
|
|
|
2018-01-16 07:03:33 +07:00
|
|
|
struct compat_siginfo;
|
|
|
|
int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
|
2018-09-25 16:27:20 +07:00
|
|
|
const kernel_siginfo_t *from, bool x32_ABI);
|
2018-01-16 07:03:33 +07:00
|
|
|
|
2008-10-23 12:26:29 +07:00
|
|
|
#endif /* _ASM_X86_COMPAT_H */
|