diff options
author | Alexander Drozdov <al.drozdov@gmail.com> | 2015-07-28 13:57:01 +0300 |
---|---|---|
committer | Sasha Levin <sasha.levin@oracle.com> | 2015-12-14 12:19:22 -0500 |
commit | e4f3c00338a3ddcc1c222396816d18a670ac4e67 (patch) | |
tree | 965134aaf23e1e003c4e034cae00c37d5fbee418 | |
parent | 302c63565452db0bdb065605ad227c88ec93d4e8 (diff) | |
download | lwn-e4f3c00338a3ddcc1c222396816d18a670ac4e67.tar.gz lwn-e4f3c00338a3ddcc1c222396816d18a670ac4e67.zip |
packet: tpacket_snd(): fix signed/unsigned comparison
[ Upstream commit dbd46ab412b8fb395f2b0ff6f6a7eec9df311550 ]
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: 52f1454f629fa ("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: Sasha Levin <sasha.levin@oracle.com>
-rw-r--r-- | net/packet/af_packet.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 9458455448bb..ec938baeb7cf 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2274,7 +2274,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 |