Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

l2tp: fix l2tp_session_register with colliding l2tpv3 IDs

When handling colliding L2TPv3 session IDs, we use the existing
session IDR entry and link the new session on that using
session->coll_list. However, when using an existing IDR entry, we must
not do the idr_replace step.

Fixes: aa5e17e1f5ec ("l2tp: store l2tpv3 sessions in per-net IDR")
Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

James Chapman and committed by
David S. Miller
2146b7dd b6c67967

+10 -8
+10 -8
net/l2tp/l2tp_core.c
··· 436 436 struct l2tp_tunnel *tunnel) 437 437 { 438 438 struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net); 439 + struct l2tp_session *other_session = NULL; 439 440 u32 session_key; 440 441 int err; 441 442 ··· 457 456 * support existing userspace which depends on it. 458 457 */ 459 458 if (err == -ENOSPC && tunnel->encap == L2TP_ENCAPTYPE_UDP) { 460 - struct l2tp_session *session2; 461 - 462 - session2 = idr_find(&pn->l2tp_v3_session_idr, 463 - session_key); 464 - err = l2tp_session_collision_add(pn, session, session2); 459 + other_session = idr_find(&pn->l2tp_v3_session_idr, 460 + session_key); 461 + err = l2tp_session_collision_add(pn, session, 462 + other_session); 465 463 } 466 464 spin_unlock_bh(&pn->l2tp_session_idr_lock); 467 465 } else { ··· 484 484 spin_unlock_bh(&tunnel->list_lock); 485 485 486 486 spin_lock_bh(&pn->l2tp_session_idr_lock); 487 - if (tunnel->version == L2TP_HDR_VER_3) 488 - idr_replace(&pn->l2tp_v3_session_idr, session, session_key); 489 - else 487 + if (tunnel->version == L2TP_HDR_VER_3) { 488 + if (!other_session) 489 + idr_replace(&pn->l2tp_v3_session_idr, session, session_key); 490 + } else { 490 491 idr_replace(&pn->l2tp_v2_session_idr, session, session_key); 492 + } 491 493 spin_unlock_bh(&pn->l2tp_session_idr_lock); 492 494 493 495 trace_register_session(session);