All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] proc: return -EPERM when preventing read of /proc/*/maps
@ 2008-01-04 13:57 Guillaume Chazarain
  2008-01-04 14:14 ` Al Viro
  0 siblings, 1 reply; 6+ messages in thread
From: Guillaume Chazarain @ 2008-01-04 13:57 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Al Viro, linux-kernel

Return an error instead of successfully reading an empty file.

Signed-off-by: Guillaume Chazarain <guichaz@yahoo.fr>
Acked-by: Al Viro <viro@ZenIV.linux.org.uk>
---

 fs/proc/base.c       |    2 +-
 fs/proc/task_mmu.c   |    6 +++---
 fs/proc/task_nommu.c |    4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)


diff --git a/fs/proc/base.c b/fs/proc/base.c
index 7411bfb..3aebc85 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -219,7 +219,7 @@ out:
 	task_unlock(task);
 	up_read(&mm->mmap_sem);
 	mmput(mm);
-	return NULL;
+	return ERR_PTR(-EPERM);
 }
 
 static int proc_pid_cmdline(struct task_struct *task, char * buffer)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 8043a3e..74b4829 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -398,8 +398,8 @@ static void *m_start(struct seq_file *m, loff_t *pos)
 		return NULL;
 
 	mm = mm_for_maps(priv->task);
-	if (!mm)
-		return NULL;
+	if (IS_ERR(mm) || !mm)
+		return mm;
 
 	priv->tail_vma = tail_vma = get_gate_vma(priv->task);
 
@@ -437,7 +437,7 @@ out:
 
 static void vma_stop(struct proc_maps_private *priv, struct vm_area_struct *vma)
 {
-	if (vma && vma != priv->tail_vma) {
+	if (vma && !IS_ERR(vma) && vma != priv->tail_vma) {
 		struct mm_struct *mm = vma->vm_mm;
 		up_read(&mm->mmap_sem);
 		mmput(mm);
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 1932c2c..53cb062 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -166,10 +166,10 @@ static void *m_start(struct seq_file *m, loff_t *pos)
 		return NULL;
 
 	mm = mm_for_maps(priv->task);
-	if (!mm) {
+	if (IS_ERR(mm) || !mm) {
 		put_task_struct(priv->task);
 		priv->task = NULL;
-		return NULL;
+		return mm;
 	}
 
 	/* start from the Nth VMA */


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-03 18:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-04 13:57 [PATCH] proc: return -EPERM when preventing read of /proc/*/maps Guillaume Chazarain
2008-01-04 14:14 ` Al Viro
2008-01-04 14:35   ` Guillaume Chazarain
2008-01-04 15:19     ` Al Viro
2008-01-04 16:15       ` Guillaume Chazarain
2008-02-03 18:20       ` Guillaume Chazarain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.