stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	"David S . Miller" <davem@davemloft.net>,
	Nathan Chancellor <natechancellor@gmail.com>
Subject: [PATCH 4.9 1/3] rxrpc: check return value of skb_to_sgvec always
Date: Mon,  9 Apr 2018 18:21:48 -0700	[thread overview]
Message-ID: <20180410012150.6573-8-natechancellor@gmail.com> (raw)
In-Reply-To: <20180410012150.6573-1-natechancellor@gmail.com>

From: "Jason A. Donenfeld" <Jason@zx2c4.com>

commit 89a5ea99662505d2d61f2a3030a6896c2cb3cdb0 upstream.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 net/rxrpc/rxkad.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index 4374e7b9c7bf..90df95e18ea4 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);
 
@@ -325,7 +327,7 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb,
 	struct sk_buff *trailer;
 	u32 data_size, buf;
 	u16 check;
-	int nsg;
+	int nsg, ret;
 
 	_enter("");
 
@@ -342,7 +344,9 @@ 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);
+	ret = skb_to_sgvec(skb, sg, offset, 8);
+	if (unlikely(ret < 0))
+		return ret;
 
 	/* start the decryption afresh */
 	memset(&iv, 0, sizeof(iv));
@@ -405,7 +409,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,
 	struct sk_buff *trailer;
 	u32 data_size, buf;
 	u16 check;
-	int nsg;
+	int nsg, ret;
 
 	_enter(",{%d}", skb->len);
 
@@ -429,7 +433,12 @@ 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);
+	ret = skb_to_sgvec(skb, sg, offset, len);
+	if (unlikely(ret < 0)) {
+		if (sg != _sg)
+			kfree(sg);
+		return ret;
+	}
 
 	/* decrypt from the session key */
 	token = call->conn->params.key->payload.data[0];
-- 
2.17.0

  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 ` [PATCH 3.18 2/3] virtio_net: " Nathan Chancellor
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 ` Nathan Chancellor [this message]
2018-04-10  1:21 ` [PATCH 4.9 2/3] virtio_net: check return value of skb_to_sgvec always 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-8-natechancellor@gmail.com \
    --to=natechancellor@gmail.com \
    --cc=Jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --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).