linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ole Bjorn Hessen <obh@telenor.net>
To: linux-c-programming@vger.kernel.org
Subject: Re: strace -p <pid> EPERM after root process changed uid/gid to non-root user
Date: Mon, 08 Oct 2012 12:43:02 +0200	[thread overview]
Message-ID: <v5y5jhxmef.fsf@shell02.nsc.no> (raw)
In-Reply-To: <v5626yi0v3.fsf@shell02.nsc.no>



Hi,

I got an email from Celelibi pointing me in the right direction
(thanks!).

It seems like that it is neccessary to use prctl(PR_SET_DUMPABLE, 1) to
let strace -p to work. The dumpable flag is cleared in some setuid
situations.

Linux requires that real uid of strace process matches all of real uid,
effective uid and saved uid and the real gid must match the real gid,
effective gid and saved gid. And the dumpable flag must be set.


--

#include <sys/types.h>
#include <unistd.h>
#include <sys/prctl.h>

#define UID 9
#define GID 13
int main(int argc, char **argv) {
    setresgid(GID, GID, GID);
    setresuid(UID, UID, UID);
    prctl(PR_SET_DUMPABLE, 1);
    while (1) {
        sleep(1);
        write(1, "hello\n", 6);
    }
 return 1;
}


Kind regards
Ole Bjorn Hessen.
Telenor

      reply	other threads:[~2012-10-08 10:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-28 16:11 strace -p <pid> EPERM after root process changed uid/gid to non-root user Ole Bjorn Hessen
2012-10-08 10:43 ` Ole Bjorn Hessen [this message]

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=v5y5jhxmef.fsf@shell02.nsc.no \
    --to=obh@telenor.net \
    --cc=linux-c-programming@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).