Re: [PATCHv4 net 1/3] bonding: move IPsec deletion to bond_ipsec_free_sa

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 06, 2025 at 01:37:15PM +0000, Cosmin Ratiu wrote:
> On Thu, 2025-03-06 at 10:02 +0000, Hangbin Liu wrote:
> > > For bond_ipsec_add_sa_all(), I will move the xso.real_dev =
> > > real_dev
> > > after .xdo_dev_state_add() in case the following situation.
> 
> xso.real_dev needs to be initialized before the call to
> xdo_dev_state_add, since many of the implementations look in
> xso.real_dev to determine on which device to operate on.
> So the ordering should be:
> - get the lock
> - set xso.real_dev to real_dev
> - release the lock
> - call xdo_dev_state_add
> - if it fails, reacquire the lock and set the device to NULL.
> 
> Unfortunately, this doesn't seem to protect against the scenario below,
> as after dropping the spinlock from bond_ipsec_add_sa_all,
> bond_ipsec_del_sa can freely call xdo_dev_state_delete() on real_dev
> before xdo_dev_state_add happens.
> 
> I don't know what to do in this case...

Yes, me neither. How about add a note and leave it there until we
have a solution?

Regards
Hangbin
> 
> > > 
> > > bond_ipsec_add_sa_all()
> > > spin_unlock(&ipsec->x->lock);
> > > ipsec->xs->xso.real_dev = real_dev;
> > >                                 __xfrm_state_delete x->state = DEAD
> > >                                   - bond_ipsec_del_sa()
> > >                                     - .xdo_dev_state_delete()
> > > .xdo_dev_state_add()
> 
> Cosmin.




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux