Release 4.14 arch/um/kernel/skas/uaccess.c
/*
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
* Licensed under the GPL
*/
#include <linux/err.h>
#include <linux/highmem.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <asm/current.h>
#include <asm/page.h>
#include <asm/pgtable.h>
#include <kern_util.h>
#include <os.h>
pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr)
{
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
if (mm == NULL)
return NULL;
pgd = pgd_offset(mm, addr);
if (!pgd_present(*pgd))
return NULL;
pud = pud_offset(pgd, addr);
if (!pud_present(*pud))
return NULL;
pmd = pmd_offset(pud, addr);
if (!pmd_present(*pmd))
return NULL;
return pte_offset_kernel(pmd, addr);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 98 | 91.59% | 2 | 66.67% |
Paolo 'Blaisorblade' Giarrusso | 9 | 8.41% | 1 | 33.33% |
Total | 107 | 100.00% | 3 | 100.00% |
static pte_t *maybe_map(unsigned long virt, int is_write)
{
pte_t *pte = virt_to_pte(current->mm, virt);
int err, dummy_code;
if ((pte == NULL) || !pte_present(*pte) ||
(is_write && !pte_write(*pte))) {
err = handle_page_fault(virt, 0, is_write, 1, &dummy_code);
if (err)
return NULL;
pte = virt_to_pte(current->mm, virt);
}
if (!pte_present(*pte))
pte = NULL;
return pte;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 72 | 65.45% | 2 | 50.00% |
Jeff Dike | 38 | 34.55% | 2 | 50.00% |
Total | 110 | 100.00% | 4 | 100.00% |
static int do_op_one_page(unsigned long addr, int len, int is_write,
int (*op)(unsigned long addr, int len, void *arg), void *arg)
{
jmp_buf buf;
struct page *page;
pte_t *pte;
int n, faulted;
pte = maybe_map(addr, is_write);
if (pte == NULL)
return -1;
page = pte_page(*pte);
addr = (unsigned long) kmap_atomic(page) +
(addr & ~PAGE_MASK);
current->thread.fault_catcher = &buf;
faulted = UML_SETJMP(&buf);
if (faulted == 0)
n = (*op)(addr, len, arg);
else
n = -1;
current->thread.fault_catcher = NULL;
kunmap_atomic((void *)addr);
return n;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 106 | 65.03% | 2 | 40.00% |
Jeff Dike | 52 | 31.90% | 2 | 40.00% |
Cesar Eduardo Barros | 5 | 3.07% | 1 | 20.00% |
Total | 163 | 100.00% | 5 | 100.00% |
static long buffer_op(unsigned long addr, int len, int is_write,
int (*op)(unsigned long, int, void *), void *arg)
{
long size, remain, n;
size = min(PAGE_ALIGN(addr) - addr, (unsigned long) len);
remain = len;
n = do_op_one_page(addr, size, is_write, op, arg);
if (n != 0) {
remain = (n < 0 ? remain : 0);
goto out;
}
addr += size;
remain -= size;
if (remain == 0)
goto out;
while (addr < ((addr + remain) & PAGE_MASK)) {
n = do_op_one_page(addr, PAGE_SIZE, is_write, op, arg);
if (n != 0) {
remain = (n < 0 ? remain : 0);
goto out;
}
addr += PAGE_SIZE;
remain -= PAGE_SIZE;
}
if (remain == 0)
goto out;
n = do_op_one_page(addr, remain, is_write, op, arg);
if (n != 0) {
remain = (n < 0 ? remain : 0);
goto out;
}
return 0;
out:
return remain;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 158 | 66.95% | 2 | 33.33% |
Jeff Dike | 48 | 20.34% | 2 | 33.33% |
Bodo Stroesser | 28 | 11.86% | 1 | 16.67% |
Richard Weinberger | 2 | 0.85% | 1 | 16.67% |
Total | 236 | 100.00% | 6 | 100.00% |
static int copy_chunk_from_user(unsigned long from, int len, void *arg)
{
unsigned long *to_ptr = arg, to = *to_ptr;
memcpy((void *) to, (void *) from, len);
*to_ptr += len;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 54 | 100.00% | 1 | 100.00% |
Total | 54 | 100.00% | 1 | 100.00% |
unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{
if (uaccess_kernel()) {
memcpy(to, (__force void*)from, n);
return 0;
}
return buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 51 | 80.95% | 1 | 20.00% |
Jeff Dike | 6 | 9.52% | 1 | 20.00% |
Al Viro | 3 | 4.76% | 2 | 40.00% |
Richard Weinberger | 3 | 4.76% | 1 | 20.00% |
Total | 63 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL(raw_copy_from_user);
static int copy_chunk_to_user(unsigned long to, int len, void *arg)
{
unsigned long *from_ptr = arg, from = *from_ptr;
memcpy((void *) to, (void *) from, len);
*from_ptr += len;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 54 | 100.00% | 1 | 100.00% |
Total | 54 | 100.00% | 1 | 100.00% |
unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{
if (uaccess_kernel()) {
memcpy((__force void *) to, from, n);
return 0;
}
return buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 51 | 80.95% | 1 | 20.00% |
Jeff Dike | 6 | 9.52% | 1 | 20.00% |
Al Viro | 3 | 4.76% | 2 | 40.00% |
Richard Weinberger | 3 | 4.76% | 1 | 20.00% |
Total | 63 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL(raw_copy_to_user);
static int strncpy_chunk_from_user(unsigned long from, int len, void *arg)
{
char **to_ptr = arg, *to = *to_ptr;
int n;
strncpy(to, (void *) from, len);
n = strnlen(to, len);
*to_ptr += n;
if (n < len)
return 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 72 | 100.00% | 1 | 100.00% |
Total | 72 | 100.00% | 1 | 100.00% |
long __strncpy_from_user(char *dst, const char __user *src, long count)
{
long n;
char *ptr = dst;
if (uaccess_kernel()) {
strncpy(dst, (__force void *) src, count);
return strnlen(dst, count);
}
n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user,
&ptr);
if (n != 0)
return -EFAULT;
return strnlen(dst, count);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 83 | 88.30% | 1 | 25.00% |
Jeff Dike | 6 | 6.38% | 1 | 25.00% |
Richard Weinberger | 4 | 4.26% | 1 | 25.00% |
Al Viro | 1 | 1.06% | 1 | 25.00% |
Total | 94 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL(__strncpy_from_user);
static int clear_chunk(unsigned long addr, int len, void *unused)
{
memset((void *) addr, 0, len);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 33 | 100.00% | 1 | 100.00% |
Total | 33 | 100.00% | 1 | 100.00% |
unsigned long __clear_user(void __user *mem, unsigned long len)
{
if (uaccess_kernel()) {
memset((__force void*)mem, 0, len);
return 0;
}
return buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 47 | 82.46% | 1 | 20.00% |
Jeff Dike | 7 | 12.28% | 2 | 40.00% |
Richard Weinberger | 2 | 3.51% | 1 | 20.00% |
Al Viro | 1 | 1.75% | 1 | 20.00% |
Total | 57 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL(__clear_user);
static int strnlen_chunk(unsigned long str, int len, void *arg)
{
int *len_ptr = arg, n;
n = strnlen((void *) str, len);
*len_ptr += n;
if (n < len)
return 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 55 | 100.00% | 1 | 100.00% |
Total | 55 | 100.00% | 1 | 100.00% |
long __strnlen_user(const void __user *str, long len)
{
int count = 0, n;
if (uaccess_kernel())
return strnlen((__force char*)str, len) + 1;
n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
if (n == 0)
return count + 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 64 | 85.33% | 1 | 20.00% |
Jeff Dike | 6 | 8.00% | 1 | 20.00% |
Richard Weinberger | 4 | 5.33% | 2 | 40.00% |
Al Viro | 1 | 1.33% | 1 | 20.00% |
Total | 75 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL(__strnlen_user);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 923 | 71.44% | 4 | 19.05% |
Jeff Dike | 279 | 21.59% | 9 | 42.86% |
Al Viro | 36 | 2.79% | 4 | 19.05% |
Bodo Stroesser | 28 | 2.17% | 1 | 4.76% |
Richard Weinberger | 21 | 1.63% | 2 | 9.52% |
Cesar Eduardo Barros | 5 | 0.39% | 1 | 4.76% |
Total | 1292 | 100.00% | 21 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.