Re: [PATCH (resend)] Input: MT - limit max slots

From: Linus Torvalds
Date: Mon Jul 29 2024 - 15:27:48 EST


On Mon, 29 Jul 2024 at 12:12, Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> wrote:
>
> OK, if you want to have limits be it. You probably want to lower from
> 1024 to 128 or something, because with 1024 slots the structure will be
> larger than one page and like I said mt->red table will be 4Mb.

So this is why subsystem maintainers should be involved and helpful.
It's hard to know what practical limits are.

That said, a 4MB allocation for some test code is nothing.

And yes, if syzbot hits other cases where the input layer just takes
user input without any limit sanity checking, those should be fixed
*too*.

"The allocation failed" is not some graceful thing. Large pointless
allocations can be very very very expensive *before* they fail,
because the VM layer will spend lots of time trying to clean things
up.

So a sane limit *UP FRONT* instead of "let's see if this random
allocation succeeds" is always the right answer when at all possible.

Linus