From: Nathan Chancellor <natechancellor@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
"David S . Miller" <davem@davemloft.net>,
Nathan Chancellor <natechancellor@gmail.com>
Subject: [PATCH 3.18 2/3] virtio_net: check return value of skb_to_sgvec always
Date: Mon, 9 Apr 2018 18:21:43 -0700 [thread overview]
Message-ID: <20180410012150.6573-3-natechancellor@gmail.com> (raw)
In-Reply-To: <20180410012150.6573-1-natechancellor@gmail.com>
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
commit e2fcad58fd230f635a74e4e983c6f4ea893642d2 upstream.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[natechancellor: backport to 3.18]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/net/virtio_net.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index ce2a29971230..ede40841e962 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -854,7 +854,7 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
struct skb_vnet_hdr *hdr;
const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
struct virtnet_info *vi = sq->vq->vdev->priv;
- unsigned num_sg;
+ int num_sg;
unsigned hdr_len;
bool can_push;
@@ -906,11 +906,16 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
if (can_push) {
__skb_push(skb, hdr_len);
num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len);
+ if (unlikely(num_sg < 0))
+ return num_sg;
/* Pull header back to avoid skew in tx bytes calculations. */
__skb_pull(skb, hdr_len);
} else {
sg_set_buf(sq->sg, hdr, hdr_len);
- num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1;
+ num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len);
+ if (unlikely(num_sg < 0))
+ return num_sg;
+ num_sg++;
}
return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb, GFP_ATOMIC);
}
--
2.17.0
next prev parent reply other threads:[~2018-04-10 1:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-10 1:21 Further fixes for 48a1df65334b Nathan Chancellor
2018-04-10 1:21 ` [PATCH 3.18 1/3] rxrpc: check return value of skb_to_sgvec always Nathan Chancellor
2018-04-10 1:21 ` Nathan Chancellor [this message]
2018-04-10 1:21 ` [PATCH 3.18 3/3] virtio_net: check return value of skb_to_sgvec in one more location Nathan Chancellor
2018-04-10 12:34 ` Patch "virtio_net: check return value of skb_to_sgvec in one more location" has been added to the 3.18-stable tree gregkh
2018-04-10 1:21 ` [PATCH 4.4 1/3] rxrpc: check return value of skb_to_sgvec always Nathan Chancellor
2018-04-10 1:21 ` [PATCH 4.4 2/3] virtio_net: " Nathan Chancellor
2018-04-10 1:21 ` [PATCH 4.4 3/3] virtio_net: check return value of skb_to_sgvec in one more location Nathan Chancellor
2018-04-10 9:07 ` Patch "virtio_net: check return value of skb_to_sgvec in one more location" has been added to the 4.4-stable tree gregkh
2018-04-10 1:21 ` [PATCH 4.9 1/3] rxrpc: check return value of skb_to_sgvec always Nathan Chancellor
2018-04-10 1:21 ` [PATCH 4.9 2/3] virtio_net: " Nathan Chancellor
2018-04-10 1:21 ` [PATCH 4.9 3/3] virtio_net: check return value of skb_to_sgvec in one more location Nathan Chancellor
2018-04-10 6:35 ` Greg Kroah-Hartman
2018-04-10 7:11 ` Greg Kroah-Hartman
2018-04-10 7:12 ` Patch "virtio_net: check return value of skb_to_sgvec in one more location" has been added to the 4.9-stable tree gregkh
2018-04-10 12:53 ` Further fixes for 48a1df65334b Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180410012150.6573-3-natechancellor@gmail.com \
--to=natechancellor@gmail.com \
--cc=Jason@zx2c4.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).