Skip to contentSkip to conversation

libselinux: selinux_check_passwd_access_internal(): respect deny_unknown

PATCH Superseded Christian Göttsche 2 participants 4 messages May 3, 2021 – May 12, 2021 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: selinux_check_passwd_access_internal(): respect deny_unknown

selinux_check_passwd_access_internal(), and thereby checkPasswdAccess(3) and selinux_check_passwd_access(3), does not respect the policy defined setting of deny_unknown, like selinux_check_access(3) does.
This means in case the security class passwd is not defined, success is returned instead of failure, i.e. permission denied.

Most policies should define the passwd class and the two affected public functions are marked deprecated.

Align the behavior with selinux_check_passwd_access(3) and respect the deny_unknown setting in case the security class is not defined.

---
 libselinux/src/checkAccess.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
libselinux/src/checkAccess.c +3 -1
index b337ea64..022cd6b5 100644
@@ -78,7 +78,9 @@ static int selinux_check_passwd_access_internal(access_vector_t requested)
 		passwd_class = string_to_security_class("passwd");
 		if (passwd_class == 0) {
 			freecon(user_context);
-			return 0;
+			if (security_deny_unknown() == 0)
+				return 0;
+			return -1;
 		}
 
 		retval = security_compute_av_raw(user_context,
Signature · 1 line
2.31.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Christian Göttsche

selinux_check_passwd_access_internal(), and thereby checkPasswdAccess(3) and selinux_check_passwd_access(3), does not respect the policy defined setting of deny_unknown, like selinux_check_access(3) does.
This means in case the security class passwd is not defined, success is returned instead of failure, i.e. permission denied.

Most policies should define the passwd class and the two affected public functions are marked deprecated.

Align the behavior with selinux_check_passwd_access(3) and respect

Should it be "Align the behavior with selinux_check_access(3)" ?

Quoted 3 lines

the deny_unknown setting in case the security class is not defined.

Quoted 21 lines
---
 libselinux/src/checkAccess.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
libselinux/src/checkAccess.c +3 -1
index b337ea64..022cd6b5 100644
@@ -78,7 +78,9 @@ static int selinux_check_passwd_access_internal(access_vector_t requested)
 		passwd_class = string_to_security_class("passwd");
 		if (passwd_class == 0) {
 			freecon(user_context);
-			return 0;
+			if (security_deny_unknown() == 0)
+				return 0;
+			return -1;
 		}
 
 		retval = security_compute_av_raw(user_context,
Signature · 1 line
2.31.1
#2 lore raw

PATCH v2 1/1 libselinux: selinux_check_passwd_access_internal(): respect deny_unknown

In reply to Christian Göttsche

selinux_check_passwd_access_internal(), and thereby checkPasswdAccess(3) and selinux_check_passwd_access(3), does not respect the policy defined setting of deny_unknown, like selinux_check_access(3) does.
This means in case the security class passwd is not defined, success is returned instead of failure, i.e. permission denied.

Most policies should define the passwd class and the two affected public functions are marked deprecated.

Align the behavior with selinux_check_access(3) and respect the deny_unknown setting in case the security class is not defined.

---
Fixed function name in commit message, spotted by Petr Lautrbach.

 libselinux/src/checkAccess.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
libselinux/src/checkAccess.c +3 -1
index b337ea64..022cd6b5 100644
@@ -78,7 +78,9 @@ static int selinux_check_passwd_access_internal(access_vector_t requested)
 		passwd_class = string_to_security_class("passwd");
 		if (passwd_class == 0) {
 			freecon(user_context);
-			return 0;
+			if (security_deny_unknown() == 0)
+				return 0;
+			return -1;
 		}
 
 		retval = security_compute_av_raw(user_context,
Signature · 1 line
2.31.1
#3 lore raw
Quoted 7 lines · Christian Göttsche

selinux_check_passwd_access_internal(), and thereby checkPasswdAccess(3) and selinux_check_passwd_access(3), does not respect the policy defined setting of deny_unknown, like selinux_check_access(3) does.
This means in case the security class passwd is not defined, success is returned instead of failure, i.e. permission denied.

Quoted 7 lines

Most policies should define the passwd class and the two affected public functions are marked deprecated.

Align the behavior with selinux_check_access(3) and respect the deny_unknown setting in case the security class is not defined.

Merged, thanks!

Quoted 23 lines

---
Fixed function name in commit message, spotted by Petr Lautrbach.

 libselinux/src/checkAccess.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
libselinux/src/checkAccess.c +3 -1
index b337ea64..022cd6b5 100644
@@ -78,7 +78,9 @@ static int selinux_check_passwd_access_internal(access_vector_t requested)
 		passwd_class = string_to_security_class("passwd");
 		if (passwd_class == 0) {
 			freecon(user_context);
-			return 0;
+			if (security_deny_unknown() == 0)
+				return 0;
+			return -1;
 		}
 
 		retval = security_compute_av_raw(user_context,
Signature · 1 line
2.31.1