Skip to content

Commit c31e72d

Browse files
q2venPaolo Abeni
authored andcommitted
tcp: Fix use-after-free of nreq in reqsk_timer_handler().
The cited commit replaced inet_csk_reqsk_queue_drop_and_put() with __inet_csk_reqsk_queue_drop() and reqsk_put() in reqsk_timer_handler(). Then, oreq should be passed to reqsk_put() instead of req; otherwise use-after-free of nreq could happen when reqsk is migrated but the retry attempt failed (e.g. due to timeout). Let's pass oreq to reqsk_put(). Fixes: e8c526f ("tcp/dccp: Don't use timer_pending() in reqsk_queue_unlink().") Reported-by: Liu Jian <[email protected]> Closes: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Reviewed-by: Liu Jian <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Reviewed-by: Martin KaFai Lau <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent e2668c3 commit c31e72d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/ipv4/inet_connection_sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ static void reqsk_timer_handler(struct timer_list *t)
11911191

11921192
drop:
11931193
__inet_csk_reqsk_queue_drop(sk_listener, oreq, true);
1194-
reqsk_put(req);
1194+
reqsk_put(oreq);
11951195
}
11961196

11971197
static bool reqsk_queue_hash_req(struct request_sock *req,

0 commit comments

Comments
 (0)