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 10:07:57 -04:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-10-23 01:26:29 -04:00
|
|
|
#ifndef _ASM_X86_MMU_H
|
|
|
|
#define _ASM_X86_MMU_H
|
2007-10-20 02:56:59 -04:00
|
|
|
|
|
|
|
#include <linux/spinlock.h>
|
2017-12-14 06:27:30 -05:00
|
|
|
#include <linux/rwsem.h>
|
2007-10-20 02:56:59 -04:00
|
|
|
#include <linux/mutex.h>
|
2017-06-29 11:53:15 -04:00
|
|
|
#include <linux/atomic.h>
|
2020-10-03 23:25:35 -04:00
|
|
|
#include <linux/bits.h>
|
|
|
|
|
|
|
|
/* Uprobes on this MM assume 32-bit code */
|
2023-03-12 07:25:57 -04:00
|
|
|
#define MM_CONTEXT_UPROBE_IA32 0
|
2020-10-03 23:25:35 -04:00
|
|
|
/* vsyscall page is accessible on this MM */
|
2023-03-12 07:25:57 -04:00
|
|
|
#define MM_CONTEXT_HAS_VSYSCALL 1
|
2023-03-12 07:26:03 -04:00
|
|
|
/* Do not allow changing LAM mode */
|
|
|
|
#define MM_CONTEXT_LOCK_LAM 2
|
2023-03-12 07:26:06 -04:00
|
|
|
/* Allow LAM and SVA coexisting */
|
|
|
|
#define MM_CONTEXT_FORCE_TAGGED_SVA 3
|
2007-10-20 02:56:59 -04:00
|
|
|
|
|
|
|
/*
|
2017-06-29 11:53:15 -04:00
|
|
|
* x86 has arch-specific MMU state beyond what lives in mm_struct.
|
2007-10-20 02:56:59 -04:00
|
|
|
*/
|
2008-03-23 04:02:44 -04:00
|
|
|
typedef struct {
|
2017-06-29 11:53:15 -04:00
|
|
|
/*
|
|
|
|
* ctx_id uniquely identifies this mm_struct. A ctx_id will never
|
|
|
|
* be reused, and zero is not a valid ctx_id.
|
|
|
|
*/
|
|
|
|
u64 ctx_id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Any code that needs to do any sort of TLB flushing for this
|
|
|
|
* mm will first make its changes to the page tables, then
|
|
|
|
* increment tlb_gen, then flush. This lets the low-level
|
|
|
|
* flushing code keep track of what needs flushing.
|
|
|
|
*
|
|
|
|
* This is not used on Xen PV.
|
|
|
|
*/
|
|
|
|
atomic64_t tlb_gen;
|
|
|
|
|
2015-07-30 17:31:34 -04:00
|
|
|
#ifdef CONFIG_MODIFY_LDT_SYSCALL
|
2017-12-14 06:27:30 -05:00
|
|
|
struct rw_semaphore ldt_usr_sem;
|
|
|
|
struct ldt_struct *ldt;
|
2015-07-30 17:31:34 -04:00
|
|
|
#endif
|
2011-03-13 15:49:13 -04:00
|
|
|
|
|
|
|
#ifdef CONFIG_X86_64
|
2023-03-12 07:25:57 -04:00
|
|
|
unsigned long flags;
|
2011-03-13 15:49:13 -04:00
|
|
|
#endif
|
|
|
|
|
2023-03-12 07:25:59 -04:00
|
|
|
#ifdef CONFIG_ADDRESS_MASKING
|
|
|
|
/* Active LAM mode: X86_CR3_LAM_U48 or X86_CR3_LAM_U57 or 0 (disabled) */
|
|
|
|
unsigned long lam_cr3_mask;
|
2023-03-12 07:26:01 -04:00
|
|
|
|
|
|
|
/* Significant bits of the virtual address. Excludes tag bits. */
|
|
|
|
u64 untag_mask;
|
2023-03-12 07:25:59 -04:00
|
|
|
#endif
|
|
|
|
|
2011-05-24 09:49:59 -04:00
|
|
|
struct mutex lock;
|
2015-12-29 23:12:21 -05:00
|
|
|
void __user *vdso; /* vdso base address */
|
|
|
|
const struct vdso_image *vdso_image; /* vdso image in use */
|
2014-10-24 18:58:12 -04:00
|
|
|
|
|
|
|
atomic_t perf_rdpmc_allowed; /* nonzero if rdpmc is allowed */
|
x86/pkeys: Allocation/free syscalls
This patch adds two new system calls:
int pkey_alloc(unsigned long flags, unsigned long init_access_rights)
int pkey_free(int pkey);
These implement an "allocator" for the protection keys
themselves, which can be thought of as analogous to the allocator
that the kernel has for file descriptors. The kernel tracks
which numbers are in use, and only allows operations on keys that
are valid. A key which was not obtained by pkey_alloc() may not,
for instance, be passed to pkey_mprotect().
These system calls are also very important given the kernel's use
of pkeys to implement execute-only support. These help ensure
that userspace can never assume that it has control of a key
unless it first asks the kernel. The kernel does not promise to
preserve PKRU (right register) contents except for allocated
pkeys.
The 'init_access_rights' argument to pkey_alloc() specifies the
rights that will be established for the returned pkey. For
instance:
pkey = pkey_alloc(flags, PKEY_DENY_WRITE);
will allocate 'pkey', but also sets the bits in PKRU[1] such that
writing to 'pkey' is already denied.
The kernel does not prevent pkey_free() from successfully freeing
in-use pkeys (those still assigned to a memory range by
pkey_mprotect()). It would be expensive to implement the checks
for this, so we instead say, "Just don't do it" since sane
software will never do it anyway.
Any piece of userspace calling pkey_alloc() needs to be prepared
for it to fail. Why? pkey_alloc() returns the same error code
(ENOSPC) when there are no pkeys and when pkeys are unsupported.
They can be unsupported for a whole host of reasons, so apps must
be prepared for this. Also, libraries or LD_PRELOADs might steal
keys before an application gets access to them.
This allocation mechanism could be implemented in userspace.
Even if we did it in userspace, we would still need additional
user/kernel interfaces to tell userspace which keys are being
used by the kernel internally (such as for execute-only
mappings). Having the kernel provide this facility completely
removes the need for these additional interfaces, or having an
implementation of this in userspace at all.
Note that we have to make changes to all of the architectures
that do not use mman-common.h because we use the new
PKEY_DENY_ACCESS/WRITE macros in arch-independent code.
1. PKRU is the Protection Key Rights User register. It is a
usermode-accessible register that controls whether writes
and/or access to each individual pkey is allowed or denied.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Cc: linux-arch@vger.kernel.org
Cc: Dave Hansen <dave@sr71.net>
Cc: arnd@arndb.de
Cc: linux-api@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: luto@kernel.org
Cc: akpm@linux-foundation.org
Cc: torvalds@linux-foundation.org
Link: http://lkml.kernel.org/r/20160729163015.444FE75F@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2016-07-29 12:30:15 -04:00
|
|
|
#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
|
|
|
|
/*
|
|
|
|
* One bit per protection key says whether userspace can
|
2020-06-09 00:33:54 -04:00
|
|
|
* use it or not. protected by mmap_lock.
|
x86/pkeys: Allocation/free syscalls
This patch adds two new system calls:
int pkey_alloc(unsigned long flags, unsigned long init_access_rights)
int pkey_free(int pkey);
These implement an "allocator" for the protection keys
themselves, which can be thought of as analogous to the allocator
that the kernel has for file descriptors. The kernel tracks
which numbers are in use, and only allows operations on keys that
are valid. A key which was not obtained by pkey_alloc() may not,
for instance, be passed to pkey_mprotect().
These system calls are also very important given the kernel's use
of pkeys to implement execute-only support. These help ensure
that userspace can never assume that it has control of a key
unless it first asks the kernel. The kernel does not promise to
preserve PKRU (right register) contents except for allocated
pkeys.
The 'init_access_rights' argument to pkey_alloc() specifies the
rights that will be established for the returned pkey. For
instance:
pkey = pkey_alloc(flags, PKEY_DENY_WRITE);
will allocate 'pkey', but also sets the bits in PKRU[1] such that
writing to 'pkey' is already denied.
The kernel does not prevent pkey_free() from successfully freeing
in-use pkeys (those still assigned to a memory range by
pkey_mprotect()). It would be expensive to implement the checks
for this, so we instead say, "Just don't do it" since sane
software will never do it anyway.
Any piece of userspace calling pkey_alloc() needs to be prepared
for it to fail. Why? pkey_alloc() returns the same error code
(ENOSPC) when there are no pkeys and when pkeys are unsupported.
They can be unsupported for a whole host of reasons, so apps must
be prepared for this. Also, libraries or LD_PRELOADs might steal
keys before an application gets access to them.
This allocation mechanism could be implemented in userspace.
Even if we did it in userspace, we would still need additional
user/kernel interfaces to tell userspace which keys are being
used by the kernel internally (such as for execute-only
mappings). Having the kernel provide this facility completely
removes the need for these additional interfaces, or having an
implementation of this in userspace at all.
Note that we have to make changes to all of the architectures
that do not use mman-common.h because we use the new
PKEY_DENY_ACCESS/WRITE macros in arch-independent code.
1. PKRU is the Protection Key Rights User register. It is a
usermode-accessible register that controls whether writes
and/or access to each individual pkey is allowed or denied.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Cc: linux-arch@vger.kernel.org
Cc: Dave Hansen <dave@sr71.net>
Cc: arnd@arndb.de
Cc: linux-api@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: luto@kernel.org
Cc: akpm@linux-foundation.org
Cc: torvalds@linux-foundation.org
Link: http://lkml.kernel.org/r/20160729163015.444FE75F@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2016-07-29 12:30:15 -04:00
|
|
|
*/
|
|
|
|
u16 pkey_allocation_map;
|
|
|
|
s16 execute_only_pkey;
|
|
|
|
#endif
|
2007-10-20 02:56:59 -04:00
|
|
|
} mm_context_t;
|
|
|
|
|
2017-06-29 11:53:15 -04:00
|
|
|
#define INIT_MM_CONTEXT(mm) \
|
|
|
|
.context = { \
|
|
|
|
.ctx_id = 1, \
|
2019-07-01 13:33:54 -04:00
|
|
|
.lock = __MUTEX_INITIALIZER(mm.context.lock), \
|
2017-06-29 11:53:15 -04:00
|
|
|
}
|
|
|
|
|
2024-01-26 03:06:43 -05:00
|
|
|
void leave_mm(void);
|
2020-08-12 06:22:17 -04:00
|
|
|
#define leave_mm leave_mm
|
2008-01-30 07:32:01 -05:00
|
|
|
|
2008-10-23 01:26:29 -04:00
|
|
|
#endif /* _ASM_X86_MMU_H */
|