]> git.baikalelectronics.ru Git - kernel.git/commit
mei: fix use-after-free in mei_cl_write
authorJohn Hubbard <jhubbard@nvidia.com>
Thu, 23 Aug 2018 06:16:58 +0000 (09:16 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 12 Sep 2018 07:14:24 +0000 (09:14 +0200)
commit006ef58fc905fc2967bceca90bf3a593dd3c5f11
treee7ca8a8b888ac979e78ca50ce7bf1582acef3894
parent5cdf575bef03d48417e89a2ce14f5acb567864c3
mei: fix use-after-free in mei_cl_write

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 6b994f7394cc ("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 blocking
call, the cb (callback) is deleted in me_cl_complete() function.

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.

Fixes: 6b994f7394cc ("mei: add support for variable length mei headers.")
CC: Arnd Bergmann <arnd@arndb.de>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/client.c