There is no reasonable need for a buffer larger than this,
and it avoids int overflow pitfalls.
Fixes: 058504edd026 ("fs/seq_file: fallback to vmalloc allocation")
Reported-by: Qualys Security Advisory <qsa@qualys.com>
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name seq_file-Disallow-extremely-large-seq-buffer-allocat.patch
static void *seq_buf_alloc(unsigned long size)
{
+ if (unlikely(size > MAX_RW_COUNT))
+ return NULL;
+
return kvmalloc(size, GFP_KERNEL_ACCOUNT);
}