On Thu, Nov 24, 2022 at 10:16:29AM +0100, Claudio Jeker wrote:
> On Wed, Nov 23, 2022 at 10:00:52PM +0000, Klemens Nanni wrote:
> > On Wed, Nov 23, 2022 at 10:47:53PM +0100, Claudio Jeker wrote:
> > > On Wed, Nov 23, 2022 at 02:54:08PM +0000, Klemens Nanni wrote:
> > > >  void
> > > > -nd6_ifdetach(struct nd_ifinfo *nd)
> > > > +nd6_ifdetach(struct ifnet *ifp)
> > > >  {
> > > > +       struct nd_ifinfo *nd = ifp->if_nd;
> > > >  
> > > 
> > > Would it make sense to set ifp->if_nd = NULL; here?
> > > 
> > > >         free(nd, M_IP6NDP, sizeof(*nd));
> > > >  }
> > 
> > I don't think so, the interface is about to be destroyed and disappear
> > shortly after nd6_ifdetach() and if_detach() return.
> 
> That may be correct right now. What if someone calls nd6_ifdetach when
> ifconfig if0 -inet6 is called? That's why I think it makes sense to set
> the ifp-?if_nd pointer to NULL here.

That'd be a double-free which shouldn't happen with proper locking and
I'd like to see a crash rather than free(9) silently doing nothing on
the already freed and NULL-ified pointer.

All call-sites expect *if_nd to be valid, should they check NULL then?

Reply via email to