Re: [syzbot] WARNING in do_proc_bulk

From: Andrew Morton
Date: Mon May 03 2021 - 15:24:33 EST


On Mon, 3 May 2021 14:56:14 -0400 Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:

> >
> > do_proc_bulk() is asking kmalloc for more than MAX_ORDER bytes, in
> >
> > tbuf = kmalloc(len1, GFP_KERNEL);
>
> This doesn't seem to be a bug. do_proc_bulk is simply trying to
> allocate a kernel buffer for data passed to/from userspace. If a user
> wants too much space all at once, that's their problem.
>
> As far as I know, the kmalloc API doesn't require the caller to filter
> out requests for more the MAX_ORDER bytes. Only to be prepared to
> handle failures -- which do_proc_bulk is all set for.
>
> Am I wrong about this? Should we add __GFP_NOWARN to the gfp flags?

Yes, if the oversized request is a can-happen and the resulting error is handled
appropriately, __GFP_NOWARN is the way to go.