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 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Kernel support for the ptrace() and syscall tracing interfaces.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000 Hewlett-Packard Co, Linuxcare Inc.
|
|
|
|
* Copyright (C) 2000 Matthew Wilcox <matthew@wil.cx>
|
|
|
|
* Copyright (C) 2000 David Huggins-Daines <dhd@debian.org>
|
2016-04-01 20:40:53 +00:00
|
|
|
* Copyright (C) 2008-2016 Helge Deller <deller@gmx.de>
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/smp.h>
|
2016-04-01 20:40:53 +00:00
|
|
|
#include <linux/elf.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/ptrace.h>
|
2009-04-27 03:53:34 +00:00
|
|
|
#include <linux/tracehook.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/user.h>
|
|
|
|
#include <linux/personality.h>
|
2016-04-01 20:40:53 +00:00
|
|
|
#include <linux/regset.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/security.h>
|
2014-09-21 19:01:15 +00:00
|
|
|
#include <linux/seccomp.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/compat.h>
|
2005-05-01 15:59:14 +00:00
|
|
|
#include <linux/signal.h>
|
2013-10-15 17:25:46 +00:00
|
|
|
#include <linux/audit.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/processor.h>
|
2005-09-09 18:57:26 +00:00
|
|
|
#include <asm/asm-offsets.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* PSW bits we allow the debugger to modify */
|
2012-12-28 23:18:01 +00:00
|
|
|
#define USER_PSW_BITS (PSW_N | PSW_B | PSW_V | PSW_CB)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-04-13 20:44:54 +00:00
|
|
|
#define CREATE_TRACE_POINTS
|
|
|
|
#include <trace/events/syscalls.h>
|
|
|
|
|
2016-04-01 20:40:53 +00:00
|
|
|
/*
|
|
|
|
* These are our native regset flavors.
|
|
|
|
*/
|
|
|
|
enum parisc_regset {
|
|
|
|
REGSET_GENERAL,
|
|
|
|
REGSET_FP
|
|
|
|
};
|
|
|
|
|
2008-10-17 18:48:36 +00:00
|
|
|
/*
|
|
|
|
* Called by kernel/ptrace.c when detaching..
|
|
|
|
*
|
|
|
|
* Make sure single step bits etc are not set.
|
|
|
|
*/
|
|
|
|
void ptrace_disable(struct task_struct *task)
|
|
|
|
{
|
2009-09-28 03:03:02 +00:00
|
|
|
clear_tsk_thread_flag(task, TIF_SINGLESTEP);
|
|
|
|
clear_tsk_thread_flag(task, TIF_BLOCKSTEP);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-17 18:48:36 +00:00
|
|
|
/* make sure the trap bits are not set */
|
|
|
|
pa_psw(task)->r = 0;
|
|
|
|
pa_psw(task)->t = 0;
|
|
|
|
pa_psw(task)->h = 0;
|
|
|
|
pa_psw(task)->l = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following functions are called by ptrace_resume() when
|
|
|
|
* enabling or disabling single/block tracing.
|
|
|
|
*/
|
|
|
|
void user_disable_single_step(struct task_struct *task)
|
|
|
|
{
|
|
|
|
ptrace_disable(task);
|
|
|
|
}
|
|
|
|
|
|
|
|
void user_enable_single_step(struct task_struct *task)
|
|
|
|
{
|
2009-09-28 03:03:02 +00:00
|
|
|
clear_tsk_thread_flag(task, TIF_BLOCKSTEP);
|
|
|
|
set_tsk_thread_flag(task, TIF_SINGLESTEP);
|
2008-10-17 18:48:36 +00:00
|
|
|
|
|
|
|
if (pa_psw(task)->n) {
|
|
|
|
/* Nullified, just crank over the queue. */
|
|
|
|
task_regs(task)->iaoq[0] = task_regs(task)->iaoq[1];
|
|
|
|
task_regs(task)->iasq[0] = task_regs(task)->iasq[1];
|
|
|
|
task_regs(task)->iaoq[1] = task_regs(task)->iaoq[0] + 4;
|
|
|
|
pa_psw(task)->n = 0;
|
|
|
|
pa_psw(task)->x = 0;
|
|
|
|
pa_psw(task)->y = 0;
|
|
|
|
pa_psw(task)->z = 0;
|
|
|
|
pa_psw(task)->b = 0;
|
|
|
|
ptrace_disable(task);
|
|
|
|
/* Don't wake up the task, but let the
|
|
|
|
parent know something happened. */
|
2018-04-20 00:14:26 +00:00
|
|
|
force_sig_fault(SIGTRAP, TRAP_TRACE,
|
|
|
|
(void __user *) (task_regs(task)->iaoq[0] & ~3),
|
|
|
|
task);
|
2008-10-17 18:48:36 +00:00
|
|
|
/* notify_parent(task, SIGCHLD); */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable recovery counter traps. The recovery counter
|
|
|
|
* itself will be set to zero on a task switch. If the
|
|
|
|
* task is suspended on a syscall then the syscall return
|
|
|
|
* path will overwrite the recovery counter with a suitable
|
|
|
|
* value such that it traps once back in user space. We
|
|
|
|
* disable interrupts in the tasks PSW here also, to avoid
|
|
|
|
* interrupts while the recovery counter is decrementing.
|
|
|
|
*/
|
|
|
|
pa_psw(task)->r = 1;
|
|
|
|
pa_psw(task)->t = 0;
|
|
|
|
pa_psw(task)->h = 0;
|
|
|
|
pa_psw(task)->l = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void user_enable_block_step(struct task_struct *task)
|
|
|
|
{
|
2009-09-28 03:03:02 +00:00
|
|
|
clear_tsk_thread_flag(task, TIF_SINGLESTEP);
|
|
|
|
set_tsk_thread_flag(task, TIF_BLOCKSTEP);
|
2008-10-17 18:48:36 +00:00
|
|
|
|
|
|
|
/* Enable taken branch trap. */
|
|
|
|
pa_psw(task)->r = 0;
|
|
|
|
pa_psw(task)->t = 1;
|
|
|
|
pa_psw(task)->h = 0;
|
|
|
|
pa_psw(task)->l = 0;
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:33:47 +00:00
|
|
|
long arch_ptrace(struct task_struct *child, long request,
|
|
|
|
unsigned long addr, unsigned long data)
|
2008-10-17 18:48:36 +00:00
|
|
|
{
|
2016-04-01 20:40:53 +00:00
|
|
|
unsigned long __user *datap = (unsigned long __user *)data;
|
2008-10-17 18:48:36 +00:00
|
|
|
unsigned long tmp;
|
|
|
|
long ret = -EIO;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-17 18:48:36 +00:00
|
|
|
switch (request) {
|
|
|
|
|
|
|
|
/* Read the word at location addr in the USER area. For ptraced
|
|
|
|
processes, the kernel saves all regs on a syscall. */
|
|
|
|
case PTRACE_PEEKUSR:
|
2010-10-27 22:33:47 +00:00
|
|
|
if ((addr & (sizeof(unsigned long)-1)) ||
|
|
|
|
addr >= sizeof(struct pt_regs))
|
2008-10-17 18:48:36 +00:00
|
|
|
break;
|
|
|
|
tmp = *(unsigned long *) ((char *) task_regs(child) + addr);
|
2016-04-01 20:40:53 +00:00
|
|
|
ret = put_user(tmp, datap);
|
2008-10-17 18:48:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Write the word at location addr in the USER area. This will need
|
|
|
|
to change when the kernel no longer saves all regs on a syscall.
|
|
|
|
FIXME. There is a problem at the moment in that r3-r18 are only
|
|
|
|
saved if the process is ptraced on syscall entry, and even then
|
|
|
|
those values are overwritten by actual register values on syscall
|
|
|
|
exit. */
|
|
|
|
case PTRACE_POKEUSR:
|
|
|
|
/* Some register values written here may be ignored in
|
|
|
|
* entry.S:syscall_restore_rfi; e.g. iaoq is written with
|
|
|
|
* r31/r31+4, and not with the values in pt_regs.
|
|
|
|
*/
|
|
|
|
if (addr == PT_PSW) {
|
|
|
|
/* Allow writing to Nullify, Divide-step-correction,
|
|
|
|
* and carry/borrow bits.
|
|
|
|
* BEWARE, if you set N, and then single step, it won't
|
|
|
|
* stop on the nullified instruction.
|
|
|
|
*/
|
|
|
|
data &= USER_PSW_BITS;
|
|
|
|
task_regs(child)->gr[0] &= ~USER_PSW_BITS;
|
|
|
|
task_regs(child)->gr[0] |= data;
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:33:47 +00:00
|
|
|
if ((addr & (sizeof(unsigned long)-1)) ||
|
|
|
|
addr >= sizeof(struct pt_regs))
|
2008-10-17 18:48:36 +00:00
|
|
|
break;
|
|
|
|
if ((addr >= PT_GR1 && addr <= PT_GR31) ||
|
|
|
|
addr == PT_IAOQ0 || addr == PT_IAOQ1 ||
|
|
|
|
(addr >= PT_FR0 && addr <= PT_FR31 + 4) ||
|
|
|
|
addr == PT_SAR) {
|
|
|
|
*(unsigned long *) ((char *) task_regs(child) + addr) = data;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-04-01 20:40:53 +00:00
|
|
|
case PTRACE_GETREGS: /* Get all gp regs from the child. */
|
|
|
|
return copy_regset_to_user(child,
|
|
|
|
task_user_regset_view(current),
|
|
|
|
REGSET_GENERAL,
|
|
|
|
0, sizeof(struct user_regs_struct),
|
|
|
|
datap);
|
|
|
|
|
|
|
|
case PTRACE_SETREGS: /* Set all gp regs in the child. */
|
|
|
|
return copy_regset_from_user(child,
|
|
|
|
task_user_regset_view(current),
|
|
|
|
REGSET_GENERAL,
|
|
|
|
0, sizeof(struct user_regs_struct),
|
|
|
|
datap);
|
|
|
|
|
|
|
|
case PTRACE_GETFPREGS: /* Get the child FPU state. */
|
|
|
|
return copy_regset_to_user(child,
|
|
|
|
task_user_regset_view(current),
|
|
|
|
REGSET_FP,
|
|
|
|
0, sizeof(struct user_fp_struct),
|
|
|
|
datap);
|
|
|
|
|
|
|
|
case PTRACE_SETFPREGS: /* Set the child FPU state. */
|
|
|
|
return copy_regset_from_user(child,
|
|
|
|
task_user_regset_view(current),
|
|
|
|
REGSET_FP,
|
|
|
|
0, sizeof(struct user_fp_struct),
|
|
|
|
datap);
|
|
|
|
|
2008-10-17 18:48:36 +00:00
|
|
|
default:
|
|
|
|
ret = ptrace_request(child, request, addr, data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_COMPAT
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* This function is needed to translate 32 bit pt_regs offsets in to
|
|
|
|
* 64 bit pt_regs offsets. For example, a 32 bit gdb under a 64 bit kernel
|
|
|
|
* will request offset 12 if it wants gr3, but the lower 32 bits of
|
|
|
|
* the 64 bit kernels view of gr3 will be at offset 28 (3*8 + 4).
|
|
|
|
* This code relies on a 32 bit pt_regs being comprised of 32 bit values
|
|
|
|
* except for the fp registers which (a) are 64 bits, and (b) follow
|
|
|
|
* the gr registers at the start of pt_regs. The 32 bit pt_regs should
|
|
|
|
* be half the size of the 64 bit pt_regs, plus 32*4 to allow for fr[]
|
|
|
|
* being 64 bit in both cases.
|
|
|
|
*/
|
|
|
|
|
2008-11-20 09:54:09 +00:00
|
|
|
static compat_ulong_t translate_usr_offset(compat_ulong_t offset)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
if (offset < 0)
|
2008-11-20 09:54:09 +00:00
|
|
|
return sizeof(struct pt_regs);
|
2005-04-16 22:20:36 +00:00
|
|
|
else if (offset <= 32*4) /* gr[0..31] */
|
|
|
|
return offset * 2 + 4;
|
|
|
|
else if (offset <= 32*4+32*8) /* gr[0..31] + fr[0..31] */
|
|
|
|
return offset + 32*4;
|
|
|
|
else if (offset < sizeof(struct pt_regs)/2 + 32*4)
|
|
|
|
return offset * 2 + 4 - 32*8;
|
|
|
|
else
|
2008-11-20 09:54:09 +00:00
|
|
|
return sizeof(struct pt_regs);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-10-17 18:48:36 +00:00
|
|
|
long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
|
|
|
|
compat_ulong_t addr, compat_ulong_t data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-10-17 18:48:36 +00:00
|
|
|
compat_uint_t tmp;
|
|
|
|
long ret = -EIO;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
switch (request) {
|
|
|
|
|
2008-10-17 18:48:36 +00:00
|
|
|
case PTRACE_PEEKUSR:
|
|
|
|
if (addr & (sizeof(compat_uint_t)-1))
|
|
|
|
break;
|
|
|
|
addr = translate_usr_offset(addr);
|
2008-11-20 09:54:09 +00:00
|
|
|
if (addr >= sizeof(struct pt_regs))
|
2008-10-17 18:48:36 +00:00
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-17 18:48:36 +00:00
|
|
|
tmp = *(compat_uint_t *) ((char *) task_regs(child) + addr);
|
|
|
|
ret = put_user(tmp, (compat_uint_t *) (unsigned long) data);
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Write the word at location addr in the USER area. This will need
|
|
|
|
to change when the kernel no longer saves all regs on a syscall.
|
|
|
|
FIXME. There is a problem at the moment in that r3-r18 are only
|
|
|
|
saved if the process is ptraced on syscall entry, and even then
|
|
|
|
those values are overwritten by actual register values on syscall
|
|
|
|
exit. */
|
|
|
|
case PTRACE_POKEUSR:
|
|
|
|
/* Some register values written here may be ignored in
|
|
|
|
* entry.S:syscall_restore_rfi; e.g. iaoq is written with
|
|
|
|
* r31/r31+4, and not with the values in pt_regs.
|
|
|
|
*/
|
|
|
|
if (addr == PT_PSW) {
|
2008-10-17 18:48:36 +00:00
|
|
|
/* Since PT_PSW==0, it is valid for 32 bit processes
|
|
|
|
* under 64 bit kernels as well.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2008-10-17 18:48:36 +00:00
|
|
|
ret = arch_ptrace(child, request, addr, data);
|
|
|
|
} else {
|
|
|
|
if (addr & (sizeof(compat_uint_t)-1))
|
|
|
|
break;
|
|
|
|
addr = translate_usr_offset(addr);
|
2008-11-20 09:54:09 +00:00
|
|
|
if (addr >= sizeof(struct pt_regs))
|
2008-10-17 18:48:36 +00:00
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (addr >= PT_FR0 && addr <= PT_FR31 + 4) {
|
|
|
|
/* Special case, fp regs are 64 bits anyway */
|
2008-10-17 18:48:36 +00:00
|
|
|
*(__u64 *) ((char *) task_regs(child) + addr) = data;
|
2005-04-16 22:20:36 +00:00
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
else if ((addr >= PT_GR1+4 && addr <= PT_GR31+4) ||
|
|
|
|
addr == PT_IAOQ0+4 || addr == PT_IAOQ1+4 ||
|
|
|
|
addr == PT_SAR+4) {
|
|
|
|
/* Zero the top 32 bits */
|
2008-10-17 18:48:36 +00:00
|
|
|
*(__u32 *) ((char *) task_regs(child) + addr - 4) = 0;
|
|
|
|
*(__u32 *) ((char *) task_regs(child) + addr) = data;
|
2005-04-16 22:20:36 +00:00
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
}
|
2008-10-17 18:48:36 +00:00
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
default:
|
2008-10-17 18:48:36 +00:00
|
|
|
ret = compat_ptrace_request(child, request, addr, data);
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2008-10-17 18:48:36 +00:00
|
|
|
#endif
|
|
|
|
|
2009-07-05 18:36:16 +00:00
|
|
|
long do_syscall_trace_enter(struct pt_regs *regs)
|
|
|
|
{
|
parisc: Fix ptrace syscall number modification
Commit 910cd32e552e ("parisc: Fix and enable seccomp filter support")
introduced a regression in ptrace-based syscall tampering: when tracer
changes syscall number to -1, the kernel fails to initialize %r28 with
-ENOSYS and subsequently fails to return the error code of the failed
syscall to userspace.
This erroneous behaviour could be observed with a simple strace syscall
fault injection command which is expected to print something like this:
$ strace -a0 -ewrite -einject=write:error=enospc echo hello
write(1, "hello\n", 6) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "echo: ", 6) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "write error", 11) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "\n", 1) = -1 ENOSPC (No space left on device) (INJECTED)
+++ exited with 1 +++
After commit 910cd32e552ea09caa89cdbe328e468979b030dd it loops printing
something like this instead:
write(1, "hello\n", 6../strace: Failed to tamper with process 12345: unexpectedly got no error (return value 0, error 0)
) = 0 (INJECTED)
This bug was found by strace test suite.
Fixes: 910cd32e552e ("parisc: Fix and enable seccomp filter support")
Cc: stable@vger.kernel.org # v4.5+
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Tested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
2019-02-16 13:10:39 +00:00
|
|
|
if (test_thread_flag(TIF_SYSCALL_TRACE)) {
|
|
|
|
int rc = tracehook_report_syscall_entry(regs);
|
|
|
|
|
2016-01-19 15:08:49 +00:00
|
|
|
/*
|
parisc: Fix ptrace syscall number modification
Commit 910cd32e552e ("parisc: Fix and enable seccomp filter support")
introduced a regression in ptrace-based syscall tampering: when tracer
changes syscall number to -1, the kernel fails to initialize %r28 with
-ENOSYS and subsequently fails to return the error code of the failed
syscall to userspace.
This erroneous behaviour could be observed with a simple strace syscall
fault injection command which is expected to print something like this:
$ strace -a0 -ewrite -einject=write:error=enospc echo hello
write(1, "hello\n", 6) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "echo: ", 6) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "write error", 11) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "\n", 1) = -1 ENOSPC (No space left on device) (INJECTED)
+++ exited with 1 +++
After commit 910cd32e552ea09caa89cdbe328e468979b030dd it loops printing
something like this instead:
write(1, "hello\n", 6../strace: Failed to tamper with process 12345: unexpectedly got no error (return value 0, error 0)
) = 0 (INJECTED)
This bug was found by strace test suite.
Fixes: 910cd32e552e ("parisc: Fix and enable seccomp filter support")
Cc: stable@vger.kernel.org # v4.5+
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Tested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
2019-02-16 13:10:39 +00:00
|
|
|
* As tracesys_next does not set %r28 to -ENOSYS
|
|
|
|
* when %r20 is set to -1, initialize it here.
|
2016-01-19 15:08:49 +00:00
|
|
|
*/
|
parisc: Fix ptrace syscall number modification
Commit 910cd32e552e ("parisc: Fix and enable seccomp filter support")
introduced a regression in ptrace-based syscall tampering: when tracer
changes syscall number to -1, the kernel fails to initialize %r28 with
-ENOSYS and subsequently fails to return the error code of the failed
syscall to userspace.
This erroneous behaviour could be observed with a simple strace syscall
fault injection command which is expected to print something like this:
$ strace -a0 -ewrite -einject=write:error=enospc echo hello
write(1, "hello\n", 6) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "echo: ", 6) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "write error", 11) = -1 ENOSPC (No space left on device) (INJECTED)
write(2, "\n", 1) = -1 ENOSPC (No space left on device) (INJECTED)
+++ exited with 1 +++
After commit 910cd32e552ea09caa89cdbe328e468979b030dd it loops printing
something like this instead:
write(1, "hello\n", 6../strace: Failed to tamper with process 12345: unexpectedly got no error (return value 0, error 0)
) = 0 (INJECTED)
This bug was found by strace test suite.
Fixes: 910cd32e552e ("parisc: Fix and enable seccomp filter support")
Cc: stable@vger.kernel.org # v4.5+
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Tested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
2019-02-16 13:10:39 +00:00
|
|
|
regs->gr[28] = -ENOSYS;
|
|
|
|
|
|
|
|
if (rc) {
|
|
|
|
/*
|
|
|
|
* A nonzero return code from
|
|
|
|
* tracehook_report_syscall_entry() tells us
|
|
|
|
* to prevent the syscall execution. Skip
|
|
|
|
* the syscall call and the syscall restart handling.
|
|
|
|
*
|
|
|
|
* Note that the tracer may also just change
|
|
|
|
* regs->gr[20] to an invalid syscall number,
|
|
|
|
* that is handled by tracesys_next.
|
|
|
|
*/
|
|
|
|
regs->gr[20] = -1UL;
|
|
|
|
return -1;
|
|
|
|
}
|
2016-01-19 15:08:49 +00:00
|
|
|
}
|
2016-06-02 20:15:52 +00:00
|
|
|
|
|
|
|
/* Do the secure computing check after ptrace. */
|
|
|
|
if (secure_computing(NULL) == -1)
|
|
|
|
return -1;
|
|
|
|
|
2016-04-13 20:44:54 +00:00
|
|
|
#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
|
|
|
|
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
|
|
|
trace_sys_enter(regs, regs->gr[20]);
|
|
|
|
#endif
|
2013-10-15 17:25:46 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_64BIT
|
|
|
|
if (!is_compat_task())
|
2014-03-11 17:29:28 +00:00
|
|
|
audit_syscall_entry(regs->gr[20], regs->gr[26], regs->gr[25],
|
|
|
|
regs->gr[24], regs->gr[23]);
|
2013-10-15 17:25:46 +00:00
|
|
|
else
|
|
|
|
#endif
|
2014-03-11 17:29:28 +00:00
|
|
|
audit_syscall_entry(regs->gr[20] & 0xffffffff,
|
2013-10-15 17:25:46 +00:00
|
|
|
regs->gr[26] & 0xffffffff,
|
|
|
|
regs->gr[25] & 0xffffffff,
|
|
|
|
regs->gr[24] & 0xffffffff,
|
|
|
|
regs->gr[23] & 0xffffffff);
|
|
|
|
|
2016-03-30 12:14:31 +00:00
|
|
|
/*
|
|
|
|
* Sign extend the syscall number to 64bit since it may have been
|
|
|
|
* modified by a compat ptrace call
|
|
|
|
*/
|
|
|
|
return (int) ((u32) regs->gr[20]);
|
2009-07-05 18:36:16 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-07-05 18:36:16 +00:00
|
|
|
void do_syscall_trace_exit(struct pt_regs *regs)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-09-28 03:03:02 +00:00
|
|
|
int stepping = test_thread_flag(TIF_SINGLESTEP) ||
|
|
|
|
test_thread_flag(TIF_BLOCKSTEP);
|
2009-04-27 03:53:34 +00:00
|
|
|
|
2013-10-15 17:25:46 +00:00
|
|
|
audit_syscall_exit(regs);
|
|
|
|
|
2016-04-13 20:44:54 +00:00
|
|
|
#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
|
|
|
|
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
|
|
|
trace_sys_exit(regs, regs->gr[20]);
|
|
|
|
#endif
|
|
|
|
|
2009-07-05 18:36:16 +00:00
|
|
|
if (stepping || test_thread_flag(TIF_SYSCALL_TRACE))
|
|
|
|
tracehook_report_syscall_exit(regs, stepping);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2016-04-01 20:40:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* regset functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int fpr_get(struct task_struct *target,
|
|
|
|
const struct user_regset *regset,
|
|
|
|
unsigned int pos, unsigned int count,
|
|
|
|
void *kbuf, void __user *ubuf)
|
|
|
|
{
|
|
|
|
struct pt_regs *regs = task_regs(target);
|
|
|
|
__u64 *k = kbuf;
|
|
|
|
__u64 __user *u = ubuf;
|
|
|
|
__u64 reg;
|
|
|
|
|
|
|
|
pos /= sizeof(reg);
|
|
|
|
count /= sizeof(reg);
|
|
|
|
|
|
|
|
if (kbuf)
|
|
|
|
for (; count > 0 && pos < ELF_NFPREG; --count)
|
|
|
|
*k++ = regs->fr[pos++];
|
|
|
|
else
|
|
|
|
for (; count > 0 && pos < ELF_NFPREG; --count)
|
|
|
|
if (__put_user(regs->fr[pos++], u++))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
kbuf = k;
|
|
|
|
ubuf = u;
|
|
|
|
pos *= sizeof(reg);
|
|
|
|
count *= sizeof(reg);
|
|
|
|
return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
|
|
|
|
ELF_NFPREG * sizeof(reg), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fpr_set(struct task_struct *target,
|
|
|
|
const struct user_regset *regset,
|
|
|
|
unsigned int pos, unsigned int count,
|
|
|
|
const void *kbuf, const void __user *ubuf)
|
|
|
|
{
|
|
|
|
struct pt_regs *regs = task_regs(target);
|
|
|
|
const __u64 *k = kbuf;
|
|
|
|
const __u64 __user *u = ubuf;
|
|
|
|
__u64 reg;
|
|
|
|
|
|
|
|
pos /= sizeof(reg);
|
|
|
|
count /= sizeof(reg);
|
|
|
|
|
|
|
|
if (kbuf)
|
|
|
|
for (; count > 0 && pos < ELF_NFPREG; --count)
|
|
|
|
regs->fr[pos++] = *k++;
|
|
|
|
else
|
|
|
|
for (; count > 0 && pos < ELF_NFPREG; --count) {
|
|
|
|
if (__get_user(reg, u++))
|
|
|
|
return -EFAULT;
|
|
|
|
regs->fr[pos++] = reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
kbuf = k;
|
|
|
|
ubuf = u;
|
|
|
|
pos *= sizeof(reg);
|
|
|
|
count *= sizeof(reg);
|
|
|
|
return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
|
|
|
|
ELF_NFPREG * sizeof(reg), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RI(reg) (offsetof(struct user_regs_struct,reg) / sizeof(long))
|
|
|
|
|
|
|
|
static unsigned long get_reg(struct pt_regs *regs, int num)
|
|
|
|
{
|
|
|
|
switch (num) {
|
|
|
|
case RI(gr[0]) ... RI(gr[31]): return regs->gr[num - RI(gr[0])];
|
|
|
|
case RI(sr[0]) ... RI(sr[7]): return regs->sr[num - RI(sr[0])];
|
|
|
|
case RI(iasq[0]): return regs->iasq[0];
|
|
|
|
case RI(iasq[1]): return regs->iasq[1];
|
|
|
|
case RI(iaoq[0]): return regs->iaoq[0];
|
|
|
|
case RI(iaoq[1]): return regs->iaoq[1];
|
|
|
|
case RI(sar): return regs->sar;
|
|
|
|
case RI(iir): return regs->iir;
|
|
|
|
case RI(isr): return regs->isr;
|
|
|
|
case RI(ior): return regs->ior;
|
|
|
|
case RI(ipsw): return regs->ipsw;
|
|
|
|
case RI(cr27): return regs->cr27;
|
|
|
|
case RI(cr0): return mfctl(0);
|
|
|
|
case RI(cr24): return mfctl(24);
|
|
|
|
case RI(cr25): return mfctl(25);
|
|
|
|
case RI(cr26): return mfctl(26);
|
|
|
|
case RI(cr28): return mfctl(28);
|
|
|
|
case RI(cr29): return mfctl(29);
|
|
|
|
case RI(cr30): return mfctl(30);
|
|
|
|
case RI(cr31): return mfctl(31);
|
|
|
|
case RI(cr8): return mfctl(8);
|
|
|
|
case RI(cr9): return mfctl(9);
|
|
|
|
case RI(cr12): return mfctl(12);
|
|
|
|
case RI(cr13): return mfctl(13);
|
|
|
|
case RI(cr10): return mfctl(10);
|
|
|
|
case RI(cr15): return mfctl(15);
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_reg(struct pt_regs *regs, int num, unsigned long val)
|
|
|
|
{
|
|
|
|
switch (num) {
|
|
|
|
case RI(gr[0]): /*
|
|
|
|
* PSW is in gr[0].
|
|
|
|
* Allow writing to Nullify, Divide-step-correction,
|
|
|
|
* and carry/borrow bits.
|
|
|
|
* BEWARE, if you set N, and then single step, it won't
|
|
|
|
* stop on the nullified instruction.
|
|
|
|
*/
|
|
|
|
val &= USER_PSW_BITS;
|
|
|
|
regs->gr[0] &= ~USER_PSW_BITS;
|
|
|
|
regs->gr[0] |= val;
|
|
|
|
return;
|
|
|
|
case RI(gr[1]) ... RI(gr[31]):
|
|
|
|
regs->gr[num - RI(gr[0])] = val;
|
|
|
|
return;
|
|
|
|
case RI(iaoq[0]):
|
|
|
|
case RI(iaoq[1]):
|
|
|
|
regs->iaoq[num - RI(iaoq[0])] = val;
|
|
|
|
return;
|
|
|
|
case RI(sar): regs->sar = val;
|
|
|
|
return;
|
|
|
|
default: return;
|
|
|
|
#if 0
|
|
|
|
/* do not allow to change any of the following registers (yet) */
|
|
|
|
case RI(sr[0]) ... RI(sr[7]): return regs->sr[num - RI(sr[0])];
|
|
|
|
case RI(iasq[0]): return regs->iasq[0];
|
|
|
|
case RI(iasq[1]): return regs->iasq[1];
|
|
|
|
case RI(iir): return regs->iir;
|
|
|
|
case RI(isr): return regs->isr;
|
|
|
|
case RI(ior): return regs->ior;
|
|
|
|
case RI(ipsw): return regs->ipsw;
|
|
|
|
case RI(cr27): return regs->cr27;
|
|
|
|
case cr0, cr24, cr25, cr26, cr27, cr28, cr29, cr30, cr31;
|
|
|
|
case cr8, cr9, cr12, cr13, cr10, cr15;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gpr_get(struct task_struct *target,
|
|
|
|
const struct user_regset *regset,
|
|
|
|
unsigned int pos, unsigned int count,
|
|
|
|
void *kbuf, void __user *ubuf)
|
|
|
|
{
|
|
|
|
struct pt_regs *regs = task_regs(target);
|
|
|
|
unsigned long *k = kbuf;
|
|
|
|
unsigned long __user *u = ubuf;
|
|
|
|
unsigned long reg;
|
|
|
|
|
|
|
|
pos /= sizeof(reg);
|
|
|
|
count /= sizeof(reg);
|
|
|
|
|
|
|
|
if (kbuf)
|
|
|
|
for (; count > 0 && pos < ELF_NGREG; --count)
|
|
|
|
*k++ = get_reg(regs, pos++);
|
|
|
|
else
|
|
|
|
for (; count > 0 && pos < ELF_NGREG; --count)
|
|
|
|
if (__put_user(get_reg(regs, pos++), u++))
|
|
|
|
return -EFAULT;
|
|
|
|
kbuf = k;
|
|
|
|
ubuf = u;
|
|
|
|
pos *= sizeof(reg);
|
|
|
|
count *= sizeof(reg);
|
|
|
|
return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
|
|
|
|
ELF_NGREG * sizeof(reg), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gpr_set(struct task_struct *target,
|
|
|
|
const struct user_regset *regset,
|
|
|
|
unsigned int pos, unsigned int count,
|
|
|
|
const void *kbuf, const void __user *ubuf)
|
|
|
|
{
|
|
|
|
struct pt_regs *regs = task_regs(target);
|
|
|
|
const unsigned long *k = kbuf;
|
|
|
|
const unsigned long __user *u = ubuf;
|
|
|
|
unsigned long reg;
|
|
|
|
|
|
|
|
pos /= sizeof(reg);
|
|
|
|
count /= sizeof(reg);
|
|
|
|
|
|
|
|
if (kbuf)
|
|
|
|
for (; count > 0 && pos < ELF_NGREG; --count)
|
|
|
|
set_reg(regs, pos++, *k++);
|
|
|
|
else
|
|
|
|
for (; count > 0 && pos < ELF_NGREG; --count) {
|
|
|
|
if (__get_user(reg, u++))
|
|
|
|
return -EFAULT;
|
|
|
|
set_reg(regs, pos++, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
kbuf = k;
|
|
|
|
ubuf = u;
|
|
|
|
pos *= sizeof(reg);
|
|
|
|
count *= sizeof(reg);
|
|
|
|
return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
|
|
|
|
ELF_NGREG * sizeof(reg), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct user_regset native_regsets[] = {
|
|
|
|
[REGSET_GENERAL] = {
|
|
|
|
.core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
|
|
|
|
.size = sizeof(long), .align = sizeof(long),
|
|
|
|
.get = gpr_get, .set = gpr_set
|
|
|
|
},
|
|
|
|
[REGSET_FP] = {
|
|
|
|
.core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
|
|
|
|
.size = sizeof(__u64), .align = sizeof(__u64),
|
|
|
|
.get = fpr_get, .set = fpr_set
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct user_regset_view user_parisc_native_view = {
|
|
|
|
.name = "parisc", .e_machine = ELF_ARCH, .ei_osabi = ELFOSABI_LINUX,
|
|
|
|
.regsets = native_regsets, .n = ARRAY_SIZE(native_regsets)
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_64BIT
|
|
|
|
#include <linux/compat.h>
|
|
|
|
|
|
|
|
static int gpr32_get(struct task_struct *target,
|
|
|
|
const struct user_regset *regset,
|
|
|
|
unsigned int pos, unsigned int count,
|
|
|
|
void *kbuf, void __user *ubuf)
|
|
|
|
{
|
|
|
|
struct pt_regs *regs = task_regs(target);
|
|
|
|
compat_ulong_t *k = kbuf;
|
|
|
|
compat_ulong_t __user *u = ubuf;
|
|
|
|
compat_ulong_t reg;
|
|
|
|
|
|
|
|
pos /= sizeof(reg);
|
|
|
|
count /= sizeof(reg);
|
|
|
|
|
|
|
|
if (kbuf)
|
|
|
|
for (; count > 0 && pos < ELF_NGREG; --count)
|
|
|
|
*k++ = get_reg(regs, pos++);
|
|
|
|
else
|
|
|
|
for (; count > 0 && pos < ELF_NGREG; --count)
|
|
|
|
if (__put_user((compat_ulong_t) get_reg(regs, pos++), u++))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
kbuf = k;
|
|
|
|
ubuf = u;
|
|
|
|
pos *= sizeof(reg);
|
|
|
|
count *= sizeof(reg);
|
|
|
|
return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
|
|
|
|
ELF_NGREG * sizeof(reg), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gpr32_set(struct task_struct *target,
|
|
|
|
const struct user_regset *regset,
|
|
|
|
unsigned int pos, unsigned int count,
|
|
|
|
const void *kbuf, const void __user *ubuf)
|
|
|
|
{
|
|
|
|
struct pt_regs *regs = task_regs(target);
|
|
|
|
const compat_ulong_t *k = kbuf;
|
|
|
|
const compat_ulong_t __user *u = ubuf;
|
|
|
|
compat_ulong_t reg;
|
|
|
|
|
|
|
|
pos /= sizeof(reg);
|
|
|
|
count /= sizeof(reg);
|
|
|
|
|
|
|
|
if (kbuf)
|
|
|
|
for (; count > 0 && pos < ELF_NGREG; --count)
|
|
|
|
set_reg(regs, pos++, *k++);
|
|
|
|
else
|
|
|
|
for (; count > 0 && pos < ELF_NGREG; --count) {
|
|
|
|
if (__get_user(reg, u++))
|
|
|
|
return -EFAULT;
|
|
|
|
set_reg(regs, pos++, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
kbuf = k;
|
|
|
|
ubuf = u;
|
|
|
|
pos *= sizeof(reg);
|
|
|
|
count *= sizeof(reg);
|
|
|
|
return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
|
|
|
|
ELF_NGREG * sizeof(reg), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are the regset flavors matching the 32bit native set.
|
|
|
|
*/
|
|
|
|
static const struct user_regset compat_regsets[] = {
|
|
|
|
[REGSET_GENERAL] = {
|
|
|
|
.core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
|
|
|
|
.size = sizeof(compat_long_t), .align = sizeof(compat_long_t),
|
|
|
|
.get = gpr32_get, .set = gpr32_set
|
|
|
|
},
|
|
|
|
[REGSET_FP] = {
|
|
|
|
.core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
|
|
|
|
.size = sizeof(__u64), .align = sizeof(__u64),
|
|
|
|
.get = fpr_get, .set = fpr_set
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct user_regset_view user_parisc_compat_view = {
|
|
|
|
.name = "parisc", .e_machine = EM_PARISC, .ei_osabi = ELFOSABI_LINUX,
|
|
|
|
.regsets = compat_regsets, .n = ARRAY_SIZE(compat_regsets)
|
|
|
|
};
|
|
|
|
#endif /* CONFIG_64BIT */
|
|
|
|
|
|
|
|
const struct user_regset_view *task_user_regset_view(struct task_struct *task)
|
|
|
|
{
|
|
|
|
BUILD_BUG_ON(sizeof(struct user_regs_struct)/sizeof(long) != ELF_NGREG);
|
|
|
|
BUILD_BUG_ON(sizeof(struct user_fp_struct)/sizeof(__u64) != ELF_NFPREG);
|
|
|
|
#ifdef CONFIG_64BIT
|
|
|
|
if (is_compat_task())
|
|
|
|
return &user_parisc_compat_view;
|
|
|
|
#endif
|
|
|
|
return &user_parisc_native_view;
|
|
|
|
}
|
2018-06-28 20:47:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* HAVE_REGS_AND_STACK_ACCESS_API feature */
|
|
|
|
|
|
|
|
struct pt_regs_offset {
|
|
|
|
const char *name;
|
|
|
|
int offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
|
|
|
|
#define REG_OFFSET_INDEX(r,i) {.name = #r#i, .offset = offsetof(struct pt_regs, r[i])}
|
|
|
|
#define REG_OFFSET_END {.name = NULL, .offset = 0}
|
|
|
|
|
|
|
|
static const struct pt_regs_offset regoffset_table[] = {
|
|
|
|
REG_OFFSET_INDEX(gr,0),
|
|
|
|
REG_OFFSET_INDEX(gr,1),
|
|
|
|
REG_OFFSET_INDEX(gr,2),
|
|
|
|
REG_OFFSET_INDEX(gr,3),
|
|
|
|
REG_OFFSET_INDEX(gr,4),
|
|
|
|
REG_OFFSET_INDEX(gr,5),
|
|
|
|
REG_OFFSET_INDEX(gr,6),
|
|
|
|
REG_OFFSET_INDEX(gr,7),
|
|
|
|
REG_OFFSET_INDEX(gr,8),
|
|
|
|
REG_OFFSET_INDEX(gr,9),
|
|
|
|
REG_OFFSET_INDEX(gr,10),
|
|
|
|
REG_OFFSET_INDEX(gr,11),
|
|
|
|
REG_OFFSET_INDEX(gr,12),
|
|
|
|
REG_OFFSET_INDEX(gr,13),
|
|
|
|
REG_OFFSET_INDEX(gr,14),
|
|
|
|
REG_OFFSET_INDEX(gr,15),
|
|
|
|
REG_OFFSET_INDEX(gr,16),
|
|
|
|
REG_OFFSET_INDEX(gr,17),
|
|
|
|
REG_OFFSET_INDEX(gr,18),
|
|
|
|
REG_OFFSET_INDEX(gr,19),
|
|
|
|
REG_OFFSET_INDEX(gr,20),
|
|
|
|
REG_OFFSET_INDEX(gr,21),
|
|
|
|
REG_OFFSET_INDEX(gr,22),
|
|
|
|
REG_OFFSET_INDEX(gr,23),
|
|
|
|
REG_OFFSET_INDEX(gr,24),
|
|
|
|
REG_OFFSET_INDEX(gr,25),
|
|
|
|
REG_OFFSET_INDEX(gr,26),
|
|
|
|
REG_OFFSET_INDEX(gr,27),
|
|
|
|
REG_OFFSET_INDEX(gr,28),
|
|
|
|
REG_OFFSET_INDEX(gr,29),
|
|
|
|
REG_OFFSET_INDEX(gr,30),
|
|
|
|
REG_OFFSET_INDEX(gr,31),
|
|
|
|
REG_OFFSET_INDEX(sr,0),
|
|
|
|
REG_OFFSET_INDEX(sr,1),
|
|
|
|
REG_OFFSET_INDEX(sr,2),
|
|
|
|
REG_OFFSET_INDEX(sr,3),
|
|
|
|
REG_OFFSET_INDEX(sr,4),
|
|
|
|
REG_OFFSET_INDEX(sr,5),
|
|
|
|
REG_OFFSET_INDEX(sr,6),
|
|
|
|
REG_OFFSET_INDEX(sr,7),
|
|
|
|
REG_OFFSET_INDEX(iasq,0),
|
|
|
|
REG_OFFSET_INDEX(iasq,1),
|
|
|
|
REG_OFFSET_INDEX(iaoq,0),
|
|
|
|
REG_OFFSET_INDEX(iaoq,1),
|
|
|
|
REG_OFFSET_NAME(cr27),
|
|
|
|
REG_OFFSET_NAME(ksp),
|
|
|
|
REG_OFFSET_NAME(kpc),
|
|
|
|
REG_OFFSET_NAME(sar),
|
|
|
|
REG_OFFSET_NAME(iir),
|
|
|
|
REG_OFFSET_NAME(isr),
|
|
|
|
REG_OFFSET_NAME(ior),
|
|
|
|
REG_OFFSET_NAME(ipsw),
|
|
|
|
REG_OFFSET_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* regs_query_register_offset() - query register offset from its name
|
|
|
|
* @name: the name of a register
|
|
|
|
*
|
|
|
|
* regs_query_register_offset() returns the offset of a register in struct
|
|
|
|
* pt_regs from its name. If the name is invalid, this returns -EINVAL;
|
|
|
|
*/
|
|
|
|
int regs_query_register_offset(const char *name)
|
|
|
|
{
|
|
|
|
const struct pt_regs_offset *roff;
|
|
|
|
for (roff = regoffset_table; roff->name != NULL; roff++)
|
|
|
|
if (!strcmp(roff->name, name))
|
|
|
|
return roff->offset;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* regs_query_register_name() - query register name from its offset
|
|
|
|
* @offset: the offset of a register in struct pt_regs.
|
|
|
|
*
|
|
|
|
* regs_query_register_name() returns the name of a register from its
|
|
|
|
* offset in struct pt_regs. If the @offset is invalid, this returns NULL;
|
|
|
|
*/
|
|
|
|
const char *regs_query_register_name(unsigned int offset)
|
|
|
|
{
|
|
|
|
const struct pt_regs_offset *roff;
|
|
|
|
for (roff = regoffset_table; roff->name != NULL; roff++)
|
|
|
|
if (roff->offset == offset)
|
|
|
|
return roff->name;
|
|
|
|
return NULL;
|
|
|
|
}
|