Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Reynolds, Brandon" <brandon.reynolds@lmco.com>
To: pottmi@gmail.com
Cc: gdb@sourceware.org
Subject: Re: unable to attach to setuid program that as reverted it privilege
Date: Mon, 14 Apr 2008 13:46:00 -0000	[thread overview]
Message-ID: <7ADDA4869AFB444695CDD37859452D5773AED1@emss04m21.us.lmco.com> (raw)


I can't seem to get this to work.

I have a setuid executable with the following code:
-----------------------------------------------------------------------------
    /* keep root capabilities as we transition to the regular user */
    prctl( PR_SET_KEEPCAPS, 1, 0, 0, 0 );

    /* switch back to user that ran us */
    setuid( p->pw_uid );
    setgid( p->pw_gid );

    /* drop all privs except CAP_SYS_NICE */
    if (cap_set_proc((cap = cap_from_text( "CAP_SYS_NICE+pe" ))) < 0)
    {
        perror( "cap_set_proc: failed to drop privs, aborting" );
        exit( 1 );
    }
    cap_free(cap);
-----------------------------------------------------------------------------

> cat /proc/sys/kernel/suid_dumpable
2

> uname -a
Linux sgi2 2.6.16.46-0.12-default #1 SMP Thu May 17 14:00:09 UTC 2007 ia64 ia64 ia64 GNU/Linux

FYI, the man 5 proc says:

/proc/sys/fs/suid_dumpable (since Linux 2.6.13)
              The value in this file determines whether core dump files are produced for set-user-ID or otherâ
              wise protected/tainted binaries.  Three different integer values can be specified:

              0 (default) This provides the traditional (pre-Linux 2.6.13) behaviour.  A core dump will not be
              produced for a process which has changed credentials (by calling seteuid(2), setgid(2), or simiâ
              lar,  or  by executing a set-user-ID or set-group-ID program) or whose binary does not have read
              permission enabled.

              1 ("debug") All processes dump core when possible.  The core dump is owned by  the  file  system
              user  ID  of the dumping process and no security is applied.  This is intended for system debugâ
              ging situations only.  Ptrace is unchecked.

              2 ("suidsafe") Any binary which normally would not be dumped (see "0" above) is dumped  readable
              by  root only.  This allows the user to remove the core dump file but not to read it.  For secuâ
              rity reasons core dumps in this mode will not overwrite one another or other files.   This  mode
              is appropriate when administrators are attempting to debug problems in a normal environment.

> This is documented as allowing core files to be created for setuid
> programs.  What I am using it for is to allow gdb run as a non-root
> user to connect to setuid programs that have _permanently_ given up
> their root privilege.  Without suid_dumpable enabled, gdb will fail
> with a EPERM error even tho the target program is no longer running as
> root and can not reacquire root privilege ( a good default behavior ).

What did you mean by "_permanently_"?

-Brandon


             reply	other threads:[~2008-04-14 13:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-14 13:46 Reynolds, Brandon [this message]
2008-04-14 16:32 ` Michael Potter
2008-04-14 16:45 ` Tavis Ormandy
2008-04-15  1:02   ` Reynolds, Brandon
2008-04-15  1:24     ` Michael Potter
  -- strict thread matches above, loose matches on Subject: below --
2008-01-22 20:00 Michael Potter
2008-01-22 20:09 ` Daniel Jacobowitz
2008-01-22 20:24   ` Michael Potter
2008-01-23 17:52 ` Mark Kettenis
2008-01-23 18:48   ` Michael Potter
2008-01-23 20:26     ` Michael Potter
2008-01-23 20:42     ` Andreas Schwab
2008-01-24  5:05       ` Michael Potter
2008-01-24  9:18         ` Andreas Schwab

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=7ADDA4869AFB444695CDD37859452D5773AED1@emss04m21.us.lmco.com \
    --to=brandon.reynolds@lmco.com \
    --cc=gdb@sourceware.org \
    --cc=pottmi@gmail.com \
    /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