[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130517185317.GM1008@kvack.org>
Date: Fri, 17 May 2013 14:53:17 -0400
From: Benjamin LaHaise <bcrl@...ck.org>
To: Sasha Levin <sasha.levin@...cle.com>
Cc: koverstreet@...gle.com, akpm@...ux-foundation.org, tytso@....edu,
viro@...iv.linux.org.uk, linux-aio@...ck.org,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs: aio: use correct integer overflow checks when creation aio ctx
On Fri, May 17, 2013 at 02:23:54PM -0400, Sasha Levin wrote:
> Commit "aio: percpu reqs_available" added some math to the nr_requests
> calculation, but didn't correct the overflow calculations to handle that.
>
> This means that this:
>
> #include <linux/aio_abi.h>
> void main(void)
> {
> aio_context_t ctx_idp;
> io_setup(0x80000001, &ctx_idp);
> }
>
> Would trigger the newly added BUG() couple of lines after the overflow
> checks.
This BUG() isn't in Linus' tree, and probably should be removed before
it gets there.
> Signed-off-by: Sasha Levin <sasha.levin@...cle.com>
> ---
> fs/aio.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/aio.c b/fs/aio.c
> index 5b7ed78..0ae450a 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -411,7 +411,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
>
> /* Prevent overflows */
> if ((nr_events > (0x10000000U / sizeof(struct io_event))) ||
> - (nr_events > (0x10000000U / sizeof(struct kiocb)))) {
> + (nr_events > (0x10000000U / sizeof(struct kiocb))) ||
> + (nr_events < num_possible_cpus() * 4)) {
> pr_debug("ENOMEM: nr_events too high\n");
> return ERR_PTR(-EINVAL);
This is completely wrong. Enforcing a minimum needs to be done in a way
that doesn't fail for existing users that potentially use a minimum
smaller than what is newly required. That is: an existing userland program
that only requests 16 events must not fail because of changes to the kernel
that increase the minimum number of requests. So I have to NACK this patch
as it stands.
-ben
> }
> --
> 1.8.2.1
--
"Thought is the essence of where you are now."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists