patch "vt: don't use kmalloc() for the unicode screen buffer" added to tty-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
vt: don't use kmalloc() for the unicode screen buffer
to my tty git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
in the tty-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 9a98e7a80f95378c9ee0c644705e3b5aa54745f1 Mon Sep 17 00:00:00 2001
From: Nicolas Pitre <[email protected]>
Date: Sat, 28 Mar 2020 22:25:11 -0400
Subject: vt: don't use kmalloc() for the unicode screen buffer
Even if the actual screen size is bounded in vc_do_resize(), the unicode buffer is still a little more than twice the size of the glyph buffer and may exceed MAX_ORDER down the kmalloc() path. This can be triggered from user space.
Since there is no point having a physically contiguous buffer here, let's avoid the above issue as well as reducing pressure on high order allocations by using vmalloc() instead.
--- drivers/tty/vt/vt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/vt/vt.c +3 -2
@@ -81,6 +81,7 @@#include <linux/errno.h> #include <linux/kd.h> #include <linux/slab.h> +#include <linux/vmalloc.h> #include <linux/major.h> #include <linux/mm.h> #include <linux/console.h>
@@ -350,7 +351,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)/* allocate everything in one go */ memsize = cols * rows *sizeof (char32_t ); memsize += rows *sizeof (char32_t *); - p =kmalloc (memsize,GFP_KERNEL ); + p =vmalloc (memsize);if (!p)return NULL ;
@@ -366,7 +367,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)static void vc_uniscr_set (struct vc_data *vc,struct uni_screen *new_uniscr) { -kfree (vc->vc_uni_screen); +vfree (vc->vc_uni_screen); vc->vc_uni_screen = new_uniscr; }
Signature · 1 line
2.26.2