Re: [PATCH net] ptr_ring: use kmalloc_array()

From
Eric Dumazet <hidden>
Date
2017-08-25 18:57:21
Reply to
Michael S. Tsirkin, 2017-08-25
On Fri, 2017-08-25 at 21:03 +0300, Michael S. Tsirkin wrote:
On Wed, Aug 16, 2017 at 10:36:47AM -0700, Eric Dumazet wrote:
quoted
From: Eric Dumazet <redacted>

As found by syzkaller, malicious users can set whatever tx_queue_len
on a tun device and eventually crash the kernel.

Lets remove the ALIGN(XXX, SMP_CACHE_BYTES) thing since a small
ring buffer is not fast anyway.
I'm not sure it's worth changing for small rings.

Does kmalloc_array guarantee cache line alignment for big buffers
then? If the ring is misaligned it will likely cause false sharing
as it's designed to be accessed from two CPUs.
I specifically said that in the changelog :

"since a small ring buffer is not fast anyway."

If one user sets up a pathological small ring buffer, kernel should not
try to fix it.

In this case, you would have to setup a ring of 2 or 4 slots to
eventually hit false sharing.
Thread (6 messages) 6 messages, 3 authors, last reply 2017-08-25
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help