lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 16 Dec 2022 06:46:01 +0000
From:   David Howells <dhowells@...hat.com>
To:     Hillf Danton <hdanton@...a.com>
Cc:     dhowells@...hat.com, netdev@...r.kernel.org,
        Marc Dionne <marc.dionne@...istor.com>,
        linux-afs@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net 7/9] rxrpc: Fix I/O thread stop

Hillf Danton <hdanton@...a.com> wrote:

> > @@ -478,13 +479,14 @@ int rxrpc_io_thread(void *data)
> >  		}
> >  
> >  		set_current_state(TASK_INTERRUPTIBLE);
> > +		should_stop = kthread_should_stop();
> >  		if (!skb_queue_empty(&local->rx_queue) ||
> >  		    !list_empty(&local->call_attend_q)) {
> >  			__set_current_state(TASK_RUNNING);
> >  			continue;
> >  		}
> >  
> > -		if (kthread_should_stop())
> > +		if (should_stop)
> >  			break;
> >  		schedule();
> >  	}
> 
> At the second glance still fail to see the difference this change can
> make.

There is a window here:

  		if (!skb_queue_empty(&local->rx_queue) ...)
			continue;
	--->
		if (kthread_should_stop())
 			break;

in which an event can happen that should be attended to.  For instance the
AF_RXRPC socket being closed, aborting all its calls and stopping the kthread
by doing the final unuse on its rxrpc_local struct - in that order.  The
window can be expanded by an interrupt or softirq handler running.

So once we've observed that we've been asked to stop, we need to check if
there's more work to be done and, if so, do that work first.

So by doing:

		should_stop = kthread_should_stop();
  		if (!skb_queue_empty(&local->rx_queue) ...)
			continue;
		if (should_stop)
 			break;

we do all outstanding cleanup work before exiting the loop to stop the thread.

David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