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

From: Alexander Duyck
Date: Fri Jun 02 2023 - 14:03:04 EST


On Fri, Jun 2, 2023 at 9:37 AM Andrew Lunn <andrew@xxxxxxx> wrote:
>
> > What this change is essentially doing is clamping the copied data to
> > the lesser of the current value versus the value when the userspace
> > was allocated. However I am wondering now if we shouldn't just update
> > the size value and return that as some sort of error for the userspace
> > to potentially reallocate and repeat until it has the right size.
>
> I'm not sure we should be putting any effort into the IOCTL
> interface. It is deprecated. We should fix overrun problems, but i
> would not change the API. Netlink handles this atomically, and that is
> the interface tools should be using, not this IOCTL.

If that is the case maybe it would just make more sense to just return
an error if we are at risk of overrunning the userspace allocated
buffer.