lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAC_TJvehHBr9Qa5akpgLB6GGNzRKPdx855a89Aq8HWnvuGN0rg@mail.gmail.com>
Date:   Tue, 26 Jul 2022 09:33:57 -0700
From:   Kalesh Singh <kaleshsingh@...gle.com>
To:     Marc Zyngier <maz@...nel.org>
Cc:     Mark Rutland <mark.rutland@....com>,
        Mark Brown <broonie@...nel.org>,
        "Madhavan T. Venkataraman" <madvenka@...ux.microsoft.com>,
        Fuad Tabba <tabba@...gle.com>,
        Oliver Upton <oliver.upton@...ux.dev>,
        Will Deacon <will@...nel.org>,
        Quentin Perret <qperret@...gle.com>,
        James Morse <james.morse@....com>,
        Alexandru Elisei <alexandru.elisei@....com>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Catalin Marinas <catalin.marinas@....com>,
        andreyknvl@...il.com, vincenzo.frascino@....com,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Kefeng Wang <wangkefeng.wang@...wei.com>,
        Marco Elver <elver@...gle.com>, Keir Fraser <keirf@...gle.com>,
        Zenghui Yu <yuzenghui@...wei.com>,
        Ard Biesheuvel <ardb@...nel.org>,
        Oliver Upton <oupton@...gle.com>,
        "moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)" 
        <linux-arm-kernel@...ts.infradead.org>,
        kvmarm <kvmarm@...ts.cs.columbia.edu>,
        LKML <linux-kernel@...r.kernel.org>, android-mm@...gle.com,
        "Cc: Android Kernel" <kernel-team@...roid.com>
Subject: Re: [PATCH v6 02/17] arm64: stacktrace: Factor out on_accessible_stack_common()

On Tue, Jul 26, 2022 at 9:01 AM Marc Zyngier <maz@...nel.org> wrote:
>
> On Tue, 26 Jul 2022 08:37:35 +0100,
> Kalesh Singh <kaleshsingh@...gle.com> wrote:
> >
> > Move common on_accessible_stack checks to stacktrace/common.h. This is
> > used in the implementation of the nVHE hypervisor unwinder later in
> > this series.
> >
> > Signed-off-by: Kalesh Singh <kaleshsingh@...gle.com>
> > Reviewed-by: Fuad Tabba <tabba@...gle.com>
> > Reviewed-by: Mark Brown <broonie@...nel.org>
> > Tested-by: Fuad Tabba <tabba@...gle.com>
> > ---
> >
> > Changes in v6:
> >   - Add Fuad's Tested-by tag
> >
> > Changes in v5:
> >   - Add Reviewed-by tags from Mark Brown and Fuad
> >   - Remove random whitespace change, per Mark Brown
> >
> >  arch/arm64/include/asm/stacktrace.h        |  6 ++----
> >  arch/arm64/include/asm/stacktrace/common.h | 18 ++++++++++++++++++
> >  2 files changed, 20 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h
> > index 79f455b37c84..43f4b4a6d383 100644
> > --- a/arch/arm64/include/asm/stacktrace.h
> > +++ b/arch/arm64/include/asm/stacktrace.h
> > @@ -65,8 +65,8 @@ static inline bool on_accessible_stack(const struct task_struct *tsk,
> >                                      unsigned long sp, unsigned long size,
> >                                      struct stack_info *info)
> >  {
> > -     if (info)
> > -             info->type = STACK_TYPE_UNKNOWN;
> > +     if (on_accessible_stack_common(tsk, sp, size, info))
> > +             return true;
> >
> >       if (on_task_stack(tsk, sp, size, info))
> >               return true;
> > @@ -74,8 +74,6 @@ static inline bool on_accessible_stack(const struct task_struct *tsk,
> >               return false;
> >       if (on_irq_stack(sp, size, info))
> >               return true;
> > -     if (on_overflow_stack(sp, size, info))
> > -             return true;
> >       if (on_sdei_stack(sp, size, info))
> >               return true;
> >
> > diff --git a/arch/arm64/include/asm/stacktrace/common.h b/arch/arm64/include/asm/stacktrace/common.h
> > index 64ae4f6b06fe..f58b786460d3 100644
> > --- a/arch/arm64/include/asm/stacktrace/common.h
> > +++ b/arch/arm64/include/asm/stacktrace/common.h
> > @@ -62,6 +62,9 @@ struct unwind_state {
> >       struct task_struct *task;
> >  };
> >
> > +static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
> > +                                  struct stack_info *info);
> > +
> >  static inline bool on_stack(unsigned long sp, unsigned long size,
> >                           unsigned long low, unsigned long high,
> >                           enum stack_type type, struct stack_info *info)
> > @@ -80,6 +83,21 @@ static inline bool on_stack(unsigned long sp, unsigned long size,
> >       return true;
> >  }
> >
> > +static inline bool on_accessible_stack_common(const struct task_struct *tsk,
> > +                                           unsigned long sp,
> > +                                           unsigned long size,
> > +                                           struct stack_info *info)
> > +{
> > +     if (info)
> > +             info->type = STACK_TYPE_UNKNOWN;
> > +
> > +     /*
> > +      * Both the kernel and nvhe hypervisor make use of
> > +      * an overflow_stack
> > +      */
> > +     return on_overflow_stack(sp, size, info);
> > +}
>
> on_accessible_stack has the following comment:
>
> /*
>  * We can only safely access per-cpu stacks from current in a non-preemptible
>  * context.
>  */
>
> With this change, I don't think we satisfy this requirement anymore,
> as we're checking the overflow stack *before* the preemptible check,
> which is a big change in behaviour.
>
> The hypervisor doesn't have this requirement: the unwinding is either
> done out of context (nVHE, where EL1 unwinds EL2) or in a
> non-preemptible section (pKVM, where the whole thing is
> non-preemptible). But the kernel is usually preemptible, so this patch
> needs fixing.
>
> I'll see if I can address it locally (I'm currently moving things
> around, stay tuned).

Hi Marc,

You are right it changes the order of the checks. I think the simplest
way then is to drop this patch, and replace uses of on_accessible
_stack_common().

Thanks,
Kalesh

>
> Thanks,
>
>         M.
>
> --
> Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