All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Fedor Sakharov <teo.montekki@gmail.com>
Cc: selinux@tycho.nsa.gov
Subject: Re: dynamic context transitions from kernel space
Date: Wed, 15 Apr 2009 08:59:17 -0400	[thread overview]
Message-ID: <1239800357.27560.32.camel@localhost.localdomain> (raw)
In-Reply-To: <49E5BB6A.5090505@gmail.com>

On Wed, 2009-04-15 at 14:48 +0400, Fedor Sakharov wrote:
> Hello,
> 
> Is it possible to somehow use the setcon() from the kernel space? Or is 
> there any other way of changing the current context of the process from 
> kernel? I need this for building a module that would monitor the 
> execution of app and switch it's rights depending on the current branch 
> of code being executed.

setcon(3) is a libselinux function that just writes the context string
to /proc/self/attr/current.  Within the kernel, the proc filesystem
invokes the security_setprocattr() LSM hook interface, which then calls
selinux_setprocattr() if SELinux is enabled.

I doubt you want to just call security_setprocattr() though.  You may
wish to look at the example of cachefiles and how it overrides
credentials.

-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

      reply	other threads:[~2009-04-15 12:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-15 10:48 dynamic context transitions from kernel space Fedor Sakharov
2009-04-15 12:59 ` Stephen Smalley [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=1239800357.27560.32.camel@localhost.localdomain \
    --to=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=teo.montekki@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 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.