public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@mips.com>
To: Miodrag Dinic <Miodrag.Dinic@mips.com>
Cc: David Daney <ddaney@caviumnetworks.com>,
	Aleksandar Markovic <aleksandar.markovic@rt-rk.com>,
	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
	Aleksandar Markovic <Aleksandar.Markovic@mips.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	DengCheng Zhu <DengCheng.Zhu@mips.com>,
	Ding Tianhong <dingtianhong@huawei.com>,
	Douglas Leung <Douglas.Leung@mips.com>,
	Frederic Weisbecker <frederic@kernel.org>,
	Goran Ferenc <Goran.Ferenc@mips.com>,
	Ingo Molnar <mingo@kernel.org>,
	James Cowgill <James.Cowgill@imgtec.com>,
	Jonathan Corbet <corbet@lwn.net>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Matt Redfearn <Matt.Redfearn@mips.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Paul Burton <Paul.Burton@mips.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Petar Jovanovic <Petar.Jovanovic@mips.com>,
	Raghu Gandham <Raghu.Gandham@mips.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Tom Saeger <tom.saeger@oracle.com>
Subject: Re: [PATCH v2] MIPS: Add nonxstack=on|off kernel parameter
Date: Thu, 30 Nov 2017 10:09:57 +0000	[thread overview]
Message-ID: <20171130100957.GG5027@jhogan-linux.mipstec.com> (raw)
In-Reply-To: <48924BBB91ABDE4D9335632A6B179DD6A8CFEA@MIPSMAIL01.mipstec.com>

[-- Attachment #1: Type: text/plain, Size: 6896 bytes --]

On Thu, Nov 30, 2017 at 09:34:15AM +0000, Miodrag Dinic wrote:
> Hi David,
> 
> Sorry for a late response, please find answers in-lined:
> 
> > > If this parameter is omitted, kernel behavior remains the same as it
> > > was before this patch is applied.
> > 
> > Do other architectures have a similar hack?
> > 
> > If arm{,64} and x86 don't need this, what would make MIPS so special
> > that we have to carry this around?
> 
> Yes, there are similar workarounds. Just a couple lines above
> nonxstack description in the documentation there are :
> 	noexec		[IA-64]
> 
> 	noexec		[X86]
> 			On X86-32 available only on PAE configured kernels.
> 			noexec=on: enable non-executable mappings (default)
> 			noexec=off: disable non-executable mappings
> ...
> 
> 	noexec32	[X86-64]
> 			This affects only 32-bit executables.
> 			noexec32=on: enable non-executable mappings (default)
> 				read doesn't imply executable mappings
> 			noexec32=off: disable non-executable mappings
> 				read implies executable mappings
> 
> > > 
> > > This functionality is convenient during debugging and is especially
> > > useful for Android development where non-exec stack is required.
> > 
> > Why not just set the PT_GNU_STACK flags correctly in the first place?
> 
> We do have PT_GNU_STACK flags set correctly, this feature is required to
> workaround CPU revisions which do not have RIXI support.

RIXI support can be discovered programatically from CP0_Config3.RXI
(cpu_has_rixi in asm/cpu-features.h), so I don't follow why CPUs without
RIXI would require a kernel parameter.

Cheers
James

> 
> Kind regards,
> Miodrag
> ________________________________________
> From: David Daney [ddaney@caviumnetworks.com]
> Sent: Tuesday, November 21, 2017 9:53 PM
> To: Aleksandar Markovic; linux-mips@linux-mips.org
> Cc: Miodrag Dinic; Aleksandar Markovic; Andrew Morton; DengCheng Zhu; Ding Tianhong; Douglas Leung; Frederic Weisbecker; Goran Ferenc; Ingo Molnar; James Cowgill; James Hogan; Jonathan Corbet; linux-doc@vger.kernel.org; linux-kernel@vger.kernel.org; Marc Zyngier; Matt Redfearn; Mimi Zohar; Paul Burton; Paul E. McKenney; Petar Jovanovic; Raghu Gandham; Ralf Baechle; Thomas Gleixner; Tom Saeger
> Subject: Re: [PATCH v2] MIPS: Add nonxstack=on|off kernel parameter
> 
> On 11/21/2017 05:56 AM, Aleksandar Markovic wrote:
> > From: Miodrag Dinic <miodrag.dinic@mips.com>
> >
> > Add a new kernel parameter to override the default behavior related
> > to the decision whether to set up stack as non-executable in function
> > mips_elf_read_implies_exec().
> >
> > The new parameter is used to control non executable stack and heap,
> > regardless of PT_GNU_STACK entry. This does apply to both stack and
> > heap, despite the name.
> >
> > Allowed values:
> >
> > nonxstack=on  Force non-exec stack & heap
> > nonxstack=off Force executable stack & heap
> >
> > If this parameter is omitted, kernel behavior remains the same as it
> > was before this patch is applied.
> 
> Do other architectures have a similar hack?
> 
> If arm{,64} and x86 don't need this, what would make MIPS so special
> that we have to carry this around?
> 
> 
> >
> > This functionality is convenient during debugging and is especially
> > useful for Android development where non-exec stack is required.
> 
> Why not just set the PT_GNU_STACK flags correctly in the first place?
> 
> >
> > Signed-off-by: Miodrag Dinic <miodrag.dinic@mips.com>
> > Signed-off-by: Aleksandar Markovic <aleksandar.markovic@mips.com>
> > ---
> >   Documentation/admin-guide/kernel-parameters.txt | 11 +++++++
> >   arch/mips/kernel/elf.c                          | 39 +++++++++++++++++++++++++
> >   2 files changed, 50 insertions(+)
> >
> > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> > index b74e133..99464ee 100644
> > --- a/Documentation/admin-guide/kernel-parameters.txt
> > +++ b/Documentation/admin-guide/kernel-parameters.txt
> > @@ -2614,6 +2614,17 @@
> >                       noexec32=off: disable non-executable mappings
> >                               read implies executable mappings
> >
> > +     nonxstack       [MIPS]
> > +                     Force setting up stack and heap as non-executable or
> > +                     executable regardless of PT_GNU_STACK entry. Both
> > +                     stack and heap are affected, despite the name. Valid
> > +                     arguments: on, off.
> > +                     nonxstack=on:   Force non-executable stack and heap
> > +                     nonxstack=off:  Force executable stack and heap
> > +                     If ommited, stack and heap will or will not be set
> > +                     up as non-executable depending on PT_GNU_STACK
> > +                     entry and possibly other factors.
> > +
> >       nofpu           [MIPS,SH] Disable hardware FPU at boot time.
> >
> >       nofxsr          [BUGS=X86-32] Disables x86 floating point extended
> > diff --git a/arch/mips/kernel/elf.c b/arch/mips/kernel/elf.c
> > index 731325a..28ef7f3 100644
> > --- a/arch/mips/kernel/elf.c
> > +++ b/arch/mips/kernel/elf.c
> > @@ -326,8 +326,47 @@ void mips_set_personality_nan(struct arch_elf_state *state)
> >       }
> >   }
> >
> > +static int nonxstack = EXSTACK_DEFAULT;
> > +
> > +/*
> > + * kernel parameter: nonxstack=on|off
> > + *
> > + *   Force setting up stack and heap as non-executable or
> > + *   executable regardless of PT_GNU_STACK entry. Both
> > + *   stack and heap are affected, despite the name. Valid
> > + *   arguments: on, off.
> > + *
> > + *     nonxstack=on:   Force non-executable stack and heap
> > + *     nonxstack=off:  Force executable stack and heap
> > + *
> > + *   If ommited, stack and heap will or will not be set
> > + *   up as non-executable depending on PT_GNU_STACK
> > + *   entry and possibly other factors.
> > + */
> > +static int __init nonxstack_setup(char *str)
> > +{
> > +     if (!strcmp(str, "on"))
> > +             nonxstack = EXSTACK_DISABLE_X;
> > +     else if (!strcmp(str, "off"))
> > +             nonxstack = EXSTACK_ENABLE_X;
> > +     else
> > +             pr_err("Malformed nonxstack format! nonxstack=on|off\n");
> > +
> > +     return 1;
> > +}
> > +__setup("nonxstack=", nonxstack_setup);
> > +
> >   int mips_elf_read_implies_exec(void *elf_ex, int exstack)
> >   {
> > +     switch (nonxstack) {
> > +     case EXSTACK_DISABLE_X:
> > +             return 0;
> > +     case EXSTACK_ENABLE_X:
> > +             return 1;
> > +     default:
> > +             break;
> > +     }
> > +
> >       if (exstack != EXSTACK_DISABLE_X) {
> >               /* The binary doesn't request a non-executable stack */
> >               return 1;
> >
> 
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-11-30 10:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 13:56 [PATCH v2] MIPS: Add nonxstack=on|off kernel parameter Aleksandar Markovic
2017-11-21 16:50 ` Randy Dunlap
2017-11-21 20:53 ` David Daney
2017-11-30  9:34   ` Miodrag Dinic
2017-11-30 10:09     ` James Hogan [this message]
2017-11-30 13:06       ` Miodrag Dinic
2017-12-01 11:35         ` Miodrag Dinic
2017-12-01 17:38         ` David Daney
2017-12-06 17:50         ` Maciej W. Rozycki
2017-12-06 18:24           ` Paul Burton
2017-12-07 11:33             ` Miodrag Dinic
2018-01-02 18:35               ` Maciej W. Rozycki
2018-02-08 11:55               ` James Hogan
2018-02-13 16:06                 ` Aleksandar Markovic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171130100957.GG5027@jhogan-linux.mipstec.com \
    --to=james.hogan@mips.com \
    --cc=Aleksandar.Markovic@mips.com \
    --cc=DengCheng.Zhu@mips.com \
    --cc=Douglas.Leung@mips.com \
    --cc=Goran.Ferenc@mips.com \
    --cc=James.Cowgill@imgtec.com \
    --cc=Matt.Redfearn@mips.com \
    --cc=Miodrag.Dinic@mips.com \
    --cc=Paul.Burton@mips.com \
    --cc=Petar.Jovanovic@mips.com \
    --cc=Raghu.Gandham@mips.com \
    --cc=akpm@linux-foundation.org \
    --cc=aleksandar.markovic@rt-rk.com \
    --cc=corbet@lwn.net \
    --cc=ddaney@caviumnetworks.com \
    --cc=dingtianhong@huawei.com \
    --cc=frederic@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=marc.zyngier@arm.com \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=ralf@linux-mips.org \
    --cc=tglx@linutronix.de \
    --cc=tom.saeger@oracle.com \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox