Message ID | 1414081998.20845.18.camel@edumazet-glaptop2.roam.corp.google.com |
---|---|
State | Rejected, archived |
Delegated to: | David Miller |
Headers | show |
On Thu, 2014-10-23 at 09:33 -0700, Eric Dumazet wrote: > From: Eric Dumazet <edumazet@google.com> > > percpu tcp_md5sig_pool contains memory blobs that ultimately > go through sg_set_buf(). > > -> sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf)); > > This requires that whole area is in a physically contiguous portion > of memory. > > Given that alloc_percpu() can use vmalloc() areas, we need to make sure > tcp_md5sig_pool is allocated from a single page. > > > Signed-off-by: Eric Dumazet <edumazet@google.com> > Fixes: 765cf9976e93 ("tcp: md5: remove one indirection level in tcp_md5sig_pool") > Reported-by: Crestez Dan Leonard <cdleonard@gmail.com> > --- Self Nack, we definitely need to avoid vmalloc() in the first place. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 1bec4e76d88c5852d8ba3392b22aa58d6453ab4d..1f59e4130db99f129279c13f89b3c058ed6167e2 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2886,10 +2886,17 @@ static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool __percpu *pool) static void __tcp_alloc_md5sig_pool(void) { - int cpu; struct tcp_md5sig_pool __percpu *pool; + size_t align; + int cpu; - pool = alloc_percpu(struct tcp_md5sig_pool); + /* sg_set_buf() assumes a contiguous memory area, but alloc_percpu() + * can use vmalloc(). So make sure we request an alignment so that + * whole tcp_md5sig_pool is contained in a single page. + */ + BUILD_BUG_ON(sizeof(struct tcp_md5sig_pool) > PAGE_SIZE); + align = roundup_pow_of_two(sizeof(struct tcp_md5sig_pool)); + pool = __alloc_percpu(sizeof(struct tcp_md5sig_pool), align); if (!pool) return;