Re: pppac(4): fix races in pppacopen()

2020-07-13 Thread Vitaliy Makkoveev
Forget please about previous diff. Except ac_ioctl() the only function which can have race with pppacclose() is pppacopen(), but since `sc' is still linked to `pppac_devs' list we can't reopen dying `sc'. So the only race is pppacopen() vs pppacopen(). We only need to malloc(9) before pppac_l

Re: pppac(4): fix races in pppacopen()

2020-07-13 Thread Vitaliy Makkoveev
On Mon, Jul 13, 2020 at 09:39:38AM +0200, Martin Pieuchot wrote: > On 11/07/20(Sat) 23:51, Vitaliy Makkoveev wrote: > > [...] > > The way you suggest to go is to introduce rwlock and serialize > > pppacopen() and pppacclose(). This is bad idea because we will sleep > > while we are holding rwlock.

Re: pppac(4): fix races in pppacopen()

2020-07-13 Thread Martin Pieuchot
On 11/07/20(Sat) 23:51, Vitaliy Makkoveev wrote: > [...] > The way you suggest to go is to introduce rwlock and serialize > pppacopen() and pppacclose(). This is bad idea because we will sleep > while we are holding rwlock. That's the whole point of a rwlock to be able to sleep while holding the

Re: pppac(4): fix races in pppacopen()

2020-07-11 Thread Vitaliy Makkoveev
On Sat, Jul 11, 2020 at 10:11:03AM +0200, Martin Pieuchot wrote: > On 10/07/20(Fri) 14:38, Vitaliy Makkoveev wrote: > > On Fri, Jul 10, 2020 at 01:22:40PM +0200, Martin Pieuchot wrote: > > > On 10/07/20(Fri) 14:07, Vitaliy Makkoveev wrote: > > > > We have some races in pppac(4) > > > > 1. malloc(9)

Re: pppac(4): fix races in pppacopen()

2020-07-11 Thread Martin Pieuchot
On 10/07/20(Fri) 14:38, Vitaliy Makkoveev wrote: > On Fri, Jul 10, 2020 at 01:22:40PM +0200, Martin Pieuchot wrote: > > On 10/07/20(Fri) 14:07, Vitaliy Makkoveev wrote: > > > We have some races in pppac(4) > > > 1. malloc(9) can sleep so we must check `sc' presence after malloc(9) > > > > Makes se

Re: pppac(4): fix races in pppacopen()

2020-07-10 Thread Vitaliy Makkoveev
On Fri, Jul 10, 2020 at 01:22:40PM +0200, Martin Pieuchot wrote: > On 10/07/20(Fri) 14:07, Vitaliy Makkoveev wrote: > > We have some races in pppac(4) > > 1. malloc(9) can sleep so we must check `sc' presence after malloc(9) > > Makes sense. > > > 2. we can sleep between `sc' insertion to `sc_ent

pppac(4): fix races in pppacopen()

2020-07-10 Thread Vitaliy Makkoveev
We have some races in pppac(4) 1. malloc(9) can sleep so we must check `sc' presence after malloc(9) 2. we can sleep between `sc' insertion to `sc_entry' list and `sc_pipex_iface' initialization. Concurrent pppacioctl() can touch this incomplete `sc'. Index: sys/net/if_pppx.c

Re: pppac(4): fix races in pppacopen()

2020-07-10 Thread Martin Pieuchot
On 10/07/20(Fri) 14:07, Vitaliy Makkoveev wrote: > We have some races in pppac(4) > 1. malloc(9) can sleep so we must check `sc' presence after malloc(9) Makes sense. > 2. we can sleep between `sc' insertion to `sc_entry' list and > `sc_pipex_iface' initialization. Concurrent pppacioctl() can to