SELinux Security Module development
 help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: "Christian Göttsche" <cgzones@googlemail.com>, selinux@vger.kernel.org
Subject: Re: [PATCH 3/3] libselinux: do not use status page fallback mode internally
Date: Tue, 01 Jun 2021 16:13:27 +0200	[thread overview]
Message-ID: <87y2btllko.fsf@redhat.com> (raw)
In-Reply-To: <20210510105648.14635-4-cgzones@googlemail.com>

Christian Göttsche <cgzones@googlemail.com> writes:

> Currently `avc_init_internal()`, called by `avc_open(3)` and
> `avc_init(3)`, does open the SELinux status page with fallback mode
> enabled.
>
> Quote from man:selinux_status_open(3):
>     In this case, this function tries to open a netlink socket using
>     .BR avc_netlink_open (3) and overwrite corresponding callbacks
>     (setenforce and policyload).  Thus, we need to pay attention to the
>     interaction with these interfaces, when fallback mode is enabled.
>
> Calling `selinux_status_open` internally in fallback mode is bad, cause
> it overrides callbacks from client applications or the internal
> fallback-callbacks get overridden by client applications.
> Note that `avc_open(3)` gets called under the hood by
> `selinux_check_access(3)` without checking for failure.
> Also the status page is available since Linux 2.6.37, so failures of
> `selinux_status_open(3)` in non-fallback mode should only be caused by
> policies not allowing the client process to open/read/map
> the /sys/fs/selinux/status file.

Acked-by: Petr Lautrbach <plautrba@redhat.com>

All 3 are merged now.

Thanks!

> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
>  libselinux/src/avc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libselinux/src/avc.c b/libselinux/src/avc.c
> index 8314d7ba..daaedbc6 100644
> --- a/libselinux/src/avc.c
> +++ b/libselinux/src/avc.c
> @@ -214,7 +214,7 @@ static int avc_init_internal(const char *prefix,
>  		avc_enforcing = rc;
>  	}
>  
> -	rc = selinux_status_open(1);
> +	rc = selinux_status_open(0);
>  	if (rc < 0) {
>  		avc_log(SELINUX_ERROR,
>  			"%s: could not open selinux status page: %d (%s)\n",
> -- 
> 2.31.1


      reply	other threads:[~2021-06-01 14:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 10:56 [PATCH 0/3] libselinux: quirks of the status page Christian Göttsche
2021-05-10 10:56 ` [PATCH 1/3] libselinux: avc_destroy(3) closes " Christian Göttsche
2021-06-01 13:53   ` Petr Lautrbach
2021-05-10 10:56 ` [PATCH 2/3] libselinux: make selinux_status_open(3) reentrant Christian Göttsche
2021-06-01 13:53   ` Petr Lautrbach
2021-05-10 10:56 ` [PATCH 3/3] libselinux: do not use status page fallback mode internally Christian Göttsche
2021-06-01 14:13   ` Petr Lautrbach [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=87y2btllko.fsf@redhat.com \
    --to=plautrba@redhat.com \
    --cc=cgzones@googlemail.com \
    --cc=selinux@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