Skip to content

Commit 8ce675f

Browse files
sowminivdavem330
authored andcommitted
RDS-TCP: Recover correctly from pskb_pull()/pksb_trim() failure in rds_tcp_data_recv
Either of pskb_pull() or pskb_trim() may fail under low memory conditions. If rds_tcp_data_recv() ignores such failures, the application will receive corrupted data because the skb has not been correctly carved to the RDS datagram size. Avoid this by handling pskb_pull/pskb_trim failure in the same manner as the skb_clone failure: bail out of rds_tcp_data_recv(), and retry via the deferred call to rds_send_worker() that gets set up on ENOMEM from rds_tcp_read_sock() Signed-off-by: Sowmini Varadhan <[email protected]> Acked-by: Santosh Shilimkar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0b7c874 commit 8ce675f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

net/rds/tcp_recv.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,15 @@ static int rds_tcp_data_recv(read_descriptor_t *desc, struct sk_buff *skb,
214214
}
215215

216216
to_copy = min(tc->t_tinc_data_rem, left);
217-
pskb_pull(clone, offset);
218-
pskb_trim(clone, to_copy);
217+
if (!pskb_pull(clone, offset) ||
218+
pskb_trim(clone, to_copy)) {
219+
pr_warn("rds_tcp_data_recv: pull/trim failed "
220+
"left %zu data_rem %zu skb_len %d\n",
221+
left, tc->t_tinc_data_rem, skb->len);
222+
kfree_skb(clone);
223+
desc->error = -ENOMEM;
224+
goto out;
225+
}
219226
skb_queue_tail(&tinc->ti_skb_list, clone);
220227

221228
rdsdebug("skb %p data %p len %d off %u to_copy %zu -> "

0 commit comments

Comments
 (0)