cregit-Linux how code gets into the kernel

Release 4.14 arch/parisc/kernel/sys_parisc.c

/*
 *    PARISC specific syscalls
 *
 *    Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org>
 *    Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org>
 *    Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org>
 *    Copyright (C) 1999-2014 Helge Deller <deller@gmx.de>
 *
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <linux/uaccess.h>
#include <asm/elf.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/linkage.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/sched/signal.h>
#include <linux/sched/mm.h>
#include <linux/shm.h>
#include <linux/syscalls.h>
#include <linux/utsname.h>
#include <linux/personality.h>
#include <linux/random.h>

/* we construct an artificial offset for the mapping based on the physical
 * address of the kernel mapping variable */

#define GET_LAST_MMAP(filp)		\
	(filp ? ((unsigned long) filp->f_mapping) >> 8 : 0UL)

#define SET_LAST_MMAP(filp, val)	\
	 { /* nothing */ }


static int get_offset(unsigned int last_mmap) { return (last_mmap & (SHM_COLOUR-1)) >> PAGE_SHIFT; }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller1147.83%250.00%
Matthew Wilcox1043.48%125.00%
Michel Lespinasse28.70%125.00%
Total23100.00%4100.00%


static unsigned long shared_align_offset(unsigned int last_mmap, unsigned long pgoff) { return (get_offset(last_mmap) + pgoff) << PAGE_SHIFT; }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller2385.19%250.00%
Matthew Wilcox27.41%125.00%
Linus Torvalds (pre-git)27.41%125.00%
Total27100.00%4100.00%


static inline unsigned long COLOR_ALIGN(unsigned long addr, unsigned int last_mmap, unsigned long pgoff) { unsigned long base = (addr+SHM_COLOUR-1) & ~(SHM_COLOUR-1); unsigned long off = (SHM_COLOUR-1) & (shared_align_offset(last_mmap, pgoff) << PAGE_SHIFT); return base + off; }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller4670.77%350.00%
Linus Torvalds (pre-git)1015.38%116.67%
Michel Lespinasse57.69%116.67%
Matthew Wilcox46.15%116.67%
Total65100.00%6100.00%

/* * Top of mmap area (just below the process stack). */
static unsigned long mmap_upper_limit(void) { unsigned long stack_base; /* Limit stack size - see setup_arg_pages() in fs/exec.c */ stack_base = rlimit_max(RLIMIT_STACK); if (stack_base > STACK_SIZE_MAX) stack_base = STACK_SIZE_MAX; /* Add space for stack randomization. */ stack_base += (STACK_RND_MASK << PAGE_SHIFT); return PAGE_ALIGN(STACK_TOP - stack_base); }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller4287.50%360.00%
Linus Torvalds (pre-git)48.33%120.00%
Michel Lespinasse24.17%120.00%
Total48100.00%5100.00%


unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { struct mm_struct *mm = current->mm; struct vm_area_struct *vma, *prev; unsigned long task_size = TASK_SIZE; int do_color_align, last_mmap; struct vm_unmapped_area_info info; if (len > task_size) return -ENOMEM; do_color_align = 0; if (filp || (flags & MAP_SHARED)) do_color_align = 1; last_mmap = GET_LAST_MMAP(filp); if (flags & MAP_FIXED) { if ((flags & MAP_SHARED) && last_mmap && (addr - shared_align_offset(last_mmap, pgoff)) & (SHM_COLOUR - 1)) return -EINVAL; goto found_addr; } if (addr) { if (do_color_align && last_mmap) addr = COLOR_ALIGN(addr, last_mmap, pgoff); else addr = PAGE_ALIGN(addr); vma = find_vma_prev(mm, addr, &prev); if (task_size - len >= addr && (!vma || addr + len <= vm_start_gap(vma)) && (!prev || addr >= vm_end_gap(prev))) goto found_addr; } info.flags = 0; info.length = len; info.low_limit = mm->mmap_legacy_base; info.high_limit = mmap_upper_limit(); info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0; info.align_offset = shared_align_offset(last_mmap, pgoff); addr = vm_unmapped_area(&info); found_addr: if (do_color_align && !last_mmap && !(addr & ~PAGE_MASK)) SET_LAST_MMAP(filp, addr - (pgoff << PAGE_SHIFT)); return addr; }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller22270.93%333.33%
Matthew Wilcox3410.86%222.22%
John David Anglin237.35%111.11%
Hugh Dickins227.03%111.11%
Benjamin Herrenschmidt61.92%111.11%
Linus Torvalds (pre-git)61.92%111.11%
Total313100.00%9100.00%


