mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Nicolas Pitre <nico@fluxnic.net>
Cc: gregkh@linuxfoundation.org, Chen Wandun <chenwandun@huawei.com>,
	Adam Borowski <kilobyte@angband.pl>,
	jslaby@suse.com, daniel.vetter@ffwll.ch,
	b.zolnierkie@samsung.com, lukas@wunner.de, ghalat@redhat.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] vt: don't use kmalloc() for the unicode screen buffer
Date: Mon, 30 Mar 2020 21:07:59 +0200	[thread overview]
Message-ID: <20200330190759.GE7594@ravnborg.org> (raw)
In-Reply-To: <nycvar.YSQ.7.76.2003282214210.2671@knanqh.ubzr>

Hi Nicolas

On Sat, Mar 28, 2020 at 10:25:11PM -0400, Nicolas Pitre wrote:
> 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.
> 
> Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
> Cc: <stable@vger.kernel.org>
> 
> ---
> 
> Changes since v1:
> 
> - Added missing include, found by kbuild test robot.
>   Strange that my own build doesn't complain.

When I did the drmP.h removal vmalloc was one of the header files
that turned up missing in many cases - but only for some architectures.
I learned to include alpha in the build.
If it survived building for alpha then I had fixed the majority
of the issues related to random inherited includes.

The patch itself looks good.

Acked-by: Sam Ravnborg <sam@ravnborg.org>

> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 15d2769805..d9eb5661e9 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -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;
>  }
>  

  reply	other threads:[~2020-03-30 19:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-28 21:59 [PATCH] " Nicolas Pitre
2020-03-28 23:35 ` kbuild test robot
2020-03-29  0:13 ` kbuild test robot
2020-03-29  2:25 ` [PATCH v2] " Nicolas Pitre
2020-03-30 19:07   ` Sam Ravnborg [this message]
2020-03-31  8:43     ` Daniel Vetter
2020-03-31  9:30       ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200330190759.GE7594@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=chenwandun@huawei.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=ghalat@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=kilobyte@angband.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=nico@fluxnic.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome