License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2008-05-20 07:53:02 +08:00
|
|
|
/*
|
2005-04-17 06:20:36 +08:00
|
|
|
* unaligned.c: Unaligned load/store trap handling with special
|
|
|
|
* cases for the kernel to do them more quickly.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
|
|
|
|
* Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2017-02-09 01:51:30 +08:00
|
|
|
#include <linux/sched/signal.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/processor.h>
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/smp.h>
|
2009-12-11 17:07:53 +08:00
|
|
|
#include <linux/perf_event.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-04-22 03:39:38 +08:00
|
|
|
#include <asm/setup.h>
|
|
|
|
|
|
|
|
#include "kernel.h"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
enum direction {
|
|
|
|
load, /* ld, ldd, ldh, ldsh */
|
|
|
|
store, /* st, std, sth, stsh */
|
|
|
|
both, /* Swap, ldstub, etc. */
|
|
|
|
fpload,
|
|
|
|
fpstore,
|
|
|
|
invalid,
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline enum direction decode_direction(unsigned int insn)
|
|
|
|
{
|
|
|
|
unsigned long tmp = (insn >> 21) & 1;
|
|
|
|
|
|
|
|
if(!tmp)
|
|
|
|
return load;
|
|
|
|
else {
|
|
|
|
if(((insn>>19)&0x3f) == 15)
|
|
|
|
return both;
|
|
|
|
else
|
|
|
|
return store;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 8 = double-word, 4 = word, 2 = half-word */
|
|
|
|
static inline int decode_access_size(unsigned int insn)
|
|
|
|
{
|
|
|
|
insn = (insn >> 19) & 3;
|
|
|
|
|
|
|
|
if(!insn)
|
|
|
|
return 4;
|
|
|
|
else if(insn == 3)
|
|
|
|
return 8;
|
|
|
|
else if(insn == 2)
|
|
|
|
return 2;
|
|
|
|
else {
|
|
|
|
printk("Impossible unaligned trap. insn=%08x\n", insn);
|
|
|
|
die_if_kernel("Byte sized unaligned access?!?!", current->thread.kregs);
|
|
|
|
return 4; /* just to keep gcc happy. */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 0x400000 = signed, 0 = unsigned */
|
|
|
|
static inline int decode_signedness(unsigned int insn)
|
|
|
|
{
|
|
|
|
return (insn & 0x400000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void maybe_flush_windows(unsigned int rs1, unsigned int rs2,
|
|
|
|
unsigned int rd)
|
|
|
|
{
|
|
|
|
if(rs2 >= 16 || rs1 >= 16 || rd >= 16) {
|
|
|
|
/* Wheee... */
|
|
|
|
__asm__ __volatile__("save %sp, -0x40, %sp\n\t"
|
|
|
|
"save %sp, -0x40, %sp\n\t"
|
|
|
|
"save %sp, -0x40, %sp\n\t"
|
|
|
|
"save %sp, -0x40, %sp\n\t"
|
|
|
|
"save %sp, -0x40, %sp\n\t"
|
|
|
|
"save %sp, -0x40, %sp\n\t"
|
|
|
|
"save %sp, -0x40, %sp\n\t"
|
|
|
|
"restore; restore; restore; restore;\n\t"
|
|
|
|
"restore; restore; restore;\n\t");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sign_extend_imm13(int imm)
|
|
|
|
{
|
|
|
|
return imm << 19 >> 19;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs)
|
|
|
|
{
|
2009-01-03 11:32:59 +08:00
|
|
|
struct reg_window32 *win;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if(reg < 16)
|
|
|
|
return (!reg ? 0 : regs->u_regs[reg]);
|
|
|
|
|
|
|
|
/* Ho hum, the slightly complicated case. */
|
2009-01-03 11:32:59 +08:00
|
|
|
win = (struct reg_window32 *) regs->u_regs[UREG_FP];
|
2005-04-17 06:20:36 +08:00
|
|
|
return win->locals[reg - 16]; /* yes, I know what this does... */
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long safe_fetch_reg(unsigned int reg, struct pt_regs *regs)
|
|
|
|
{
|
2009-01-03 11:32:59 +08:00
|
|
|
struct reg_window32 __user *win;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long ret;
|
|
|
|
|
|
|
|
if (reg < 16)
|
|
|
|
return (!reg ? 0 : regs->u_regs[reg]);
|
|
|
|
|
|
|
|
/* Ho hum, the slightly complicated case. */
|
2009-01-03 11:32:59 +08:00
|
|
|
win = (struct reg_window32 __user *) regs->u_regs[UREG_FP];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if ((unsigned long)win & 3)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (get_user(ret, &win->locals[reg - 16]))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long *fetch_reg_addr(unsigned int reg, struct pt_regs *regs)
|
|
|
|
{
|
2009-01-03 11:32:59 +08:00
|
|
|
struct reg_window32 *win;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if(reg < 16)
|
|
|
|
return ®s->u_regs[reg];
|
2009-01-03 11:32:59 +08:00
|
|
|
win = (struct reg_window32 *) regs->u_regs[UREG_FP];
|
2005-04-17 06:20:36 +08:00
|
|
|
return &win->locals[reg - 16];
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long compute_effective_address(struct pt_regs *regs,
|
|
|
|
unsigned int insn)
|
|
|
|
{
|
|
|
|
unsigned int rs1 = (insn >> 14) & 0x1f;
|
|
|
|
unsigned int rs2 = insn & 0x1f;
|
|
|
|
unsigned int rd = (insn >> 25) & 0x1f;
|
|
|
|
|
|
|
|
if(insn & 0x2000) {
|
|
|
|
maybe_flush_windows(rs1, 0, rd);
|
|
|
|
return (fetch_reg(rs1, regs) + sign_extend_imm13(insn));
|
|
|
|
} else {
|
|
|
|
maybe_flush_windows(rs1, rs2, rd);
|
|
|
|
return (fetch_reg(rs1, regs) + fetch_reg(rs2, regs));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long safe_compute_effective_address(struct pt_regs *regs,
|
|
|
|
unsigned int insn)
|
|
|
|
{
|
|
|
|
unsigned int rs1 = (insn >> 14) & 0x1f;
|
|
|
|
unsigned int rs2 = insn & 0x1f;
|
|
|
|
unsigned int rd = (insn >> 25) & 0x1f;
|
|
|
|
|
|
|
|
if(insn & 0x2000) {
|
|
|
|
maybe_flush_windows(rs1, 0, rd);
|
|
|
|
return (safe_fetch_reg(rs1, regs) + sign_extend_imm13(insn));
|
|
|
|
} else {
|
|
|
|
maybe_flush_windows(rs1, rs2, rd);
|
|
|
|
return (safe_fetch_reg(rs1, regs) + safe_fetch_reg(rs2, regs));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is just to make gcc think panic does return... */
|
|
|
|
static void unaligned_panic(char *str)
|
|
|
|
{
|
2014-07-01 04:37:59 +08:00
|
|
|
panic("%s", str);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-03-04 07:01:05 +08:00
|
|
|
/* una_asm.S */
|
|
|
|
extern int do_int_load(unsigned long *dest_reg, int size,
|
|
|
|
unsigned long *saddr, int is_signed);
|
|
|
|
extern int __do_int_store(unsigned long *dst_addr, int size,
|
|
|
|
unsigned long *src_val);
|
|
|
|
|
|
|
|
static int do_int_store(int reg_num, int size, unsigned long *dst_addr,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
unsigned long zero[2] = { 0, 0 };
|
|
|
|
unsigned long *src_val;
|
|
|
|
|
|
|
|
if (reg_num)
|
|
|
|
src_val = fetch_reg_addr(reg_num, regs);
|
|
|
|
else {
|
|
|
|
src_val = &zero[0];
|
|
|
|
if (size == 8)
|
|
|
|
zero[1] = fetch_reg(1, regs);
|
|
|
|
}
|
|
|
|
return __do_int_store(dst_addr, size, src_val);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern void smp_capture(void);
|
|
|
|
extern void smp_release(void);
|
|
|
|
|
|
|
|
static inline void advance(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
regs->pc = regs->npc;
|
|
|
|
regs->npc += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int floating_point_load_or_store_p(unsigned int insn)
|
|
|
|
{
|
|
|
|
return (insn >> 24) & 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ok_for_kernel(unsigned int insn)
|
|
|
|
{
|
|
|
|
return !floating_point_load_or_store_p(insn);
|
|
|
|
}
|
|
|
|
|
2008-03-04 07:01:05 +08:00
|
|
|
static void kernel_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned long g2 = regs->u_regs [UREG_G2];
|
|
|
|
unsigned long fixup = search_extables_range(regs->pc, &g2);
|
|
|
|
|
|
|
|
if (!fixup) {
|
|
|
|
unsigned long address = compute_effective_address(regs, insn);
|
|
|
|
if(address < PAGE_SIZE) {
|
|
|
|
printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference in mna handler");
|
|
|
|
} else
|
|
|
|
printk(KERN_ALERT "Unable to handle kernel paging request in mna handler");
|
|
|
|
printk(KERN_ALERT " at virtual address %08lx\n",address);
|
|
|
|
printk(KERN_ALERT "current->{mm,active_mm}->context = %08lx\n",
|
|
|
|
(current->mm ? current->mm->context :
|
|
|
|
current->active_mm->context));
|
|
|
|
printk(KERN_ALERT "current->{mm,active_mm}->pgd = %08lx\n",
|
|
|
|
(current->mm ? (unsigned long) current->mm->pgd :
|
|
|
|
(unsigned long) current->active_mm->pgd));
|
|
|
|
die_if_kernel("Oops", regs);
|
|
|
|
/* Not reached */
|
|
|
|
}
|
|
|
|
regs->pc = fixup;
|
|
|
|
regs->npc = regs->pc + 4;
|
|
|
|
regs->u_regs [UREG_G2] = g2;
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
|
|
|
|
{
|
|
|
|
enum direction dir = decode_direction(insn);
|
|
|
|
int size = decode_access_size(insn);
|
|
|
|
|
|
|
|
if(!ok_for_kernel(insn) || dir == both) {
|
|
|
|
printk("Unsupported unaligned load/store trap for kernel at <%08lx>.\n",
|
|
|
|
regs->pc);
|
|
|
|
unaligned_panic("Wheee. Kernel does fpu/atomic unaligned load/store.");
|
|
|
|
} else {
|
|
|
|
unsigned long addr = compute_effective_address(regs, insn);
|
2008-03-04 07:01:05 +08:00
|
|
|
int err;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-06-27 20:41:57 +08:00
|
|
|
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
|
2008-03-04 07:01:05 +08:00
|
|
|
switch (dir) {
|
2005-04-17 06:20:36 +08:00
|
|
|
case load:
|
2008-03-04 07:01:05 +08:00
|
|
|
err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
|
|
|
|
regs),
|
|
|
|
size, (unsigned long *) addr,
|
|
|
|
decode_signedness(insn));
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case store:
|
2008-03-04 07:01:05 +08:00
|
|
|
err = do_int_store(((insn>>25)&0x1f), size,
|
|
|
|
(unsigned long *) addr, regs);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
panic("Impossible kernel unaligned trap.");
|
|
|
|
/* Not reached... */
|
|
|
|
}
|
2008-03-04 07:01:05 +08:00
|
|
|
if (err)
|
|
|
|
kernel_mna_trap_fault(regs, insn);
|
|
|
|
else
|
|
|
|
advance(regs);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ok_for_user(struct pt_regs *regs, unsigned int insn,
|
|
|
|
enum direction dir)
|
|
|
|
{
|
|
|
|
unsigned int reg;
|
|
|
|
int size = ((insn >> 19) & 3) == 3 ? 8 : 4;
|
|
|
|
|
|
|
|
if ((regs->pc | regs->npc) & 3)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Must access_ok() in all the necessary places. */
|
|
|
|
#define WINREG_ADDR(regnum) \
|
|
|
|
((void __user *)(((unsigned long *)regs->u_regs[UREG_FP])+(regnum)))
|
|
|
|
|
|
|
|
reg = (insn >> 25) & 0x1f;
|
|
|
|
if (reg >= 16) {
|
Remove 'type' argument from access_ok() function
Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
of the user address range verification function since we got rid of the
old racy i386-only code to walk page tables by hand.
It existed because the original 80386 would not honor the write protect
bit when in kernel mode, so you had to do COW by hand before doing any
user access. But we haven't supported that in a long time, and these
days the 'type' argument is a purely historical artifact.
A discussion about extending 'user_access_begin()' to do the range
checking resulted this patch, because there is no way we're going to
move the old VERIFY_xyz interface to that model. And it's best done at
the end of the merge window when I've done most of my merges, so let's
just get this done once and for all.
This patch was mostly done with a sed-script, with manual fix-ups for
the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.
There were a couple of notable cases:
- csky still had the old "verify_area()" name as an alias.
- the iter_iov code had magical hardcoded knowledge of the actual
values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
really used it)
- microblaze used the type argument for a debug printout
but other than those oddities this should be a total no-op patch.
I tried to fix up all architectures, did fairly extensive grepping for
access_ok() uses, and the changes are trivial, but I may have missed
something. Any missed conversion should be trivially fixable, though.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 10:57:57 +08:00
|
|
|
if (!access_ok(WINREG_ADDR(reg - 16), size))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
reg = (insn >> 14) & 0x1f;
|
|
|
|
if (reg >= 16) {
|
Remove 'type' argument from access_ok() function
Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
of the user address range verification function since we got rid of the
old racy i386-only code to walk page tables by hand.
It existed because the original 80386 would not honor the write protect
bit when in kernel mode, so you had to do COW by hand before doing any
user access. But we haven't supported that in a long time, and these
days the 'type' argument is a purely historical artifact.
A discussion about extending 'user_access_begin()' to do the range
checking resulted this patch, because there is no way we're going to
move the old VERIFY_xyz interface to that model. And it's best done at
the end of the merge window when I've done most of my merges, so let's
just get this done once and for all.
This patch was mostly done with a sed-script, with manual fix-ups for
the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.
There were a couple of notable cases:
- csky still had the old "verify_area()" name as an alias.
- the iter_iov code had magical hardcoded knowledge of the actual
values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
really used it)
- microblaze used the type argument for a debug printout
but other than those oddities this should be a total no-op patch.
I tried to fix up all architectures, did fairly extensive grepping for
access_ok() uses, and the changes are trivial, but I may have missed
something. Any missed conversion should be trivially fixable, though.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 10:57:57 +08:00
|
|
|
if (!access_ok(WINREG_ADDR(reg - 16), size))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
if (!(insn & 0x2000)) {
|
|
|
|
reg = (insn & 0x1f);
|
|
|
|
if (reg >= 16) {
|
Remove 'type' argument from access_ok() function
Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
of the user address range verification function since we got rid of the
old racy i386-only code to walk page tables by hand.
It existed because the original 80386 would not honor the write protect
bit when in kernel mode, so you had to do COW by hand before doing any
user access. But we haven't supported that in a long time, and these
days the 'type' argument is a purely historical artifact.
A discussion about extending 'user_access_begin()' to do the range
checking resulted this patch, because there is no way we're going to
move the old VERIFY_xyz interface to that model. And it's best done at
the end of the merge window when I've done most of my merges, so let's
just get this done once and for all.
This patch was mostly done with a sed-script, with manual fix-ups for
the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.
There were a couple of notable cases:
- csky still had the old "verify_area()" name as an alias.
- the iter_iov code had magical hardcoded knowledge of the actual
values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
really used it)
- microblaze used the type argument for a debug printout
but other than those oddities this should be a total no-op patch.
I tried to fix up all architectures, did fairly extensive grepping for
access_ok() uses, and the changes are trivial, but I may have missed
something. Any missed conversion should be trivially fixable, though.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 10:57:57 +08:00
|
|
|
if (!access_ok(WINREG_ADDR(reg - 16), size))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#undef WINREG_ADDR
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-03-04 07:01:05 +08:00
|
|
|
static void user_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2018-04-20 05:57:48 +08:00
|
|
|
send_sig_fault(SIGBUS, BUS_ADRALN,
|
|
|
|
(void __user *)safe_compute_effective_address(regs, insn),
|
|
|
|
0, current);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)
|
|
|
|
{
|
|
|
|
enum direction dir;
|
|
|
|
|
|
|
|
if(!(current->thread.flags & SPARC_FLAG_UNALIGNED) ||
|
|
|
|
(((insn >> 30) & 3) != 3))
|
|
|
|
goto kill_user;
|
|
|
|
dir = decode_direction(insn);
|
|
|
|
if(!ok_for_user(regs, insn, dir)) {
|
|
|
|
goto kill_user;
|
|
|
|
} else {
|
2008-03-04 07:01:05 +08:00
|
|
|
int err, size = decode_access_size(insn);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long addr;
|
|
|
|
|
|
|
|
if(floating_point_load_or_store_p(insn)) {
|
|
|
|
printk("User FPU load/store unaligned unsupported.\n");
|
|
|
|
goto kill_user;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = compute_effective_address(regs, insn);
|
2011-06-27 20:41:57 +08:00
|
|
|
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
|
2005-04-17 06:20:36 +08:00
|
|
|
switch(dir) {
|
|
|
|
case load:
|
2008-03-04 07:01:05 +08:00
|
|
|
err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
|
|
|
|
regs),
|
|
|
|
size, (unsigned long *) addr,
|
|
|
|
decode_signedness(insn));
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case store:
|
2008-03-04 07:01:05 +08:00
|
|
|
err = do_int_store(((insn>>25)&0x1f), size,
|
|
|
|
(unsigned long *) addr, regs);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case both:
|
|
|
|
/*
|
|
|
|
* This was supported in 2.4. However, we question
|
|
|
|
* the value of SWAP instruction across word boundaries.
|
|
|
|
*/
|
|
|
|
printk("Unaligned SWAP unsupported.\n");
|
2008-03-04 07:01:05 +08:00
|
|
|
err = -EFAULT;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unaligned_panic("Impossible user unaligned trap.");
|
|
|
|
goto out;
|
|
|
|
}
|
2008-03-04 07:01:05 +08:00
|
|
|
if (err)
|
|
|
|
goto kill_user;
|
|
|
|
else
|
|
|
|
advance(regs);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
kill_user:
|
|
|
|
user_mna_trap_fault(regs, insn);
|
|
|
|
out:
|
2010-09-09 11:57:59 +08:00
|
|
|
;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|