unsigned long arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, const unsigned long len, const unsigned long pgoff, const unsigned long flags) { struct vm_area_struct *vma, *prev; struct mm_struct *mm = current->mm; unsigned long addr = addr0; int do_color_align, last_mmap; struct vm_unmapped_area_info info; #ifdef CONFIG_64BIT /* This should only ever run for 32-bit processes. */ BUG_ON(!test_thread_flag(TIF_32BIT)); #endif /* requested length too big for entire address space */ if (len > TASK_SIZE) return -ENOMEM; do_color_align = 0; if (filp || (flags & MAP_SHARED)) do_color_align = 1; last_mmap = GET_LAST_MMAP(filp); if (flags & MAP_FIXED) { if ((flags & MAP_SHARED) && last_mmap && (addr - shared_align_offset(last_mmap, pgoff)) & (SHM_COLOUR - 1)) return -EINVAL; goto found_addr; } /* requesting a specific address */ if (addr) { if (do_color_align && last_mmap) addr = COLOR_ALIGN(addr, last_mmap, pgoff); else addr = PAGE_ALIGN(addr); vma = find_vma_prev(mm, addr, &prev); if (TASK_SIZE - len >= addr && (!vma || addr + len <= vm_start_gap(vma)) && (!prev || addr >= vm_end_gap(prev))) goto found_addr; } info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; info.low_limit = PAGE_SIZE; info.high_limit = mm->mmap_base; info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0; info.align_offset = shared_align_offset(last_mmap, pgoff); addr = vm_unmapped_area(&info); if (!(addr & ~PAGE_MASK)) goto found_addr; VM_BUG_ON(addr != -ENOMEM); /* * A failed mmap() very likely causes application failure, * so fall back to the bottom-up function here. This scenario * can happen with large stack limits and large mmap() * allocations. */ return arch_get_unmapped_area(filp, addr0, len, pgoff, flags); found_addr: if (do_color_align && !last_mmap && !(addr & ~PAGE_MASK)) SET_LAST_MMAP(filp, addr - (pgoff << PAGE_SHIFT)); return addr; }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller31785.91%337.50%
Matthew Wilcox297.86%337.50%
Hugh Dickins225.96%112.50%
Andrew Morton10.27%112.50%
Total369100.00%8100.00%


static int mmap_is_legacy(void) { if (current->personality & ADDR_COMPAT_LAYOUT) return 1; /* parisc stack always grows up - so a unlimited stack should * not be an indicator to use the legacy memory layout. * if (rlimit(RLIMIT_STACK) == RLIM_INFINITY) * return 1; */ return sysctl_legacy_va_layout; }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller2191.30%150.00%
Matthew Wilcox28.70%150.00%
Total23100.00%2100.00%


static unsigned long mmap_rnd(void) { unsigned long rnd = 0; if (current->flags & PF_RANDOMIZE) rnd = get_random_int() & MMAP_RND_MASK; return rnd << PAGE_SHIFT; }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller35100.00%2100.00%
Total35100.00%2100.00%


unsigned long arch_mmap_rnd(void) { return (get_random_int() & MMAP_RND_MASK) << PAGE_SHIFT; }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller18100.00%2100.00%
Total18100.00%2100.00%


static unsigned long mmap_legacy_base(void) { return TASK_UNMAPPED_BASE + mmap_rnd(); }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller15100.00%1100.00%
Total15100.00%1100.00%

/* * This function, called very early during the creation of a new * process VM image, sets up which VM layout function to use: */
void arch_pick_mmap_layout(struct mm_struct *mm) { mm->mmap_legacy_base = mmap_legacy_base(); mm->mmap_base = mmap_upper_limit(); if (mmap_is_legacy()) { mm->mmap_base = mm->mmap_legacy_base; mm->get_unmapped_area = arch_get_unmapped_area; } else { mm->get_unmapped_area = arch_get_unmapped_area_topdown; } }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller54100.00%1100.00%
Total54100.00%1100.00%


asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff) { /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE we have. */ return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT - 12)); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox5398.15%150.00%
Al Viro11.85%150.00%
Total54100.00%2100.00%


asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long offset) { if (!(offset & ~PAGE_MASK)) { return sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT); } else { return -EINVAL; } }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox6798.53%150.00%
Al Viro11.47%150.00%
Total68100.00%2100.00%

