lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 21 Jul 2021 19:41:31 +0100 From: "Matthew Wilcox (Oracle)" <willy@...radead.org> To: Al Viro <viro@...iv.linux.org.uk>, Qualys Security Advisory <qsa@...lys.com>, Eric Sandeen <sandeen@...hat.com>, Linus Torvalds <torvalds@...ux-foundation.org>, linux-mm@...ck.org, linux-kernel@...r.kernel.org Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org> Subject: [PATCH] mm: Make kvmalloc refuse to allocate more than 2GB It's generally dangerous to allocate such large quantities of memory within the kernel owing to our propensity to use 'int' to represent a length. If somebody really needs it, we can add a kvmalloc_large() later, but let's default to "You can't allocate that much memory". Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org> --- fs/seq_file.c | 3 --- mm/util.c | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index 4a2cda04d3e2..b117b212ef28 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -32,9 +32,6 @@ static void seq_set_overflow(struct seq_file *m) static void *seq_buf_alloc(unsigned long size) { - if (unlikely(size > MAX_RW_COUNT)) - return NULL; - return kvmalloc(size, GFP_KERNEL_ACCOUNT); } diff --git a/mm/util.c b/mm/util.c index 9043d03750a7..8ff2a8924d5f 100644 --- a/mm/util.c +++ b/mm/util.c @@ -593,6 +593,13 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node) if (ret || size <= PAGE_SIZE) return ret; + /* + * Succeeding for sizes above 2GiB can lead to truncation if + * someone casts the size to an int. + */ + if (size > INT_MAX) + return NULL; + return __vmalloc_node(size, 1, flags, node, __builtin_return_address(0)); } -- 2.30.2
Powered by blists - more mailing lists