]> git.itanic.dy.fi Git - linux-stable/commit
efi: capsule-loader: Fix use-after-free in efi_capsule_write
authorHyunwoo Kim <imv4bel@gmail.com>
Wed, 7 Sep 2022 16:07:14 +0000 (09:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Sep 2022 09:32:02 +0000 (11:32 +0200)
commit918d9c4a4bdf5205f2fb3f64dddfb56c9a1d01d6
tree90dc618aa0db463b18bf6b06cb67a0b349f8bccf
parent94f0f30b2d9dcc3ac920029b518bff99f5b66f79
efi: capsule-loader: Fix use-after-free in efi_capsule_write

commit 9cb636b5f6a8cc6d1b50809ec8f8d33ae0c84c95 upstream.

A race condition may occur if the user calls close() on another thread
during a write() operation on the device node of the efi capsule.

This is a race condition that occurs between the efi_capsule_write() and
efi_capsule_flush() functions of efi_capsule_fops, which ultimately
results in UAF.

So, the page freeing process is modified to be done in
efi_capsule_release() instead of efi_capsule_flush().

Cc: <stable@vger.kernel.org> # v4.9+
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Link: https://lore.kernel.org/all/20220907102920.GA88602@ubuntu/
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/efi/capsule-loader.c