Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752254AbdGDOsY (ORCPT ); Tue, 4 Jul 2017 10:48:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:46777 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752053AbdGDOsX (ORCPT ); Tue, 4 Jul 2017 10:48:23 -0400 Date: Tue, 4 Jul 2017 16:48:17 +0200 From: Michal Hocko To: Ximin Luo Cc: Ben Hutchings , Willy Tarreau , Linus Torvalds , Hugh Dickins , Oleg Nesterov , "Jason A. Donenfeld" , Rik van Riel , Larry Woodman , "Kirill A. Shutemov" , Tony Luck , "James E.J. Bottomley" , Helge Diller , James Hogan , Laura Abbott , Greg KH , "security@kernel.org" , linux-distros@vs.openwall.org, Qualys Security Advisory , LKML Subject: Re: [PATCH] mm: larger stack guard gap, between vmas Message-ID: <20170704144817.GT14722@dhcp22.suse.cz> References: <20170704084122.GC14722@dhcp22.suse.cz> <20170704093538.GF14722@dhcp22.suse.cz> <20170704094728.GB22013@1wt.eu> <20170704104211.GG14722@dhcp22.suse.cz> <20170704113611.GA4732@decadent.org.uk> <20170704115959.GM14722@dhcp22.suse.cz> <1499170862.2707.27.camel@decadent.org.uk> <20170704123314.GO14722@dhcp22.suse.cz> <67c6905f-319d-81d2-819a-2a63a482d155@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <67c6905f-319d-81d2-819a-2a63a482d155@debian.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 782 Lines: 21 On Tue 04-07-17 14:19:00, Ximin Luo wrote: [...] > I've written up an explanation of what happens in the Rust case here: > > https://github.com/rust-lang/rust/issues/43052 The most important part is https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/thread.rs#L248 // Rellocate the last page of the stack. // This ensures SIGBUS will be raised on // stack overflow. let result = mmap(stackaddr, psize, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0); so this is basically the same thing Java does. Except that Java doesn't do that on main thread usually. Only some JNI runtimes do that. pthread_attr_getstack() usage on the main thread sounds like a real bug in rust to me. Thanks for the writeup! -- Michal Hocko SUSE Labs