diff options
-rw-r--r-- | fs/proc/base.c | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index ff9c131e6b30..3c41149dea88 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -660,7 +660,6 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf, | |||
660 | char buffer[PROC_NUMBUF]; | 660 | char buffer[PROC_NUMBUF]; |
661 | size_t len; | 661 | size_t len; |
662 | int oom_adjust; | 662 | int oom_adjust; |
663 | loff_t __ppos = *ppos; | ||
664 | 663 | ||
665 | if (!task) | 664 | if (!task) |
666 | return -ESRCH; | 665 | return -ESRCH; |
@@ -668,14 +667,8 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf, | |||
668 | put_task_struct(task); | 667 | put_task_struct(task); |
669 | 668 | ||
670 | len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust); | 669 | len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust); |
671 | if (__ppos >= len) | 670 | |
672 | return 0; | 671 | return simple_read_from_buffer(buf, count, ppos, buffer, len); |
673 | if (count > len-__ppos) | ||
674 | count = len-__ppos; | ||
675 | if (copy_to_user(buf, buffer + __ppos, count)) | ||
676 | return -EFAULT; | ||
677 | *ppos = __ppos + count; | ||
678 | return count; | ||
679 | } | 672 | } |
680 | 673 | ||
681 | static ssize_t oom_adjust_write(struct file *file, const char __user *buf, | 674 | static ssize_t oom_adjust_write(struct file *file, const char __user *buf, |
@@ -823,7 +816,6 @@ static ssize_t seccomp_read(struct file *file, char __user *buf, | |||
823 | { | 816 | { |
824 | struct task_struct *tsk = get_proc_task(file->f_dentry->d_inode); | 817 | struct task_struct *tsk = get_proc_task(file->f_dentry->d_inode); |
825 | char __buf[20]; | 818 | char __buf[20]; |
826 | loff_t __ppos = *ppos; | ||
827 | size_t len; | 819 | size_t len; |
828 | 820 | ||
829 | if (!tsk) | 821 | if (!tsk) |
@@ -831,14 +823,8 @@ static ssize_t seccomp_read(struct file *file, char __user *buf, | |||
831 | /* no need to print the trailing zero, so use only len */ | 823 | /* no need to print the trailing zero, so use only len */ |
832 | len = sprintf(__buf, "%u\n", tsk->seccomp.mode); | 824 | len = sprintf(__buf, "%u\n", tsk->seccomp.mode); |
833 | put_task_struct(tsk); | 825 | put_task_struct(tsk); |
834 | if (__ppos >= len) | 826 | |
835 | return 0; | 827 | return simple_read_from_buffer(buf, count, ppos, __buf, len); |
836 | if (count > len - __ppos) | ||
837 | count = len - __ppos; | ||
838 | if (copy_to_user(buf, __buf + __ppos, count)) | ||
839 | return -EFAULT; | ||
840 | *ppos = __ppos + count; | ||
841 | return count; | ||
842 | } | 828 | } |
843 | 829 | ||
844 | static ssize_t seccomp_write(struct file *file, const char __user *buf, | 830 | static ssize_t seccomp_write(struct file *file, const char __user *buf, |
@@ -897,7 +883,6 @@ static ssize_t proc_fault_inject_read(struct file * file, char __user * buf, | |||
897 | char buffer[PROC_NUMBUF]; | 883 | char buffer[PROC_NUMBUF]; |
898 | size_t len; | 884 | size_t len; |
899 | int make_it_fail; | 885 | int make_it_fail; |
900 | loff_t __ppos = *ppos; | ||
901 | 886 | ||
902 | if (!task) | 887 | if (!task) |
903 | return -ESRCH; | 888 | return -ESRCH; |
@@ -905,14 +890,8 @@ static ssize_t proc_fault_inject_read(struct file * file, char __user * buf, | |||
905 | put_task_struct(task); | 890 | put_task_struct(task); |
906 | 891 | ||
907 | len = snprintf(buffer, sizeof(buffer), "%i\n", make_it_fail); | 892 | len = snprintf(buffer, sizeof(buffer), "%i\n", make_it_fail); |
908 | if (__ppos >= len) | 893 | |
909 | return 0; | 894 | return simple_read_from_buffer(buf, count, ppos, buffer, len); |
910 | if (count > len-__ppos) | ||
911 | count = len-__ppos; | ||
912 | if (copy_to_user(buf, buffer + __ppos, count)) | ||
913 | return -EFAULT; | ||
914 | *ppos = __ppos + count; | ||
915 | return count; | ||
916 | } | 895 | } |
917 | 896 | ||
918 | static ssize_t proc_fault_inject_write(struct file * file, | 897 | static ssize_t proc_fault_inject_write(struct file * file, |
@@ -975,7 +954,7 @@ static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt, | |||
975 | 954 | ||
976 | if (!tmp) | 955 | if (!tmp) |
977 | return -ENOMEM; | 956 | return -ENOMEM; |
978 | 957 | ||
979 | inode = dentry->d_inode; | 958 | inode = dentry->d_inode; |
980 | path = d_path(dentry, mnt, tmp, PAGE_SIZE); | 959 | path = d_path(dentry, mnt, tmp, PAGE_SIZE); |
981 | len = PTR_ERR(path); | 960 | len = PTR_ERR(path); |