From: Vasily Averin <vvs@virtuozzo.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
netdev <netdev@vger.kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] tcp: detect use sendpage for slab-based objects
Date: Tue, 5 Mar 2019 21:35:33 +0300 [thread overview]
Message-ID: <c689e501-4dbf-a569-d64b-ab9b7ca52007@virtuozzo.com> (raw)
In-Reply-To: <CANn89iKe7rWsh3=2hK_meCrNcdzsKCwafp-WMJ17QfELOY9W6w@mail.gmail.com>
On 3/5/19 7:44 PM, Eric Dumazet wrote:
> On Tue, Mar 5, 2019 at 7:11 AM Eric Dumazet <edumazet@google.com> 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 :/
>>>
>
prev parent reply other threads:[~2019-03-05 18:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 15:30 [PATCH] tcp: detect use sendpage for slab-based objects Vasily Averin
2019-02-21 16:00 ` Eric Dumazet
2019-02-22 14:02 ` Vasily Averin
2019-02-22 16:39 ` Eric Dumazet
2019-02-25 9:15 ` Vasily Averin
2019-02-25 9:32 ` Vasily Averin
2019-03-04 12:58 ` Vasily Averin
2019-03-04 15:51 ` Eric Dumazet
2019-03-05 14:24 ` Vasily Averin
[not found] ` <CANn89iKss+mzwbeZgy3Bzct6sBe3UeyezXXGocAYtOe9pP8a9w@mail.gmail.com>
2019-03-05 15:11 ` Eric Dumazet
2019-03-05 16:44 ` Eric Dumazet
2019-03-05 18:35 ` Vasily Averin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c689e501-4dbf-a569-d64b-ab9b7ca52007@virtuozzo.com \
--to=vvs@virtuozzo.com \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).