Re: [PATCH net-next] net: ethtool: Fix out-of-bounds copy to user

From: Andrew Lunn
Date: Fri Jun 02 2023 - 08:26:56 EST


> > Changing the copy size would not fix this. The problem is the driver
> > will be overwriting with the size that it thinks it should be using.
> > Reducing the value that is provided for the memory allocations will
> > cause the driver to corrupt memory.
> >
>
> I noticed that, in fact I did use the returned length to allocate
> kernel memory, and only use adjusted length to copy to user.

This is also something i checked when quickly looking at the patch. It
does look correct.

Also, RTNL should be held during the time both calls are made into the
driver. So nothing from userspace should be able to get in the middle
of these calls to change the number of queues.

Andrew