Skip to content

Commit ef72b08

Browse files
sowminivgerd-rausch
authored andcommitted
RDS-TCP: Recover correctly from pskb_pull()/pksb_trim() failure in rds_tcp_data_recv
[ Upstream commit 8ce675f ] 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() Orabug: 22623837 Signed-off-by: Sowmini Varadhan <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Dan Duval <[email protected]> Acked-by: Santosh Shilimkar <[email protected]> Orabug: 27364391 (cherry picked from commit ad81286) cherry-pick-repo=linux-uek.git Signed-off-by: Gerd Rausch <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent 9e53269 commit ef72b08

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
@@ -215,8 +215,15 @@ static int rds_tcp_data_recv(read_descriptor_t *desc, struct sk_buff *skb,
215215
}
216216

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

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

0 commit comments

Comments
 (0)