On Fri, 13 Nov 2026 at 20:19, Akihiko Odaki
<[email protected]> wrote:
>
> On 2026/11/12 13:02, Peter Maydell wrote:
> > In net_checksum_calculate() we are careless about handling of the IP
> > header length, in a way which can allow it to become negative for a
> > suitably crafted packet.  This bypasses the attempt to check that
> > it's big enough, because in comparisons like
> >    if (ip_len < sizeof(tcp_header))
> > ip_len is converted to size_t and we do this as an unsigned
> > comparison, so negative values of ip_len pass the check.
> >
> > This results in net_checksum_tcpudp() attempting to checksum nearly
> > 64K of memory (because it takes the length as a uint16_t), which will
> > typically be a read off the end of a buffer resulting in a segfault.
> > If the attacker is able to set up a situation where the read doesn't
> > fault, it's possible for some callers that the 2-byte store of the
> > updated checksum is an out-of-bounds write.
> >
> > This code is used by at least xen-nic, virtio-net, and the COLOj
> > filter-rewriter, all of which are in QEMU's security "virtualization
> > use case", though the write is probably only exploitable for the
> > filter-rewriter; otherwise it's just a theoretical "information leak
> > to guest" of a 2-byte checksum of 64K of host RAM.
> >
> > Improve the checking of lengths in this function:
> >   * assert that the caller provided us a positive buffer length
>
> The new assertion is reachable through eTSEC. It assumes callers always
> supply a nonnegative length. However, eTSEC accumulates descriptor
> lengths without a frame-size cap, then passes the unsigned length to
> this signed parameter in process_tx_fcb(). An aggregate exceeding 2 GiB
> can therefore abort QEMU.
>
> A natural way to fix it would be to change the type to an unsigned one
> that can contain that large length, which would also eliminate the need
> for the assertion.

Rats. The reason I didn't change the type was I was hoping to avoid
having to look at all the callsites and whether the type change
would make a difference to them :-)

The eTSEC behaviour seems like a bug in that device to me (of the
kind that I put the assertion in there to catch): if it has
no frame size cap then presumably the guest can also get it to
overflow its own uint32_t tx_buffer_len ...

thanks
-- PMM

Reply via email to