Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-03 Thread Michael S. Tsirkin
On Wed, Jan 03, 2018 at 09:46:15AM -0800, John Fastabend wrote: > On 01/03/2018 07:50 AM, Michael S. Tsirkin wrote: > > On Tue, Jan 02, 2018 at 04:25:03PM -0800, John Fastabend wrote: > >>> > >>> More generally, what makes this usage safe? > >>> Is there a way to formalize it at the API level? > >>

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-03 Thread John Fastabend
On 01/03/2018 07:50 AM, Michael S. Tsirkin wrote: > On Tue, Jan 02, 2018 at 04:25:03PM -0800, John Fastabend wrote: >>> >>> More generally, what makes this usage safe? >>> Is there a way to formalize it at the API level? >>> >> >> Right I think these are good questions. I think the ptr_ring API sho

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-03 Thread Michael S. Tsirkin
On Tue, Jan 02, 2018 at 04:25:03PM -0800, John Fastabend wrote: > > > > More generally, what makes this usage safe? > > Is there a way to formalize it at the API level? > > > > Right I think these are good questions. I think the ptr_ring API should > allow a peek operation to be used without a l

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-02 Thread John Fastabend
On 01/02/2018 03:12 PM, Michael S. Tsirkin wrote: > On Tue, Jan 02, 2018 at 01:27:23PM -0800, John Fastabend wrote: >> On 01/02/2018 09:17 AM, Michael S. Tsirkin wrote: >>> On Tue, Jan 02, 2018 at 07:01:33PM +0200, Michael S. Tsirkin wrote: On Tue, Jan 02, 2018 at 11:52:19AM -0500, David Mille

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-02 Thread Michael S. Tsirkin
On Tue, Jan 02, 2018 at 01:27:23PM -0800, John Fastabend wrote: > On 01/02/2018 09:17 AM, Michael S. Tsirkin wrote: > > On Tue, Jan 02, 2018 at 07:01:33PM +0200, Michael S. Tsirkin wrote: > >> On Tue, Jan 02, 2018 at 11:52:19AM -0500, David Miller wrote: > >>> From: John Fastabend > >>> Date: Wed,

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-02 Thread John Fastabend
On 01/02/2018 09:17 AM, Michael S. Tsirkin wrote: > On Tue, Jan 02, 2018 at 07:01:33PM +0200, Michael S. Tsirkin wrote: >> On Tue, Jan 02, 2018 at 11:52:19AM -0500, David Miller wrote: >>> From: John Fastabend >>> Date: Wed, 27 Dec 2017 19:50:25 -0800 >>> When running consumer and/or producer

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-02 Thread David Miller
From: "Michael S. Tsirkin" Date: Tue, 2 Jan 2018 19:01:33 +0200 > On Tue, Jan 02, 2018 at 11:52:19AM -0500, David Miller wrote: >> From: John Fastabend >> Date: Wed, 27 Dec 2017 19:50:25 -0800 >> >> > When running consumer and/or producer operations and empty checks in >> > parallel its possibl

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-02 Thread Michael S. Tsirkin
On Tue, Jan 02, 2018 at 07:01:33PM +0200, Michael S. Tsirkin wrote: > On Tue, Jan 02, 2018 at 11:52:19AM -0500, David Miller wrote: > > From: John Fastabend > > Date: Wed, 27 Dec 2017 19:50:25 -0800 > > > > > When running consumer and/or producer operations and empty checks in > > > parallel its

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-02 Thread Michael S. Tsirkin
On Tue, Jan 02, 2018 at 06:53:08PM +0200, Michael S. Tsirkin wrote: > On Wed, Dec 27, 2017 at 07:50:25PM -0800, John Fastabend wrote: > > When running consumer and/or producer operations and empty checks in > > parallel its possible to have the empty check run past the end of the > > array. The sce

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-02 Thread Michael S. Tsirkin
On Tue, Jan 02, 2018 at 11:52:19AM -0500, David Miller wrote: > From: John Fastabend > Date: Wed, 27 Dec 2017 19:50:25 -0800 > > > When running consumer and/or producer operations and empty checks in > > parallel its possible to have the empty check run past the end of the > > array. The scenario

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-02 Thread Michael S. Tsirkin
On Wed, Dec 27, 2017 at 07:50:25PM -0800, John Fastabend wrote: > When running consumer and/or producer operations and empty checks in > parallel its possible to have the empty check run past the end of the > array. The scenario occurs when an empty check is run while > __ptr_ring_discard_one() is

Re: [net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2018-01-02 Thread David Miller
From: John Fastabend Date: Wed, 27 Dec 2017 19:50:25 -0800 > When running consumer and/or producer operations and empty checks in > parallel its possible to have the empty check run past the end of the > array. The scenario occurs when an empty check is run while > __ptr_ring_discard_one() is in

[net-next PATCH] net: ptr_ring: otherwise safe empty checks can overrun array bounds

2017-12-27 Thread John Fastabend
When running consumer and/or producer operations and empty checks in parallel its possible to have the empty check run past the end of the array. The scenario occurs when an empty check is run while __ptr_ring_discard_one() is in progress. Specifically after the consumer_head is incremented but bef