From patchwork Tue May 9 13:50:07 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: 9717985 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 E3976603F8 for ; Tue, 9 May 2017 13:52:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D743526E46 for ; Tue, 9 May 2017 13:52:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBF5528414; Tue, 9 May 2017 13:52:14 +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 05CE728408 for ; Tue, 9 May 2017 13:52:13 +0000 (UTC) Received: (qmail 27973 invoked by uid 550); 9 May 2017 13:51:51 -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 27880 invoked from network); 9 May 2017 13:51:49 -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=n5G5 PCv0QP5L0LzW140urO5pX6o=; b=wgHXmwQtu3wrxQ87AP2LMi+nXX305Gxi7WWB NFA2t9OOkFik0fpgxM2Iemu+fdnmp18+86SZSWH0K/8iR4yKZcE2FzpxcUA35W/1 kNJm+yT1G3/9Gzbbe9mjecVMrsWjqHtFVUqgVy2fLoXqO4QxKr6/DN9uLnPgSoEM p02ES4ad3W1KpPW46+BWs2RKOzSCH8LyCzjKWTEbBthQaewEy3WbIxA5H8l52uqT rub12ad2+UVqnyHwUtfFnC+OGc+Q0SPHk/5WmRAbY5A1cIUNHTQ0iL9HWP+N1+yw wUwaMr/F0ze/PynUeB7s+RixtLfiqDE/pVX4+586oiTYaH1a9w== From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, kernel-hardening@lists.openwall.com Cc: "Jason A. Donenfeld" , David Howells Date: Tue, 9 May 2017 15:50:07 +0200 Message-Id: <20170509135009.13751-4-Jason@zx2c4.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170509135009.13751-1-Jason@zx2c4.com> References: <20170509135009.13751-1-Jason@zx2c4.com> Subject: [kernel-hardening] [PATCH v7 3/5] rxrpc: check return value of skb_to_sgvec always X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jason A. Donenfeld Cc: David Howells --- net/rxrpc/rxkad.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c index 4374e7b9c7bf..486026689448 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,11 @@ 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)) { + if (sg != _sg) + kfree(sg); + goto nomem; + } /* decrypt from the session key */ token = call->conn->params.key->payload.data[0];