diff options
| author | Bernard Pidoux <bernard.f6bvp@gmail.com> | 2026-05-28 19:38:31 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-06-27 11:07:40 +0100 |
| commit | 570e76a3c25f2edd2f5c6c15649f45e5a56f9eb1 (patch) | |
| tree | 5611ff2600bbbe744d5840b4392431cd760e085f | |
| parent | 4f9aa720a80f1a23b26a04d8bc9d403f96770d09 (diff) | |
| download | linux-stable-570e76a3c25f2edd2f5c6c15649f45e5a56f9eb1.tar.gz linux-stable-570e76a3c25f2edd2f5c6c15649f45e5a56f9eb1.zip | |
rose: release netdev ref and destroy orphaned incoming sockets
commit df12be096302d2c947388acc25764456c7f18cc1 upstream.
Two related cleanup gaps left the module unremovable after a loopback
session:
1. rose_destroy_socket() did not release the device reference. When
an unaccepted incoming socket (created by rose_rx_call_request()) is
destroyed via rose_heartbeat_expiry(), it is removed from rose_list
before rose_kill_by_device() can find it, so the netdev_hold() taken
in rose_rx_call_request() was never matched by netdev_put(). Add the
release at the top of rose_destroy_socket() guarded by a NULL check
so that rose_release() and rose_kill_by_device(), which already call
netdev_put() and set device = NULL, are not affected.
2. rose_heartbeat_expiry() STATE_0 cleanup required TCP_LISTEN in
addition to SOCK_DEAD. Unaccepted incoming sockets are
TCP_ESTABLISHED, so the condition was never true and those sockets
lingered forever, holding the module use count above zero and
blocking rmmod. Drop the TCP_LISTEN restriction: any STATE_0 +
SOCK_DEAD socket is orphaned and should be destroyed.
Together with the earlier rose_make_new() double-hold fix these three
patches allow clean rmmod after loopback sessions.
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | net/rose/af_rose.c | 9 | ||||
| -rw-r--r-- | net/rose/rose_timer.c | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 1f641516e03e..81b34b2ddf04 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -363,6 +363,7 @@ static void rose_destroy_timer(struct timer_list *t) */ void rose_destroy_socket(struct sock *sk) { + struct rose_sock *rose = rose_sk(sk); struct sk_buff *skb; rose_remove_socket(sk); @@ -370,6 +371,14 @@ void rose_destroy_socket(struct sock *sk) rose_stop_idletimer(sk); rose_stop_timer(sk); + /* Drop any device reference not already released by rose_kill_by_device() + * or rose_release() -- e.g. incoming sockets that were never accepted. + */ + if (rose->device) { + netdev_put(rose->device, &rose->dev_tracker); + rose->device = NULL; + } + rose_clear_queues(sk); /* Flush the queues */ while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { diff --git a/net/rose/rose_timer.c b/net/rose/rose_timer.c index aa3dd4ab4a49..76204b8250d0 100644 --- a/net/rose/rose_timer.c +++ b/net/rose/rose_timer.c @@ -128,10 +128,11 @@ static void rose_heartbeat_expiry(struct timer_list *t) } switch (rose->state) { case ROSE_STATE_0: - /* Magic here: If we listen() and a new link dies before it - is accepted() it isn't 'dead' so doesn't get removed. */ - if (sock_flag(sk, SOCK_DESTROY) || - (sk->sk_state == TCP_LISTEN && sock_flag(sk, SOCK_DEAD))) { + /* Destroy any orphaned STATE_0 socket: either explicitly + * flagged SOCK_DESTROY, or SOCK_DEAD (covers both unaccepted + * incoming connections and listening sockets whose link died). + */ + if (sock_flag(sk, SOCK_DESTROY) || sock_flag(sk, SOCK_DEAD)) { bh_unlock_sock(sk); rose_destroy_socket(sk); sock_put(sk); |
