linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 4.10-rc3, firmware loading via user space helper crashes if firmware not present
@ 2017-01-13 21:32 Jakub Kicinski
  2017-01-14  3:40 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2017-01-13 21:32 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Luis R. Rodriguez, Bjorn Andersson, linux-kernel

Hi!

If one requests a FW which does not exist in the FS and the user space
helper is used then fw_load_abort() will be called twice which leads to
NULL-deref.

It will be called once in firmware_loading_store() (handling the -1
case) and then again in _request_firmware_load() because return value
from fw_state_wait_timeout() was negative.

I think this is introduced in by f52cc379423d ("firmware: refactor
loading status").

The simple fix would be to not "unlink" the buf by fw_load_abort() in
firmware_loading_store() and always rely on firmware_loading_store().

------->8------------------------------------

diff --git a/drivers/base/firmware_class.c
b/drivers/base/firmware_class.c index 4497d263209f..89eb9de81145 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -766,7 +770,7 @@ static ssize_t firmware_loading_store(struct device
*dev, dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading);
 		/* fallthrough */
 	case -1:
-		fw_load_abort(fw_priv);
+		fw_state_aborted(&fw_buf->fw_st);
 		break;
 	}
 out:

-------8<------------------------------------

Or should we fix up the ret code handling in __fw_state_wait_common()?

Kuba

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

end of thread, other threads:[~2017-01-14  3:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-13 21:32 4.10-rc3, firmware loading via user space helper crashes if firmware not present Jakub Kicinski
2017-01-14  3:40 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).