diff options
-rw-r--r-- | fs/proc/base.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 2772208338f8..39ee093b5e96 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -827,15 +827,16 @@ static ssize_t environ_read(struct file *file, char __user *buf, | |||
827 | if (!atomic_inc_not_zero(&mm->mm_users)) | 827 | if (!atomic_inc_not_zero(&mm->mm_users)) |
828 | goto free; | 828 | goto free; |
829 | while (count > 0) { | 829 | while (count > 0) { |
830 | int this_len, retval, max_len; | 830 | size_t this_len, max_len; |
831 | int retval; | ||
831 | 832 | ||
832 | this_len = mm->env_end - (mm->env_start + src); | 833 | if (src >= (mm->env_end - mm->env_start)) |
833 | |||
834 | if (this_len <= 0) | ||
835 | break; | 834 | break; |
836 | 835 | ||
837 | max_len = (count > PAGE_SIZE) ? PAGE_SIZE : count; | 836 | this_len = mm->env_end - (mm->env_start + src); |
838 | this_len = (this_len > max_len) ? max_len : this_len; | 837 | |
838 | max_len = min_t(size_t, PAGE_SIZE, count); | ||
839 | this_len = min(max_len, this_len); | ||
839 | 840 | ||
840 | retval = access_remote_vm(mm, (mm->env_start + src), | 841 | retval = access_remote_vm(mm, (mm->env_start + src), |
841 | page, this_len, 0); | 842 | page, this_len, 0); |