Skip to contentSkip to conversation

libsemanage: properly check return value of iterate function

PATCH In review Jan Zarsky 2 participants 6 messages Nov 22, 2017 – Dec 11, 2017 SELinux security module

lore
Share & tools
lore

Jan Zarsky

author
#0 lore raw

PATCH 1/1 libsemanage: properly check return value of iterate function

Function dbase_llist_iterate iterates over records and checks return value of iterate function. According to a manpage semanage_iterate(3), handler can return value 1 for early exit. dbase_llist_iterate currently checks for return value > 1, which does not include expected value 1. This affects most of the semanage_*_iterate and semanage_*_local functions.

---
 libsemanage/src/database_llist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/database_llist.c +1 -1
index 8ce2e2c1..c8f4ff0b 100644
@@ -263,7 +263,7 @@ int dbase_llist_iterate(semanage_handle_t * handle,
 		if (rc < 0)
 			goto err;
 
-		else if (rc > 1)
+		else if (rc > 0)
 			break;
 	}
 
Signature · 1 line
2.14.3
#1 lore raw
Quoted 6 lines · Jan Zarsky

Function dbase_llist_iterate iterates over records and checks return value of iterate function. According to a manpage semanage_iterate(3), handler can return value 1 for early exit. dbase_llist_iterate currently checks for return value > 1, which does not include expected value 1. This affects most of the semanage_*_iterate and semanage_*_local functions.

Can you update this message to describe what is affected.

Quoted 11 lines
---
 libsemanage/src/database_llist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/database_llist.c +0 -0
index 8ce2e2c1..c8f4ff0b 100644

libsemanage/src/database_llist.c int dbase_llist_iterate(semanage_handle_t * handle, · line 266

Quoted 5 lines
libsemanage/src/database_llist.c +1 -1
@@ -263,7 +263,7 @@ int dbase_llist_iterate(semanage_handle_t * handle,
                if (rc < 0)
                        goto err;
 
-               else if (rc > 1)
+               else if (rc > 0)

This looks fine to me.

Quoted 6 lines
libsemanage/src/database_llist.c +0 -1
                        break;
        }
 
--

2.14.3

Please resend with the message updated and I'll ack.

author
#2 lore raw

PATCH 1/1 libsemanage: properly check return value of iterate function

Function dbase_llist_iterate() iterates over records and checks return value of iterate function. According to a manpage semanage_iterate(3), handler can return value 1 for early exit. dbase_llist_iterate() currently checks for return value > 1, which does not include expected value 1.

Affected functions:
semanage_bool_iterate_local
semanage_fcontext_iterate
semanage_fcontext_iterate_local
semanage_ibendport_iterate_local
semanage_ibpkey_iterate_local
semanage_iface_iterate_local
semanage_node_iterate_local
semanage_port_iterate_local
semanage_seuser_iterate
semanage_seuser_iterate_local
semanage_user_iterate
semanage_user_iterate_local

---
 libsemanage/src/database_llist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/database_llist.c +1 -1
index 8ce2e2c1..c8f4ff0b 100644
@@ -263,7 +263,7 @@ int dbase_llist_iterate(semanage_handle_t * handle,
 		if (rc < 0)
 			goto err;
 
-		else if (rc > 1)
+		else if (rc > 0)
 			break;
 	}
 
Signature · 1 line
2.14.3
#3 lore raw
Quoted 6 lines · Jan Zarsky

Function dbase_llist_iterate() iterates over records and checks return value of iterate function. According to a manpage semanage_iterate(3), handler can return value 1 for early exit. dbase_llist_iterate() currently checks for return value > 1, which does not include expected value 1.

Quoted 13 lines

Affected functions:
semanage_bool_iterate_local
semanage_fcontext_iterate
semanage_fcontext_iterate_local
semanage_ibendport_iterate_local
semanage_ibpkey_iterate_local
semanage_iface_iterate_local
semanage_node_iterate_local
semanage_port_iterate_local
semanage_seuser_iterate
semanage_seuser_iterate_local
semanage_user_iterate
semanage_user_iterate_local

Not really what I had in mind. I meant what was the affect. This is simple enough to gather, so ack on v1,

My understanding is that the affect is that it that it doesn't short circuit the iterate
routine so lockups take longer than they need be, is that correct?

Quoted 23 lines
---
 libsemanage/src/database_llist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/database_llist.c +1 -2
index 8ce2e2c1..c8f4ff0b 100644
@@ -263,7 +263,7 @@ int dbase_llist_iterate(semanage_handle_t * handle,
                if (rc < 0)
                        goto err;
 
-               else if (rc > 1)
+               else if (rc > 0)
                        break;
        }
 
--

2.14.3

Signature · 3 lines
Respectfully,

William C Roberts
author
#4 lore raw

----- Original Message -----

Quoted 21 lines · Jan Zarsky
Quoted 6 lines

Function dbase_llist_iterate() iterates over records and checks return value of iterate function. According to a manpage semanage_iterate(3), handler can return value 1 for early exit. dbase_llist_iterate() currently checks for return value > 1, which does not include expected value 1.

Quoted 13 lines

Affected functions:
semanage_bool_iterate_local
semanage_fcontext_iterate
semanage_fcontext_iterate_local
semanage_ibendport_iterate_local
semanage_ibpkey_iterate_local
semanage_iface_iterate_local
semanage_node_iterate_local
semanage_port_iterate_local
semanage_seuser_iterate
semanage_seuser_iterate_local
semanage_user_iterate
semanage_user_iterate_local

Quoted 6 lines

Not really what I had in mind. I meant what was the affect. This is simple enough to gather, so ack on v1,

My understanding is that the affect is that it that it doesn't short circuit the iterate
routine so lockups take longer than they need be, is that correct?

Yes, that is the exactly the problem. I will try to be more clear next time.

Quoted 33 lines
Quoted 22 lines
---
 libsemanage/src/database_llist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/database_llist.c +1 -2
index 8ce2e2c1..c8f4ff0b 100644
@@ -263,7 +263,7 @@ int dbase_llist_iterate(semanage_handle_t * handle,
                if (rc < 0)
                        goto err;
 
-               else if (rc > 1)
+               else if (rc > 0)
                        break;
        }
 
--
Quoted 3 lines

2.14.3

--
Respectfully,

William C Roberts

#5 lore raw
In reply to Jan Zarsky

Thanks. Applied: https://github.com/SELinuxProject/selinux/pull/71

Quoted 29 lines · Jan Zarsky

Function dbase_llist_iterate iterates over records and checks return value of iterate function. According to a manpage semanage_iterate(3), handler can return value 1 for early exit. dbase_llist_iterate currently checks for return value > 1, which does not include expected value 1. This affects most of the semanage_*_iterate and semanage_*_local functions.

---
 libsemanage/src/database_llist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/database_llist.c +1 -2
index 8ce2e2c1..c8f4ff0b 100644
@@ -263,7 +263,7 @@ int dbase_llist_iterate(semanage_handle_t * handle,
                if (rc < 0)
                        goto err;
 
-               else if (rc > 1)
+               else if (rc > 0)
                        break;
        }
 
--

2.14.3

Signature · 3 lines
Respectfully,

William C Roberts