[rh7] tty/vt: avoid high order pages allocation on GIO_UNIMAP ioctl

Submitted by Konstantin Khorenko on April 12, 2019, 4:19 p.m.

Details

Message ID 20190412161957.18972-1-khorenko@virtuozzo.com
State New
Series "tty/vt: avoid high order pages allocation on GIO_UNIMAP ioctl"
Headers show

Commit Message

Konstantin Khorenko April 12, 2019, 4:19 p.m.
GIO_UNIMAP can easily result in a high order allocation,
seen 6th order allocation on radeondrmfb:

  fbcon: radeondrmfb (fb0) is primary device
  Console: switching to colour frame buffer device 160x64
  radeon 0000:01:05.0: fb0: radeondrmfb frame buffer device
  WARNING: CPU: 0 PID: 78661 at mm/page_alloc.c:3532
	__alloc_pages_nodemask+0x1b1/0x600
  order 6 >= 3, gfp 0x40d0

At the same time it's safe to use kvmalloc() for allocation in
con_get_unimap(), so let's do the substitution.

And do the same for con_set_unimap().

https://jira.sw.ru/browse/PSBM-93812

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 drivers/tty/vt/consolemap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index 58d5f08e6d7f..2dc2b997f26f 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -553,7 +553,7 @@  int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
 	struct uni_pagedir *p, *q;
 	struct unipair *unilist, *plist;
 
-	unilist = kmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL);
+	unilist = kvmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL);
 	if (!unilist)
 		return -ENOMEM;
 
@@ -663,7 +663,7 @@  int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
 
 out_unlock:
 	console_unlock();
-	kfree(unilist);
+	kvfree(unilist);
 	return err;
 }
 
@@ -765,7 +765,7 @@  int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni
 	struct uni_pagedir *p;
 	struct unipair *unilist, *plist;
 
-	unilist = kmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL);
+	unilist = kvmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL);
 	if (!unilist)
 		return -ENOMEM;
 
@@ -795,7 +795,7 @@  int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni
 		__put_user(plist->fontpos, &list->fontpos);
 	}
 	__put_user(ect, uct);
-	kfree(unilist);
+	kvfree(unilist);
 	return ((ect <= ct) ? 0 : -ENOMEM);
 }