Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-25 Thread Vitaliy Makkoveev
On Thu, Jun 25, 2020 at 11:54:48AM +0200, Martin Pieuchot wrote: > On 23/06/20(Tue) 16:21, Martin Pieuchot wrote: > > On 23/06/20(Tue) 04:53, Jason A. Donenfeld wrote: > > > On 6/23/20, Martin Pieuchot wrote: > > > > On 23/06/20(Tue) 01:00, Jason A. Donenfeld wrote: > > > >> You can crash a system

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-25 Thread Vitaliy Makkoveev
On Tue, Jun 23, 2020 at 01:00:06AM -0600, Jason A. Donenfeld wrote: > You can crash a system by running something like: > > for i in 1 2 3; do while true; do ifconfig bridge0 create& ifconfig > bridge0 destroy& done& done > > This works with every type of interface I've tried. It appears tha

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-25 Thread Jason A. Donenfeld
On Thu, Jun 25, 2020 at 3:54 AM Vitaliy Makkoveev wrote: > ifp = ifunit(name); > if (ifp == NULL) > return (ENXIO); > + ifp->if_dying = 1; Reference counting, plus an explicit tear-down window, and wait period, like you've proposed sounds like a good idea. Yo

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-25 Thread Martin Pieuchot
On 23/06/20(Tue) 16:21, Martin Pieuchot wrote: > On 23/06/20(Tue) 04:53, Jason A. Donenfeld wrote: > > On 6/23/20, Martin Pieuchot wrote: > > > On 23/06/20(Tue) 01:00, Jason A. Donenfeld wrote: > > >> You can crash a system by running something like: > > >> > > >> for i in 1 2 3; do while true

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-25 Thread Jason A. Donenfeld
On Thu, Jun 25, 2020 at 2:49 AM Martin Pieuchot wrote: > > On 24/06/20(Wed) 19:54, Jason A. Donenfeld wrote: > > On Wed, Jun 24, 2020 at 4:02 AM Martin Pieuchot wrote: > > > Yes, that might be a better way. If I understood your original mail the > > > issue is related to ifunit(), right? ifunit

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-25 Thread Martin Pieuchot
On 24/06/20(Wed) 19:54, Jason A. Donenfeld wrote: > On Wed, Jun 24, 2020 at 4:02 AM Martin Pieuchot wrote: > > Yes, that might be a better way. If I understood your original mail the > > issue is related to ifunit(), right? ifunit() is not used in packet- > > processing contexts, that's why we d

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-25 Thread Vitaliy Makkoveev
> On 23 Jun 2020, at 10:00, Jason A. Donenfeld wrote: > > You can crash a system by running something like: > >for i in 1 2 3; do while true; do ifconfig bridge0 create& ifconfig > bridge0 destroy& done& done > > This works with every type of interface I've tried. It appears that > if_clon

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-24 Thread Jason A. Donenfeld
Hi Martin, On Wed, Jun 24, 2020 at 4:02 AM Martin Pieuchot wrote: > Yes, that might be a better way. If I understood your original mail the > issue is related to ifunit(), right? ifunit() is not used in packet- > processing contexts, that's why we did not protect it by the NET_LOCK(). > > I'm n

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-24 Thread Martin Pieuchot
On 23/06/20(Tue) 17:21, Jason A. Donenfeld wrote: > On Tue, Jun 23, 2020 at 8:21 AM Martin Pieuchot wrote: > > I'd argue this is a related problem but a different one. The diff I > > sent serializes cloning/destroying pseudo-interfaces. It has value on > > its own because *all* if_clone_*() oper

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-23 Thread Jason A. Donenfeld
On Tue, Jun 23, 2020 at 8:21 AM Martin Pieuchot wrote: > I'd argue this is a related problem but a different one. The diff I > sent serializes cloning/destroying pseudo-interfaces. It has value on > its own because *all* if_clone_*() operations are now serialized. > > Now you correctly points ou

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-23 Thread Martin Pieuchot
On 23/06/20(Tue) 04:53, Jason A. Donenfeld wrote: > On 6/23/20, Martin Pieuchot wrote: > > On 23/06/20(Tue) 01:00, Jason A. Donenfeld wrote: > >> You can crash a system by running something like: > >> > >> for i in 1 2 3; do while true; do ifconfig bridge0 create& ifconfig > >> bridge0 destroy

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-23 Thread Jason A. Donenfeld
On 6/23/20, Martin Pieuchot wrote: > On 23/06/20(Tue) 01:00, Jason A. Donenfeld wrote: >> You can crash a system by running something like: >> >> for i in 1 2 3; do while true; do ifconfig bridge0 create& ifconfig >> bridge0 destroy& done& done >> >> This works with every type of interface I'v

Re: [PATCH] net: prevent if_clone_destroy from racing with rest of stack

2020-06-23 Thread Martin Pieuchot
On 23/06/20(Tue) 01:00, Jason A. Donenfeld wrote: > You can crash a system by running something like: > > for i in 1 2 3; do while true; do ifconfig bridge0 create& ifconfig > bridge0 destroy& done& done > > This works with every type of interface I've tried. It appears that > if_clone_destr