Skip to contentSkip to conversation

firmware: Always initialize the fw_priv list object

PATCH In review Bjorn Andersson 5 participants 9 messages Sep 20, 2018 – Oct 1, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware: Always initialize the fw_priv list object

When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Fixes 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc Rishabh Bhatnagar <[email protected]>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/base/firmware_loader/main.c +5 -2
index b3c0498ee433..8e9213b36e31 100644
@@ -226,8 +226,11 @@ static int alloc_lookup_fw_priv(const char *fw_name,
 	}
 
 	tmp = __allocate_fw_priv(fw_name, fwc, dbuf, size);
-	if (tmp && !(opt_flags & FW_OPT_NOCACHE))
-		list_add(&tmp->list, &fwc->head);
+	if (tmp) {
+		INIT_LIST_HEAD(&tmp->list);
+		if (!(opt_flags & FW_OPT_NOCACHE))
+			list_add(&tmp->list, &fwc->head);
+	}
 	spin_unlock(&fwc->lock);
 
 	*fw_priv = tmp;
Signature · 1 line
2.18.0
#1 lore raw
Quoted 5 lines · Bjorn Andersson

When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Quoted 7 lines
Fixes 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc Rishabh Bhatnagar <[email protected]>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Is this being triggered by some hardware somewhere today? Or is this just a fix found by code inspection?

thanks,

greg k-h

#2 lore raw
Quoted 14 lines · Greg Kroah-Hartman
Quoted 5 lines · Bjorn Andersson

When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Quoted 7 lines
Fixes 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc Rishabh Bhatnagar <[email protected]>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 3 lines

Is this being triggered by some hardware somewhere today? Or is this just a fix found by code inspection?

Hi Greg,

Yes, I found this issue while attempting to load the firmware and boot one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it can be reproduced on the upstream Dragonboard 820c.

Regards,
Bjorn

maintainer Reviewed-by on v1 1/1
#8 lore raw
In reply to Bjorn Andersson
Quoted 23 lines · Bjorn Andersson

When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Fixes 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc Rishabh Bhatnagar <[email protected]>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/base/firmware_loader/main.c +0 -1
index b3c0498ee433..8e9213b36e31 100644
@@ -226,8 +226,11 @@ static int alloc_lookup_fw_priv(const char *fw_name,
        }
 
        tmp = __allocate_fw_priv(fw_name, fwc, dbuf, size);
-       if (tmp && !(opt_flags & FW_OPT_NOCACHE))

