Re: [PATCH 3/3] m68k: leave stack mangling to asm wrapper of sigreturn()

From: Michael Schmitz
Date: Thu Sep 16 2021 - 01:04:13 EST


Hi Al,

On 16/09/21 15:21, Al Viro wrote:
On Thu, Sep 16, 2021 at 12:53:53PM +1200, Michael Schmitz wrote:
IOW, what would be the benefit of trying to avoid unconditional gap there?

Avoiding a kernel stack overflow - there are comments in the code that warn
against that, but those may be largely historic...

This is syscall entry; moreover, it critically relies upon the fixed stack
layout - type 0 exception frame + pt_regs + switch_stack + (now) gap.

AFAIR, the concerns in the comments I saw were about interrupts - come to think of it, back in the early days, we used to have 'fast' and 'slow' interrupt handlers, with much of the heavy lifting done in the handler, and slow interrupts allowed to lower the IPL. Probably no longer relevant.

Followed by fairly shallow C call chain. I suspect that the deepest you
can get there is when you get an unmapped page when reading the sigframe
and go into page fault handling, with call chain going into some filesystem's
->readpage(). If it was that close to stack overflow, we'd see them all
the time in e.g. random net ioctl doing copy_from_user() - that's going
to be deeper. Or in stat(2), for that matter.

Your points are well taken - I can see now that my concerns are without merit.

The only question that remains is whether the third patch can also go to -stable. Most of my testing was with all three patches applied, I can drop the third one and retest if you're worries the third one is not appropriate for -stable.

Cheers,

Michael