diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-17 11:58:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-17 11:58:04 -0400 |
commit | 57a8ec387e1441ea5e1232bc0749fb99a8cba7e7 (patch) | |
tree | b5fb03fc6bc5754de8b5b1f8b0e4f36d67c8315c /kernel/ptrace.c | |
parent | 0a8ad0ffa4d80a544f6cbff703bf6394339afcdf (diff) | |
parent | 43e11fa2d1d3b6e35629fa556eb7d571edba2010 (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton:
"VM:
- z3fold fixes and enhancements by Henry Burns and Vitaly Wool
- more accurate reclaimed slab caches calculations by Yafang Shao
- fix MAP_UNINITIALIZED UAPI symbol to not depend on config, by
Christoph Hellwig
- !CONFIG_MMU fixes by Christoph Hellwig
- new novmcoredd parameter to omit device dumps from vmcore, by
Kairui Song
- new test_meminit module for testing heap and pagealloc
initialization, by Alexander Potapenko
- ioremap improvements for huge mappings, by Anshuman Khandual
- generalize kprobe page fault handling, by Anshuman Khandual
- device-dax hotplug fixes and improvements, by Pavel Tatashin
- enable synchronous DAX fault on powerpc, by Aneesh Kumar K.V
- add pte_devmap() support for arm64, by Robin Murphy
- unify locked_vm accounting with a helper, by Daniel Jordan
- several misc fixes
core/lib:
- new typeof_member() macro including some users, by Alexey Dobriyan
- make BIT() and GENMASK() available in asm, by Masahiro Yamada
- changed LIST_POISON2 on x86_64 to 0xdead000000000122 for better
code generation, by Alexey Dobriyan
- rbtree code size optimizations, by Michel Lespinasse
- convert struct pid count to refcount_t, by Joel Fernandes
get_maintainer.pl:
- add --no-moderated switch to skip moderated ML's, by Joe Perches
misc:
- ptrace PTRACE_GET_SYSCALL_INFO interface
- coda updates
- gdb scripts, various"
[ Using merge message suggestion from Vlastimil Babka, with some editing - Linus ]
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (100 commits)
fs/select.c: use struct_size() in kmalloc()
mm: add account_locked_vm utility function
arm64: mm: implement pte_devmap support
mm: introduce ARCH_HAS_PTE_DEVMAP
mm: clean up is_device_*_page() definitions
mm/mmap: move common defines to mman-common.h
mm: move MAP_SYNC to asm-generic/mman-common.h
device-dax: "Hotremove" persistent memory that is used like normal RAM
mm/hotplug: make remove_memory() interface usable
device-dax: fix memory and resource leak if hotplug fails
include/linux/lz4.h: fix spelling and copy-paste errors in documentation
ipc/mqueue.c: only perform resource calculation if user valid
include/asm-generic/bug.h: fix "cut here" for WARN_ON for __WARN_TAINT architectures
scripts/gdb: add helpers to find and list devices
scripts/gdb: add lx-genpd-summary command
drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl
kernel/pid.c: convert struct pid count to refcount_t
drivers/rapidio/devices/rio_mport_cdev.c: NUL terminate some strings
select: shift restore_saved_sigmask_unless() into poll_select_copy_remaining()
select: change do_poll() to return -ERESTARTNOHAND rather than -EINTR
...
Diffstat (limited to 'kernel/ptrace.c')
-rw-r--r-- | kernel/ptrace.c | 101 |
1 files changed, 100 insertions, 1 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 83a531cea2f3..cb9ddcc08119 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <linux/compat.h> | 32 | #include <linux/compat.h> |
33 | #include <linux/sched/signal.h> | 33 | #include <linux/sched/signal.h> |
34 | 34 | ||
35 | #include <asm/syscall.h> /* for syscall_get_* */ | ||
36 | |||
35 | /* | 37 | /* |
36 | * Access another process' address space via ptrace. | 38 | * Access another process' address space via ptrace. |
37 | * Source/target buffer must be kernel space, | 39 | * Source/target buffer must be kernel space, |
@@ -897,7 +899,100 @@ static int ptrace_regset(struct task_struct *task, int req, unsigned int type, | |||
897 | * to ensure no machine forgets it. | 899 | * to ensure no machine forgets it. |
898 | */ | 900 | */ |
899 | EXPORT_SYMBOL_GPL(task_user_regset_view); | 901 | EXPORT_SYMBOL_GPL(task_user_regset_view); |
900 | #endif | 902 | |
903 | static unsigned long | ||
904 | ptrace_get_syscall_info_entry(struct task_struct *child, struct pt_regs *regs, | ||
905 | struct ptrace_syscall_info *info) | ||
906 | { | ||
907 | unsigned long args[ARRAY_SIZE(info->entry.args)]; | ||
908 | int i; | ||
909 | |||
910 | info->op = PTRACE_SYSCALL_INFO_ENTRY; | ||
911 | info->entry.nr = syscall_get_nr(child, regs); | ||
912 | syscall_get_arguments(child, regs, args); | ||
913 | for (i = 0; i < ARRAY_SIZE(args); i++) | ||
914 | info->entry.args[i] = args[i]; | ||
915 | |||
916 | /* args is the last field in struct ptrace_syscall_info.entry */ | ||
917 | return offsetofend(struct ptrace_syscall_info, entry.args); | ||
918 | } | ||
919 | |||
920 | static unsigned long | ||
921 | ptrace_get_syscall_info_seccomp(struct task_struct *child, struct pt_regs *regs, | ||
922 | struct ptrace_syscall_info *info) | ||
923 | { | ||
924 | /* | ||
925 | * As struct ptrace_syscall_info.entry is currently a subset | ||
926 | * of struct ptrace_syscall_info.seccomp, it makes sense to | ||
927 | * initialize that subset using ptrace_get_syscall_info_entry(). | ||
928 | * This can be reconsidered in the future if these structures | ||
929 | * diverge significantly enough. | ||
930 | */ | ||
931 | ptrace_get_syscall_info_entry(child, regs, info); | ||
932 | info->op = PTRACE_SYSCALL_INFO_SECCOMP; | ||
933 | info->seccomp.ret_data = child->ptrace_message; | ||
934 | |||
935 | /* ret_data is the last field in struct ptrace_syscall_info.seccomp */ | ||
936 | return offsetofend(struct ptrace_syscall_info, seccomp.ret_data); | ||
937 | } | ||
938 | |||
939 | static unsigned long | ||
940 | ptrace_get_syscall_info_exit(struct task_struct *child, struct pt_regs *regs, | ||
941 | struct ptrace_syscall_info *info) | ||
942 | { | ||
943 | info->op = PTRACE_SYSCALL_INFO_EXIT; | ||
944 | info->exit.rval = syscall_get_error(child, regs); | ||
945 | info->exit.is_error = !!info->exit.rval; | ||
946 | if (!info->exit.is_error) | ||
947 | info->exit.rval = syscall_get_return_value(child, regs); | ||
948 | |||
949 | /* is_error is the last field in struct ptrace_syscall_info.exit */ | ||
950 | return offsetofend(struct ptrace_syscall_info, exit.is_error); | ||
951 | } | ||
952 | |||
953 | static int | ||
954 | ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size, | ||
955 | void __user *datavp) | ||
956 | { | ||
957 | struct pt_regs *regs = task_pt_regs(child); | ||
958 | struct ptrace_syscall_info info = { | ||
959 | .op = PTRACE_SYSCALL_INFO_NONE, | ||
960 | .arch = syscall_get_arch(child), | ||
961 | .instruction_pointer = instruction_pointer(regs), | ||
962 | .stack_pointer = user_stack_pointer(regs), | ||
963 | }; | ||
964 | unsigned long actual_size = offsetof(struct ptrace_syscall_info, entry); | ||
965 | unsigned long write_size; | ||
966 | |||
967 | /* | ||
968 | * This does not need lock_task_sighand() to access | ||
969 | * child->last_siginfo because ptrace_freeze_traced() | ||
970 | * called earlier by ptrace_check_attach() ensures that | ||
971 | * the tracee cannot go away and clear its last_siginfo. | ||
972 | */ | ||
973 | switch (child->last_siginfo ? child->last_siginfo->si_code : 0) { | ||
974 | case SIGTRAP | 0x80: | ||
975 | switch (child->ptrace_message) { | ||
976 | case PTRACE_EVENTMSG_SYSCALL_ENTRY: | ||
977 | actual_size = ptrace_get_syscall_info_entry(child, regs, | ||
978 | &info); | ||
979 | break; | ||
980 | case PTRACE_EVENTMSG_SYSCALL_EXIT: | ||
981 | actual_size = ptrace_get_syscall_info_exit(child, regs, | ||
982 | &info); | ||
983 | break; | ||
984 | } | ||
985 | break; | ||
986 | case SIGTRAP | (PTRACE_EVENT_SECCOMP << 8): | ||
987 | actual_size = ptrace_get_syscall_info_seccomp(child, regs, | ||
988 | &info); | ||
989 | break; | ||
990 | } | ||
991 | |||
992 | write_size = min(actual_size, user_size); | ||
993 | return copy_to_user(datavp, &info, write_size) ? -EFAULT : actual_size; | ||
994 | } | ||
995 | #endif /* CONFIG_HAVE_ARCH_TRACEHOOK */ | ||
901 | 996 | ||
902 | int ptrace_request(struct task_struct *child, long request, | 997 | int ptrace_request(struct task_struct *child, long request, |
903 | unsigned long addr, unsigned long data) | 998 | unsigned long addr, unsigned long data) |
@@ -1114,6 +1209,10 @@ int ptrace_request(struct task_struct *child, long request, | |||
1114 | ret = __put_user(kiov.iov_len, &uiov->iov_len); | 1209 | ret = __put_user(kiov.iov_len, &uiov->iov_len); |
1115 | break; | 1210 | break; |
1116 | } | 1211 | } |
1212 | |||
1213 | case PTRACE_GET_SYSCALL_INFO: | ||
1214 | ret = ptrace_get_syscall_info(child, addr, datavp); | ||
1215 | break; | ||
1117 | #endif | 1216 | #endif |
1118 | 1217 | ||
1119 | case PTRACE_SECCOMP_GET_FILTER: | 1218 | case PTRACE_SECCOMP_GET_FILTER: |