* [PATCH net] sctp: change to hold/put transport for proto_unreach_timer
@ 2020-11-13 9:18 Xin Long
2020-11-13 12:35 ` Marcelo Ricardo Leitner
0 siblings, 1 reply; 3+ messages in thread
From: Xin Long @ 2020-11-13 9:18 UTC (permalink / raw)
To: network dev, linux-sctp
Cc: davem, kuba, Marcelo Ricardo Leitner, Neil Horman, Hangbin Liu
A call trace was found in Hangbin's Codenomicon testing with debug kernel:
[ 2615.981988] ODEBUG: free active (active state 0) object type: timer_list hint: sctp_generate_proto_unreach_event+0x0/0x3a0 [sctp]
[ 2615.995050] WARNING: CPU: 17 PID: 0 at lib/debugobjects.c:328 debug_print_object+0x199/0x2b0
[ 2616.095934] RIP: 0010:debug_print_object+0x199/0x2b0
[ 2616.191533] Call Trace:
[ 2616.194265] <IRQ>
[ 2616.202068] debug_check_no_obj_freed+0x25e/0x3f0
[ 2616.207336] slab_free_freelist_hook+0xeb/0x140
[ 2616.220971] kfree+0xd6/0x2c0
[ 2616.224293] rcu_do_batch+0x3bd/0xc70
[ 2616.243096] rcu_core+0x8b9/0xd00
[ 2616.256065] __do_softirq+0x23d/0xacd
[ 2616.260166] irq_exit+0x236/0x2a0
[ 2616.263879] smp_apic_timer_interrupt+0x18d/0x620
[ 2616.269138] apic_timer_interrupt+0xf/0x20
[ 2616.273711] </IRQ>
This is because it holds asoc when transport->proto_unreach_timer starts
and puts asoc when the timer stops, and without holding transport the
transport could be freed when the timer is still running.
So fix it by holding/putting transport instead for proto_unreach_timer
in transport, just like other timers in transport.
Fixes: 50b5d6ad6382 ("sctp: Fix a race between ICMP protocol unreachable and connect()")
Reported-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/sctp/input.c | 4 ++--
net/sctp/sm_sideeffect.c | 2 +-
net/sctp/transport.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 55d4fc6..d508f6f 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -449,7 +449,7 @@ void sctp_icmp_proto_unreachable(struct sock *sk,
else {
if (!mod_timer(&t->proto_unreach_timer,
jiffies + (HZ/20)))
- sctp_association_hold(asoc);
+ sctp_transport_hold(t);
}
} else {
struct net *net = sock_net(sk);
@@ -458,7 +458,7 @@ void sctp_icmp_proto_unreachable(struct sock *sk,
"encountered!\n", __func__);
if (del_timer(&t->proto_unreach_timer))
- sctp_association_put(asoc);
+ sctp_transport_put(t);
sctp_do_sm(net, SCTP_EVENT_T_OTHER,
SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 813d307..0a51150 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -419,7 +419,7 @@ void sctp_generate_proto_unreach_event(struct timer_list *t)
/* Try again later. */
if (!mod_timer(&transport->proto_unreach_timer,
jiffies + (HZ/20)))
- sctp_association_hold(asoc);
+ sctp_transport_hold(transport);
goto out_unlock;
}
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 806af58..60fcf31 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -133,7 +133,7 @@ void sctp_transport_free(struct sctp_transport *transport)
/* Delete the ICMP proto unreachable timer if it's active. */
if (del_timer(&transport->proto_unreach_timer))
- sctp_association_put(transport->asoc);
+ sctp_transport_put(transport);
sctp_transport_put(transport);
}
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] sctp: change to hold/put transport for proto_unreach_timer
2020-11-13 9:18 [PATCH net] sctp: change to hold/put transport for proto_unreach_timer Xin Long
@ 2020-11-13 12:35 ` Marcelo Ricardo Leitner
2020-11-14 5:26 ` Xin Long
0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-11-13 12:35 UTC (permalink / raw)
To: Xin Long; +Cc: network dev, linux-sctp, davem, kuba, Neil Horman, Hangbin Liu
Hi,
On Fri, Nov 13, 2020 at 05:18:24PM +0800, Xin Long wrote:
...
> diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
> index 813d307..0a51150 100644
> --- a/net/sctp/sm_sideeffect.c
> +++ b/net/sctp/sm_sideeffect.c
> @@ -419,7 +419,7 @@ void sctp_generate_proto_unreach_event(struct timer_list *t)
> /* Try again later. */
> if (!mod_timer(&transport->proto_unreach_timer,
> jiffies + (HZ/20)))
> - sctp_association_hold(asoc);
> + sctp_transport_hold(transport);
> goto out_unlock;
> }
>
The chunk above covers the socket busy case, but for the normal cases
it also needs:
@@ -435,7 +435,7 @@ void sctp_generate_proto_unreach_event(struct timer_list *t)
out_unlock:
bh_unlock_sock(sk);
- sctp_association_put(asoc);
+ sctp_transport_put(asoc);
}
/* Handle the timeout of the RE-CONFIG timer. */
> diff --git a/net/sctp/transport.c b/net/sctp/transport.c
> index 806af58..60fcf31 100644
> --- a/net/sctp/transport.c
> +++ b/net/sctp/transport.c
> @@ -133,7 +133,7 @@ void sctp_transport_free(struct sctp_transport *transport)
>
> /* Delete the ICMP proto unreachable timer if it's active. */
> if (del_timer(&transport->proto_unreach_timer))
> - sctp_association_put(transport->asoc);
> + sctp_transport_put(transport);
>
> sctp_transport_put(transport);
Btw, quite noticeable on the above list of timers that only this timer
was using a reference on the asoc. Seems we're good now, then. :-)
Marcelo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] sctp: change to hold/put transport for proto_unreach_timer
2020-11-13 12:35 ` Marcelo Ricardo Leitner
@ 2020-11-14 5:26 ` Xin Long
0 siblings, 0 replies; 3+ messages in thread
From: Xin Long @ 2020-11-14 5:26 UTC (permalink / raw)
To: Marcelo Ricardo Leitner
Cc: network dev, linux-sctp, davem, Jakub Kicinski, Neil Horman, Hangbin Liu
On Fri, Nov 13, 2020 at 8:35 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> Hi,
>
> On Fri, Nov 13, 2020 at 05:18:24PM +0800, Xin Long wrote:
> ...
> > diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
> > index 813d307..0a51150 100644
> > --- a/net/sctp/sm_sideeffect.c
> > +++ b/net/sctp/sm_sideeffect.c
> > @@ -419,7 +419,7 @@ void sctp_generate_proto_unreach_event(struct timer_list *t)
> > /* Try again later. */
> > if (!mod_timer(&transport->proto_unreach_timer,
> > jiffies + (HZ/20)))
> > - sctp_association_hold(asoc);
> > + sctp_transport_hold(transport);
> > goto out_unlock;
> > }
> >
>
> The chunk above covers the socket busy case, but for the normal cases
> it also needs:
>
> @@ -435,7 +435,7 @@ void sctp_generate_proto_unreach_event(struct timer_list *t)
>
> out_unlock:
> bh_unlock_sock(sk);
> - sctp_association_put(asoc);
> + sctp_transport_put(asoc);
> }
yeah, right, posted v2.
Thanks.
>
> /* Handle the timeout of the RE-CONFIG timer. */
>
> > diff --git a/net/sctp/transport.c b/net/sctp/transport.c
> > index 806af58..60fcf31 100644
> > --- a/net/sctp/transport.c
> > +++ b/net/sctp/transport.c
> > @@ -133,7 +133,7 @@ void sctp_transport_free(struct sctp_transport *transport)
> >
> > /* Delete the ICMP proto unreachable timer if it's active. */
> > if (del_timer(&transport->proto_unreach_timer))
> > - sctp_association_put(transport->asoc);
> > + sctp_transport_put(transport);
> >
> > sctp_transport_put(transport);
>
> Btw, quite noticeable on the above list of timers that only this timer
> was using a reference on the asoc. Seems we're good now, then. :-)
>
correct! :D
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-14 5:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 9:18 [PATCH net] sctp: change to hold/put transport for proto_unreach_timer Xin Long
2020-11-13 12:35 ` Marcelo Ricardo Leitner
2020-11-14 5:26 ` Xin Long
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.