Skip to contentSkip to conversation

selinux: fix uninitalised stack variable read in sel_netport_init

PATCH Dave Jones 2 participants 2 messages Aug 7, 2014 – Aug 8, 2014 SELinux security module

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

After the removal of the avc_add_callback() in commit 615e51fdda6 ("selinux: reduce the number of calls to synchronize_net() when flushing caches"), ret is never set to anything, but we return uninitialized stack data on success.

Given the absense of other failure paths, just explicitly return 0.

security/selinux/netport.c +1 -2
index 73ac6784d091..3311cc393cb4 100644
@@ -237,7 +237,6 @@ void sel_netport_flush(void)
 static __init int sel_netport_init(void)
 {
 	int iter;
-	int ret;
 
 	if (!selinux_enabled)
 		return 0;
@@ -247,7 +246,7 @@ static __init int sel_netport_init(void)
 		sel_netport_hash[iter].size = 0;
 	}
 
-	return ret;
+	return 0;
 }
 
 __initcall(sel_netport_init);
#1 lore raw
Quoted 8 lines · Dave Jones

After the removal of the avc_add_callback() in commit 615e51fdda6 ("selinux: reduce the number of calls to synchronize_net() when flushing caches"), ret is never set to anything, but we return uninitialized stack data on success.

Given the absense of other failure paths, just explicitly return 0.

Thanks for the patch, but another more comprehensive patch (there are similar problems in netnode.c and netif.c) was posted earlier this week and reposted last night ... although evidently I need to send the patch(es) directly to Linus, so you'll likely see another repost in a few moments.

Quoted 21 lines
security/selinux/netport.c +1 -2
index 73ac6784d091..3311cc393cb4 100644
@@ -237,7 +237,6 @@ void sel_netport_flush(void)
 static __init int sel_netport_init(void)
 {
 	int iter;
-	int ret;
 
 	if (!selinux_enabled)
 		return 0;
@@ -247,7 +246,7 @@ static __init int sel_netport_init(void)
 		sel_netport_hash[iter].size = 0;
 	}
 
-	return ret;
+	return 0;
 }
 
 __initcall(sel_netport_init);
Signature · 2 lines
paul moore
security and virtualization @ redhat