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 */
|
2005-10-29 14:51:31 +07:00
|
|
|
#ifndef _ARCH_POWERPC_UACCESS_H
|
|
|
|
#define _ARCH_POWERPC_UACCESS_H
|
|
|
|
|
2008-07-17 14:17:52 +07:00
|
|
|
#include <asm/asm-compat.h>
|
2016-10-13 12:42:53 +07:00
|
|
|
#include <asm/ppc_asm.h>
|
2005-10-29 14:51:31 +07:00
|
|
|
#include <asm/processor.h>
|
2006-05-03 20:02:04 +07:00
|
|
|
#include <asm/page.h>
|
2016-12-26 12:50:06 +07:00
|
|
|
#include <asm/extable.h>
|
2005-10-29 14:51:31 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The fs value determines whether argument validity checking should be
|
|
|
|
* performed or not. If get_fs() == USER_DS, checking is performed, with
|
|
|
|
* get_fs() == KERNEL_DS, checking is bypassed.
|
|
|
|
*
|
|
|
|
* For historical reasons, these macros are grossly misnamed.
|
|
|
|
*
|
|
|
|
* The fs/ds values are now the highest legal address in the "segment".
|
|
|
|
* This simplifies the checking in the routines below.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
|
|
|
|
|
2005-10-31 14:39:20 +07:00
|
|
|
#define KERNEL_DS MAKE_MM_SEG(~0UL)
|
2005-10-29 14:51:31 +07:00
|
|
|
#ifdef __powerpc64__
|
2005-10-31 14:39:20 +07:00
|
|
|
/* We use TASK_SIZE_USER64 as TASK_SIZE is not constant */
|
|
|
|
#define USER_DS MAKE_MM_SEG(TASK_SIZE_USER64 - 1)
|
2005-10-29 14:51:31 +07:00
|
|
|
#else
|
|
|
|
#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define get_ds() (KERNEL_DS)
|
|
|
|
#define get_fs() (current->thread.fs)
|
|
|
|
#define set_fs(val) (current->thread.fs = (val))
|
|
|
|
|
|
|
|
#define segment_eq(a, b) ((a).seg == (b).seg)
|
|
|
|
|
2012-05-28 10:03:47 +07:00
|
|
|
#define user_addr_max() (get_fs().seg)
|
|
|
|
|
2005-10-29 14:51:31 +07:00
|
|
|
#ifdef __powerpc64__
|
|
|
|
/*
|
2005-10-31 14:39:20 +07:00
|
|
|
* This check is sufficient because there is a large enough
|
|
|
|
* gap between user addresses and the kernel addresses
|
2005-10-29 14:51:31 +07:00
|
|
|
*/
|
|
|
|
#define __access_ok(addr, size, segment) \
|
2005-10-31 14:39:20 +07:00
|
|
|
(((addr) <= (segment).seg) && ((size) <= (segment).seg))
|
2005-10-29 14:51:31 +07:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-03-03 02:50:51 +07:00
|
|
|
static inline int __access_ok(unsigned long addr, unsigned long size,
|
|
|
|
mm_segment_t seg)
|
|
|
|
{
|
|
|
|
if (addr > seg.seg)
|
|
|
|
return 0;
|
|
|
|
return (size == 0 || size - 1 <= seg.seg - addr);
|
|
|
|
}
|
2005-10-29 14:51:31 +07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define access_ok(type, addr, size) \
|
|
|
|
(__chk_user_ptr(addr), \
|
|
|
|
__access_ok((__force unsigned long)(addr), (size), get_fs()))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are the main single-value transfer routines. They automatically
|
|
|
|
* use the right size if we just have the right pointer type.
|
|
|
|
*
|
|
|
|
* This gets kind of ugly. We want to return _two_ values in "get_user()"
|
|
|
|
* and yet we don't want to do any pointers, because that is too much
|
|
|
|
* of a performance impact. Thus we have a few rather ugly macros here,
|
|
|
|
* and hide all the ugliness from the user.
|
|
|
|
*
|
|
|
|
* The "__xxx" versions of the user access functions are versions that
|
|
|
|
* do not verify the address space, that must have been done previously
|
|
|
|
* with a separate "access_ok()" call (this is used when we do multiple
|
|
|
|
* accesses to the same area of user memory).
|
|
|
|
*
|
|
|
|
* As we use the same address space for kernel and user data on the
|
|
|
|
* PowerPC, we can just do these as direct assignments. (Of course, the
|
|
|
|
* exception handling means that it's no longer "just"...)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define get_user(x, ptr) \
|
|
|
|
__get_user_check((x), (ptr), sizeof(*(ptr)))
|
|
|
|
#define put_user(x, ptr) \
|
|
|
|
__put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
|
|
|
|
|
|
|
|
#define __get_user(x, ptr) \
|
|
|
|
__get_user_nocheck((x), (ptr), sizeof(*(ptr)))
|
|
|
|
#define __put_user(x, ptr) \
|
|
|
|
__put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
|
2007-04-11 13:13:19 +07:00
|
|
|
|
|
|
|
#define __get_user_inatomic(x, ptr) \
|
|
|
|
__get_user_nosleep((x), (ptr), sizeof(*(ptr)))
|
|
|
|
#define __put_user_inatomic(x, ptr) \
|
|
|
|
__put_user_nosleep((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
|
|
|
|
|
2005-10-29 14:51:31 +07:00
|
|
|
extern long __put_user_bad(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't tell gcc that we are accessing memory, but this is OK
|
|
|
|
* because we do not write to any memory gcc knows about, so there
|
|
|
|
* are no aliasing issues.
|
|
|
|
*/
|
|
|
|
#define __put_user_asm(x, addr, err, op) \
|
|
|
|
__asm__ __volatile__( \
|
|
|
|
"1: " op " %1,0(%2) # put_user\n" \
|
|
|
|
"2:\n" \
|
|
|
|
".section .fixup,\"ax\"\n" \
|
|
|
|
"3: li %0,%3\n" \
|
|
|
|
" b 2b\n" \
|
|
|
|
".previous\n" \
|
2016-10-13 12:42:53 +07:00
|
|
|
EX_TABLE(1b, 3b) \
|
2005-10-29 14:51:31 +07:00
|
|
|
: "=r" (err) \
|
2008-07-17 14:17:52 +07:00
|
|
|
: "r" (x), "b" (addr), "i" (-EFAULT), "0" (err))
|
2005-10-29 14:51:31 +07:00
|
|
|
|
2005-10-31 14:39:20 +07:00
|
|
|
#ifdef __powerpc64__
|
|
|
|
#define __put_user_asm2(x, ptr, retval) \
|
|
|
|
__put_user_asm(x, ptr, retval, "std")
|
|
|
|
#else /* __powerpc64__ */
|
2005-10-29 14:51:31 +07:00
|
|
|
#define __put_user_asm2(x, addr, err) \
|
|
|
|
__asm__ __volatile__( \
|
|
|
|
"1: stw %1,0(%2)\n" \
|
|
|
|
"2: stw %1+1,4(%2)\n" \
|
|
|
|
"3:\n" \
|
|
|
|
".section .fixup,\"ax\"\n" \
|
|
|
|
"4: li %0,%3\n" \
|
|
|
|
" b 3b\n" \
|
|
|
|
".previous\n" \
|
2016-10-13 12:42:53 +07:00
|
|
|
EX_TABLE(1b, 4b) \
|
|
|
|
EX_TABLE(2b, 4b) \
|
2005-10-29 14:51:31 +07:00
|
|
|
: "=r" (err) \
|
2008-07-17 14:17:52 +07:00
|
|
|
: "r" (x), "b" (addr), "i" (-EFAULT), "0" (err))
|
2005-10-29 14:51:31 +07:00
|
|
|
#endif /* __powerpc64__ */
|
|
|
|
|
|
|
|
#define __put_user_size(x, ptr, size, retval) \
|
|
|
|
do { \
|
|
|
|
retval = 0; \
|
|
|
|
switch (size) { \
|
|
|
|
case 1: __put_user_asm(x, ptr, retval, "stb"); break; \
|
|
|
|
case 2: __put_user_asm(x, ptr, retval, "sth"); break; \
|
|
|
|
case 4: __put_user_asm(x, ptr, retval, "stw"); break; \
|
|
|
|
case 8: __put_user_asm2(x, ptr, retval); break; \
|
|
|
|
default: __put_user_bad(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define __put_user_nocheck(x, ptr, size) \
|
|
|
|
({ \
|
|
|
|
long __pu_err; \
|
2006-05-03 20:02:04 +07:00
|
|
|
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \
|
|
|
|
if (!is_kernel_addr((unsigned long)__pu_addr)) \
|
2013-05-26 21:31:38 +07:00
|
|
|
might_fault(); \
|
2005-10-29 14:51:31 +07:00
|
|
|
__chk_user_ptr(ptr); \
|
2006-05-03 20:02:04 +07:00
|
|
|
__put_user_size((x), __pu_addr, (size), __pu_err); \
|
2005-10-29 14:51:31 +07:00
|
|
|
__pu_err; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define __put_user_check(x, ptr, size) \
|
|
|
|
({ \
|
|
|
|
long __pu_err = -EFAULT; \
|
|
|
|
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \
|
2013-05-26 21:31:38 +07:00
|
|
|
might_fault(); \
|
2005-10-29 14:51:31 +07:00
|
|
|
if (access_ok(VERIFY_WRITE, __pu_addr, size)) \
|
|
|
|
__put_user_size((x), __pu_addr, (size), __pu_err); \
|
|
|
|
__pu_err; \
|
|
|
|
})
|
|
|
|
|
2007-04-11 13:13:19 +07:00
|
|
|
#define __put_user_nosleep(x, ptr, size) \
|
|
|
|
({ \
|
|
|
|
long __pu_err; \
|
|
|
|
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \
|
|
|
|
__chk_user_ptr(ptr); \
|
|
|
|
__put_user_size((x), __pu_addr, (size), __pu_err); \
|
|
|
|
__pu_err; \
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2005-10-29 14:51:31 +07:00
|
|
|
extern long __get_user_bad(void);
|
|
|
|
|
2017-09-15 12:25:48 +07:00
|
|
|
/*
|
|
|
|
* This does an atomic 128 byte aligned load from userspace.
|
|
|
|
* Upto caller to do enable_kernel_vmx() before calling!
|
|
|
|
*/
|
|
|
|
#define __get_user_atomic_128_aligned(kaddr, uaddr, err) \
|
|
|
|
__asm__ __volatile__( \
|
|
|
|
"1: lvx 0,0,%1 # get user\n" \
|
|
|
|
" stvx 0,0,%2 # put kernel\n" \
|
|
|
|
"2:\n" \
|
|
|
|
".section .fixup,\"ax\"\n" \
|
|
|
|
"3: li %0,%3\n" \
|
|
|
|
" b 2b\n" \
|
|
|
|
".previous\n" \
|
|
|
|
EX_TABLE(1b, 3b) \
|
|
|
|
: "=r" (err) \
|
|
|
|
: "b" (uaddr), "b" (kaddr), "i" (-EFAULT), "0" (err))
|
|
|
|
|
2005-10-29 14:51:31 +07:00
|
|
|
#define __get_user_asm(x, addr, err, op) \
|
|
|
|
__asm__ __volatile__( \
|
2005-10-31 14:39:20 +07:00
|
|
|
"1: "op" %1,0(%2) # get_user\n" \
|
2005-10-29 14:51:31 +07:00
|
|
|
"2:\n" \
|
|
|
|
".section .fixup,\"ax\"\n" \
|
|
|
|
"3: li %0,%3\n" \
|
|
|
|
" li %1,0\n" \
|
|
|
|
" b 2b\n" \
|
|
|
|
".previous\n" \
|
2016-10-13 12:42:53 +07:00
|
|
|
EX_TABLE(1b, 3b) \
|
2005-10-29 14:51:31 +07:00
|
|
|
: "=r" (err), "=r" (x) \
|
2008-07-17 14:17:52 +07:00
|
|
|
: "b" (addr), "i" (-EFAULT), "0" (err))
|
2005-10-29 14:51:31 +07:00
|
|
|
|
2005-10-31 14:39:20 +07:00
|
|
|
#ifdef __powerpc64__
|
|
|
|
#define __get_user_asm2(x, addr, err) \
|
|
|
|
__get_user_asm(x, addr, err, "ld")
|
|
|
|
#else /* __powerpc64__ */
|
|
|
|
#define __get_user_asm2(x, addr, err) \
|
2005-10-29 14:51:31 +07:00
|
|
|
__asm__ __volatile__( \
|
|
|
|
"1: lwz %1,0(%2)\n" \
|
|
|
|
"2: lwz %1+1,4(%2)\n" \
|
|
|
|
"3:\n" \
|
|
|
|
".section .fixup,\"ax\"\n" \
|
|
|
|
"4: li %0,%3\n" \
|
|
|
|
" li %1,0\n" \
|
|
|
|
" li %1+1,0\n" \
|
|
|
|
" b 3b\n" \
|
|
|
|
".previous\n" \
|
2016-10-13 12:42:53 +07:00
|
|
|
EX_TABLE(1b, 4b) \
|
|
|
|
EX_TABLE(2b, 4b) \
|
2005-10-29 14:51:31 +07:00
|
|
|
: "=r" (err), "=&r" (x) \
|
2008-07-17 14:17:52 +07:00
|
|
|
: "b" (addr), "i" (-EFAULT), "0" (err))
|
2005-10-29 14:51:31 +07:00
|
|
|
#endif /* __powerpc64__ */
|
|
|
|
|
|
|
|
#define __get_user_size(x, ptr, size, retval) \
|
|
|
|
do { \
|
|
|
|
retval = 0; \
|
|
|
|
__chk_user_ptr(ptr); \
|
2005-10-31 14:39:20 +07:00
|
|
|
if (size > sizeof(x)) \
|
|
|
|
(x) = __get_user_bad(); \
|
2005-10-29 14:51:31 +07:00
|
|
|
switch (size) { \
|
|
|
|
case 1: __get_user_asm(x, ptr, retval, "lbz"); break; \
|
|
|
|
case 2: __get_user_asm(x, ptr, retval, "lhz"); break; \
|
|
|
|
case 4: __get_user_asm(x, ptr, retval, "lwz"); break; \
|
|
|
|
case 8: __get_user_asm2(x, ptr, retval); break; \
|
|
|
|
default: (x) = __get_user_bad(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define __get_user_nocheck(x, ptr, size) \
|
|
|
|
({ \
|
|
|
|
long __gu_err; \
|
|
|
|
unsigned long __gu_val; \
|
2017-01-30 13:41:54 +07:00
|
|
|
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
|
2005-10-29 14:51:31 +07:00
|
|
|
__chk_user_ptr(ptr); \
|
2006-05-03 20:02:04 +07:00
|
|
|
if (!is_kernel_addr((unsigned long)__gu_addr)) \
|
2013-05-26 21:31:38 +07:00
|
|
|
might_fault(); \
|
2006-05-03 20:02:04 +07:00
|
|
|
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
|
2005-10-29 14:51:31 +07:00
|
|
|
(x) = (__typeof__(*(ptr)))__gu_val; \
|
|
|
|
__gu_err; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define __get_user_check(x, ptr, size) \
|
|
|
|
({ \
|
|
|
|
long __gu_err = -EFAULT; \
|
|
|
|
unsigned long __gu_val = 0; \
|
2017-01-30 13:41:53 +07:00
|
|
|
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
|
2013-05-26 21:31:38 +07:00
|
|
|
might_fault(); \
|
2005-10-29 14:51:31 +07:00
|
|
|
if (access_ok(VERIFY_READ, __gu_addr, (size))) \
|
|
|
|
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
|
2014-12-14 23:52:51 +07:00
|
|
|
(x) = (__force __typeof__(*(ptr)))__gu_val; \
|
2005-10-29 14:51:31 +07:00
|
|
|
__gu_err; \
|
|
|
|
})
|
|
|
|
|
2007-04-11 13:13:19 +07:00
|
|
|
#define __get_user_nosleep(x, ptr, size) \
|
|
|
|
({ \
|
|
|
|
long __gu_err; \
|
|
|
|
unsigned long __gu_val; \
|
2017-01-30 13:41:55 +07:00
|
|
|
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
|
2007-04-11 13:13:19 +07:00
|
|
|
__chk_user_ptr(ptr); \
|
|
|
|
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
|
2014-12-14 23:52:51 +07:00
|
|
|
(x) = (__force __typeof__(*(ptr)))__gu_val; \
|
2007-04-11 13:13:19 +07:00
|
|
|
__gu_err; \
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2005-10-29 14:51:31 +07:00
|
|
|
/* more complex routines */
|
|
|
|
|
|
|
|
extern unsigned long __copy_tofrom_user(void __user *to,
|
|
|
|
const void __user *from, unsigned long size);
|
|
|
|
|
2017-06-26 08:30:57 +07:00
|
|
|
#ifdef __powerpc64__
|
2017-03-22 03:35:08 +07:00
|
|
|
static inline unsigned long
|
|
|
|
raw_copy_in_user(void __user *to, const void __user *from, unsigned long n)
|
|
|
|
{
|
|
|
|
return __copy_tofrom_user(to, from, n);
|
|
|
|
}
|
2005-11-01 11:53:19 +07:00
|
|
|
#endif /* __powerpc64__ */
|
|
|
|
|
2017-03-22 03:35:08 +07:00
|
|
|
static inline unsigned long raw_copy_from_user(void *to,
|
2005-10-31 14:39:20 +07:00
|
|
|
const void __user *from, unsigned long n)
|
2005-10-29 14:51:31 +07:00
|
|
|
{
|
|
|
|
if (__builtin_constant_p(n) && (n <= 8)) {
|
[POWERPC] Fix uninitialized variable bug in copy_{to|from}_user
Calls to copy_to_user() or copy_from_user() can fail when copying N
bytes, where N is a constant less than 8, but not 1, 2, 4, or 8,
because 'ret' is not initialized and is only set if the size is 1,
2, 4 or 8, but is tested after the switch statement for any constant
size <= 8. This fixes it by initializing 'ret' to 1, causing the
code to fall through to the __copy_tofrom_user call for sizes other
than 1, 2, 4 or 8.
Signed-off-by: Dave Scidmore <dscidmore@xes-inc.com>
Signed-off-by: Nate Case <ncase@xes-inc.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-05-13 03:14:14 +07:00
|
|
|
unsigned long ret = 1;
|
2005-10-29 14:51:31 +07:00
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
case 1:
|
|
|
|
__get_user_size(*(u8 *)to, from, 1, ret);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
__get_user_size(*(u16 *)to, from, 2, ret);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
__get_user_size(*(u32 *)to, from, 4, ret);
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
__get_user_size(*(u64 *)to, from, 8, ret);
|
|
|
|
break;
|
|
|
|
}
|
2005-11-01 11:53:19 +07:00
|
|
|
if (ret == 0)
|
|
|
|
return 0;
|
2005-10-29 14:51:31 +07:00
|
|
|
}
|
2016-06-24 05:10:01 +07:00
|
|
|
|
2005-11-01 11:53:19 +07:00
|
|
|
return __copy_tofrom_user((__force void __user *)to, from, n);
|
2005-10-29 14:51:31 +07:00
|
|
|
}
|
|
|
|
|
2017-03-22 03:35:08 +07:00
|
|
|
static inline unsigned long raw_copy_to_user(void __user *to,
|
2005-10-31 14:39:20 +07:00
|
|
|
const void *from, unsigned long n)
|
2005-10-29 14:51:31 +07:00
|
|
|
{
|
|
|
|
if (__builtin_constant_p(n) && (n <= 8)) {
|
[POWERPC] Fix uninitialized variable bug in copy_{to|from}_user
Calls to copy_to_user() or copy_from_user() can fail when copying N
bytes, where N is a constant less than 8, but not 1, 2, 4, or 8,
because 'ret' is not initialized and is only set if the size is 1,
2, 4 or 8, but is tested after the switch statement for any constant
size <= 8. This fixes it by initializing 'ret' to 1, causing the
code to fall through to the __copy_tofrom_user call for sizes other
than 1, 2, 4 or 8.
Signed-off-by: Dave Scidmore <dscidmore@xes-inc.com>
Signed-off-by: Nate Case <ncase@xes-inc.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-05-13 03:14:14 +07:00
|
|
|
unsigned long ret = 1;
|
2005-10-29 14:51:31 +07:00
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
case 1:
|
|
|
|
__put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
__put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
__put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret);
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
__put_user_size(*(u64 *)from, (u64 __user *)to, 8, ret);
|
|
|
|
break;
|
|
|
|
}
|
2005-11-01 11:53:19 +07:00
|
|
|
if (ret == 0)
|
|
|
|
return 0;
|
2005-10-29 14:51:31 +07:00
|
|
|
}
|
2016-09-01 06:04:21 +07:00
|
|
|
|
2005-11-01 11:53:19 +07:00
|
|
|
return __copy_tofrom_user(to, (__force const void __user *)from, n);
|
2005-10-29 14:51:31 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
extern unsigned long __clear_user(void __user *addr, unsigned long size);
|
|
|
|
|
|
|
|
static inline unsigned long clear_user(void __user *addr, unsigned long size)
|
|
|
|
{
|
2013-05-26 21:31:38 +07:00
|
|
|
might_fault();
|
2005-10-29 14:51:31 +07:00
|
|
|
if (likely(access_ok(VERIFY_WRITE, addr, size)))
|
|
|
|
return __clear_user(addr, size);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2012-05-28 10:03:47 +07:00
|
|
|
extern long strncpy_from_user(char *dst, const char __user *src, long count);
|
|
|
|
extern __must_check long strnlen_user(const char __user *str, long n);
|
2005-10-29 14:51:31 +07:00
|
|
|
|
2017-10-19 14:13:55 +07:00
|
|
|
extern long __copy_from_user_flushcache(void *dst, const void __user *src,
|
|
|
|
unsigned size);
|
|
|
|
extern void memcpy_page_flushcache(char *to, struct page *page, size_t offset,
|
|
|
|
size_t len);
|
|
|
|
|
2005-10-29 14:51:31 +07:00
|
|
|
#endif /* _ARCH_POWERPC_UACCESS_H */
|