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 */
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifndef __PARISC_UACCESS_H
|
|
|
|
#define __PARISC_UACCESS_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* User space memory access functions
|
|
|
|
*/
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/cache.h>
|
|
|
|
|
2014-10-22 03:29:09 +08:00
|
|
|
#include <linux/bug.h>
|
2016-08-21 07:03:37 +08:00
|
|
|
#include <linux/string.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define KERNEL_DS ((mm_segment_t){0})
|
|
|
|
#define USER_DS ((mm_segment_t){1})
|
|
|
|
|
2015-01-06 23:45:34 +08:00
|
|
|
#define segment_eq(a, b) ((a).seg == (b).seg)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define get_ds() (KERNEL_DS)
|
|
|
|
#define get_fs() (current_thread_info()->addr_limit)
|
|
|
|
#define set_fs(x) (current_thread_info()->addr_limit = (x))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that since kernel addresses are in a separate address space on
|
2005-05-01 23:59:08 +08:00
|
|
|
* parisc, we don't need to do anything for access_ok().
|
2005-04-17 06:20:36 +08:00
|
|
|
* We just let the page fault handler do the right thing. This also means
|
|
|
|
* that put_user is the same as __put_user, etc.
|
|
|
|
*/
|
|
|
|
|
2017-03-16 04:48:42 +08:00
|
|
|
#define access_ok(type, uaddr, size) \
|
|
|
|
( (uaddr) == (uaddr) )
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define put_user __put_user
|
|
|
|
#define get_user __get_user
|
|
|
|
|
2006-12-20 07:35:57 +08:00
|
|
|
#if !defined(CONFIG_64BIT)
|
2017-04-16 16:00:14 +08:00
|
|
|
#define LDD_USER(val, ptr) __get_user_asm64(val, ptr)
|
2015-01-06 23:45:34 +08:00
|
|
|
#define STD_USER(x, ptr) __put_user_asm64(x, ptr)
|
2005-04-17 06:20:36 +08:00
|
|
|
#else
|
2017-04-16 16:00:14 +08:00
|
|
|
#define LDD_USER(val, ptr) __get_user_asm(val, "ldd", ptr)
|
2015-01-06 23:45:34 +08:00
|
|
|
#define STD_USER(x, ptr) __put_user_asm("std", x, ptr)
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2016-04-09 03:36:06 +08:00
|
|
|
* The exception table contains two values: the first is the relative offset to
|
|
|
|
* the address of the instruction that is allowed to fault, and the second is
|
|
|
|
* the relative offset to the address of the fixup routine. Since relative
|
|
|
|
* addresses are used, 32bit values are sufficient even on 64bit kernel.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
2016-03-23 23:00:46 +08:00
|
|
|
#define ARCH_HAS_RELATIVE_EXTABLE
|
2005-04-17 06:20:36 +08:00
|
|
|
struct exception_table_entry {
|
2016-03-23 23:00:46 +08:00
|
|
|
int insn; /* relative address of insn that is allowed to fault. */
|
|
|
|
int fixup; /* relative address of fixup routine */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2007-01-28 21:52:57 +08:00
|
|
|
#define ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr )\
|
|
|
|
".section __ex_table,\"aw\"\n" \
|
2016-03-23 23:00:46 +08:00
|
|
|
".word (" #fault_addr " - .), (" #except_addr " - .)\n\t" \
|
2007-01-28 21:52:57 +08:00
|
|
|
".previous\n"
|
|
|
|
|
2017-03-25 18:59:15 +08:00
|
|
|
/*
|
|
|
|
* ASM_EXCEPTIONTABLE_ENTRY_EFAULT() creates a special exception table entry
|
|
|
|
* (with lowest bit set) for which the fault handler in fixup_exception() will
|
|
|
|
* load -EFAULT into %r8 for a read or write fault, and zeroes the target
|
|
|
|
* register in case of a read fault in get_user().
|
|
|
|
*/
|
|
|
|
#define ASM_EXCEPTIONTABLE_ENTRY_EFAULT( fault_addr, except_addr )\
|
|
|
|
ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr + 1)
|
|
|
|
|
2016-04-09 14:26:14 +08:00
|
|
|
/*
|
|
|
|
* load_sr2() preloads the space register %%sr2 - based on the value of
|
|
|
|
* get_fs() - with either a value of 0 to access kernel space (KERNEL_DS which
|
|
|
|
* is 0), or with the current value of %%sr3 to access user space (USER_DS)
|
|
|
|
* memory. The following __get_user_asm() and __put_user_asm() functions have
|
|
|
|
* %%sr2 hard-coded to access the requested memory.
|
|
|
|
*/
|
|
|
|
#define load_sr2() \
|
|
|
|
__asm__(" or,= %0,%%r0,%%r0\n\t" \
|
|
|
|
" mfsp %%sr3,%0\n\t" \
|
|
|
|
" mtsp %0,%%sr2\n\t" \
|
|
|
|
: : "r"(get_fs()) : )
|
|
|
|
|
2017-04-16 16:00:14 +08:00
|
|
|
#define __get_user_internal(val, ptr) \
|
|
|
|
({ \
|
|
|
|
register long __gu_err __asm__ ("r8") = 0; \
|
|
|
|
\
|
|
|
|
switch (sizeof(*(ptr))) { \
|
|
|
|
case 1: __get_user_asm(val, "ldb", ptr); break; \
|
|
|
|
case 2: __get_user_asm(val, "ldh", ptr); break; \
|
|
|
|
case 4: __get_user_asm(val, "ldw", ptr); break; \
|
|
|
|
case 8: LDD_USER(val, ptr); break; \
|
|
|
|
default: BUILD_BUG(); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
__gu_err; \
|
2005-04-17 06:20:36 +08:00
|
|
|
})
|
|
|
|
|
2017-04-16 16:00:14 +08:00
|
|
|
#define __get_user(val, ptr) \
|
|
|
|
({ \
|
|
|
|
load_sr2(); \
|
|
|
|
__get_user_internal(val, ptr); \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define __get_user_asm(val, ldx, ptr) \
|
|
|
|
{ \
|
|
|
|
register long __gu_val; \
|
|
|
|
\
|
2017-03-25 18:59:15 +08:00
|
|
|
__asm__("1: " ldx " 0(%%sr2,%2),%0\n" \
|
|
|
|
"9:\n" \
|
|
|
|
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
|
2005-04-17 06:20:36 +08:00
|
|
|
: "=r"(__gu_val), "=r"(__gu_err) \
|
2017-04-16 16:00:14 +08:00
|
|
|
: "r"(ptr), "1"(__gu_err)); \
|
|
|
|
\
|
|
|
|
(val) = (__force __typeof__(*(ptr))) __gu_val; \
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-04-09 14:27:08 +08:00
|
|
|
#if !defined(CONFIG_64BIT)
|
|
|
|
|
2017-04-16 16:00:14 +08:00
|
|
|
#define __get_user_asm64(val, ptr) \
|
|
|
|
{ \
|
|
|
|
union { \
|
|
|
|
unsigned long long l; \
|
|
|
|
__typeof__(*(ptr)) t; \
|
|
|
|
} __gu_tmp; \
|
|
|
|
\
|
2017-03-25 18:59:15 +08:00
|
|
|
__asm__(" copy %%r0,%R0\n" \
|
|
|
|
"1: ldw 0(%%sr2,%2),%0\n" \
|
|
|
|
"2: ldw 4(%%sr2,%2),%R0\n" \
|
|
|
|
"9:\n" \
|
|
|
|
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
|
|
|
|
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \
|
2017-04-16 16:00:14 +08:00
|
|
|
: "=&r"(__gu_tmp.l), "=r"(__gu_err) \
|
|
|
|
: "r"(ptr), "1"(__gu_err)); \
|
|
|
|
\
|
|
|
|
(val) = __gu_tmp.t; \
|
|
|
|
}
|
2016-04-09 14:27:08 +08:00
|
|
|
|
|
|
|
#endif /* !defined(CONFIG_64BIT) */
|
|
|
|
|
|
|
|
|
2017-04-16 16:00:14 +08:00
|
|
|
#define __put_user_internal(x, ptr) \
|
2005-04-17 06:20:36 +08:00
|
|
|
({ \
|
|
|
|
register long __pu_err __asm__ ("r8") = 0; \
|
|
|
|
__typeof__(*(ptr)) __x = (__typeof__(*(ptr)))(x); \
|
|
|
|
\
|
2016-04-09 14:26:14 +08:00
|
|
|
switch (sizeof(*(ptr))) { \
|
2017-04-16 16:00:14 +08:00
|
|
|
case 1: __put_user_asm("stb", __x, ptr); break; \
|
|
|
|
case 2: __put_user_asm("sth", __x, ptr); break; \
|
|
|
|
case 4: __put_user_asm("stw", __x, ptr); break; \
|
|
|
|
case 8: STD_USER(__x, ptr); break; \
|
|
|
|
default: BUILD_BUG(); \
|
|
|
|
} \
|
2005-04-17 06:20:36 +08:00
|
|
|
\
|
|
|
|
__pu_err; \
|
|
|
|
})
|
|
|
|
|
2017-04-16 16:00:14 +08:00
|
|
|
#define __put_user(x, ptr) \
|
|
|
|
({ \
|
|
|
|
load_sr2(); \
|
|
|
|
__put_user_internal(x, ptr); \
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* The "__put_user/kernel_asm()" macros tell gcc they read from memory
|
|
|
|
* instead of writing. This is because they do not write to any memory
|
2006-04-23 04:47:21 +08:00
|
|
|
* gcc knows about, so there are no aliasing issues. These macros must
|
2017-03-25 18:59:15 +08:00
|
|
|
* also be aware that fixups are executed in the context of the fault,
|
|
|
|
* and any registers used there must be listed as clobbers.
|
|
|
|
* r8 is already listed as err.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
2015-01-06 23:45:34 +08:00
|
|
|
#define __put_user_asm(stx, x, ptr) \
|
2005-04-17 06:20:36 +08:00
|
|
|
__asm__ __volatile__ ( \
|
2017-03-25 18:59:15 +08:00
|
|
|
"1: " stx " %2,0(%%sr2,%1)\n" \
|
|
|
|
"9:\n" \
|
|
|
|
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
|
2005-04-17 06:20:36 +08:00
|
|
|
: "=r"(__pu_err) \
|
2017-03-25 18:59:15 +08:00
|
|
|
: "r"(ptr), "r"(x), "0"(__pu_err))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
2006-12-20 07:35:57 +08:00
|
|
|
#if !defined(CONFIG_64BIT)
|
2006-12-20 05:33:58 +08:00
|
|
|
|
2015-01-06 23:45:34 +08:00
|
|
|
#define __put_user_asm64(__val, ptr) do { \
|
2005-04-17 06:20:36 +08:00
|
|
|
__asm__ __volatile__ ( \
|
2017-03-25 18:59:15 +08:00
|
|
|
"1: stw %2,0(%%sr2,%1)\n" \
|
|
|
|
"2: stw %R2,4(%%sr2,%1)\n" \
|
|
|
|
"9:\n" \
|
|
|
|
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
|
|
|
|
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \
|
2005-04-17 06:20:36 +08:00
|
|
|
: "=r"(__pu_err) \
|
2017-03-25 18:59:15 +08:00
|
|
|
: "r"(ptr), "r"(__val), "0"(__pu_err)); \
|
2005-04-17 06:20:36 +08:00
|
|
|
} while (0)
|
|
|
|
|
2006-12-20 07:35:57 +08:00
|
|
|
#endif /* !defined(CONFIG_64BIT) */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Complex access routines -- external declarations
|
|
|
|
*/
|
|
|
|
|
2012-05-26 16:48:19 +08:00
|
|
|
extern long strncpy_from_user(char *, const char __user *, long);
|
2015-01-06 23:45:34 +08:00
|
|
|
extern unsigned lclear_user(void __user *, unsigned long);
|
|
|
|
extern long lstrnlen_user(const char __user *, long);
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Complex access routines -- macros
|
|
|
|
*/
|
2013-11-20 06:31:35 +08:00
|
|
|
#define user_addr_max() (~0UL)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define strnlen_user lstrnlen_user
|
|
|
|
#define clear_user lclear_user
|
|
|
|
#define __clear_user lclear_user
|
|
|
|
|
2017-03-25 11:11:26 +08:00
|
|
|
unsigned long __must_check raw_copy_to_user(void __user *dst, const void *src,
|
|
|
|
unsigned long len);
|
|
|
|
unsigned long __must_check raw_copy_from_user(void *dst, const void __user *src,
|
|
|
|
unsigned long len);
|
|
|
|
unsigned long __must_check raw_copy_in_user(void __user *dst, const void __user *src,
|
|
|
|
unsigned long len);
|
|
|
|
#define INLINE_COPY_TO_USER
|
|
|
|
#define INLINE_COPY_FROM_USER
|
2010-02-02 03:56:33 +08:00
|
|
|
|
2009-01-14 03:52:46 +08:00
|
|
|
struct pt_regs;
|
parisc: fix kernel crash (protection id trap) when compiling ruby1.9
On Wed, Dec 17, 2008 at 11:46:05PM +0100, Helge Deller wrote:
>
Honestly, I can't decide whether to apply this. It really should never
happen in the kernel, since the kernel can guarantee it won't get the
access rights failure (highest privilege level, and can set %sr and
%protid to whatever it wants.)
It really genuinely is a bug that probably should panic the kernel. The
only precedent I can easily see is x86 fixing up a bad iret with a
general protection fault, which is more or less analogous to code 27
here.
On the other hand, taking the exception on a userspace access really
isn't all that critical, and there's fundamentally little reason for the
kernel not to SIGSEGV the process, and continue...
Argh.
(btw, I've instrumented my do_sys_poll with a pile of assertions that
%cr8 << 1 == %sr3 == current->mm.context... let's see if where we're
getting corrupted is deterministic, though, I would guess that it won't
be.)
Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
2008-12-20 10:29:06 +08:00
|
|
|
int fixup_exception(struct pt_regs *regs);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* __PARISC_UACCESS_H */
|