[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7c75a9bf-204f-1159-a2db-4679158652a2@kernel.dk>
Date: Wed, 1 May 2019 10:00:41 -0600
From: Jens Axboe <axboe@...nel.dk>
To: Mark Rutland <mark.rutland@....com>, linux-kernel@...r.kernel.org
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
linux-fsdevel@...r.kernel.org, linux-block@...r.kernel.org
Subject: Re: [PATCHv2] io_uring: avoid page allocation warnings
On 5/1/19 9:59 AM, Mark Rutland wrote:
> In io_sqe_buffer_register() we allocate a number of arrays based on the
> iov_len from the user-provided iov. While we limit iov_len to SZ_1G,
> we can still attempt to allocate arrays exceeding MAX_ORDER.
>
> On a 64-bit system with 4KiB pages, for an iov where iov_base = 0x10 and
> iov_len = SZ_1G, we'll calculate that nr_pages = 262145. When we try to
> allocate a corresponding array of (16-byte) bio_vecs, requiring 4194320
> bytes, which is greater than 4MiB. This results in SLUB warning that
> we're trying to allocate greater than MAX_ORDER, and failing the
> allocation.
>
> Avoid this by using kvmalloc() for allocations dependent on the
> user-provided iov_len. At the same time, fix a leak of imu->bvec when
> registration fails.
Applied, thanks.
--
Jens Axboe
Powered by blists - more mailing lists