All of lore.kernel.org
 help / color / mirror / Atom feed
From: FabF <fabian.frederick@skynet.be>
To: Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: question about /proc/<PID>/mem in 2.4
Date: Mon, 05 Jul 2004 16:25:23 +0200	[thread overview]
Message-ID: <1089037523.2129.15.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44.0407051518300.18740-100000@localhost.localdomain>

On Mon, 2004-07-05 at 16:22, Tigran Aivazian wrote:
> On Mon, 5 Jul 2004, FabF wrote:
> > > I noticed that in 2.4.x kernels the fs/proc/base.c:mem_read() function has 
> > > this permission check:
> > > 
> > >         if (!MAY_PTRACE(task) || !may_ptrace_attach(task))
> > >                 return -ESRCH;
> > > 
> > > Are you sure it shouldn't be like this instead:
> > > 
> > >         if (!MAY_PTRACE(task) && !may_ptrace_attach(task))
> > >                 return -ESRCH;
> > > 
> > > Because, normally MAY_PTRACE() is 0 (i.e. for any process worth looking at :)
> > > so may_ptrace_attach() is never even called.
> > > 
> > MAY_PTRACE is 1 normally AFAICS.The check as it stands wants both to
> > have non zero returns so is more restrictive than the one you're asking
> > for.
> 
> MAY_PTRACE is defined as:
> 
> #define MAY_PTRACE(task) \
>         (task == current || \
>         (task->parent == current && \
>         (task->ptrace & PT_PTRACED) && task->state == TASK_STOPPED))
> 
> so, if a process (current) is interested in another process (task) which
> is not itself and not one of its children then MAY_PTRACE is 0. and the
> test in mem_read() immediately returns ESRCH error without checking
> may_ptrace_attach() at all. I questioned this behaviour as being too
> restrictive and would like to know the reason for it.
> 
> Surely, the super user (i.e. CAP_SYS_PTRACE in this context) should be 
> allowed to read any process' memory without having to do the 
> PTRACE_ATTACH/PTRACE_PEEKUSER kind of thing which strace(8) is doing?

FYI may_ptrace_attach plugged somewhere between 2.4.21 & 22.This one get
used as is (ie without MAY_PTRACE) in proc_pid_environ but dunno about
reason why CAP_SYS_PTRACE isn't authoritative elsewhere.

Regards,
FabF



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


  reply	other threads:[~2004-07-05 14:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-05 13:27 question about /proc/<PID>/mem in 2.4 Tigran Aivazian
2004-07-05 13:37 ` FabF
2004-07-05 14:22   ` Tigran Aivazian
2004-07-05 14:25     ` FabF [this message]
2004-07-06 11:14       ` Tigran Aivazian
2004-07-06 10:49         ` Arjan van de Ven
2004-07-06 11:35           ` Tigran Aivazian
2004-07-06 11:04         ` Marcelo Tosatti
2004-07-06 13:08           ` Tigran Aivazian
2004-07-06 16:31             ` Alan Cox
2004-07-07 13:53               ` Tigran Aivazian
2004-07-07 13:26                 ` Tigran Aivazian
2004-07-07 16:21                   ` Daniel Jacobowitz
2004-07-07 16:13                 ` Alan Cox

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=1089037523.2129.15.camel@localhost.localdomain \
    --to=fabian.frederick@skynet.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tigran@aivazian.fsnet.co.uk \
    /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 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.