From patchwork Tue Apr 25 15:52:13 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: 9698689 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 B198B60224 for ; Tue, 25 Apr 2017 15:52:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FD852862A for ; Tue, 25 Apr 2017 15:52:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9261A28630; Tue, 25 Apr 2017 15:52:44 +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 BED952862A for ; Tue, 25 Apr 2017 15:52:43 +0000 (UTC) Received: (qmail 30619 invoked by uid 550); 25 Apr 2017 15:52:41 -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 30027 invoked from network); 25 Apr 2017 15:52:34 -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=iEby DWy+h8/LDmdYfRtHjX9XPro=; b=u7VqWySmu6U8yM1b6hYvJ6cJbZ25dB8zofF0 VNOjES1gI5qnpZ84o+PLZmjJ3okTWoHtNysRkRxIDW2uvqvU918y5QeKLu8+jq8P JdGDq/oOHJ15RDIY73+BugMsF6VXAXPAg9/Bb9pploEo0wNWEddZVtq5ZDDwZQ2P NUves5HqC1wJSY6r3iR3jkr5jhwj4ZEyJf5yB1FZ1GkF065F04bL4SkxIUR8e5VE PS1t+VgbJx+XOmJd73De5V6ZbGbu4s5D/FBHhM318iMZF29sWYqPiT02rmz3nw2/ h74UKkjbM3EiZ1KcJpmjqmGOfll1P1/oIyapjr6ZCAkOtNA59g== 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:13 +0200 Message-Id: <20170425155215.4835-3-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 3/5] rxrpc: check return value of skb_to_sgvec always X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jason A. Donenfeld --- net/rxrpc/rxkad.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c index 4374e7b9c7bf..dcf46c9c3ece 100644 --- a/net/rxrpc/rxkad.c +++ b/net/rxrpc/rxkad.c @@ -229,7 +229,9 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call, len &= ~(call->conn->size_align - 1); sg_init_table(sg, nsg); - skb_to_sgvec(skb, sg, 0, len); + err = skb_to_sgvec(skb, sg, 0, len); + if (unlikely(err < 0)) + goto out; skcipher_request_set_crypt(req, sg, sg, len, iv.x); crypto_skcipher_encrypt(req); @@ -342,7 +344,8 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, goto nomem; sg_init_table(sg, nsg); - skb_to_sgvec(skb, sg, offset, 8); + if (unlikely(skb_to_sgvec(skb, sg, offset, 8) < 0)) + goto nomem; /* start the decryption afresh */ memset(&iv, 0, sizeof(iv)); @@ -429,7 +432,8 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, } sg_init_table(sg, nsg); - skb_to_sgvec(skb, sg, offset, len); + if (unlikely(skb_to_sgvec(skb, sg, offset, len) < 0)) + goto nomem; /* decrypt from the session key */ token = call->conn->params.key->payload.data[0];