aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDjalal Harouni <tixxdz@opendz.org>2012-07-30 17:42:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 20:25:20 -0400
commitbc452b4b65bd589083a7a7ba4f14f85dfc8454fa (patch)
tree43e2d8031fea729f32f7800936d61fbc59fc7cdd
parente8905ec27e2f4ea1b9f7e03df68a060b3ae6fca8 (diff)
proc: do not allow negative offsets on /proc/<pid>/environ
__mem_open() which is called by both /proc/<pid>/environ and /proc/<pid>/mem ->open() handlers will allow the use of negative offsets. /proc/<pid>/mem has negative offsets but not /proc/<pid>/environ. Clean this by moving the 'force FMODE_UNSIGNED_OFFSET flag' to mem_open() to allow negative offsets only on /proc/<pid>/mem. Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Brad Spengler <spender@grsecurity.net> Acked-by: Kees Cook <keescook@chromium.org> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/proc/base.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 39ee093b5e96..1b6c84cbdb73 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)
695 mmput(mm); 695 mmput(mm);
696 } 696 }
697 697
698 /* OK to pass negative loff_t, we can catch out-of-range */
699 file->f_mode |= FMODE_UNSIGNED_OFFSET;
700 file->private_data = mm; 698 file->private_data = mm;
701 699
702 return 0; 700 return 0;
@@ -704,7 +702,12 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
704 702
705static int mem_open(struct inode *inode, struct file *file) 703static int mem_open(struct inode *inode, struct file *file)
706{ 704{
707 return __mem_open(inode, file, PTRACE_MODE_ATTACH); 705 int ret = __mem_open(inode, file, PTRACE_MODE_ATTACH);
706
707 /* OK to pass negative loff_t, we can catch out-of-range */
708 file->f_mode |= FMODE_UNSIGNED_OFFSET;
709
710 return ret;
708} 711}
709 712
710static ssize_t mem_rw(struct file *file, char __user *buf, 713static ssize_t mem_rw(struct file *file, char __user *buf,