lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sun, 17 Feb 2008 18:02:07 +0100 (CET)
From:	Jean-Marc Saffroy <saffroy@...il.com>
To:	linux-kernel@...r.kernel.org
cc:	Al Viro <viro@...iv.linux.org.uk>
Subject: [PATCH] return useful error when accessing /proc/<pid>/maps

Hello folks,

Access to /proc/<pid>/maps is now restricted to legitimate users, but 
read(2) simply returns 0 instead of a more explicit error. The patch below 
fixes this.

Signed-off-by: Jean-Marc Saffroy <saffroy@...il.com>

---

Index: linux-2.6.24.2/fs/proc/base.c
===================================================================
--- linux-2.6.24.2.orig/fs/proc/base.c	2008-02-17 16:43:49.000000000 +0100
+++ linux-2.6.24.2/fs/proc/base.c	2008-02-17 17:18:13.000000000 +0100
@@ -204,6 +204,7 @@

  struct mm_struct *mm_for_maps(struct task_struct *task)
  {
+	int rc = 0;
  	struct mm_struct *mm = get_task_mm(task);
  	if (!mm)
  		return NULL;
@@ -211,7 +212,7 @@
  	task_lock(task);
  	if (task->mm != mm)
  		goto out;
-	if (task->mm != current->mm && __ptrace_may_attach(task) < 0)
+	if (task->mm != current->mm && (rc = __ptrace_may_attach(task)) < 0)
  		goto out;
  	task_unlock(task);
  	return mm;
@@ -219,7 +220,7 @@
  	task_unlock(task);
  	up_read(&mm->mmap_sem);
  	mmput(mm);
-	return NULL;
+	return rc ? ERR_PTR(rc) : NULL;
  }

  static int proc_pid_cmdline(struct task_struct *task, char * buffer)
Index: linux-2.6.24.2/fs/proc/task_mmu.c
===================================================================
--- linux-2.6.24.2.orig/fs/proc/task_mmu.c	2008-02-17 16:43:49.000000000 +0100
+++ linux-2.6.24.2/fs/proc/task_mmu.c	2008-02-17 17:27:55.000000000 +0100
@@ -398,8 +398,8 @@
  		return NULL;

  	mm = mm_for_maps(priv->task);
-	if (!mm)
-		return NULL;
+	if (!mm || IS_ERR(mm))
+		return mm;

  	priv->tail_vma = tail_vma = get_gate_vma(priv->task);

@@ -437,7 +437,7 @@

  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);
Index: linux-2.6.24.2/fs/proc/task_nommu.c
===================================================================
--- linux-2.6.24.2.orig/fs/proc/task_nommu.c	2008-02-17 16:43:49.000000000 +0100
+++ linux-2.6.24.2/fs/proc/task_nommu.c	2008-02-17 17:18:13.000000000 +0100
@@ -166,10 +166,10 @@
  		return NULL;

  	mm = mm_for_maps(priv->task);
-	if (!mm) {
+	if (!mm || IS_ERR(mm)) {
  		put_task_struct(priv->task);
  		priv->task = NULL;
-		return NULL;
+		return mm;
  	}

  	/* start from the Nth VMA */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