[Devel] [PATCH RHEL7 COMMIT] tty/vt: avoid high order pages allocation on GIO_UNIMAP ioctl

Konstantin Khorenko khorenko at virtuozzo.com
Mon Apr 15 15:45:06 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.10.1.vz7.94.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.10.1.vz7.94.13
------>
commit ef5f88eb5f7aaf8c678dfd89552ba36563ae99f4
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Fri Apr 12 14:58:24 2019 +0300

    tty/vt: avoid high order pages allocation on GIO_UNIMAP ioctl
    
    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 at virtuozzo.com>
---
 drivers/tty/vt/consolemap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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);
 }
 



More information about the Devel mailing list