* [PATCH] aio: Cleanup unnecessary test for nr_pages
@ 2016-06-12 16:33 Minfei Huang
2016-06-20 14:05 ` Minfei Huang
0 siblings, 1 reply; 4+ messages in thread
From: Minfei Huang @ 2016-06-12 16:33 UTC (permalink / raw)
To: viro, bcrl
Cc: linux-fsdevel, linux-aio, linux-kernel, minfei.hmf, Minfei Huang
The variable nr_pages is always more than 1, because the size of
structure aio_ring is bigger than 0. So remove unnecessary test for
nr_page.
Signed-off-by: Minfei Huang <mnghuan@gmail.com>
---
fs/aio.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fs/aio.c b/fs/aio.c
index fb8e45b..ec05137 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -450,8 +450,6 @@ static int aio_setup_ring(struct kioctx *ctx)
size += sizeof(struct io_event) * nr_events;
nr_pages = PFN_UP(size);
- if (nr_pages < 0)
- return -EINVAL;
file = aio_private_file(ctx, nr_pages);
if (IS_ERR(file)) {
--
2.7.4 (Apple Git-66)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] aio: Cleanup unnecessary test for nr_pages
2016-06-12 16:33 [PATCH] aio: Cleanup unnecessary test for nr_pages Minfei Huang
@ 2016-06-20 14:05 ` Minfei Huang
2016-06-20 14:17 ` Al Viro
0 siblings, 1 reply; 4+ messages in thread
From: Minfei Huang @ 2016-06-20 14:05 UTC (permalink / raw)
To: viro, bcrl; +Cc: linux-fsdevel, linux-aio, linux-kernel, minfei.hmf
Ping. Any comment is appreciate.
Thanks
Minfei
On 06/13/16 at 12:33P, Minfei Huang wrote:
> The variable nr_pages is always more than 1, because the size of
> structure aio_ring is bigger than 0. So remove unnecessary test for
> nr_page.
>
> Signed-off-by: Minfei Huang <mnghuan@gmail.com>
> ---
> fs/aio.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/fs/aio.c b/fs/aio.c
> index fb8e45b..ec05137 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -450,8 +450,6 @@ static int aio_setup_ring(struct kioctx *ctx)
> size += sizeof(struct io_event) * nr_events;
>
> nr_pages = PFN_UP(size);
> - if (nr_pages < 0)
> - return -EINVAL;
>
> file = aio_private_file(ctx, nr_pages);
> if (IS_ERR(file)) {
> --
> 2.7.4 (Apple Git-66)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] aio: Cleanup unnecessary test for nr_pages
2016-06-20 14:05 ` Minfei Huang
@ 2016-06-20 14:17 ` Al Viro
2016-06-22 6:06 ` Minfei Huang
0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2016-06-20 14:17 UTC (permalink / raw)
To: Minfei Huang; +Cc: bcrl, linux-fsdevel, linux-aio, linux-kernel, minfei.hmf
On Mon, Jun 20, 2016 at 10:05:45PM +0800, Minfei Huang wrote:
> Ping. Any comment is appreciate.
>
> Thanks
> Minfei
>
> On 06/13/16 at 12:33P, Minfei Huang wrote:
> > The variable nr_pages is always more than 1, because the size of
> > structure aio_ring is bigger than 0. So remove unnecessary test for
> > nr_page.
What this test really checks is that the value we'd put into nr_pages
(PFN_UP(size)) is not greater than 2^31. Whether it's redundant or not
is a separate question - it very well might be, due to the code in
ioctx_alloc() that caps nr_events, but that needs a proof. In any case,
the reasons you are offering in commit message are wrong - it's about
size being too _large_, not too small.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] aio: Cleanup unnecessary test for nr_pages
2016-06-20 14:17 ` Al Viro
@ 2016-06-22 6:06 ` Minfei Huang
0 siblings, 0 replies; 4+ messages in thread
From: Minfei Huang @ 2016-06-22 6:06 UTC (permalink / raw)
To: Al Viro; +Cc: bcrl, linux-fsdevel, linux-aio, linux-kernel, minfei.hmf
On 06/20/16 at 03:17P, Al Viro wrote:
> On Mon, Jun 20, 2016 at 10:05:45PM +0800, Minfei Huang wrote:
> > Ping. Any comment is appreciate.
> >
> > Thanks
> > Minfei
> >
> > On 06/13/16 at 12:33P, Minfei Huang wrote:
> > > The variable nr_pages is always more than 1, because the size of
> > > structure aio_ring is bigger than 0. So remove unnecessary test for
> > > nr_page.
>
> What this test really checks is that the value we'd put into nr_pages
> (PFN_UP(size)) is not greater than 2^31. Whether it's redundant or not
> is a separate question - it very well might be, due to the code in
> ioctx_alloc() that caps nr_events, but that needs a proof. In any case,
> the reasons you are offering in commit message are wrong - it's about
> size being too _large_, not too small.
Hmm. But there is a following test in function ioctx_alloc which is used
to limit the max of nr_events.
713 /* Prevent overflows */
714 if (nr_events > (0x10000000U / sizeof(struct io_event))) {
715 pr_debug("ENOMEM: nr_events too high\n");
716 return ERR_PTR(-EINVAL);
717 }
So according to this test, we can make sure that nr_pages(PFN_UP(size))
cann't be greater than 2^31, and max to 2^28.
Thanks
Minfei
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-06-22 6:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-12 16:33 [PATCH] aio: Cleanup unnecessary test for nr_pages Minfei Huang
2016-06-20 14:05 ` Minfei Huang
2016-06-20 14:17 ` Al Viro
2016-06-22 6:06 ` Minfei Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).