Re: [PATCH v7 21/41] mm: Add guard pages around a shadow stack.

Edgecombe, Rick P
2023-03-08T22:49:04Z

On Tue, 2023-03-07 at 11:44 +0100, David Hildenbrand wrote:
> On 07.03.23 11:32, Borislav Petkov wrote:
> > On Tue, Mar 07, 2023 at 01:29:50AM +0000, Edgecombe, Rick P wrote:
> > > On Mon, 2023-03-06 at 09:08 +0100, Borislav Petkov wrote:
> > > > Just typos:
> > >
> > > All seem reasonable to me. Thanks.
> > >
> > > For using the log verbiage for the comment, it is quite big. Does
> > > something like this seem reasonable?
> >
> > Yeah, it does. I wouldn't want to lose that explanation in a commit
> > message.
> >
> > However, this special aspect pertains to the shstk implementation
> > in x86
> > but the code is generic mm and such arch-specific comments are
> > kinda
> > unfitting there.
> >
> > I wonder if it would be better if you could stick that explanation
> > somewhere in arch/x86/ and only refer to it in a short comment
> > above
> > VM_SHADOW_STACK check in stack_guard_start_gap()...
>
> +1

I can't find a good place for it in the arch code. Basically there is
no arch/x86 functionality that has to do with guard pages. The closest
is pte_mkwrite() because it at least references VM_SHADOW_STACK but it
doesn't really fit.

We could to add an arch version of stack_guard_start_gap() but we had
that and removed it for other style reasons. Code duplication IIRC.

So I thought to just move it elsewhere in mm.h where VM_SHADOW_STACK is
defined.