mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
packet: tpacket_snd(): fix signed/unsigned comparison
[ Upstream commitdbd46ab412] tpacket_fill_skb() can return a negative value (-errno) which is stored in tp_len variable. In that case the following condition will be (but shouldn't be) true: tp_len > dev->mtu + dev->hard_header_len as dev->mtu and dev->hard_header_len are both unsigned. That may lead to just returning an incorrect EMSGSIZE errno to the user. Fixes:52f1454f62("packet: allow to transmit +4 byte in TX_RING slot for VLAN case") Signed-off-by: Alexander Drozdov <al.drozdov@gmail.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d339d03860
commit
2ef3d434d3
@@ -2307,7 +2307,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
|
||||
}
|
||||
tp_len = tpacket_fill_skb(po, skb, ph, dev, size_max, proto,
|
||||
addr, hlen);
|
||||
if (tp_len > dev->mtu + dev->hard_header_len) {
|
||||
if (likely(tp_len >= 0) &&
|
||||
tp_len > dev->mtu + dev->hard_header_len) {
|
||||
struct ethhdr *ehdr;
|
||||
/* Earlier code assumed this would be a VLAN pkt,
|
||||
* double-check this now that we have the actual
|
||||
|
||||
Reference in New Issue
Block a user