diff options
author | Alexander Drozdov <al.drozdov@gmail.com> | 2015-07-28 13:57:01 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-09-29 19:26:24 +0200 |
commit | 2ef3d434d30f074fc744f86a956239feea922b04 (patch) | |
tree | 8e7879e19b4bb0ad1a1b7b0ee8c6c10db78e5dfe | |
parent | d339d03860f21b3f27a674312df09b6ce92c0c42 (diff) | |
download | lwn-2ef3d434d30f074fc744f86a956239feea922b04.tar.gz lwn-2ef3d434d30f074fc744f86a956239feea922b04.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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-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 733ef5a56dee..e1ea5d43b01e 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -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 |