Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754055AbbHFAPr (ORCPT ); Wed, 5 Aug 2015 20:15:47 -0400 Received: from mail-bn1on0053.outbound.protection.outlook.com ([157.56.110.53]:34113 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752836AbbHFAPp (ORCPT ); Wed, 5 Aug 2015 20:15:45 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Daney@caviumnetworks.com; Message-ID: <55C2A38F.6000708@caviumnetworks.com> Date: Wed, 5 Aug 2015 17:00:15 -0700 From: David Daney User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Leonid Yegoshin CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v4 0/3] MIPS executable stack protection References: <20150805234348.20722.71740.stgit@ubuntu-yegoshin> In-Reply-To: <20150805234348.20722.71740.stgit@ubuntu-yegoshin> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [64.2.3.194] X-ClientProxiedBy: BLUPR07CA071.namprd07.prod.outlook.com (25.160.24.26) To BY1PR0701MB1722.namprd07.prod.outlook.com (25.162.111.141) X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1722;2:YAnmggAG9HS3y0AEnhCj60ypoDxVCoWqEQawlxMyvvjsomOZroP3Nf3tcrao+bdWd7aGXooABsFqjOolPBcyvNnPT+pn6uf1pRrDEUNXITEB5ASD7kwFjBLWAN5UnXKRMZQnxW1QgFAG27aTvzvi0O7gXSTpTAXE+HRIKdFNwhE=;3:lOGQv7AxBUdtxerxkpJAALI9EvCPmCUchHiizNqjOxC8WT+jiF/CvsbnpIV721rBYZZPUzcaEI3/9/xAu+0h+/F7UuI9KlxN7/fE/Gv01L0wysBoTcqOI4iuQS/mW0EQZKGPPsgluTHCaQ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t6zXYKLcW/1tZatuIpzNhk05hVl+8kILnD9DP/YNHzp3VL8rSKzoNSY20TmW4ZvBoSOcS9q7t+BrT6whsxA1jndower01Z4Zsif67/eVpv8k1TTCCGOt9LjQIlUDjjD3BrdHFBa+7HD5SF5ogpHvc86/j+1qV9VhGEynOZ57WO8ffaeh0E+oHktJdpXB8aRogLJArHPXc+O8QncP5kn9q1ywz2S38G7cKNMVhyi60UMMz6E13ylJdyiM3tjlWbbINHhcuJLbTNgLTlNT0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY1PR0701MB1722;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1722; X-Forefront-PRVS: 06607E485E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(199003)(479174004)(377454003)(189002)(24454002)(4001350100001)(77156002)(42186005)(64126003)(83506001)(50986999)(5001830100001)(5001860100001)(81156007)(80316001)(97736004)(53416004)(23676002)(65816999)(47776003)(54356999)(4001540100001)(87976001)(64706001)(65806001)(65956001)(101416001)(76176999)(66066001)(87266999)(50466002)(92566002)(77096005)(2950100001)(5001960100002)(69596002)(59896002)(105586002)(106356001)(189998001)(62966003)(36756003)(33656002)(46102003)(40100003)(68736005)(122386002)(110136002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1722;H:dl.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTFQUjA3MDFNQjE3MjI7MjM6c3gxWnk1VG82eVRVTzhZN2V5cW5TR0cv?= =?utf-8?B?U0RpZk5GU3ZaNmo2Wi96ZjBabXRvZFZuTnFOVzg0aW1ZWloxaUMyRlh4Qk1R?= =?utf-8?B?SkRteldyb3FWOHJQNDU2cmRQdWE0UXlHZGdNYUgveHl0cDhIY2loaTBLSE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hXy9zLyK4Jdh9A94obGc5rRM=;20:ZfjK+kKsUcDJNIbZdf91neOAVmowpH0mG1W5KaXCS5q/5nd+6bucWnkTo6CP2ntqL3EshrhaHRCmjRoSleQzmQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2015 00:00:20.0820 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1722 X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1658;2:3B16xQMceFq+tDBD4/oKSUZcqYpMFLyU/oq7fTHGnxf3wgvjq32YA+ONd/hEM1pecmY6ULIQRCYK2LFbqnszgSuP0rbMcnPQXWZp78QIl1iaPrmSw3FV/aVnjgmfXBd1x829yumV7JUwciR9Ze0fb2g5ALnN6FDLi4zDQicCsvQ=;3:vG5E0bi0ajlZMPVDhkS+RyxCMs1as8xLClxULlWVYI5ELqpVnrxQvI1DcGN7eu8xhcUKjXx64OITiX99m4CUu3m9yuVIbiKgD0Oasj8H+07NJckY5jIx/BsrV31zUZwblIVs/6dMePmGYEgBvSGGFg==;25:SJkQrGLfZ2ltBCBekA+rSrDxaLaBoa1kQ+SMXQnbu0ii27mZPVo/d1usyjgeAPXM0QjH3h6cwH/W98nb0R54OQrMiZDld0PRoXrKy0Fn0aYSrLbCDI9N/aJdymkoWzaoUhUZLgqVzLoSYhq86JRGBhomfjQcIJfnXvdbhzTTXXBNq6lpbTV/Y8jUnWUkPOVWrGd2GfvgAWxdivcKLVWD6d0T4MiS9eQDc9ujcprOaniymAkCsSp+5tOHq5dfbG7zmP5gvNyKuuv9LiOph482gg==;23:pWFcsS84anxCu1vS1ur0eiCfQ/txRSGXE1VwcX6WcXrIbN6egDp/0tXXWvr11coXo4l54vTWGRq3vyqU+IJdCdJOjcRZMHssaam970ZrXvxoeXyu876z+WJaRlulVRtFjjnqW1+jwDcR0gSbb4ruGHKKB9GmqaLLsi55RqDUSg2KpEZTbj2amXv8LW0rrkP0UHdnzvk3/e6ka3pEqPMRCyolLeN4b6xoAOB1BiOIO3uRlXUknWbCoW3nsydGDO4K X-OriginatorOrg: caviumnetworks.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3502 Lines: 90 On 08/05/2015 04:49 PM, Leonid Yegoshin wrote: > The following series implements an executable stack protection in MIPS. > > It sets up a per-thread 'VDSO' page and appropriate TLB support. > Page is set write-protected from user and is maintained via kernel VA. > MIPS FPU emulation is shifted to new page and stack is relieved for > execute protection as is as all data pages in default setup during ELF > binary initialization. Does it handle nested emulation? 1) Emulation started on instruction in main program flow, we are about to re-enter user space.. 2) Asynchronous signal is received. 3) Return to user space. Where do we go? Is it the signal handler or the instruction emulation? If we go to the signal handler and it needs emulation, what happens? David Daney > The real protection is controlled by GLIBC and > it can do stack protected now as it is done in other architectures and > I learned today that GLIBC team is ready for this. > > Note: actual execute-protection depends from HW capability, of course. > > This patch is required for MIPS32/64 R2 emulation on MIPS R6 architecture. > Without it 'ssh-keygen' crashes pretty fast on attempt to execute instruction > in stack. > > v2 changes: > - Added an optimization during mmap switch - doesn't switch if the same > thread is rescheduled and other threads don't intervene (Peter Zijlstra) > - Fixed uMIPS support (Paul Burton) > - Added unwinding of VDSO emulation stack at signal handler invocation, > hiding an emulation page (Andy Lutomirski note in other patch comments) > > V3 change: heavy preemption friendly. > > V4 changes: > - Fixed bug in supplementary TLB flush (change KVA to user address space) > - Rebased to 4.X kernel > --- > > Leonid Yegoshin (3): > MIPS: mips_flush_cache_range is added > MIPS: Setup an instruction emulation in VDSO protected page instead of user stack > MIPS: set stack/data protection as non-executable > > > arch/mips/include/asm/cacheflush.h | 3 + > arch/mips/include/asm/fpu_emulator.h | 2 > arch/mips/include/asm/mmu.h | 3 + > arch/mips/include/asm/page.h | 2 > arch/mips/include/asm/processor.h | 2 > arch/mips/include/asm/switch_to.h | 14 +++ > arch/mips/include/asm/thread_info.h | 3 + > arch/mips/include/asm/tlbmisc.h | 1 > arch/mips/include/asm/vdso.h | 3 + > arch/mips/kernel/mips-r2-to-r6-emul.c | 10 +- > arch/mips/kernel/process.c | 7 ++ > arch/mips/kernel/signal.c | 4 + > arch/mips/kernel/vdso.c | 44 +++++++++ > arch/mips/math-emu/cp1emu.c | 8 +- > arch/mips/math-emu/dsemul.c | 154 +++++++++++++++++++++++++++------ > arch/mips/mm/c-octeon.c | 8 ++ > arch/mips/mm/c-r3k.c | 8 ++ > arch/mips/mm/c-r4k.c | 43 +++++++++ > arch/mips/mm/c-tx39.c | 9 ++ > arch/mips/mm/cache.c | 4 + > arch/mips/mm/fault.c | 5 + > arch/mips/mm/tlb-r4k.c | 42 +++++++++ > 22 files changed, 343 insertions(+), 36 deletions(-) > > -- > Signature > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/