Re: [PATCH] tty: use __GFP_NOWARN for user-controlled kmalloc
From: David Rientjes
Date: Thu Feb 04 2016 - 17:11:43 EST
On Thu, 4 Feb 2016, Dmitry Vyukov wrote:
> Size of kmalloc() in vc_do_resize() is controlled by user.
> Too large kmalloc() size triggers WARNING message on console.
>
> Use __GFP_NOWARN for this kmalloc() to not scare admins.
>
Hmm, this is hitting the WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN)) for
order >= MAX_ORDER.
vc_do_resize() has
if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW)
return -EINVAL;
so the appropriate fix would seem to be to reject sizes that would exceed
the page allocator's ability to return contiguous memory (MAX_ORDER)
rather than ever trying the allocation in the first place.