mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Andres Freund <andres@anarazel.de>, Jens Axboe <axboe@kernel.dk>,
	io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Memory uninitialized after "io_uring: keep table of pointers to ubufs"
Date: Sat, 29 May 2021 12:03:12 +0100	[thread overview]
Message-ID: <d2c5b250-5a0f-5de5-061f-38257216389d@gmail.com> (raw)
In-Reply-To: <20210529003350.m3bqhb3rnug7yby7@alap3.anarazel.de>

On 5/29/21 1:33 AM, Andres Freund wrote:
> Hi,
> 
> I started to see buffer registration randomly failing with ENOMEM on
> 5.13. Registering buffer or two often succeeds, but more than that
> rarely. Running the same program as root succeeds - but the user has a high
> rlimit.
> 
> The issue is that io_sqe_buffer_register() doesn't initialize
> imu. io_buffer_account_pin() does imu->acct_pages++, before calling
> io_account_mem(ctx, imu->acct_pages);
> 
> Which means that a random amount of memory is being accounted for. On the first
> few allocations this sometimes fails to fail because the memory is zero, but
> after a bit of reuse...

Makes sense, thanks for digging in. I've just sent a patch, would
be great if you can test it or send your own.


> It only doesn't fail as root because the rlimit doesn't apply.
> 
> This is caused by
> 
> commit 41edf1a5ec967bf4bddedb83c48e02dfea8315b4
> Author: Pavel Begunkov <asml.silence@gmail.com>
> Date:   2021-04-25 14:32:23 +0100
> 
>     io_uring: keep table of pointers to ubufs
> 
> Greetings,
> 
> Andres Freund
> 

-- 
Pavel Begunkov

  reply	other threads:[~2021-05-29 11:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-29  0:33 Andres Freund
2021-05-29 11:03 ` Pavel Begunkov [this message]
2021-06-03 18:06   ` Andres Freund
2021-06-03 18:13     ` Jens Axboe
2021-06-04 14:16     ` Pavel Begunkov

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=d2c5b250-5a0f-5de5-061f-38257216389d@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=andres@anarazel.de \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®