Re: [PATCH v2] xfs: fix wrong compat fields in xfs_ioctl32_bstat_copyin()

From: David Laight

Date: Wed Oct 28 2026 - 15:04:23 EST


On Wed, 28 Oct 2026 08:18:40 -0700
Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:

> On Tue, Oct 27, 2026 at 04:49:11PM +0000, David Laight wrote:
> > On Tue, 27 Oct 2026 12:17:48 -0400
> > Reid Downing <skibletz@xxxxxxxxx> wrote:
> >
> > > bs_blocks and bs_xflags were both read from bstat32->bs_size.
> > > Read each one from its own field instead.
> >
> > It would be much better to do a single copy_from_user() of the entire
> > compat structure and copy the fields to the standard one.
>
> Care to explain why it would be "much better" to do two copies instead of
> one? The only benefits from copy_from/to_user over the current
> get_put/user is avoidind the conctant user access disabling/enabling,

That is a massive hit.
The current code also has all the conditionals from access_ok().

> but the scoped uaccess thing would do the same.

True, but unnecessarily 'technical' for this bit of code.
You also save all the exception table entries - so the code size
would be rather smaller.

David