--- zzzz-none-000/linux-4.9.279/net/l2tp/l2tp_ppp.c 2021-08-08 06:38:54.000000000 +0000 +++ puma7-atom-6591-750/linux-4.9.279/net/l2tp/l2tp_ppp.c 2023-02-08 11:43:43.000000000 +0000 @@ -449,6 +449,9 @@ inet_shutdown(sk->sk_socket, SEND_SHUTDOWN); sock_put(sk); } + + /* Don't let the session go away before our socket does */ + l2tp_session_inc_refcount(session); } /* Really kill the session socket. (Called from sock_put() if @@ -504,7 +507,8 @@ if (session != NULL) { struct pppol2tp_session *ps; - l2tp_session_delete(session); + __l2tp_session_unhash(session); + l2tp_session_queue_purge(session); ps = l2tp_session_priv(session); mutex_lock(&ps->sk_lock); @@ -749,7 +753,7 @@ if (tunnel->peer_tunnel_id == 0) tunnel->peer_tunnel_id = peer_tunnel_id; - session = l2tp_session_get(sock_net(sk), tunnel, session_id, false); + session = l2tp_session_get(sock_net(sk), tunnel, session_id); if (session) { drop_refcnt = true; ps = l2tp_session_priv(session); @@ -858,6 +862,7 @@ { int error; struct l2tp_session *session; + struct pppol2tp_session *ps; /* Error if tunnel socket is not prepped */ if (!tunnel->sock) { @@ -886,6 +891,9 @@ if (error < 0) goto err_sess; + l2tp_info(session, L2TP_MSG_CONTROL, "%s: created\n", + session->name); + return 0; err_sess: @@ -1200,13 +1208,11 @@ /* resend to session ioctl handler */ struct l2tp_session *session = l2tp_session_get(sock_net(sk), tunnel, - stats.session_id, true); + stats.session_id); if (session) { err = pppol2tp_session_ioctl(session, cmd, arg); - if (session->deref) - session->deref(session); l2tp_session_dec_refcount(session); } else { err = -EBADR; @@ -1337,7 +1343,7 @@ err = -EINVAL; break; } - session->recv_seq = val ? -1 : 0; + session->recv_seq = !!val; l2tp_info(session, L2TP_MSG_CONTROL, "%s: set recv_seq=%d\n", session->name, session->recv_seq); @@ -1348,7 +1354,7 @@ err = -EINVAL; break; } - session->send_seq = val ? -1 : 0; + session->send_seq = !!val; { struct pppox_sock *po = pppox_sk(sk); @@ -1366,7 +1372,7 @@ err = -EINVAL; break; } - session->lns_mode = val ? -1 : 0; + session->lns_mode = !!val; l2tp_info(session, L2TP_MSG_CONTROL, "%s: set lns_mode=%d\n", session->name, session->lns_mode); @@ -1619,7 +1625,7 @@ static void pppol2tp_next_session(struct net *net, struct pppol2tp_seq_data *pd) { - pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx, true); + pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx); pd->session_idx++; if (pd->session == NULL) { @@ -1672,7 +1678,7 @@ seq_printf(m, "\nTUNNEL '%s', %c %d\n", tunnel->name, (tunnel == tunnel->sock->sk_user_data) ? 'Y' : 'N', - atomic_read(&tunnel->ref_count) - 1); + refcount_read(&tunnel->ref_count) - 1); seq_printf(m, " %08x %ld/%ld/%ld %ld/%ld/%ld\n", tunnel->debug, atomic_long_read(&tunnel->stats.tx_packets), @@ -1762,8 +1768,6 @@ pppol2tp_seq_tunnel_show(m, pd->tunnel); } else { pppol2tp_seq_session_show(m, pd->session); - if (pd->session->deref) - pd->session->deref(pd->session); l2tp_session_dec_refcount(pd->session); }