eth_get_protocols() already rejects some out-of-bounds offsets found in
packets. Add a missing check for TCP data offset.
Fixes: eb700029c783 ("net_pkt: Extend packet abstraction as required by e1000e
functionality")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4155
Cc: [email protected]
Signed-off-by: Akihiko Odaki <[email protected]>
---
net/eth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/eth.c b/net/eth.c
index 038f7d889c33..a444377fd0ae 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -197,7 +197,8 @@ void eth_get_protocols(const struct iovec *iov, size_t
iovcnt, size_t iovoff,
if (_eth_copy_chunk(input_size,
iov, iovcnt,
*l4hdr_off, sizeof(l4hdr_info->hdr.tcp),
- &l4hdr_info->hdr.tcp)) {
+ &l4hdr_info->hdr.tcp) &&
+ input_size - *l4hdr_off >=
TCP_HEADER_DATA_OFFSET(&l4hdr_info->hdr.tcp)) {
l4hdr_info->proto = ETH_L4_HDR_PROTO_TCP;
*l5hdr_off = *l4hdr_off +
TCP_HEADER_DATA_OFFSET(&l4hdr_info->hdr.tcp);
--
2.56.0