/* Fucking broken ABI */ #ifdef CONFIG_64BIT
asmlinkage long parisc_truncate64(const char __user * path, unsigned int high, unsigned int low) { return sys_truncate(path, (long)high << 32 | low); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox35100.00%3100.00%
Total35100.00%3100.00%


asmlinkage long parisc_ftruncate64(unsigned int fd, unsigned int high, unsigned int low) { return sys_ftruncate(fd, (long)high << 32 | low); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox33100.00%2100.00%
Total33100.00%2100.00%

/* stubs for the benefit of the syscall_table since truncate64 and truncate * are identical on LP64 */
asmlinkage long sys_truncate64(const char __user * path, unsigned long length) { return sys_truncate(path, length); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox24100.00%2100.00%
Total24100.00%2100.00%


asmlinkage long sys_ftruncate64(unsigned int fd, unsigned long length) { return sys_ftruncate(fd, length); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox22100.00%1100.00%
Total22100.00%1100.00%


asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg) { return sys_fcntl(fd, cmd, arg); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox28100.00%1100.00%
Total28100.00%1100.00%

#else
asmlinkage long parisc_truncate64(const char __user * path, unsigned int high, unsigned int low) { return sys_truncate64(path, (loff_t)high << 32 | low); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox35100.00%3100.00%
Total35100.00%3100.00%


asmlinkage long parisc_ftruncate64(unsigned int fd, unsigned int high, unsigned int low) { return sys_ftruncate64(fd, (loff_t)high << 32 | low); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox33100.00%2100.00%
Total33100.00%2100.00%

#endif
asmlinkage ssize_t parisc_pread64(unsigned int fd, char __user *buf, size_t count, unsigned int high, unsigned int low) { return sys_pread64(fd, buf, count, (loff_t)high << 32 | low); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox45100.00%2100.00%
Total45100.00%2100.00%


asmlinkage ssize_t parisc_pwrite64(unsigned int fd, const char __user *buf, size_t count, unsigned int high, unsigned int low) { return sys_pwrite64(fd, buf, count, (loff_t)high << 32 | low); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox46100.00%2100.00%
Total46100.00%2100.00%


asmlinkage ssize_t parisc_readahead(int fd, unsigned int high, unsigned int low, size_t count) { return sys_readahead(fd, (loff_t)high << 32 | low, count); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox37100.00%1100.00%
Total37100.00%1100.00%


asmlinkage long parisc_fadvise64_64(int fd, unsigned int high_off, unsigned int low_off, unsigned int high_len, unsigned int low_len, int advice) { return sys_fadvise64_64(fd, (loff_t)high_off << 32 | low_off, (loff_t)high_len << 32 | low_len, advice); }

Contributors

PersonTokensPropCommitsCommitProp
Matthew Wilcox54100.00%1100.00%
Total54100.00%1100.00%


asmlinkage long parisc_sync_file_range(int fd, u32 hi_off, u32 lo_off, u32 hi_nbytes, u32 lo_nbytes, unsigned int flags) { return sys_sync_file_range(fd, (loff_t)hi_off << 32 | lo_off, (loff_t)hi_nbytes << 32 | lo_nbytes, flags); }

Contributors

PersonTokensPropCommitsCommitProp
Kyle McMartin51100.00%1100.00%
Total51100.00%1100.00%


asmlinkage long parisc_fallocate(int fd, int mode, u32 offhi, u32 offlo, u32 lenhi, u32 lenlo) { return sys_fallocate(fd, mode, ((u64)offhi << 32) | offlo, ((u64)lenhi << 32) | lenlo); }

Contributors

PersonTokensPropCommitsCommitProp
Helge Deller54100.00%1100.00%
Total54100.00%1100.00%


long parisc_personality(unsigned long personality) { long err; if (personality(current->personality) == PER_LINUX32 && personality(personality) == PER_LINUX) personality = (personality & ~PER_MASK) | PER_LINUX32; err = sys_personality(personality); if (personality(err) == PER_LINUX32) err = (err & ~PER_MASK) | PER_LINUX; return err; }

Contributors

PersonTokensPropCommitsCommitProp
Kyle McMartin5171.83%150.00%
Jiri Kosina2028.17%150.00%
Total71100.00%2100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Helge Deller88850.60%724.14%
Matthew Wilcox60534.47%827.59%
Kyle McMartin1086.15%26.90%
Hugh Dickins442.51%13.45%
Linus Torvalds (pre-git)412.34%13.45%
John David Anglin231.31%13.45%
Jiri Kosina201.14%13.45%
Michel Lespinasse90.51%13.45%
Ingo Molnar60.34%26.90%
Benjamin Herrenschmidt60.34%13.45%
Andrew Morton20.11%26.90%
Al Viro20.11%13.45%
Linus Torvalds10.06%13.45%
Total1755100.00%29100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.