From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09B59C43381 for ; Tue, 5 Mar 2019 18:35:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D09112064A for ; Tue, 5 Mar 2019 18:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbfCESfi (ORCPT ); Tue, 5 Mar 2019 13:35:38 -0500 Received: from relay.sw.ru ([185.231.240.75]:39300 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725818AbfCESfi (ORCPT ); Tue, 5 Mar 2019 13:35:38 -0500 Received: from [172.16.24.21] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h1Euc-0006vx-FC; Tue, 05 Mar 2019 21:35:34 +0300 Subject: Re: [PATCH] tcp: detect use sendpage for slab-based objects To: Eric Dumazet Cc: Eric Dumazet , netdev , Al Viro References: <4a7d3903-971d-26ea-1d70-514abff88f91@virtuozzo.com> <85b6a52f-f997-6fc6-bc5a-99aaeaa27cc5@virtuozzo.com> From: Vasily Averin Message-ID: Date: Tue, 5 Mar 2019 21:35:33 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 3/5/19 7:44 PM, Eric Dumazet wrote: > On Tue, Mar 5, 2019 at 7:11 AM Eric Dumazet wrote: >>> My original suggestion was to use VM_WARN_ONCE() so that the debug checks would >>> be compiled out by the compiler, unless you compile a debug kernel. >>> >>> Something like : >>> >>> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c >>> index ad07dd71063da09843ccfbd3e00d3f41567e1205..889563a66dde2a41c198d92a80183cf5382f632d 100644 >>> --- a/net/ipv4/tcp.c >>> +++ b/net/ipv4/tcp.c >>> @@ -943,6 +943,9 @@ ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset, >>> ssize_t copied; >>> long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); >>> >>> + if (VM_WARN_ONCE(PageSlab(page)), "page must not be a Slab one") >>> + return -EINVAL; >>> + > > Well, VM_WARN_ONCE() returns 1 if !CONFIG_DEBUG_VM, > so it is not behaving like WARN_ONCE(), which is unfortunate. > > But you get the idea ;) Thanks, I did not know this trick. Seems it can be replaced by following construction, I'll check it tomorrow morning. #ifdef CONFIG_DEBUG_VM if (WARN_ONCE(PageSlab(page), "page must not be a Slab one") return -EINVAL; #endif I expect it should affect debug kernels only, fail all incorrect requests, taint the kernel and generate warning only once. >>> * (passive side) where data is allowed to be sent before a connection >>> * is fully established. >>> >>> >>> For some reason you added a fallback :/ >>> >