Skip to content

Commit

Permalink
libselinux: make selinux_status_open(3) reentrant
Browse files Browse the repository at this point in the history
Do not mmap the status page again if `selinux_status_open(3)` has already
been called with success.

`selinux_status_open(3)` might be called unintentionally multiple times,
e.g. once to manually be able to call `selinux_status_getenforce(3)` and
once indirectly through `selinux_check_access(3)`
(since libselinux 3.2).

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
  • Loading branch information
cgzones authored and bachradsusi committed Jun 1, 2021
1 parent a2304ce commit c5a6990
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libselinux/src/sestatus.c
Expand Up @@ -282,6 +282,10 @@ int selinux_status_open(int fallback)
long pagesize;
uint32_t seqno;

if (selinux_status != NULL) {
return 0;
}

if (!selinux_mnt) {
errno = ENOENT;
return -1;
Expand Down

0 comments on commit c5a6990

Please sign in to comment.