All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] network: add L_WARN for known network lookup failure
@ 2019-10-25 16:53 James Prestwood
  2019-10-25 18:19 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: James Prestwood @ 2019-10-25 16:53 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 965 bytes --]

When updating the network ranking there was a potential out of bounds
array access. The condition was if known_network_offset returned a
negative value, indicating the known network was not found. Since
network->info is only set for known networks this should not ever
happen as network->info is checked prior.

Though this is likely impossible, knownnetworks is complex enough that
its better to just be paranoid and put an L_WARN_ON to check the
return.
---
 src/network.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/network.c b/src/network.c
index 3270b57c..0f29022b 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1376,6 +1376,8 @@ void network_rank_update(struct network *network, bool connected)
 	if (network->info->connected_time != 0) {
 		int n = known_network_offset(network->info);
 
+		L_WARN_ON(n < 0);
+
 		if (n >= (int) L_ARRAY_SIZE(rankmod_table))
 			n = L_ARRAY_SIZE(rankmod_table) - 1;
 
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] network: add L_WARN for known network lookup failure
  2019-10-25 16:53 [PATCH] network: add L_WARN for known network lookup failure James Prestwood
@ 2019-10-25 18:19 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2019-10-25 18:19 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 656 bytes --]

Hi James,

On 10/25/19 11:53 AM, James Prestwood wrote:
> When updating the network ranking there was a potential out of bounds
> array access. The condition was if known_network_offset returned a
> negative value, indicating the known network was not found. Since
> network->info is only set for known networks this should not ever
> happen as network->info is checked prior.
> 
> Though this is likely impossible, knownnetworks is complex enough that
> its better to just be paranoid and put an L_WARN_ON to check the
> return.
> ---
>   src/network.c | 2 ++
>   1 file changed, 2 insertions(+)
> 

Applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-25 18:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-25 16:53 [PATCH] network: add L_WARN for known network lookup failure James Prestwood
2019-10-25 18:19 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.