Linux io-uring development
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Gabriel Krisman Bertazi <krisman@suse.de>
Cc: io-uring@vger.kernel.org
Subject: Re: [PATCH liburing 1/2] test/send_recvmsg: Preserve msghdr until op_recvmsg completes
Date: Sun, 26 Jul 2026 18:23:16 -0600	[thread overview]
Message-ID: <dc7df695-c891-4cf9-b124-d595a94facf3@kernel.dk> (raw)
In-Reply-To: <87se55cmry.fsf@mailhost.krisman.be>

On 7/26/26 6:13 PM, Gabriel Krisman Bertazi wrote:
> Gabriel Krisman Bertazi <krisman@suse.de> writes:
> 
>> Gabriel Krisman Bertazi <krisman@suse.de> writes:
>>
>>> Jens Axboe <axboe@kernel.dk> writes:
>>>
>>>> On 7/22/26 12:17 PM, Gabriel Krisman Bertazi wrote:
>>>>> msghdr is allocated on the stack at recv_prep, which means it may go out
>>>>> of scope before the kernel has a chance to complete the operation.  This
>>>>> results in spurious test failures when we reach far enough into recv_fn
>>>>> to reuse the stack space before op_recvmsg executes.  I found it easily
>>>>> reproducible when compiling with '-O0 -g3' to avoid gcc from optimizing
>>>>> further local variables out of the stack.
>>>>
>>>> Hmm, but that should be fine as long as a) we submit in scope, and b)
>>>> we're not using SQPOLL, where it does need to remain consistent until
>>>> completion.
>>>>
>>>> And recv_prep() certainly submits before it returns, and we're not using
>>>> SQPOLL. So I'm curious what issue this is?? Same questions on patch 2.
>>>
>>> Hm, I assumed it was submitted via iowq, which would explain this,
>>> because the execution in io_recvmsg() passes a pointer to the original
>>> memory:
>>
>> So, __sys_recvmsg_sock during the inline attempt throws -EAGAIN at
>> first, which makes io_recv return IOU_RETRY, which punts to tw after
>> the socket is ready.  By tracing, I can see the tw is executed only
>> during the io_uring_enter from io_uring_wait_cqe, which is when
>> __sys_recvmsg_sock touches sr->umsg pointing to an already out-of-scope
>> stack variable.
> 
> Hello, do you disagree or did I miss anything?

Still on vacation and sporadically available, just haven't had time to
look at it yet. I agree it looks fishy! I would encourage you to dig into
the kernel side and get to the bottom of it.

-- 
Jens Axboe


  reply	other threads:[~2026-07-27  0:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 18:17 [PATCH liburing 0/2] Fix op_recv stack corruption Gabriel Krisman Bertazi
2026-07-22 18:17 ` [PATCH liburing 1/2] test/send_recvmsg: Preserve msghdr until op_recvmsg completes Gabriel Krisman Bertazi
2026-07-22 18:24   ` Gabriel Krisman Bertazi
2026-07-22 19:21   ` Jens Axboe
2026-07-22 20:00     ` Gabriel Krisman Bertazi
2026-07-22 20:33       ` Gabriel Krisman Bertazi
2026-07-27  0:13         ` Gabriel Krisman Bertazi
2026-07-27  0:23           ` Jens Axboe [this message]
2026-07-27 18:49             ` Gabriel Krisman Bertazi
2026-07-22 18:17 ` [PATCH liburing 2/2] test/recv-msgall-stream: " Gabriel Krisman Bertazi

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=dc7df695-c891-4cf9-b124-d595a94facf3@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=krisman@suse.de \
    /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