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
|
|
|
/* ptrace.c: Sparc process tracing support.
|
|
|
|
*
|
2008-02-07 05:00:44 +00:00
|
|
|
* Copyright (C) 1996, 2008 David S. Miller (davem@davemloft.net)
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Based upon code written by Ross Biro, Linus Torvalds, Bob Manson,
|
|
|
|
* and David Mosberger.
|
|
|
|
*
|
2007-12-20 21:55:45 +00:00
|
|
|
* Added Linux support -miguel (weird, eh?, the original code was meant
|
2005-04-16 22:20:36 +00:00
|
|
|
* to emulate SunOS).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/user.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/security.h>
|
2005-05-01 15:59:14 +00:00
|
|
|
#include <linux/signal.h>
|
2008-02-07 05:00:44 +00:00
|
|
|
#include <linux/regset.h>
|
|
|
|
#include <linux/elf.h>
|
2008-07-27 10:13:13 +00:00
|
|
|
#include <linux/tracehook.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <asm/pgtable.h>
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2012-03-28 17:30:03 +00:00
|
|
|
#include <asm/cacheflush.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-04-21 19:39:37 +00:00
|
|
|
#include "kernel.h"
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* #define ALLOW_INIT_TRACING */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called by kernel/ptrace.c when detaching..
|
|
|
|
*
|
|
|
|
* Make sure single step bits etc are not set.
|
|
|
|
*/
|
|
|
|
void ptrace_disable(struct task_struct *child)
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
2008-02-07 05:00:44 +00:00
|
|
|
enum sparc_regset {
|
|
|
|
REGSET_GENERAL,
|
|
|
|
REGSET_FP,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int genregs32_get(struct task_struct *target,
|
|
|
|
const struct user_regset *regset,
|
|
|
|
unsigned int pos, unsigned int count,
|
|
|
|
void *kbuf, void __user *ubuf)
|
|
|
|
{
|
|
|
|
const struct pt_regs *regs = target->thread.kregs;
|
|
|
|
unsigned long __user *reg_window;
|
|
|
|
unsigned long *k = kbuf;
|
|
|
|
unsigned long __user *u = ubuf;
|
|
|
|
unsigned long reg;
|
|
|
|
|
|
|
|
if (target == current)
|
|
|
|
flush_user_windows();
|
|
|
|
|
|
|
|
pos /= sizeof(reg);
|
|
|
|
count /= sizeof(reg);
|
|
|
|
|
|
|
|
if (kbuf) {
|
|
|
|
for (; count > 0 && pos < 16; count--)
|
|
|
|
*k++ = regs->u_regs[pos++];
|
|
|
|
|
|
|
|
reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
|
2010-04-01 01:05:05 +00:00
|
|
|
reg_window -= 16;
|
2008-02-07 05:00:44 +00:00
|
|
|
for (; count > 0 && pos < 32; count--) {
|
|
|
|
if (get_user(*k++, ®_window[pos++]))
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (; count > 0 && pos < 16; count--) {
|
|
|
|
if (put_user(regs->u_regs[pos++], u++))
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
|
2010-04-01 01:05:05 +00:00
|
|
|
reg_window -= 16;
|
2008-02-07 05:00:44 +00:00
|
|
|
for (; count > 0 && pos < 32; count--) {
|
|
|
|
if (get_user(reg, ®_window[pos++]) ||
|
|
|
|
put_user(reg, u++))
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (count > 0) {
|
|
|
|
switch (pos) {
|
|
|
|
case 32: /* PSR */
|
|
|
|
reg = regs->psr;
|
|
|
|
break;
|
|
|
|
case 33: /* PC */
|
|
|
|
reg = regs->pc;
|
|
|
|
break;
|
|
|
|
case 34: /* NPC */
|
|
|
|
reg = regs->npc;
|
|
|
|
break;
|
|
|
|
case 35: /* Y */
|
|
|
|
reg = regs->y;
|
|
|
|
break;
|
|
|
|
case 36: /* WIM */
|
|
|
|
case 37: /* TBR */
|
|
|
|
reg = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto finish;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kbuf)
|
|
|
|
*k++ = reg;
|
|
|
|
else if (put_user(reg, u++))
|
|
|
|
return -EFAULT;
|
|
|
|
pos++;
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
finish:
|
|
|
|
pos *= sizeof(reg);
|
|
|
|
count *= sizeof(reg);
|
|
|
|
|
|
|
|
return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
|
|
|
|
38 * sizeof(reg), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int genregs32_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 = target->thread.kregs;
|
|
|
|
unsigned long __user *reg_window;
|
|
|
|
const unsigned long *k = kbuf;
|
|
|
|
const unsigned long __user *u = ubuf;
|
|
|
|
unsigned long reg;
|
|
|
|
|
|
|
|
if (target == current)
|
|
|
|
flush_user_windows();
|
|
|
|
|
|
|
|
pos /= sizeof(reg);
|
|
|
|
count /= sizeof(reg);
|
|
|
|
|
|
|
|
if (kbuf) {
|
|
|
|
for (; count > 0 && pos < 16; count--)
|
|
|
|
regs->u_regs[pos++] = *k++;
|
|
|
|
|
|
|
|
reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
|
2010-04-01 01:05:05 +00:00
|
|
|
reg_window -= 16;
|
2008-02-07 05:00:44 +00:00
|
|
|
for (; count > 0 && pos < 32; count--) {
|
|
|
|
if (put_user(*k++, ®_window[pos++]))
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (; count > 0 && pos < 16; count--) {
|
|
|
|
if (get_user(reg, u++))
|
|
|
|
return -EFAULT;
|
|
|
|
regs->u_regs[pos++] = reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
|
2010-04-01 01:05:05 +00:00
|
|
|
reg_window -= 16;
|
2008-02-07 05:00:44 +00:00
|
|
|
for (; count > 0 && pos < 32; count--) {
|
|
|
|
if (get_user(reg, u++) ||
|
|
|
|
put_user(reg, ®_window[pos++]))
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (count > 0) {
|
|
|
|
unsigned long psr;
|
|
|
|
|
|
|
|
if (kbuf)
|
|
|
|
reg = *k++;
|
|
|
|
else if (get_user(reg, u++))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
switch (pos) {
|
|
|
|
case 32: /* PSR */
|
|
|
|
psr = regs->psr;
|
sparc: Fix debugger syscall restart interactions.
So, forever, we've had this ptrace_signal_deliver implementation
which tries to handle all of the nasties that can occur when the
debugger looks at a process about to take a signal. It's meant
to address all of these issues inside of the kernel so that the
debugger need not be mindful of such things.
Problem is, this doesn't work.
The idea was that we should do the syscall restart business first, so
that the debugger captures that state. Otherwise, if the debugger for
example saves the child's state, makes the child execute something
else, then restores the saved state, we won't handle the syscall
restart properly because we lose the "we're in a syscall" state.
The code here worked for most cases, but if the debugger actually
passes the signal through to the child unaltered, it's possible that
we would do a syscall restart when we shouldn't have.
In particular this breaks the case of debugging a process under a gdb
which is being debugged by yet another gdb. gdb uses sigsuspend
to wait for SIGCHLD of the inferior, but if gdb itself is being
debugged by a top-level gdb we get a ptrace_stop(). The top-level gdb
does a PTRACE_CONT with SIGCHLD to let the inferior gdb see the
signal. But ptrace_signal_deliver() assumed the debugger would cancel
out the signal and therefore did a syscall restart, because the return
error was ERESTARTNOHAND.
Fix this by simply making ptrace_signal_deliver() a nop, and providing
a way for the debugger to control system call restarting properly:
1) Report a "in syscall" software bit in regs->{tstate,psr}.
It is set early on in trap entry to a system call and is fully
visible to the debugger via ptrace() and regsets.
2) Test this bit right before doing a syscall restart. We have
to do a final recheck right after get_signal_to_deliver() in
case the debugger cleared the bit during ptrace_stop().
3) Clear the bit in trap return so we don't accidently try to set
that bit in the real register.
As a result we also get a ptrace_{is,clear}_syscall() for sparc32 just
like sparc64 has.
M68K has this same exact bug, and is now the only other user of the
ptrace_signal_deliver hook. It needs to be fixed in the same exact
way as sparc.
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-11 09:07:19 +00:00
|
|
|
psr &= ~(PSR_ICC | PSR_SYSCALL);
|
|
|
|
psr |= (reg & (PSR_ICC | PSR_SYSCALL));
|
2008-02-07 05:00:44 +00:00
|
|
|
regs->psr = psr;
|
|
|
|
break;
|
|
|
|
case 33: /* PC */
|
|
|
|
regs->pc = reg;
|
|
|
|
break;
|
|
|
|
case 34: /* NPC */
|
|
|
|
regs->npc = reg;
|
|
|
|
break;
|
|
|
|
case 35: /* Y */
|
|
|
|
regs->y = reg;
|
|
|
|
break;
|
|
|
|
case 36: /* WIM */
|
|
|
|
case 37: /* TBR */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto finish;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos++;
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
finish:
|
|
|
|
pos *= sizeof(reg);
|
|
|
|
count *= sizeof(reg);
|
|
|
|
|
|
|
|
return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
|
|
|
|
38 * sizeof(reg), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fpregs32_get(struct task_struct *target,
|
|
|
|
const struct user_regset *regset,
|
|
|
|
unsigned int pos, unsigned int count,
|
|
|
|
void *kbuf, void __user *ubuf)
|
|
|
|
{
|
|
|
|
const unsigned long *fpregs = target->thread.float_regs;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (target == current)
|
|
|
|
save_and_clear_fpu();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
|
|
|
|
fpregs,
|
|
|
|
0, 32 * sizeof(u32));
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
|
|
|
|
32 * sizeof(u32),
|
|
|
|
33 * sizeof(u32));
|
|
|
|
if (!ret)
|
|
|
|
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
|
|
|
|
&target->thread.fsr,
|
|
|
|
33 * sizeof(u32),
|
|
|
|
34 * sizeof(u32));
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
unsigned long val;
|
|
|
|
|
|
|
|
val = (1 << 8) | (8 << 16);
|
|
|
|
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
|
|
|
|
&val,
|
|
|
|
34 * sizeof(u32),
|
|
|
|
35 * sizeof(u32));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
|
|
|
|
35 * sizeof(u32), -1);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fpregs32_set(struct task_struct *target,
|
|
|
|
const struct user_regset *regset,
|
|
|
|
unsigned int pos, unsigned int count,
|
|
|
|
const void *kbuf, const void __user *ubuf)
|
|
|
|
{
|
|
|
|
unsigned long *fpregs = target->thread.float_regs;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (target == current)
|
|
|
|
save_and_clear_fpu();
|
|
|
|
#endif
|
|
|
|
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
|
|
|
|
fpregs,
|
|
|
|
0, 32 * sizeof(u32));
|
|
|
|
if (!ret)
|
|
|
|
user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
|
|
|
|
32 * sizeof(u32),
|
|
|
|
33 * sizeof(u32));
|
|
|
|
if (!ret && count > 0) {
|
|
|
|
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
|
|
|
|
&target->thread.fsr,
|
|
|
|
33 * sizeof(u32),
|
|
|
|
34 * sizeof(u32));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
|
|
|
|
34 * sizeof(u32), -1);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct user_regset sparc32_regsets[] = {
|
|
|
|
/* Format is:
|
|
|
|
* G0 --> G7
|
|
|
|
* O0 --> O7
|
|
|
|
* L0 --> L7
|
|
|
|
* I0 --> I7
|
|
|
|
* PSR, PC, nPC, Y, WIM, TBR
|
|
|
|
*/
|
|
|
|
[REGSET_GENERAL] = {
|
|
|
|
.core_note_type = NT_PRSTATUS,
|
2008-09-12 22:01:31 +00:00
|
|
|
.n = 38,
|
2008-02-07 05:00:44 +00:00
|
|
|
.size = sizeof(u32), .align = sizeof(u32),
|
|
|
|
.get = genregs32_get, .set = genregs32_set
|
|
|
|
},
|
|
|
|
/* Format is:
|
|
|
|
* F0 --> F31
|
|
|
|
* empty 32-bit word
|
|
|
|
* FSR (32--bit word)
|
|
|
|
* FPU QUEUE COUNT (8-bit char)
|
|
|
|
* FPU QUEUE ENTRYSIZE (8-bit char)
|
|
|
|
* FPU ENABLED (8-bit char)
|
|
|
|
* empty 8-bit char
|
|
|
|
* FPU QUEUE (64 32-bit ints)
|
|
|
|
*/
|
|
|
|
[REGSET_FP] = {
|
|
|
|
.core_note_type = NT_PRFPREG,
|
2008-09-12 22:01:31 +00:00
|
|
|
.n = 99,
|
2008-02-07 05:00:44 +00:00
|
|
|
.size = sizeof(u32), .align = sizeof(u32),
|
|
|
|
.get = fpregs32_get, .set = fpregs32_set
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct user_regset_view user_sparc32_view = {
|
|
|
|
.name = "sparc", .e_machine = EM_SPARC,
|
|
|
|
.regsets = sparc32_regsets, .n = ARRAY_SIZE(sparc32_regsets)
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct user_regset_view *task_user_regset_view(struct task_struct *task)
|
|
|
|
{
|
|
|
|
return &user_sparc32_view;
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:34:03 +00:00
|
|
|
struct fps {
|
|
|
|
unsigned long regs[32];
|
|
|
|
unsigned long fsr;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long extra;
|
|
|
|
unsigned long fpqd;
|
|
|
|
struct fq {
|
|
|
|
unsigned long *insnaddr;
|
|
|
|
unsigned long insn;
|
|
|
|
} fpq[16];
|
|
|
|
};
|
|
|
|
|
2010-10-27 22:33:47 +00:00
|
|
|
long arch_ptrace(struct task_struct *child, long request,
|
|
|
|
unsigned long addr, unsigned long data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-02-07 11:00:17 +00:00
|
|
|
unsigned long addr2 = current->thread.kregs->u_regs[UREG_I4];
|
2010-10-27 22:34:03 +00:00
|
|
|
void __user *addr2p;
|
2008-02-07 13:06:51 +00:00
|
|
|
const struct user_regset_view *view;
|
2010-10-27 22:34:03 +00:00
|
|
|
struct pt_regs __user *pregs;
|
|
|
|
struct fps __user *fps;
|
2008-02-07 13:06:51 +00:00
|
|
|
int ret;
|
|
|
|
|
2008-04-10 02:39:25 +00:00
|
|
|
view = task_user_regset_view(current);
|
2010-10-27 22:34:03 +00:00
|
|
|
addr2p = (void __user *) addr2;
|
|
|
|
pregs = (struct pt_regs __user *) addr;
|
|
|
|
fps = (struct fps __user *) addr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
switch(request) {
|
|
|
|
case PTRACE_GETREGS: {
|
2008-02-07 13:06:51 +00:00
|
|
|
ret = copy_regset_to_user(child, view, REGSET_GENERAL,
|
|
|
|
32 * sizeof(u32),
|
|
|
|
4 * sizeof(u32),
|
|
|
|
&pregs->psr);
|
|
|
|
if (!ret)
|
|
|
|
copy_regset_to_user(child, view, REGSET_GENERAL,
|
|
|
|
1 * sizeof(u32),
|
|
|
|
15 * sizeof(u32),
|
|
|
|
&pregs->u_regs[0]);
|
2008-02-07 11:00:17 +00:00
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case PTRACE_SETREGS: {
|
2008-02-07 13:06:51 +00:00
|
|
|
ret = copy_regset_from_user(child, view, REGSET_GENERAL,
|
|
|
|
32 * sizeof(u32),
|
|
|
|
4 * sizeof(u32),
|
|
|
|
&pregs->psr);
|
|
|
|
if (!ret)
|
|
|
|
copy_regset_from_user(child, view, REGSET_GENERAL,
|
|
|
|
1 * sizeof(u32),
|
|
|
|
15 * sizeof(u32),
|
|
|
|
&pregs->u_regs[0]);
|
2008-02-07 11:00:17 +00:00
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case PTRACE_GETFPREGS: {
|
2008-02-07 13:06:51 +00:00
|
|
|
ret = copy_regset_to_user(child, view, REGSET_FP,
|
|
|
|
0 * sizeof(u32),
|
|
|
|
32 * sizeof(u32),
|
|
|
|
&fps->regs[0]);
|
|
|
|
if (!ret)
|
|
|
|
ret = copy_regset_to_user(child, view, REGSET_FP,
|
|
|
|
33 * sizeof(u32),
|
|
|
|
1 * sizeof(u32),
|
|
|
|
&fps->fsr);
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
if (__put_user(0, &fps->fpqd) ||
|
|
|
|
__put_user(0, &fps->flags) ||
|
|
|
|
__put_user(0, &fps->extra) ||
|
|
|
|
clear_user(fps->fpq, sizeof(fps->fpq)))
|
|
|
|
ret = -EFAULT;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-02-07 11:00:17 +00:00
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case PTRACE_SETFPREGS: {
|
2008-02-07 13:06:51 +00:00
|
|
|
ret = copy_regset_from_user(child, view, REGSET_FP,
|
|
|
|
0 * sizeof(u32),
|
|
|
|
32 * sizeof(u32),
|
|
|
|
&fps->regs[0]);
|
|
|
|
if (!ret)
|
|
|
|
ret = copy_regset_from_user(child, view, REGSET_FP,
|
|
|
|
33 * sizeof(u32),
|
|
|
|
1 * sizeof(u32),
|
|
|
|
&fps->fsr);
|
2008-02-07 11:00:17 +00:00
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case PTRACE_READTEXT:
|
2008-02-07 11:00:17 +00:00
|
|
|
case PTRACE_READDATA:
|
2010-10-27 22:34:03 +00:00
|
|
|
ret = ptrace_readdata(child, addr, addr2p, data);
|
2008-02-07 11:00:17 +00:00
|
|
|
|
|
|
|
if (ret == data)
|
|
|
|
ret = 0;
|
|
|
|
else if (ret >= 0)
|
|
|
|
ret = -EIO;
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
case PTRACE_WRITETEXT:
|
2008-02-07 11:00:17 +00:00
|
|
|
case PTRACE_WRITEDATA:
|
2010-10-27 22:34:03 +00:00
|
|
|
ret = ptrace_writedata(child, addr2p, addr, data);
|
2008-02-07 11:00:17 +00:00
|
|
|
|
|
|
|
if (ret == data)
|
|
|
|
ret = 0;
|
|
|
|
else if (ret >= 0)
|
|
|
|
ret = -EIO;
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-02-07 11:00:17 +00:00
|
|
|
default:
|
2008-05-11 04:11:23 +00:00
|
|
|
if (request == PTRACE_SPARC_DETACH)
|
|
|
|
request = PTRACE_DETACH;
|
2008-02-07 11:00:17 +00:00
|
|
|
ret = ptrace_request(child, request, addr, data);
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-02-07 11:00:17 +00:00
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 10:13:13 +00:00
|
|
|
asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-07-27 10:13:13 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (test_thread_flag(TIF_SYSCALL_TRACE)) {
|
|
|
|
if (syscall_exit_p)
|
|
|
|
tracehook_report_syscall_exit(regs, 0);
|
|
|
|
else
|
|
|
|
ret = tracehook_report_syscall_entry(regs);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-07-27 10:13:13 +00:00
|
|
|
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|