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 */
|
2008-10-23 13:26:29 +08:00
|
|
|
#ifndef _ASM_X86_COMPAT_H
|
|
|
|
#define _ASM_X86_COMPAT_H
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Architecture specific compatibility types
|
|
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/sched.h>
|
2017-11-02 15:59:16 +08:00
|
|
|
#include <linux/sched/task_stack.h>
|
2012-02-20 02:06:34 +08:00
|
|
|
#include <asm/processor.h>
|
2007-10-20 02:35:02 +08:00
|
|
|
#include <asm/user32.h>
|
2012-02-19 23:56:26 +08:00
|
|
|
#include <asm/unistd.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-03-11 07:21:19 +08:00
|
|
|
#define COMPAT_USER_HZ 100
|
|
|
|
#define COMPAT_UTS_MACHINE "i686\0\0"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
typedef u32 compat_size_t;
|
|
|
|
typedef s32 compat_ssize_t;
|
|
|
|
typedef s32 compat_time_t;
|
|
|
|
typedef s32 compat_clock_t;
|
|
|
|
typedef s32 compat_pid_t;
|
2005-09-07 06:16:40 +08:00
|
|
|
typedef u16 __compat_uid_t;
|
|
|
|
typedef u16 __compat_gid_t;
|
|
|
|
typedef u32 __compat_uid32_t;
|
|
|
|
typedef u32 __compat_gid32_t;
|
2005-04-17 06:20:36 +08:00
|
|
|
typedef u16 compat_mode_t;
|
|
|
|
typedef u32 compat_ino_t;
|
|
|
|
typedef u16 compat_dev_t;
|
|
|
|
typedef s32 compat_off_t;
|
|
|
|
typedef s64 compat_loff_t;
|
|
|
|
typedef u16 compat_nlink_t;
|
|
|
|
typedef u16 compat_ipc_pid_t;
|
|
|
|
typedef s32 compat_daddr_t;
|
|
|
|
typedef u32 compat_caddr_t;
|
|
|
|
typedef __kernel_fsid_t compat_fsid_t;
|
|
|
|
typedef s32 compat_timer_t;
|
|
|
|
typedef s32 compat_key_t;
|
|
|
|
|
|
|
|
typedef s32 compat_int_t;
|
|
|
|
typedef s32 compat_long_t;
|
2007-07-16 14:41:11 +08:00
|
|
|
typedef s64 __attribute__((aligned(4))) compat_s64;
|
2005-04-17 06:20:36 +08:00
|
|
|
typedef u32 compat_uint_t;
|
|
|
|
typedef u32 compat_ulong_t;
|
2016-06-09 01:25:33 +08:00
|
|
|
typedef u32 compat_u32;
|
2007-07-16 14:41:11 +08:00
|
|
|
typedef u64 __attribute__((aligned(4))) compat_u64;
|
2012-10-05 08:15:31 +08:00
|
|
|
typedef u32 compat_uptr_t;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct compat_timespec {
|
|
|
|
compat_time_t tv_sec;
|
|
|
|
s32 tv_nsec;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct compat_timeval {
|
|
|
|
compat_time_t tv_sec;
|
|
|
|
s32 tv_usec;
|
|
|
|
};
|
|
|
|
|
|
|
|
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 06:16:40 +08:00
|
|
|
__compat_uid_t st_uid;
|
|
|
|
__compat_gid_t st_gid;
|
2005-04-17 06:20:36 +08: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 04:40:02 +08:00
|
|
|
int f_flags;
|
|
|
|
int f_spare[4];
|
2005-04-17 06:20:36 +08: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;
|
|
|
|
|
2012-10-05 08:15:31 +08:00
|
|
|
typedef union compat_sigval {
|
|
|
|
compat_int_t sival_int;
|
|
|
|
compat_uptr_t sival_ptr;
|
|
|
|
} compat_sigval_t;
|
|
|
|
|
|
|
|
typedef struct compat_siginfo {
|
|
|
|
int si_signo;
|
|
|
|
int si_errno;
|
|
|
|
int si_code;
|
|
|
|
|
|
|
|
union {
|
|
|
|
int _pad[128/sizeof(int) - 3];
|
|
|
|
|
|
|
|
/* kill() */
|
|
|
|
struct {
|
|
|
|
unsigned int _pid; /* sender's pid */
|
|
|
|
unsigned int _uid; /* sender's uid */
|
|
|
|
} _kill;
|
|
|
|
|
|
|
|
/* POSIX.1b timers */
|
|
|
|
struct {
|
|
|
|
compat_timer_t _tid; /* timer id */
|
|
|
|
int _overrun; /* overrun count */
|
|
|
|
compat_sigval_t _sigval; /* same as below */
|
|
|
|
int _sys_private; /* not to be passed to user */
|
|
|
|
int _overrun_incr; /* amount to add to overrun */
|
|
|
|
} _timer;
|
|
|
|
|
|
|
|
/* POSIX.1b signals */
|
|
|
|
struct {
|
|
|
|
unsigned int _pid; /* sender's pid */
|
|
|
|
unsigned int _uid; /* sender's uid */
|
|
|
|
compat_sigval_t _sigval;
|
|
|
|
} _rt;
|
|
|
|
|
|
|
|
/* SIGCHLD */
|
|
|
|
struct {
|
|
|
|
unsigned int _pid; /* which child */
|
|
|
|
unsigned int _uid; /* sender's uid */
|
|
|
|
int _status; /* exit code */
|
|
|
|
compat_clock_t _utime;
|
|
|
|
compat_clock_t _stime;
|
|
|
|
} _sigchld;
|
|
|
|
|
|
|
|
/* SIGCHLD (x32 version) */
|
|
|
|
struct {
|
|
|
|
unsigned int _pid; /* which child */
|
|
|
|
unsigned int _uid; /* sender's uid */
|
|
|
|
int _status; /* exit code */
|
|
|
|
compat_s64 _utime;
|
|
|
|
compat_s64 _stime;
|
|
|
|
} _sigchld_x32;
|
|
|
|
|
|
|
|
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
|
|
|
|
struct {
|
|
|
|
unsigned int _addr; /* faulting insn/memory ref. */
|
2016-06-09 01:25:33 +08:00
|
|
|
short int _addr_lsb; /* Valid LSB of the reported address. */
|
|
|
|
union {
|
|
|
|
/* used when si_code=SEGV_BNDERR */
|
|
|
|
struct {
|
|
|
|
compat_uptr_t _lower;
|
|
|
|
compat_uptr_t _upper;
|
|
|
|
} _addr_bnd;
|
|
|
|
/* used when si_code=SEGV_PKUERR */
|
|
|
|
compat_u32 _pkey;
|
|
|
|
};
|
2012-10-05 08:15:31 +08:00
|
|
|
} _sigfault;
|
|
|
|
|
|
|
|
/* SIGPOLL */
|
|
|
|
struct {
|
|
|
|
int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
|
|
|
|
int _fd;
|
|
|
|
} _sigpoll;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
unsigned int _call_addr; /* calling insn */
|
|
|
|
int _syscall; /* triggering system call number */
|
|
|
|
unsigned int _arch; /* AUDIT_ARCH_* of syscall */
|
|
|
|
} _sigsys;
|
|
|
|
} _sifields;
|
|
|
|
} compat_siginfo_t;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define COMPAT_OFF_T_MAX 0x7fffffff
|
|
|
|
|
|
|
|
struct compat_ipc64_perm {
|
|
|
|
compat_key_t key;
|
2005-09-07 06:16:40 +08:00
|
|
|
__compat_uid32_t uid;
|
|
|
|
__compat_gid32_t gid;
|
|
|
|
__compat_uid32_t cuid;
|
|
|
|
__compat_gid32_t cgid;
|
2005-04-17 06:20:36 +08: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;
|
|
|
|
compat_time_t sem_otime;
|
|
|
|
compat_ulong_t __unused1;
|
|
|
|
compat_time_t sem_ctime;
|
|
|
|
compat_ulong_t __unused2;
|
|
|
|
compat_ulong_t sem_nsems;
|
|
|
|
compat_ulong_t __unused3;
|
|
|
|
compat_ulong_t __unused4;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct compat_msqid64_ds {
|
|
|
|
struct compat_ipc64_perm msg_perm;
|
|
|
|
compat_time_t msg_stime;
|
|
|
|
compat_ulong_t __unused1;
|
|
|
|
compat_time_t msg_rtime;
|
|
|
|
compat_ulong_t __unused2;
|
|
|
|
compat_time_t msg_ctime;
|
|
|
|
compat_ulong_t __unused3;
|
|
|
|
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;
|
|
|
|
compat_time_t shm_atime;
|
|
|
|
compat_ulong_t __unused1;
|
|
|
|
compat_time_t shm_dtime;
|
|
|
|
compat_ulong_t __unused2;
|
|
|
|
compat_time_t shm_ctime;
|
|
|
|
compat_ulong_t __unused3;
|
|
|
|
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 02:35:02 +08:00
|
|
|
/*
|
|
|
|
* The type of struct elf_prstatus.pr_reg in compatible core dumps.
|
|
|
|
*/
|
2012-02-20 02:06:34 +08:00
|
|
|
typedef struct user_regs_struct compat_elf_gregset_t;
|
|
|
|
|
2016-09-05 21:33:06 +08: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 02:06:34 +08: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 02:13:30 +08:00
|
|
|
#ifdef CONFIG_X86_X32_ABI
|
2012-02-20 02:06:34 +08:00
|
|
|
#define COMPAT_USE_64BIT_TIME \
|
|
|
|
(!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
|
|
|
|
#endif
|
2007-10-20 02:35:02 +08:00
|
|
|
|
2005-04-17 06:20:36 +08: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 22:32:51 +08:00
|
|
|
* appropriately converted them already.
|
2005-04-17 06:20:36 +08: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 07:16:18 +08:00
|
|
|
static inline void __user *arch_compat_alloc_user_space(long len)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2012-02-20 02:06:34 +08: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 02:39:23 +08:00
|
|
|
sp = task_pt_regs(current)->sp - 128;
|
2012-02-20 02:06:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return (void __user *)round_down(sp - len, 16);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2016-04-18 21:43:43 +08:00
|
|
|
static inline bool in_x32_syscall(void)
|
2012-03-06 05:39:29 +08:00
|
|
|
{
|
2012-02-19 23:56:26 +08:00
|
|
|
#ifdef CONFIG_X86_X32_ABI
|
|
|
|
if (task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
return false;
|
2006-01-12 05:44:06 +08:00
|
|
|
}
|
|
|
|
|
2016-03-23 05:25:27 +08:00
|
|
|
static inline bool in_compat_syscall(void)
|
2012-03-06 05:39:29 +08:00
|
|
|
{
|
2016-04-18 21:43:43 +08:00
|
|
|
return in_ia32_syscall() || in_x32_syscall();
|
2012-03-06 05:39:29 +08:00
|
|
|
}
|
2016-03-23 05:25:27 +08:00
|
|
|
#define in_compat_syscall in_compat_syscall /* override the generic impl */
|
2012-03-06 05:39:29 +08:00
|
|
|
|
2008-10-23 13:26:29 +08:00
|
|
|
#endif /* _ASM_X86_COMPAT_H */
|