diff options
| author | John W. Linville <linville@tuxdriver.com> | 2012-09-07 15:07:55 -0400 | 
|---|---|---|
| committer | John W. Linville <linville@tuxdriver.com> | 2012-09-07 15:07:55 -0400 | 
| commit | fac805f8c198092de9a2842efd7f5022e2937b18 (patch) | |
| tree | 7557809c373f97a343c427d8fded0696060394ce /fs/proc/base.c | |
| parent | 2461c7d60f9f3821274e4acf9019cba8b82c94b5 (diff) | |
| parent | f10723841e624c0726c70356b31d91befed01dd6 (diff) | |
| download | olio-linux-3.10-fac805f8c198092de9a2842efd7f5022e2937b18.tar.xz olio-linux-3.10-fac805f8c198092de9a2842efd7f5022e2937b18.zip  | |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless
Diffstat (limited to 'fs/proc/base.c')
| -rw-r--r-- | fs/proc/base.c | 22 | 
1 files changed, 13 insertions, 9 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 2772208338f..1b6c84cbdb7 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -695,8 +695,6 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)  		mmput(mm);  	} -	/* OK to pass negative loff_t, we can catch out-of-range */ -	file->f_mode |= FMODE_UNSIGNED_OFFSET;  	file->private_data = mm;  	return 0; @@ -704,7 +702,12 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)  static int mem_open(struct inode *inode, struct file *file)  { -	return __mem_open(inode, file, PTRACE_MODE_ATTACH); +	int ret = __mem_open(inode, file, PTRACE_MODE_ATTACH); + +	/* OK to pass negative loff_t, we can catch out-of-range */ +	file->f_mode |= FMODE_UNSIGNED_OFFSET; + +	return ret;  }  static ssize_t mem_rw(struct file *file, char __user *buf, @@ -827,15 +830,16 @@ static ssize_t environ_read(struct file *file, char __user *buf,  	if (!atomic_inc_not_zero(&mm->mm_users))  		goto free;  	while (count > 0) { -		int this_len, retval, max_len; - -		this_len = mm->env_end - (mm->env_start + src); +		size_t this_len, max_len; +		int retval; -		if (this_len <= 0) +		if (src >= (mm->env_end - mm->env_start))  			break; -		max_len = (count > PAGE_SIZE) ? PAGE_SIZE : count; -		this_len = (this_len > max_len) ? max_len : this_len; +		this_len = mm->env_end - (mm->env_start + src); + +		max_len = min_t(size_t, PAGE_SIZE, count); +		this_len = min(max_len, this_len);  		retval = access_remote_vm(mm, (mm->env_start + src),  			page, this_len, 0);  |