Received: by 10.223.164.202 with SMTP id h10csp431769wrb; Thu, 30 Nov 2017 01:36:28 -0800 (PST) X-Google-Smtp-Source: AGs4zMYK0vkTl3RdMxoCX8HDVBMso8R6t8UmxpjMLO5o8UmdNGXzt6dEDj+IXRF85kLZVUYHHQIL X-Received: by 10.99.106.137 with SMTP id f131mr1829666pgc.334.1512034587925; Thu, 30 Nov 2017 01:36:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512034587; cv=none; d=google.com; s=arc-20160816; b=ZSyWFIRXIa8L0GJAsZPa6wpsXxRRSDOSWxiYS2KEM0vtfYle55zoK1SD36BnkJxffv 0rNb/374h3reth7imftAcSeEfnTMfahoCvUXMm2jT/efMpZ0c2OwHIXM2ecgIrb9AOqR cQZS3DzbLm6xZc7xEloT1I0HWivhR4oLwCpRtx6mPAsHjRayFSU7ghvo+yhQNq8iMvlu 3J6CfqWumoYH7R+2HrblSl7CgvgxiLpTrNTuNUo2FW/6A7zjMeGymAItQl+9ShOuIgNc kklRBChcXWtqQk+fB8u00HhbkQV2qdelZGvEIwwT23Pm0aNH0pAlgfvLD8Y0QOfkyc2r DZfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=OpPE9YlLfLN4JUGGPuT228pg0yZU6cwVvj/iRnuKPPk=; b=lCeJhGsuLzOzgr3JyzCHsacjn10j5RPJJSS7yYJEy72wBRAjOG4KS+hjw6ZfEhPpdL OoT9TYiWaVPcb+TNkf2w9BalYCK6OSc2Oc+sLQrLjEMjxw4X4FnW1sVjoeI1GNAtKiBa n7NYNFaD2zUmaKxHTXJC5ocEHvPLhoImgFlYQolh6RXmS64IV9Zv1pcHZlOuutlJmc0H Y6EbmmXeBeZKgnpS9+gCveLLtgBDQZBGVZjNj2ubZ0/PASOq2UBfu38TPNHZAb1bTAhb RU3r4sadnZD0Xhpntnsr8K4bUQXHcNJdW8dyuP1jtqNlYYnjysO3Vdx+LlKVsUBeHMCB 0HeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si2716265pgq.431.2017.11.30.01.36.15; Thu, 30 Nov 2017 01:36:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752161AbdK3Jfl convert rfc822-to-8bit (ORCPT + 99 others); Thu, 30 Nov 2017 04:35:41 -0500 Received: from 9pmail.ess.barracuda.com ([64.235.154.210]:36380 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902AbdK3Jfh (ORCPT ); Thu, 30 Nov 2017 04:35:37 -0500 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx1412.ess.rzc.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Thu, 30 Nov 2017 09:34:16 +0000 Received: from MIPSMAIL01.mipstec.com ([fe80::5c93:1f20:524d:a563]) by MIPSMAIL01.mipstec.com ([fe80::5c93:1f20:524d:a563%13]) with mapi id 14.03.0361.001; Thu, 30 Nov 2017 01:34:16 -0800 From: Miodrag Dinic To: David Daney , Aleksandar Markovic , "linux-mips@linux-mips.org" CC: 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 Thread-Topic: [PATCH v2] MIPS: Add nonxstack=on|off kernel parameter Thread-Index: AQHTYtCGiXJpn3ndkEa756uEAr0gK6Mf1f6AgAPtqzY= Date: Thu, 30 Nov 2017 09:34:15 +0000 Message-ID: <48924BBB91ABDE4D9335632A6B179DD6A8CFEA@MIPSMAIL01.mipstec.com> References: <1511272574-10509-1-git-send-email-aleksandar.markovic@rt-rk.com>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [82.117.201.26] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-BESS-ID: 1512034456-452060-20055-147433-1 X-BESS-VER: 2017.14.1-r1710272128 X-BESS-Apparent-Source-IP: 12.201.5.28 X-BESS-Outbound-Spam-Score: 0.20 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.187456 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.20 PR0N_SUBJECT META: Subject has letters around special characters (pr0n) X-BESS-Outbound-Spam-Status: SCORE=0.20 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND, PR0N_SUBJECT X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 > > 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 > Signed-off-by: Aleksandar Markovic > --- > 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; > From 1584710475850604665@xxx Tue Nov 21 20:54:39 +0000 2017 X-GM-THRID: 1584684002037682770 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread