linux-um archives
 help / color / mirror / Atom feed
From: Blaisorblade <blaisorblade_spam@yahoo.it>
To: Michael Richardson <mcr@sandelman.ottawa.on.ca>
Cc: user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] mm->dumpable issue (was: Re: /proc/mm patches)
Date: Wed, 3 Nov 2004 17:18:54 +0100	[thread overview]
Message-ID: <200411031718.54774.blaisorblade_spam@yahoo.it> (raw)
In-Reply-To: <6343.1099436425@marajade.sandelman.ottawa.on.ca>

[-- Attachment #1: Type: text/plain, Size: 810 bytes --]

On Wednesday 03 November 2004 00:00, Michael Richardson wrote:
> Is there a final patch that you think might work, and deal with the
> mm->dumpable flag issue?

> I was all set to test the previous patch, but then you said not to...
On top of -V7 you can apply the attached patch. I'm almost sure it works. The 
problem is that I have not the certainty that it is not exploitable, i.e. it 
can be used to gain access to root privileges. I am almost sure it is not... 
but please *avoid* using a setuid UML binary with this patch (it is not a 
good idea, anyway, but it is even worse with this patch. I believe that to 
exploit it, if at all possible, having a setuid binary which is coded to use 
SKAS (either UML or a malicious program).

-- 
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729

[-- Attachment #2: fix-dumpable-handling.patch --]
[-- Type: text/x-diff, Size: 2018 bytes --]


From: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>, Henrik Nordstrom <uml@hno.marasystems.com>, Michael Richardson <mcr@sandelman.ottawa.on.ca>

When a child mm is created by opening /proc/mm, without this patch its
mm->dumpable flag is left set to 0, even when there is no reason to do so.

This way, for instance, if <pid> is the pid of a userspace thread,
/proc/<pid> is only readable by root (which was the original reason letting
this be diagnosed by Michael Richardson).

Paolo and Henrik discussed about this in detail, finally Paolo wrote the patch
and sent it for comment.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
---

 vanilla-linux-2.6.9-paolo/arch/i386/kernel/ptrace.c |    8 ++++++++
 vanilla-linux-2.6.9-paolo/mm/proc_mm.c              |    2 ++
 2 files changed, 10 insertions(+)

diff -puN mm/proc_mm.c~fix-dumpable-handling mm/proc_mm.c
--- vanilla-linux-2.6.9/mm/proc_mm.c~fix-dumpable-handling	2004-10-26 00:54:35.478864480 +0200
+++ vanilla-linux-2.6.9-paolo/mm/proc_mm.c	2004-10-26 00:54:35.482863872 +0200
@@ -126,6 +126,8 @@ static int open_proc_mm(struct inode *in
 
 	init_new_empty_context(mm);
 	arch_pick_mmap_layout(mm);
+	mm->dumpable = current->mm->dumpable;
+	wmb();
 
 	spin_lock(&mmlist_lock);
 	list_add(&mm->mmlist, &current->mm->mmlist);
diff -puN arch/i386/kernel/ptrace.c~fix-dumpable-handling arch/i386/kernel/ptrace.c
--- vanilla-linux-2.6.9/arch/i386/kernel/ptrace.c~fix-dumpable-handling	2004-10-26 00:54:35.480864176 +0200
+++ vanilla-linux-2.6.9-paolo/arch/i386/kernel/ptrace.c	2004-10-26 00:54:35.483863720 +0200
@@ -568,6 +568,14 @@ asmlinkage int sys_ptrace(long request, 
 			break;
 		}
 
+		/* Let's be safe. If we are ptraced from a non-dumpable process,
+		 * let's not be dumpable. Don't try to be smart and turn
+		 * current->dumpable to 1: it may be unsafe.*/
+		if (!current->dumpable) {
+			new->dumpable = 0;
+			wmb();
+		}
+
 		atomic_inc(&new->mm_users);
 		child->mm = new;
 		child->active_mm = new;
_

  parent reply	other threads:[~2004-11-03 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-22 17:29 [uml-devel] FAQ: 2.6.9 - why "make linux ARCH=um" fails? BlaisorBlade
     [not found] ` <6343.1099436425@marajade.sandelman.ottawa.on.ca>
2004-11-03 16:18   ` Blaisorblade [this message]
2004-11-20 19:58     ` [uml-devel] mm->dumpable issue (was: Re: /proc/mm patches) Michael Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200411031718.54774.blaisorblade_spam@yahoo.it \
    --to=blaisorblade_spam@yahoo.it \
    --cc=mcr@sandelman.ottawa.on.ca \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox