From patchwork Tue Apr 25 15:52:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 9698693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6BFC160224 for ; Tue, 25 Apr 2017 15:52:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B10928630 for ; Tue, 25 Apr 2017 15:52:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FE8C2864D; Tue, 25 Apr 2017 15:52:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 6E8AF28630 for ; Tue, 25 Apr 2017 15:52:51 +0000 (UTC) Received: (qmail 30644 invoked by uid 550); 25 Apr 2017 15:52:42 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 30267 invoked from network); 25 Apr 2017 15:52:36 -0000 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=mail; bh=nyXn SXWiPMRxGDPQNyPBOxCezw4=; b=ybg33FgqwbxxD4TXikWgoyoiYCeBMi98R9Eg 0g5fgeDD/ttNIWkxkIZ1GSlq4cxAeb/uAmquslEyqReMyq8pFihDD9hieqwDrvvV YExjACLlXm5LbQa9qKH/Jys3VMepM7NWYYQCiak4gNySKprjJX4tyTjZG4dlFp/a lTv+24pyCcWIpK6Vj+P37AVsIP5QFqVx08jcEOCOA2o2TDOTNWNAyAyzBW/dhVec JHToySuWKOS7l+MJzvA1LaxNcGSxlJvT+2gtxFFqrVGN9Qv8uIFguXYJfgoSkTQI Hi10a5JJK3g9ZeV2Xk6VV9LXGHvaF4ew4yg+oJbAluxZqR59qQ== From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David.Laight@aculab.com, kernel-hardening@lists.openwall.com, davem@davemloft.net Cc: "Jason A. Donenfeld" Date: Tue, 25 Apr 2017 17:52:15 +0200 Message-Id: <20170425155215.4835-5-Jason@zx2c4.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170425155215.4835-1-Jason@zx2c4.com> References: <20170425.111717.1973239615715123840.davem@davemloft.net> <20170425155215.4835-1-Jason@zx2c4.com> Subject: [kernel-hardening] [PATCH v5 5/5] virtio_net: check return value of skb_to_sgvec always X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jason A. Donenfeld --- drivers/net/virtio_net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index f36584616e7d..1709fd0b4bf7 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1081,7 +1081,7 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb) struct virtio_net_hdr_mrg_rxbuf *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 = vi->hdr_len; bool can_push; @@ -1114,6 +1114,8 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb) sg_set_buf(sq->sg, hdr, hdr_len); num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1; } + if (unlikely(num_sg < 0)) + return num_sg; return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb, GFP_ATOMIC); }