Skip to contentSkip to conversation

libselinux: selinux_status_open: return 1 in fallback mode

PATCH In review Christian Göttsche 2 participants 3 messages Jun 1, 2021 – Jun 9, 2021 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: selinux_status_open: return 1 in fallback mode

In case of a recurring call to selinux_status_open(3), which previously has been opened in fallback mode, return 1 according to its documentation.

Fixes c5a699046f4 ("libselinux: make selinux_status_open(3) reentrant")
---
 libselinux/src/sestatus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/sestatus.c +1 -1
index 531a522c..89c1f621 100644
@@ -283,7 +283,7 @@ int selinux_status_open(int fallback)
 	uint32_t	seqno;
 
 	if (selinux_status != NULL) {
-		return 0;
+		return (selinux_status == MAP_FAILED) ? 1 : 0;
 	}
 
 	if (!selinux_mnt) {
Signature · 1 line
2.32.0.rc2
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Christian Göttsche

In case of a recurring call to selinux_status_open(3), which previously has been opened in fallback mode, return 1 according to its documentation.

Fixes c5a699046f4 ("libselinux: make selinux_status_open(3) reentrant")
Quoted 19 lines
---
 libselinux/src/sestatus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/sestatus.c +1 -1
index 531a522c..89c1f621 100644
@@ -283,7 +283,7 @@ int selinux_status_open(int fallback)
 	uint32_t	seqno;
 
 	if (selinux_status != NULL) {
-		return 0;
+		return (selinux_status == MAP_FAILED) ? 1 : 0;
 	}
 
 	if (!selinux_mnt) {
Signature · 1 line
2.32.0.rc2
#2 lore raw
Quoted 6 lines · Petr Lautrbach
Quoted 4 lines · Christian Göttsche

In case of a recurring call to selinux_status_open(3), which previously has been opened in fallback mode, return 1 according to its documentation.

Quoted 6 lines
Quoted 4 lines
Fixes c5a699046f4 ("libselinux: make selinux_status_open(3) reentrant")

This is merged now. Thanks!

Quoted 20 lines
Quoted 20 lines
---
 libselinux/src/sestatus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/sestatus.c +1 -1
index 531a522c..89c1f621 100644
@@ -283,7 +283,7 @@ int selinux_status_open(int fallback)
 	uint32_t	seqno;
 
 	if (selinux_status != NULL) {
-		return 0;
+		return (selinux_status == MAP_FAILED) ? 1 : 0;
 	}
 
 	if (!selinux_mnt) {
Signature · 1 line
2.32.0.rc2