drivers/base/firmware_loader/main.c static int alloc_lookup_fw_priv(const char *fw_name,

Quoted 10 lines
drivers/base/firmware_loader/main.c +5 -2
-               list_add(&tmp->list, &fwc->head);
+       if (tmp) {
+               INIT_LIST_HEAD(&tmp->list);
+               if (!(opt_flags & FW_OPT_NOCACHE))
+                       list_add(&tmp->list, &fwc->head);
+       }
        spin_unlock(&fwc->lock);
 
        *fw_priv = tmp;
--
#3 lore raw
In reply to Bjorn Andersson
Quoted 20 lines · Bjorn Andersson
Quoted 14 lines · Greg Kroah-Hartman
Quoted 5 lines · Bjorn Andersson

When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Quoted 7 lines
Fixes 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc Rishabh Bhatnagar <[email protected]>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 3 lines

Is this being triggered by some hardware somewhere today? Or is this just a fix found by code inspection?

Quoted 5 lines

Hi Greg,

Yes, I found this issue while attempting to load the firmware and boot one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it can be reproduced on the upstream Dragonboard 820c.

I still see this issue on v4.19-rc6.

It would be nice if this fix gets merged before v4.19 gets released.

Kind regards,
Niklas

maintainer
#4 lore raw
Quoted 23 lines · Niklas Cassel
Quoted 22 lines · Bjorn Andersson
Quoted 14 lines · Greg Kroah-Hartman
Quoted 5 lines · Bjorn Andersson

When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Quoted 7 lines
Fixes 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc Rishabh Bhatnagar <[email protected]>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 3 lines

Is this being triggered by some hardware somewhere today? Or is this just a fix found by code inspection?

Hi Greg,

Quoted 7 lines
Quoted 3 lines

Yes, I found this issue while attempting to load the firmware and boot one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it can be reproduced on the upstream Dragonboard 820c.

I still see this issue on v4.19-rc6.

It would be nice if this fix gets merged before v4.19 gets released.

This is the first I hear of this and this patch, so you should re-send it and I can review it. Also please Cc Rishabh.

Rishabh, had you heard of this and can you confirm as well as 422b3db2a503 was your commit?

Luis

#5 lore raw
Quoted 30 lines · Luis Chamberlain
Quoted 29 lines · Niklas Cassel
Quoted 20 lines · Bjorn Andersson
Quoted 14 lines · Greg Kroah-Hartman
Quoted 5 lines · Bjorn Andersson

When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Quoted 7 lines
Fixes 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc Rishabh Bhatnagar <[email protected]>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 3 lines

Is this being triggered by some hardware somewhere today? Or is this just a fix found by code inspection?

Quoted 5 lines

Hi Greg,

Yes, I found this issue while attempting to load the firmware and boot one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it can be reproduced on the upstream Dragonboard 820c.

I still see this issue on v4.19-rc6.

Quoted 8 lines
Quoted 1 line

It would be nice if this fix gets merged before v4.19 gets released.

This is the first I hear of this and this patch, so you should re-send it and I can review it. Also please Cc Rishabh.

Rishabh, had you heard of this and can you confirm as well as 422b3db2a503 was your commit?

Thanks Luis,

It seems like Greg did pick the patch yesterday [1], so hopefully he sends himself a pull request this week for inclusion in v4.19-rc7.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/log/?h=char-misc-linus

Regards,
Bjorn

maintainer
#6 lore raw
Quoted 41 lines · Bjorn Andersson
Quoted 30 lines · Luis Chamberlain
Quoted 29 lines · Niklas Cassel
Quoted 20 lines · Bjorn Andersson
Quoted 14 lines · Greg Kroah-Hartman
Quoted 5 lines · Bjorn Andersson

When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Quoted 7 lines
Fixes 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc Rishabh Bhatnagar <[email protected]>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 3 lines

Is this being triggered by some hardware somewhere today? Or is this just a fix found by code inspection?

Quoted 5 lines

Hi Greg,

Yes, I found this issue while attempting to load the firmware and boot one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it can be reproduced on the upstream Dragonboard 820c.

I still see this issue on v4.19-rc6.

Quoted 8 lines
Quoted 1 line

It would be nice if this fix gets merged before v4.19 gets released.

This is the first I hear of this and this patch, so you should re-send it and I can review it. Also please Cc Rishabh.

Rishabh, had you heard of this and can you confirm as well as 422b3db2a503 was your commit?

Quoted 6 lines

Thanks Luis,

It seems like Greg did pick the patch yesterday [1], so hopefully he sends himself a pull request this week for inclusion in v4.19-rc7.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/log/?h=char-misc-linus

The patch looks good. Next time please send patches to the maintainer as well.

Luis

#7 lore raw
In reply to Bjorn Andersson
Quoted 37 lines · Bjorn Andersson
Quoted 35 lines · Luis Chamberlain
Quoted 23 lines · Niklas Cassel
Quoted 22 lines · Bjorn Andersson
Quoted 14 lines · Greg Kroah-Hartman
Quoted 5 lines · Bjorn Andersson

When freeing the fw_priv the item is taken off the list. This causes an oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Quoted 7 lines
Fixes 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc Rishabh Bhatnagar <[email protected]>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 3 lines

Is this being triggered by some hardware somewhere today? Or is this just a fix found by code inspection?

Hi Greg,

Quoted 7 lines
Quoted 3 lines

Yes, I found this issue while attempting to load the firmware and boot one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it can be reproduced on the upstream Dragonboard 820c.

I still see this issue on v4.19-rc6.

It would be nice if this fix gets merged before v4.19 gets released.

This is the first I hear of this and this patch, so you should re-send it and I can review it. Also please Cc Rishabh.

Quoted 8 lines
Quoted 3 lines

Rishabh, had you heard of this and can you confirm as well as 422b3db2a503 was your commit?

Thanks Luis,

It seems like Greg did pick the patch yesterday [1], so hopefully he sends himself a pull request this week for inclusion in v4.19-rc7.

That was going to be my plan :)

thanks,

greg k-h