Skip to contentSkip to conversation

mei: fix use-after-free in mei_cl_write

PATCH New [email protected] 1 participant 1 message Aug 23, 2018

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

PATCH 1/1 mei: fix use-after-free in mei_cl_write

From: John Hubbard <[email protected]>

KASAN reports a use-after-free during startup, in mei_cl_write:

    BUG: KASAN: use-after-free in mei_cl_write+0x601/0x870 [mei]
       (drivers/misc/mei/client.c:1770)

This is caused by commit 98e70866aacb ("mei: add support for variable length mei headers."), which changed the return value from len, to buf-size. That ends up using a stale buf pointer, because in some situations, the cb (callback) is deleted before it gets here.

However, fortunately, len remains unchanged throughout the function (and I don't see anything else that would require re-reading buf->size either), so the fix is to simply revert the change, and return len, as before.

CC Tomas Winkler <[email protected]>
CC Arnd Bergmann <[email protected]>
CC Greg Kroah-Hartman <[email protected]>
---
 drivers/misc/mei/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/client.c +1 -1
index 4ab6251d418e..ebdcf0b450e2 100644
@@ -1767,7 +1767,7 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
 		}
 	}
 
-	rets = buf->size;
+	rets = len;
 err:
 	cl_dbg(dev, cl, "rpm: autosuspend\n");
 	pm_runtime_mark_last_busy(dev->dev);
Signature · 1 line
2.18.0