* [PATCH] drivers:wireless: Fix a dereference before null check issue
@ 2024-11-21 17:02 Paolo Perego
2024-11-21 17:28 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Perego @ 2024-11-21 17:02 UTC (permalink / raw)
To: linux-wireless, linux-kernel
Cc: Miri Korenblit, Kalle Valo, Johannes Berg, Shaul Triebitz,
Emmanuel Grumbach, Yedidya Benshimol, Benjamin Berg, Paolo Perego
This patch fixes a dereference before null check issue discovered by
Coverity (CID 1601547)
In iwl_mvm_parse_wowlan_info_notif() routine data is checked against
NULL value at line 2501 but it has been dereferenced three lines before
when calculating sizeof() in an assignment.
Signed-off-by: Paolo Perego <pperego@suse.de>
---
drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
index f85c01e04ebf..f733c16ffd8e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
@@ -2495,8 +2495,7 @@ static void iwl_mvm_parse_wowlan_info_notif(struct iwl_mvm *mvm,
struct iwl_wowlan_status_data *status,
u32 len)
{
- u32 expected_len = sizeof(*data) +
- data->num_mlo_link_keys * sizeof(status->mlo_keys[0]);
+ u32 expected_len = 0;
if (!data) {
IWL_ERR(mvm, "iwl_wowlan_info_notif data is NULL\n");
@@ -2504,6 +2503,8 @@ static void iwl_mvm_parse_wowlan_info_notif(struct iwl_mvm *mvm,
return;
}
+ expected_len = sizeof(*data) + data->num_mlo_link_keys * sizeof(status->mlo_keys[0]);
+
if (len < expected_len) {
IWL_ERR(mvm, "Invalid WoWLAN info notification!\n");
status = NULL;
--
2.47.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers:wireless: Fix a dereference before null check issue
2024-11-21 17:02 [PATCH] drivers:wireless: Fix a dereference before null check issue Paolo Perego
@ 2024-11-21 17:28 ` Johannes Berg
2024-11-21 17:35 ` Paolo Perego
2024-11-22 7:25 ` Markus Elfring
0 siblings, 2 replies; 6+ messages in thread
From: Johannes Berg @ 2024-11-21 17:28 UTC (permalink / raw)
To: Paolo Perego, linux-wireless, linux-kernel
Cc: Miri Korenblit, Kalle Valo, Shaul Triebitz, Emmanuel Grumbach,
Yedidya Benshimol, Benjamin Berg
On Thu, 2024-11-21 at 18:02 +0100, Paolo Perego wrote:
> This patch fixes a dereference before null check issue discovered by
> Coverity (CID 1601547)
>
This was reported before by smatch too, and Emmanuel just made a patch
to simply remove the NULL checks, because the pointers are statically
known to be not NULL. So it's not really an issue other than
style/checkers/... anyway :)
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers:wireless: Fix a dereference before null check issue
2024-11-21 17:28 ` Johannes Berg
@ 2024-11-21 17:35 ` Paolo Perego
2024-11-21 17:40 ` Johannes Berg
2024-11-22 7:50 ` wireless: " Markus Elfring
2024-11-22 7:25 ` Markus Elfring
1 sibling, 2 replies; 6+ messages in thread
From: Paolo Perego @ 2024-11-21 17:35 UTC (permalink / raw)
To: Johannes Berg
Cc: linux-wireless, linux-kernel, Miri Korenblit, Kalle Valo,
Shaul Triebitz, Emmanuel Grumbach, Yedidya Benshimol,
Benjamin Berg
[-- Attachment #1: Type: text/plain, Size: 915 bytes --]
On Thu, Nov 21, 2024 at 06:28:14PM GMT, Johannes Berg wrote:
> On Thu, 2024-11-21 at 18:02 +0100, Paolo Perego wrote:
> > This patch fixes a dereference before null check issue discovered by
> > Coverity (CID 1601547)
> >
>
> This was reported before by smatch too, and Emmanuel just made a patch
> to simply remove the NULL checks, because the pointers are statically
> known to be not NULL. So it's not really an issue other than
> style/checkers/... anyway :)
Oops, I'm so sorry this was already fixed. In Coverity dashboard the
item seemed to be still open.
Apart from that, did I followed the right steps? Was my submission good
enough? (I'm new to kernel hacking and I'm still in the learning phase)
Thanks
Paolo
--
(*_ Paolo Perego @thesp0nge
//\ Software security engineer suse.com
V_/_ 0A1A 2003 9AE0 B09C 51A4 7ACD FC0D CEA6 0806 294B
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers:wireless: Fix a dereference before null check issue
2024-11-21 17:35 ` Paolo Perego
@ 2024-11-21 17:40 ` Johannes Berg
2024-11-22 7:50 ` wireless: " Markus Elfring
1 sibling, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2024-11-21 17:40 UTC (permalink / raw)
To: Paolo Perego
Cc: linux-wireless, linux-kernel, Miri Korenblit, Kalle Valo,
Shaul Triebitz, Emmanuel Grumbach, Yedidya Benshimol,
Benjamin Berg
On Thu, 2024-11-21 at 18:35 +0100, Paolo Perego wrote:
> On Thu, Nov 21, 2024 at 06:28:14PM GMT, Johannes Berg wrote:
> > On Thu, 2024-11-21 at 18:02 +0100, Paolo Perego wrote:
> > > This patch fixes a dereference before null check issue discovered by
> > > Coverity (CID 1601547)
> > >
> >
> > This was reported before by smatch too, and Emmanuel just made a patch
> > to simply remove the NULL checks, because the pointers are statically
> > known to be not NULL. So it's not really an issue other than
> > style/checkers/... anyway :)
> Oops, I'm so sorry this was already fixed. In Coverity dashboard the
> item seemed to be still open.
Oh it wasn't fixed yet, the patch isn't anywhere near the trees. But
it's also not very important, so I doubt we'll handle it urgently.
> Apart from that, did I followed the right steps? Was my submission good
> enough? (I'm new to kernel hacking and I'm still in the learning phase)
>
Well, should've had the right subject prefix, as "wifi: iwlwifi:" but
other than that, I guess?
Arguably, you also shouldn't have had the = 0 in the code, since it got
unconditionally assigned anyway.
And, if you're going to continue looking at Coverity reports, I'd
suggest to dig a bit deeper. We're not here to fix reports from Coverity
after all, we should fix _bugs_, and tools will get things wrong :)
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: wireless: Fix a dereference before null check issue
2024-11-21 17:28 ` Johannes Berg
2024-11-21 17:35 ` Paolo Perego
@ 2024-11-22 7:25 ` Markus Elfring
1 sibling, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2024-11-22 7:25 UTC (permalink / raw)
To: Johannes Berg, linux-wireless
Cc: LKML, Benjamin Berg, Emmanuel Grumbach, Kalle Valo,
Miri Korenblit, Paolo Perego, Shaul Triebitz, Yedidya Benshimol
> This was reported before by smatch too, and Emmanuel just made a patch
> to simply remove the NULL checks, because the pointers are statically
> known to be not NULL. …
To which messages would you like to refer here?
Regards,
Markus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: wireless: Fix a dereference before null check issue
2024-11-21 17:35 ` Paolo Perego
2024-11-21 17:40 ` Johannes Berg
@ 2024-11-22 7:50 ` Markus Elfring
1 sibling, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2024-11-22 7:50 UTC (permalink / raw)
To: Paolo Perego, linux-wireless
Cc: LKML, Benjamin Berg, Emmanuel Grumbach, Johannes Berg, Kalle Valo,
Miri Korenblit, Shaul Triebitz, Yedidya Benshimol
> Oops, I'm so sorry this was already fixed.
It can occasionally happen that some contributors would like to adjust
the same source code places somehow.
> In Coverity dashboard the
> item seemed to be still open.
It might occasionally be unclear with which delay corresponding items
will be synchronised.
> Apart from that, did I followed the right steps?
Partly, yes.
> Was my submission good
> enough? (I'm new to kernel hacking and I'm still in the learning phase)
I find details improvable.
1. Change description
2. Patch subject
Regards,
Markus
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-22 7:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-21 17:02 [PATCH] drivers:wireless: Fix a dereference before null check issue Paolo Perego
2024-11-21 17:28 ` Johannes Berg
2024-11-21 17:35 ` Paolo Perego
2024-11-21 17:40 ` Johannes Berg
2024-11-22 7:50 ` wireless: " Markus Elfring
2024-11-22 7:25 ` Markus Elfring
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.