diff options
Diffstat (limited to 'fs/proc/base.c')
| -rw-r--r-- | fs/proc/base.c | 118 | 
1 files changed, 36 insertions, 82 deletions
| diff --git a/fs/proc/base.c b/fs/proc/base.c index dfa532730e5..8a84210ca08 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -83,6 +83,9 @@  #include <linux/pid_namespace.h>  #include <linux/fs_struct.h>  #include <linux/slab.h> +#ifdef CONFIG_HARDWALL +#include <asm/hardwall.h> +#endif  #include "internal.h"  /* NOTE: @@ -600,7 +603,7 @@ static int proc_fd_access_allowed(struct inode *inode)  	return allowed;  } -static int proc_setattr(struct dentry *dentry, struct iattr *attr) +int proc_setattr(struct dentry *dentry, struct iattr *attr)  {  	int error;  	struct inode *inode = dentry->d_inode; @@ -894,20 +897,20 @@ static ssize_t mem_write(struct file * file, const char __user *buf,  	if (!task)  		goto out_no_task; +	copied = -ENOMEM; +	page = (char *)__get_free_page(GFP_TEMPORARY); +	if (!page) +		goto out_task; +  	mm = check_mem_permission(task);  	copied = PTR_ERR(mm);  	if (IS_ERR(mm)) -		goto out_task; +		goto out_free;  	copied = -EIO;  	if (file->private_data != (void *)((long)current->self_exec_id))  		goto out_mm; -	copied = -ENOMEM; -	page = (char *)__get_free_page(GFP_TEMPORARY); -	if (!page) -		goto out_mm; -  	copied = 0;  	while (count > 0) {  		int this_len, retval; @@ -929,9 +932,11 @@ static ssize_t mem_write(struct file * file, const char __user *buf,  		count -= retval;			  	}  	*ppos = dst; -	free_page((unsigned long) page); +  out_mm:  	mmput(mm); +out_free: +	free_page((unsigned long) page);  out_task:  	put_task_struct(task);  out_no_task: @@ -1059,7 +1064,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,  {  	struct task_struct *task;  	char buffer[PROC_NUMBUF]; -	long oom_adjust; +	int oom_adjust;  	unsigned long flags;  	int err; @@ -1071,7 +1076,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,  		goto out;  	} -	err = strict_strtol(strstrip(buffer), 0, &oom_adjust); +	err = kstrtoint(strstrip(buffer), 0, &oom_adjust);  	if (err)  		goto out;  	if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) && @@ -1168,7 +1173,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,  	struct task_struct *task;  	char buffer[PROC_NUMBUF];  	unsigned long flags; -	long oom_score_adj; +	int oom_score_adj;  	int err;  	memset(buffer, 0, sizeof(buffer)); @@ -1179,7 +1184,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,  		goto out;  	} -	err = strict_strtol(strstrip(buffer), 0, &oom_score_adj); +	err = kstrtoint(strstrip(buffer), 0, &oom_score_adj);  	if (err)  		goto out;  	if (oom_score_adj < OOM_SCORE_ADJ_MIN || @@ -1468,7 +1473,7 @@ sched_autogroup_write(struct file *file, const char __user *buf,  	struct inode *inode = file->f_path.dentry->d_inode;  	struct task_struct *p;  	char buffer[PROC_NUMBUF]; -	long nice; +	int nice;  	int err;  	memset(buffer, 0, sizeof(buffer)); @@ -1477,9 +1482,9 @@ sched_autogroup_write(struct file *file, const char __user *buf,  	if (copy_from_user(buffer, buf, count))  		return -EFAULT; -	err = strict_strtol(strstrip(buffer), 0, &nice); -	if (err) -		return -EINVAL; +	err = kstrtoint(strstrip(buffer), 0, &nice); +	if (err < 0) +		return err;  	p = get_proc_task(inode);  	if (!p) @@ -1576,57 +1581,6 @@ static const struct file_operations proc_pid_set_comm_operations = {  	.release	= single_release,  }; -/* - * We added or removed a vma mapping the executable. The vmas are only mapped - * during exec and are not mapped with the mmap system call. - * Callers must hold down_write() on the mm's mmap_sem for these - */ -void added_exe_file_vma(struct mm_struct *mm) -{ -	mm->num_exe_file_vmas++; -} - -void removed_exe_file_vma(struct mm_struct *mm) -{ -	mm->num_exe_file_vmas--; -	if ((mm->num_exe_file_vmas == 0) && mm->exe_file){ -		fput(mm->exe_file); -		mm->exe_file = NULL; -	} - -} - -void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file) -{ -	if (new_exe_file) -		get_file(new_exe_file); -	if (mm->exe_file) -		fput(mm->exe_file); -	mm->exe_file = new_exe_file; -	mm->num_exe_file_vmas = 0; -} - -struct file *get_mm_exe_file(struct mm_struct *mm) -{ -	struct file *exe_file; - -	/* We need mmap_sem to protect against races with removal of -	 * VM_EXECUTABLE vmas */ -	down_read(&mm->mmap_sem); -	exe_file = mm->exe_file; -	if (exe_file) -		get_file(exe_file); -	up_read(&mm->mmap_sem); -	return exe_file; -} - -void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm) -{ -	/* It's safe to write the exe_file pointer without exe_file_lock because -	 * this is called during fork when the task is not yet in /proc */ -	newmm->exe_file = get_mm_exe_file(oldmm); -} -  static int proc_exe_link(struct inode *inode, struct path *exe_path)  {  	struct task_struct *task; @@ -1736,8 +1690,7 @@ static int task_dumpable(struct task_struct *task)  	return 0;  } - -static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *task) +struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *task)  {  	struct inode * inode;  	struct proc_inode *ei; @@ -1779,7 +1732,7 @@ out_unlock:  	return NULL;  } -static int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) +int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)  {  	struct inode *inode = dentry->d_inode;  	struct task_struct *task; @@ -1820,7 +1773,7 @@ static int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat   * made this apply to all per process world readable and executable   * directories.   */ -static int pid_revalidate(struct dentry *dentry, struct nameidata *nd) +int pid_revalidate(struct dentry *dentry, struct nameidata *nd)  {  	struct inode *inode;  	struct task_struct *task; @@ -1862,7 +1815,7 @@ static int pid_delete_dentry(const struct dentry * dentry)  	return !proc_pid(dentry->d_inode)->tasks[PIDTYPE_PID].first;  } -static const struct dentry_operations pid_dentry_operations = +const struct dentry_operations pid_dentry_operations =  {  	.d_revalidate	= pid_revalidate,  	.d_delete	= pid_delete_dentry, @@ -1870,9 +1823,6 @@ static const struct dentry_operations pid_dentry_operations =  /* Lookups */ -typedef struct dentry *instantiate_t(struct inode *, struct dentry *, -				struct task_struct *, const void *); -  /*   * Fill a directory entry.   * @@ -1885,8 +1835,8 @@ typedef struct dentry *instantiate_t(struct inode *, struct dentry *,   * reported by readdir in sync with the inode numbers reported   * by stat.   */ -static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir, -	char *name, int len, +int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir, +	const char *name, int len,  	instantiate_t instantiate, struct task_struct *task, const void *ptr)  {  	struct dentry *child, *dir = filp->f_path.dentry; @@ -2219,11 +2169,7 @@ static const struct file_operations proc_fd_operations = {   */  static int proc_fd_permission(struct inode *inode, int mask, unsigned int flags)  { -	int rv; - -	if (flags & IPERM_FLAG_RCU) -		return -ECHILD; -	rv = generic_permission(inode, mask, flags, NULL); +	int rv = generic_permission(inode, mask, flags, NULL);  	if (rv == 0)  		return 0;  	if (task_pid(current) == proc_pid(inode)) @@ -2820,6 +2766,7 @@ static const struct pid_entry tgid_base_stuff[] = {  	DIR("task",       S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),  	DIR("fd",         S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),  	DIR("fdinfo",     S_IRUSR|S_IXUSR, proc_fdinfo_inode_operations, proc_fdinfo_operations), +	DIR("ns",	  S_IRUSR|S_IXUGO, proc_ns_dir_inode_operations, proc_ns_dir_operations),  #ifdef CONFIG_NET  	DIR("net",        S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),  #endif @@ -2894,6 +2841,9 @@ static const struct pid_entry tgid_base_stuff[] = {  #ifdef CONFIG_TASK_IO_ACCOUNTING  	INF("io",	S_IRUGO, proc_tgid_io_accounting),  #endif +#ifdef CONFIG_HARDWALL +	INF("hardwall",   S_IRUGO, proc_pid_hardwall), +#endif  };  static int proc_tgid_base_readdir(struct file * filp, @@ -3168,6 +3118,7 @@ out_no_task:  static const struct pid_entry tid_base_stuff[] = {  	DIR("fd",        S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),  	DIR("fdinfo",    S_IRUSR|S_IXUSR, proc_fdinfo_inode_operations, proc_fdinfo_operations), +	DIR("ns",	 S_IRUSR|S_IXUGO, proc_ns_dir_inode_operations, proc_ns_dir_operations),  	REG("environ",   S_IRUSR, proc_environ_operations),  	INF("auxv",      S_IRUSR, proc_pid_auxv),  	ONE("status",    S_IRUGO, proc_pid_status), @@ -3232,6 +3183,9 @@ static const struct pid_entry tid_base_stuff[] = {  #ifdef CONFIG_TASK_IO_ACCOUNTING  	INF("io",	S_IRUGO, proc_tid_io_accounting),  #endif +#ifdef CONFIG_HARDWALL +	INF("hardwall",   S_IRUGO, proc_pid_hardwall), +#endif  };  static int proc_tid_base_readdir(struct file * filp, | 
