From: Eric Sandeen Date: Tue, 6 Jul 2021 17:56:03 +0000 (+0200) Subject: [PATCH] seq_file: Disallow extremely large seq buffer allocations X-Git-Tag: archive/raspbian/5.10.46-3+rpi1^2~19 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e05b08c49e21a98b6fa6bece8ea549f3150c03db;p=linux.git [PATCH] seq_file: Disallow extremely large seq buffer allocations 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 Suggested-by: Al Viro Signed-off-by: Eric Sandeen Gbp-Pq: Topic bugfix/all Gbp-Pq: Name seq_file-Disallow-extremely-large-seq-buffer-allocat.patch --- diff --git a/fs/seq_file.c b/fs/seq_file.c index 03a369ccd28..472714716be 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -32,6 +32,9 @@ 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); }