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
|
2014-03-29 16:50:47 +07:00
|
|
|
/*
|
2014-04-09 15:42:37 +07:00
|
|
|
* Compat system call wrappers.
|
2014-03-29 16:50:47 +07:00
|
|
|
*
|
|
|
|
* Copyright IBM Corp. 2014
|
|
|
|
*/
|
|
|
|
|
2014-02-27 15:52:01 +07:00
|
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <linux/compat.h>
|
2014-02-27 21:16:04 +07:00
|
|
|
#include "entry.h"
|
2014-02-27 15:52:01 +07:00
|
|
|
|
|
|
|
#define COMPAT_SYSCALL_WRAP1(name, ...) \
|
|
|
|
COMPAT_SYSCALL_WRAPx(1, _##name, __VA_ARGS__)
|
|
|
|
#define COMPAT_SYSCALL_WRAP2(name, ...) \
|
|
|
|
COMPAT_SYSCALL_WRAPx(2, _##name, __VA_ARGS__)
|
|
|
|
#define COMPAT_SYSCALL_WRAP3(name, ...) \
|
|
|
|
COMPAT_SYSCALL_WRAPx(3, _##name, __VA_ARGS__)
|
|
|
|
#define COMPAT_SYSCALL_WRAP4(name, ...) \
|
|
|
|
COMPAT_SYSCALL_WRAPx(4, _##name, __VA_ARGS__)
|
|
|
|
#define COMPAT_SYSCALL_WRAP5(name, ...) \
|
|
|
|
COMPAT_SYSCALL_WRAPx(5, _##name, __VA_ARGS__)
|
|
|
|
#define COMPAT_SYSCALL_WRAP6(name, ...) \
|
|
|
|
COMPAT_SYSCALL_WRAPx(6, _##name, __VA_ARGS__)
|
|
|
|
|
2014-03-03 16:06:12 +07:00
|
|
|
#define __SC_COMPAT_TYPE(t, a) \
|
|
|
|
__typeof(__builtin_choose_expr(sizeof(t) > 4, 0L, (t)0)) a
|
|
|
|
|
2014-03-01 19:45:03 +07:00
|
|
|
#define __SC_COMPAT_CAST(t, a) \
|
|
|
|
({ \
|
|
|
|
long __ReS = a; \
|
|
|
|
\
|
|
|
|
BUILD_BUG_ON((sizeof(t) > 4) && !__TYPE_IS_L(t) && \
|
|
|
|
!__TYPE_IS_UL(t) && !__TYPE_IS_PTR(t)); \
|
|
|
|
if (__TYPE_IS_L(t)) \
|
|
|
|
__ReS = (s32)a; \
|
|
|
|
if (__TYPE_IS_UL(t)) \
|
|
|
|
__ReS = (u32)a; \
|
|
|
|
if (__TYPE_IS_PTR(t)) \
|
|
|
|
__ReS = a & 0x7fffffff; \
|
|
|
|
(t)__ReS; \
|
|
|
|
})
|
|
|
|
|
2014-03-03 16:06:12 +07:00
|
|
|
/*
|
|
|
|
* The COMPAT_SYSCALL_WRAP macro generates system call wrappers to be used by
|
|
|
|
* compat tasks. These wrappers will only be used for system calls where only
|
|
|
|
* the system call arguments need sign or zero extension or zeroing of the upper
|
|
|
|
* 33 bits of pointers.
|
|
|
|
* Note: since the wrapper function will afterwards call a system call which
|
|
|
|
* again performs zero and sign extension for all system call arguments with
|
|
|
|
* a size of less than eight bytes, these compat wrappers only touch those
|
|
|
|
* system call arguments with a size of eight bytes ((unsigned) long and
|
|
|
|
* pointers). Zero and sign extension for e.g. int parameters will be done by
|
|
|
|
* the regular system call wrappers.
|
|
|
|
*/
|
2014-02-27 15:52:01 +07:00
|
|
|
#define COMPAT_SYSCALL_WRAPx(x, name, ...) \
|
2015-09-17 23:30:34 +07:00
|
|
|
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
|
|
|
|
asmlinkage long notrace compat_sys##name(__MAP(x,__SC_COMPAT_TYPE,__VA_ARGS__));\
|
|
|
|
asmlinkage long notrace compat_sys##name(__MAP(x,__SC_COMPAT_TYPE,__VA_ARGS__)) \
|
|
|
|
{ \
|
|
|
|
return sys##name(__MAP(x,__SC_COMPAT_CAST,__VA_ARGS__)); \
|
|
|
|
}
|
2014-02-27 15:52:01 +07:00
|
|
|
|
|
|
|
COMPAT_SYSCALL_WRAP2(creat, const char __user *, pathname, umode_t, mode);
|
|
|
|
COMPAT_SYSCALL_WRAP2(link, const char __user *, oldname, const char __user *, newname);
|
|
|
|
COMPAT_SYSCALL_WRAP1(unlink, const char __user *, pathname);
|
|
|
|
COMPAT_SYSCALL_WRAP1(chdir, const char __user *, filename);
|
|
|
|
COMPAT_SYSCALL_WRAP3(mknod, const char __user *, filename, umode_t, mode, unsigned, dev);
|
|
|
|
COMPAT_SYSCALL_WRAP2(chmod, const char __user *, filename, umode_t, mode);
|
|
|
|
COMPAT_SYSCALL_WRAP1(oldumount, char __user *, name);
|
|
|
|
COMPAT_SYSCALL_WRAP2(access, const char __user *, filename, int, mode);
|
2014-02-27 19:42:10 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(rename, const char __user *, oldname, const char __user *, newname);
|
|
|
|
COMPAT_SYSCALL_WRAP2(mkdir, const char __user *, pathname, umode_t, mode);
|
|
|
|
COMPAT_SYSCALL_WRAP1(rmdir, const char __user *, pathname);
|
|
|
|
COMPAT_SYSCALL_WRAP1(pipe, int __user *, fildes);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP1(brk, unsigned long, brk);
|
2014-02-27 19:42:10 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(signal, int, sig, __sighandler_t, handler);
|
|
|
|
COMPAT_SYSCALL_WRAP1(acct, const char __user *, name);
|
|
|
|
COMPAT_SYSCALL_WRAP2(umount, char __user *, name, int, flags);
|
2014-02-27 20:04:43 +07:00
|
|
|
COMPAT_SYSCALL_WRAP1(chroot, const char __user *, filename);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(sigsuspend, int, unused1, int, unused2, old_sigset_t, mask);
|
2014-02-27 20:04:43 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(sethostname, char __user *, name, int, len);
|
|
|
|
COMPAT_SYSCALL_WRAP2(symlink, const char __user *, old, const char __user *, new);
|
|
|
|
COMPAT_SYSCALL_WRAP3(readlink, const char __user *, path, char __user *, buf, int, bufsiz);
|
|
|
|
COMPAT_SYSCALL_WRAP1(uselib, const char __user *, library);
|
|
|
|
COMPAT_SYSCALL_WRAP2(swapon, const char __user *, specialfile, int, swap_flags);
|
2014-02-27 20:20:53 +07:00
|
|
|
COMPAT_SYSCALL_WRAP4(reboot, int, magic1, int, magic2, unsigned int, cmd, void __user *, arg);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(munmap, unsigned long, addr, size_t, len);
|
2014-02-27 20:20:53 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(syslog, int, type, char __user *, buf, int, len);
|
|
|
|
COMPAT_SYSCALL_WRAP1(swapoff, const char __user *, specialfile);
|
|
|
|
COMPAT_SYSCALL_WRAP2(setdomainname, char __user *, name, int, len);
|
|
|
|
COMPAT_SYSCALL_WRAP1(newuname, struct new_utsname __user *, name);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(mprotect, unsigned long, start, size_t, len, unsigned long, prot);
|
|
|
|
COMPAT_SYSCALL_WRAP3(init_module, void __user *, umod, unsigned long, len, const char __user *, uargs);
|
2014-02-27 21:16:04 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(delete_module, const char __user *, name_user, unsigned int, flags);
|
|
|
|
COMPAT_SYSCALL_WRAP4(quotactl, unsigned int, cmd, const char __user *, special, qid_t, id, void __user *, addr);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(bdflush, int, func, long, data);
|
|
|
|
COMPAT_SYSCALL_WRAP3(sysfs, int, option, unsigned long, arg1, unsigned long, arg2);
|
|
|
|
COMPAT_SYSCALL_WRAP5(llseek, unsigned int, fd, unsigned long, high, unsigned long, low, loff_t __user *, result, unsigned int, whence);
|
|
|
|
COMPAT_SYSCALL_WRAP3(msync, unsigned long, start, size_t, len, int, flags);
|
|
|
|
COMPAT_SYSCALL_WRAP2(mlock, unsigned long, start, size_t, len);
|
|
|
|
COMPAT_SYSCALL_WRAP2(munlock, unsigned long, start, size_t, len);
|
|
|
|
COMPAT_SYSCALL_WRAP2(sched_setparam, pid_t, pid, struct sched_param __user *, param);
|
|
|
|
COMPAT_SYSCALL_WRAP2(sched_getparam, pid_t, pid, struct sched_param __user *, param);
|
|
|
|
COMPAT_SYSCALL_WRAP3(sched_setscheduler, pid_t, pid, int, policy, struct sched_param __user *, param);
|
|
|
|
COMPAT_SYSCALL_WRAP5(mremap, unsigned long, addr, unsigned long, old_len, unsigned long, new_len, unsigned long, flags, unsigned long, new_addr);
|
2014-02-27 22:49:10 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(poll, struct pollfd __user *, ufds, unsigned int, nfds, int, timeout);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, unsigned long, arg4, unsigned long, arg5);
|
|
|
|
COMPAT_SYSCALL_WRAP2(getcwd, char __user *, buf, unsigned long, size);
|
2014-02-27 22:49:10 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(capget, cap_user_header_t, header, cap_user_data_t, dataptr);
|
|
|
|
COMPAT_SYSCALL_WRAP2(capset, cap_user_header_t, header, const cap_user_data_t, data);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(lchown, const char __user *, filename, uid_t, user, gid_t, group);
|
|
|
|
COMPAT_SYSCALL_WRAP2(getgroups, int, gidsetsize, gid_t __user *, grouplist);
|
|
|
|
COMPAT_SYSCALL_WRAP2(setgroups, int, gidsetsize, gid_t __user *, grouplist);
|
|
|
|
COMPAT_SYSCALL_WRAP3(getresuid, uid_t __user *, ruid, uid_t __user *, euid, uid_t __user *, suid);
|
|
|
|
COMPAT_SYSCALL_WRAP3(getresgid, gid_t __user *, rgid, gid_t __user *, egid, gid_t __user *, sgid);
|
|
|
|
COMPAT_SYSCALL_WRAP3(chown, const char __user *, filename, uid_t, user, gid_t, group);
|
2014-02-28 16:31:37 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(pivot_root, const char __user *, new_root, const char __user *, put_old);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(mincore, unsigned long, start, size_t, len, unsigned char __user *, vec);
|
|
|
|
COMPAT_SYSCALL_WRAP3(madvise, unsigned long, start, size_t, len, int, behavior);
|
|
|
|
COMPAT_SYSCALL_WRAP5(setxattr, const char __user *, path, const char __user *, name, const void __user *, value, size_t, size, int, flags);
|
|
|
|
COMPAT_SYSCALL_WRAP5(lsetxattr, const char __user *, path, const char __user *, name, const void __user *, value, size_t, size, int, flags);
|
|
|
|
COMPAT_SYSCALL_WRAP5(fsetxattr, int, fd, const char __user *, name, const void __user *, value, size_t, size, int, flags);
|
2014-02-28 18:59:44 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(getdents64, unsigned int, fd, struct linux_dirent64 __user *, dirent, unsigned int, count);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP4(getxattr, const char __user *, path, const char __user *, name, void __user *, value, size_t, size);
|
|
|
|
COMPAT_SYSCALL_WRAP4(lgetxattr, const char __user *, path, const char __user *, name, void __user *, value, size_t, size);
|
|
|
|
COMPAT_SYSCALL_WRAP4(fgetxattr, int, fd, const char __user *, name, void __user *, value, size_t, size);
|
|
|
|
COMPAT_SYSCALL_WRAP3(listxattr, const char __user *, path, char __user *, list, size_t, size);
|
|
|
|
COMPAT_SYSCALL_WRAP3(llistxattr, const char __user *, path, char __user *, list, size_t, size);
|
|
|
|
COMPAT_SYSCALL_WRAP3(flistxattr, int, fd, char __user *, list, size_t, size);
|
2014-02-28 18:59:44 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(removexattr, const char __user *, path, const char __user *, name);
|
|
|
|
COMPAT_SYSCALL_WRAP2(lremovexattr, const char __user *, path, const char __user *, name);
|
|
|
|
COMPAT_SYSCALL_WRAP2(fremovexattr, int, fd, const char __user *, name);
|
2014-02-28 19:22:47 +07:00
|
|
|
COMPAT_SYSCALL_WRAP1(set_tid_address, int __user *, tidptr);
|
|
|
|
COMPAT_SYSCALL_WRAP4(epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event __user *, event);
|
|
|
|
COMPAT_SYSCALL_WRAP4(epoll_wait, int, epfd, struct epoll_event __user *, events, int, maxevents, int, timeout);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP1(io_destroy, aio_context_t, ctx);
|
|
|
|
COMPAT_SYSCALL_WRAP3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb, struct io_event __user *, result);
|
2014-02-28 19:22:47 +07:00
|
|
|
COMPAT_SYSCALL_WRAP1(mq_unlink, const char __user *, name);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(add_key, const char __user *, tp, const char __user *, dsc, const void __user *, pld, size_t, len, key_serial_t, id);
|
2014-02-28 19:46:09 +07:00
|
|
|
COMPAT_SYSCALL_WRAP4(request_key, const char __user *, tp, const char __user *, dsc, const char __user *, info, key_serial_t, id);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(remap_file_pages, unsigned long, start, unsigned long, size, unsigned long, prot, unsigned long, pgoff, unsigned long, flags);
|
2014-02-28 19:46:09 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(inotify_add_watch, int, fd, const char __user *, path, u32, mask);
|
|
|
|
COMPAT_SYSCALL_WRAP3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode);
|
|
|
|
COMPAT_SYSCALL_WRAP4(mknodat, int, dfd, const char __user *, filename, umode_t, mode, unsigned, dev);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(fchownat, int, dfd, const char __user *, filename, uid_t, user, gid_t, group, int, flag);
|
2014-02-28 21:33:00 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(unlinkat, int, dfd, const char __user *, pathname, int, flag);
|
|
|
|
COMPAT_SYSCALL_WRAP4(renameat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname);
|
|
|
|
COMPAT_SYSCALL_WRAP5(linkat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname, int, flags);
|
|
|
|
COMPAT_SYSCALL_WRAP3(symlinkat, const char __user *, oldname, int, newdfd, const char __user *, newname);
|
|
|
|
COMPAT_SYSCALL_WRAP4(readlinkat, int, dfd, const char __user *, path, char __user *, buf, int, bufsiz);
|
|
|
|
COMPAT_SYSCALL_WRAP3(fchmodat, int, dfd, const char __user *, filename, umode_t, mode);
|
|
|
|
COMPAT_SYSCALL_WRAP3(faccessat, int, dfd, const char __user *, filename, int, mode);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP1(unshare, unsigned long, unshare_flags);
|
|
|
|
COMPAT_SYSCALL_WRAP6(splice, int, fd_in, loff_t __user *, off_in, int, fd_out, loff_t __user *, off_out, size_t, len, unsigned int, flags);
|
|
|
|
COMPAT_SYSCALL_WRAP4(tee, int, fdin, int, fdout, size_t, len, unsigned int, flags);
|
2014-03-01 17:52:48 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(getcpu, unsigned __user *, cpu, unsigned __user *, node, struct getcpu_cache __user *, cache);
|
|
|
|
COMPAT_SYSCALL_WRAP2(pipe2, int __user *, fildes, int, flags);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(perf_event_open, struct perf_event_attr __user *, attr_uptr, pid_t, pid, int, cpu, int, group_fd, unsigned long, flags);
|
clone: support passing tls argument via C rather than pt_regs magic
clone has some of the quirkiest syscall handling in the kernel, with a
pile of special cases, historical curiosities, and architecture-specific
calling conventions. In particular, clone with CLONE_SETTLS accepts a
parameter "tls" that the C entry point completely ignores and some
assembly entry points overwrite; instead, the low-level arch-specific
code pulls the tls parameter out of the arch-specific register captured
as part of pt_regs on entry to the kernel. That's a massive hack, and
it makes the arch-specific code only work when called via the specific
existing syscall entry points; because of this hack, any new clone-like
system call would have to accept an identical tls argument in exactly
the same arch-specific position, rather than providing a unified system
call entry point across architectures.
The first patch allows architectures to handle the tls argument via
normal C parameter passing, if they opt in by selecting
HAVE_COPY_THREAD_TLS. The second patch makes 32-bit and 64-bit x86 opt
into this.
These two patches came out of the clone4 series, which isn't ready for
this merge window, but these first two cleanup patches were entirely
uncontroversial and have acks. I'd like to go ahead and submit these
two so that other architectures can begin building on top of this and
opting into HAVE_COPY_THREAD_TLS. However, I'm also happy to wait and
send these through the next merge window (along with v3 of clone4) if
anyone would prefer that.
This patch (of 2):
clone with CLONE_SETTLS accepts an argument to set the thread-local
storage area for the new thread. sys_clone declares an int argument
tls_val in the appropriate point in the argument list (based on the
various CLONE_BACKWARDS variants), but doesn't actually use or pass along
that argument. Instead, sys_clone calls do_fork, which calls
copy_process, which calls the arch-specific copy_thread, and copy_thread
pulls the corresponding syscall argument out of the pt_regs captured at
kernel entry (knowing what argument of clone that architecture passes tls
in).
Apart from being awful and inscrutable, that also only works because only
one code path into copy_thread can pass the CLONE_SETTLS flag, and that
code path comes from sys_clone with its architecture-specific
argument-passing order. This prevents introducing a new version of the
clone system call without propagating the same architecture-specific
position of the tls argument.
However, there's no reason to pull the argument out of pt_regs when
sys_clone could just pass it down via C function call arguments.
Introduce a new CONFIG_HAVE_COPY_THREAD_TLS for architectures to opt into,
and a new copy_thread_tls that accepts the tls parameter as an additional
unsigned long (syscall-argument-sized) argument. Change sys_clone's tls
argument to an unsigned long (which does not change the ABI), and pass
that down to copy_thread_tls.
Architectures that don't opt into copy_thread_tls will continue to ignore
the C argument to sys_clone in favor of the pt_regs captured at kernel
entry, and thus will be unable to introduce new versions of the clone
syscall.
Patch co-authored by Josh Triplett and Thiago Macieira.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Thiago Macieira <thiago.macieira@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-26 05:01:19 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(clone, unsigned long, newsp, unsigned long, clone_flags, int __user *, parent_tidptr, int __user *, child_tidptr, unsigned long, tls);
|
2014-03-01 18:18:46 +07:00
|
|
|
COMPAT_SYSCALL_WRAP4(prlimit64, pid_t, pid, unsigned int, resource, const struct rlimit64 __user *, new_rlim, struct rlimit64 __user *, old_rlim);
|
|
|
|
COMPAT_SYSCALL_WRAP5(name_to_handle_at, int, dfd, const char __user *, name, struct file_handle __user *, handle, int __user *, mnt_id, int, flag);
|
2014-03-01 19:45:03 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(kcmp, pid_t, pid1, pid_t, pid2, int, type, unsigned long, idx1, unsigned long, idx2);
|
2014-03-01 18:18:46 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(finit_module, int, fd, const char __user *, uargs, int, flags);
|
|
|
|
COMPAT_SYSCALL_WRAP3(sched_setattr, pid_t, pid, struct sched_attr __user *, attr, unsigned int, flags);
|
|
|
|
COMPAT_SYSCALL_WRAP4(sched_getattr, pid_t, pid, struct sched_attr __user *, attr, unsigned int, size, unsigned int, flags);
|
2014-04-08 18:13:38 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(renameat2, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname, unsigned int, flags);
|
2014-08-08 14:39:14 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(seccomp, unsigned int, op, unsigned int, flags, const char __user *, uargs)
|
|
|
|
COMPAT_SYSCALL_WRAP3(getrandom, char __user *, buf, size_t, count, unsigned int, flags)
|
2014-08-11 19:50:37 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(memfd_create, const char __user *, uname, unsigned int, flags)
|
2014-10-09 17:58:25 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(bpf, int, cmd, union bpf_attr *, attr, unsigned int, size);
|
2014-11-14 20:27:58 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(s390_pci_mmio_write, const unsigned long, mmio_addr, const void __user *, user_buffer, const size_t, length);
|
|
|
|
COMPAT_SYSCALL_WRAP3(s390_pci_mmio_read, const unsigned long, mmio_addr, void __user *, user_buffer, const size_t, length);
|
2015-09-17 23:30:36 +07:00
|
|
|
COMPAT_SYSCALL_WRAP4(socketpair, int, family, int, type, int, protocol, int __user *, usockvec);
|
|
|
|
COMPAT_SYSCALL_WRAP3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen);
|
|
|
|
COMPAT_SYSCALL_WRAP3(connect, int, fd, struct sockaddr __user *, uservaddr, int, addrlen);
|
|
|
|
COMPAT_SYSCALL_WRAP4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr, int __user *, upeer_addrlen, int, flags);
|
|
|
|
COMPAT_SYSCALL_WRAP3(getsockname, int, fd, struct sockaddr __user *, usockaddr, int __user *, usockaddr_len);
|
|
|
|
COMPAT_SYSCALL_WRAP3(getpeername, int, fd, struct sockaddr __user *, usockaddr, int __user *, usockaddr_len);
|
|
|
|
COMPAT_SYSCALL_WRAP6(sendto, int, fd, void __user *, buff, size_t, len, unsigned int, flags, struct sockaddr __user *, addr, int, addr_len);
|
2015-11-16 18:31:33 +07:00
|
|
|
COMPAT_SYSCALL_WRAP3(mlock2, unsigned long, start, size_t, len, int, flags);
|
2016-01-19 16:19:02 +07:00
|
|
|
COMPAT_SYSCALL_WRAP6(copy_file_range, int, fd_in, loff_t __user *, off_in, int, fd_out, loff_t __user *, off_out, size_t, len, unsigned int, flags);
|
2016-01-26 20:10:34 +07:00
|
|
|
COMPAT_SYSCALL_WRAP2(s390_guarded_storage, int, command, struct gs_cb *, gs_cb);
|
2017-03-06 15:57:17 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(statx, int, dfd, const char __user *, path, unsigned, flags, unsigned, mask, struct statx __user *, buffer);
|
2017-09-29 17:41:52 +07:00
|
|
|
COMPAT_SYSCALL_WRAP4(s390_sthyi, unsigned long, code, void __user *, info, u64 __user *, rc, unsigned long, flags);
|
2017-06-19 15:45:33 +07:00
|
|
|
COMPAT_SYSCALL_WRAP5(kexec_file_load, int, kernel_fd, int, initrd_fd, unsigned long, cmdline_len, const char __user *, cmdline_ptr, unsigned long, flags)
|