From patchwork Tue Apr 25 15:52:14 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: 9698697 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 C764060224 for ; Tue, 25 Apr 2017 15:52:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6DDA2862A for ; Tue, 25 Apr 2017 15:52:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABDF728630; Tue, 25 Apr 2017 15:52:57 +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 0439D2862A for ; Tue, 25 Apr 2017 15:52:56 +0000 (UTC) Received: (qmail 31776 invoked by uid 550); 25 Apr 2017 15:52:43 -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 30078 invoked from network); 25 Apr 2017 15:52:35 -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=+kXQ bOnU6hXEtpg/VBqSW8muPog=; b=2h4tEkODtvrAL4k3oNhypKmkLdUcDsNgSHae 74ZSRO77aEd169Xfu54ruba57to9ZU/ZosfEWzA3EUhoPM7L3BMqvh3fTQvXXehg XzlEM3kOOHs2oaUxEM6JigA51dgqJUpf7xz/nEXDlU4tJtitDkWV3k3KL7gSp8XJ wOwvzJdXm9zHXy6mgceAfvdPPlgD0hQ7li2tiMKHnqAkhFUD8MECbDpf5GiG1S7k XgRgLAGFjI+HcROaA3ZTglnT8lgW1ZfK3f2igg7CaIsNK+r8zibBmn85lZrKhjL3 9/Hl7vuy+WV+1CIn3WXmJ5KbfaLoY3qv8R+ux94d4DvKGqwEog== 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:14 +0200 Message-Id: <20170425155215.4835-4-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 4/5] macsec: check return value of skb_to_sgvec always X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jason A. Donenfeld --- drivers/net/macsec.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index dbab05afcdbe..d846f42b99ec 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -733,7 +733,12 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb, macsec_fill_iv(iv, secy->sci, pn); sg_init_table(sg, MAX_SKB_FRAGS + 1); - skb_to_sgvec(skb, sg, 0, skb->len); + ret = skb_to_sgvec(skb, sg, 0, skb->len); + if (unlikely(ret < 0)) { + macsec_txsa_put(tx_sa); + kfree_skb(skb); + return ERR_PTR(ret); + } if (tx_sc->encrypt) { int len = skb->len - macsec_hdr_len(sci_present) - @@ -937,7 +942,11 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb, macsec_fill_iv(iv, sci, ntohl(hdr->packet_number)); sg_init_table(sg, MAX_SKB_FRAGS + 1); - skb_to_sgvec(skb, sg, 0, skb->len); + ret = skb_to_sgvec(skb, sg, 0, skb->len); + if (unlikely(ret < 0)) { + kfree_skb(skb); + return ERR_PTR(ret); + } if (hdr->tci_an & MACSEC_TCI_E) { /* confidentiality: ethernet + macsec header