Re: use-after-free in sixpack_close
From: One Thousand Gnomes
Date: Thu Dec 17 2015 - 18:48:11 EST
On Thu, 17 Dec 2015 16:05:32 -0500 (EST)
David Miller <davem@xxxxxxxxxxxxx> wrote:
> From: One Thousand Gnomes <gnomes@xxxxxxxxxxxxxxxxxxx>
> Date: Thu, 17 Dec 2015 11:41:04 +0000
>
> >> This report is then followed by a dozen of other use-after-free reports.
> >>
> >> On commit edb42dc7bc0da0125ceacab810a553ce1f0cac8d (Dec 15).
> >>
> >> Thank you
> >
> > sixpack_close does unregister_netdev(sp->dev), which frees sp as sp is
> > actually allocated via alloc_netdev()
> >
> > Then deletes two timers within sp
> >
> > Then frees two buffers indexed off sp
>
> This should fix it, the only thing I'm unsure of is if we should perhaps
> also use del_timer_sync() here. Anyone?
I think you need to yes as the timers use the data you wil be freeing in
the unregister.
Also you are at the point the tty is closing so the net device may be
active. Don't you need to netif_stop_queue() or defer the buffer
kfrees until after the network device is unregistered so you don't pee
into free memory if you have a transmit occurring ?
Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/