Netdev List
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Mina Almasry <almasrymina@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net 1/1] tcp: reject non zerocopy devmem tx
Date: Fri, 28 Aug 2026 13:37:36 +0100	[thread overview]
Message-ID: <0db1151c-35a0-4597-b69c-091b60cb864c@gmail.com> (raw)
In-Reply-To: <CAHS8izPB6xS5KOKOUORvJ99d-mF7F+9gZCFe5aoQPQpUeDhWBA@mail.gmail.com>

On 8/26/26 18:29, Mina Almasry wrote:
> On Wed, Aug 26, 2026 at 7:36 AM Pavel Begunkov <asml.silence@gmail.com> wrote:
>>
>> On 8/23/26 16:58, Mina Almasry wrote:
>>> On Sat, Aug 22, 2026 at 3:57 AM Pavel Begunkov <asml.silence@gmail.com> wrote:
>> ...> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
>>> index b4237d0e994d6..1e34f50770446 100644
>>> --- a/net/ipv4/tcp.c
>>> +++ b/net/ipv4/tcp.c
>>> @@ -1170,7 +1170,8 @@ int tcp_sendmsg_locked(struct sock *sk, struct
>>> msghdr *msg, size_t size)
>>>           }
>>>
>>>           if (!sockc_err && sockc.dmabuf_id &&
>>> -           (!(flags & MSG_ZEROCOPY) || !sock_flag(sk, SOCK_ZEROCOPY))) {
>>> +           (!(flags & MSG_ZEROCOPY) || !sock_flag(sk, SOCK_ZEROCOPY) ||
>>
>> This check before your diff fells off. From a quick look, via io_uring
>> you can have a sendmsg call with dmabuf_id that would happily pass this
>> check but never goes through net_devmem_get_binding() and
>> msg_zerocopy_realloc(). It's not much too problematic for now but feels
>> dangerous to rely on it in the current form. I think we want sth like
>> this in the end.
>>
>> if (sockc.dmabuf_id && !sockc_err) {
>>          if (!binding || zc != MSG_ZEROCOPY)
>>                  // fail;
>> }
>>
> 
> OK it sorta makes sense to me. I think we're making a mistake checking
> SOCK_ZEROCOPY/MSG_ZEROCOPY when instead all these are conveniently
> condensed into 'zc == MSG_ZEROCOPY' when everything lines up. The
> point of this line was roughly 'if the user is trying to send devmem
> but not MSG_ZEROCOPY'd, fail'.

Alright, good to know as I was assuming that. Let's do it like that
then, I'll send a patch.

-- 
Pavel Begunkov


      reply	other threads:[~2026-08-28 12:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-22 10:57 [PATCH net 1/1] tcp: reject non zerocopy devmem tx Pavel Begunkov
2026-08-23 15:58 ` Mina Almasry
2026-08-24  8:27   ` David Laight
2026-08-26 14:36   ` Pavel Begunkov
2026-08-26 17:29     ` Mina Almasry
2026-08-28 12:37       ` Pavel Begunkov [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=0db1151c-35a0-4597-b69c-091b60cb864c@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=almasrymina@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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