efi_loader: fix use after free in receive path
authorPatrick Wildt <patrick@blueri.se>
Wed, 7 Oct 2020 09:04:33 +0000 (11:04 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 19 Oct 2020 20:59:53 +0000 (22:59 +0200)
commit42f804fbba2836e64f472306ff7616c812d5c54d
tree6ec73e69086dd764748b7c26bd60ddc4f07af6ec
parent36ea0cab2696655030dc953e559f5c5bd223a38e
efi_loader: fix use after free in receive path

With DM enabled the ethernet code will receive a packet, call
the push method that's set by the EFI network implementation
and then free the packet.  Unfortunately the push methods only
sets a flag that the packet needs to be handled, but the code
that provides the packet to an EFI application runs after the
packet has already been freed.

To rectify this issue, adjust the push method to accept the packet
and store it in a temporary buffer.  The EFI application then gets
the data copied from that buffer.  This way the packet is cached
until is is needed.

The DM Ethernet stack tries to receive 32 packets at once, thus
we better allocate as many buffers as the stack.

Signed-off-by: Patrick Wildt <patrick@blueri.se>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_net.c