Skip to content

Commit 89a5ea9

Browse files
zx2c4davem330
authored andcommitted
rxrpc: check return value of skb_to_sgvec always
Signed-off-by: Jason A. Donenfeld <[email protected]> Acked-by: David Howells <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3f29770 commit 89a5ea9

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

net/rxrpc/rxkad.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call,
227227
len &= ~(call->conn->size_align - 1);
228228

229229
sg_init_table(sg, nsg);
230-
skb_to_sgvec(skb, sg, 0, len);
230+
err = skb_to_sgvec(skb, sg, 0, len);
231+
if (unlikely(err < 0))
232+
goto out;
231233
skcipher_request_set_crypt(req, sg, sg, len, iv.x);
232234
crypto_skcipher_encrypt(req);
233235

@@ -324,7 +326,7 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb,
324326
bool aborted;
325327
u32 data_size, buf;
326328
u16 check;
327-
int nsg;
329+
int nsg, ret;
328330

329331
_enter("");
330332

@@ -342,7 +344,9 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb,
342344
goto nomem;
343345

344346
sg_init_table(sg, nsg);
345-
skb_to_sgvec(skb, sg, offset, 8);
347+
ret = skb_to_sgvec(skb, sg, offset, 8);
348+
if (unlikely(ret < 0))
349+
return ret;
346350

347351
/* start the decryption afresh */
348352
memset(&iv, 0, sizeof(iv));
@@ -409,7 +413,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,
409413
bool aborted;
410414
u32 data_size, buf;
411415
u16 check;
412-
int nsg;
416+
int nsg, ret;
413417

414418
_enter(",{%d}", skb->len);
415419

@@ -434,7 +438,12 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,
434438
}
435439

436440
sg_init_table(sg, nsg);
437-
skb_to_sgvec(skb, sg, offset, len);
441+
ret = skb_to_sgvec(skb, sg, offset, len);
442+
if (unlikely(ret < 0)) {
443+
if (sg != _sg)
444+
kfree(sg);
445+
return ret;
446+
}
438447

439448
/* decrypt from the session key */
440449
token = call->conn->params.key->payload.data[0];

0 commit comments

Comments
 (0)