Message ID | 20210510105648.14635-3-cgzones@googlemail.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | libselinux: quirks of the status page | expand |
Christian Göttsche <cgzones@googlemail.com> writes: > 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> Acked-by: Petr Lautrbach <plautrba@redhat.com> > --- > libselinux/src/sestatus.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libselinux/src/sestatus.c b/libselinux/src/sestatus.c > index 12b015e0..531a522c 100644 > --- a/libselinux/src/sestatus.c > +++ b/libselinux/src/sestatus.c > @@ -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; > -- > 2.31.1
diff --git a/libselinux/src/sestatus.c b/libselinux/src/sestatus.c index 12b015e0..531a522c 100644 --- a/libselinux/src/sestatus.c +++ b/libselinux/src/sestatus.c @@ -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;
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> --- libselinux/src/sestatus.c | 4 ++++ 1 file changed, 4 insertions(+)