RE: in_compat_syscall() on x86

From: David Laight
Date: Wed Jan 06 2021 - 04:44:20 EST


From: Andy Lutomirski
> Sent: 05 January 2021 17:35
>
> On Tue, Jan 5, 2021 at 1:53 AM David Laight <David.Laight@xxxxxxxxxx> wrote:
> > ...
...
> > > > I also wondered about resetting it to zero when an x32 system call
> > > > exits (rather than entry to a 64bit one).
> > > >
> > > > For ia32 the flag is set (with |=) on every syscall entry.
> > > > Even though I'm pretty sure it can only change during exec.
> > >
> > > It can change for every syscall. I have tests that do this.
> >
> > Do they still work?
>
> They seem to.
>
> > I don't think the ia32 flag is cleared anywhere.
>
> It's hiding in arch_exit_to_user_mode_prepare().

No wonder I don't notice.
There is a RMW to clear TS_COMPAT | TS_I386_REGS_POKED as (about)
the very last thing done before returning to user.

Short or renaming the 'status' field and fixing the compilation errors
I can't see an obvious way of detecting any other status flag bits.

If none are used (or a different field is used) then an unconditional
write of the syscall type in the entry paths would remove the need for
the clear in the syscall exit path.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)