[PATCH] fs: aio: use correct integer overflow checks when creation aio ctx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Sasha Levin <sasha.levin@xxxxxxxxxx>
---
 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);
 	}
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux