From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14380 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Fix the use of sigaltstack to return to the saved main stack. Date: Wed, 10 Jul 2019 14:39:31 -0400 Message-ID: <20190710183931.GT1506@brightrain.aerifal.cx> References: <20190709193004.GQ1506@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="256106"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14396-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jul 10 20:39:48 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hlHVK-0014Tq-CC for gllmg-musl@m.gmane.org; Wed, 10 Jul 2019 20:39:46 +0200 Original-Received: (qmail 27705 invoked by uid 550); 10 Jul 2019 18:39:44 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 27685 invoked from network); 10 Jul 2019 18:39:43 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14380 Archived-At: On Wed, Jul 10, 2019 at 02:04:18PM -0400, James Y Knight wrote: > On Tue, Jul 9, 2019 at 3:30 PM Rich Felker wrote: > > > On Tue, Jul 09, 2019 at 03:01:50PM -0400, James Y Knight wrote: > > > Previously, musl would reject the call, because the main stack has > > > ss_size == 0 and ss_flags == SS_DISABLE. > > > > > > We could condition on ss_flags not containing SS_DISABLE, but instead, > > > simply remove the ss_size check, as the kernel performs the same check, > > > anyhow. > > > > Are you sure the kernel does? I'm pretty sure the reason the code is > > here is that the kernel either does not check it, or does not perform > > the check correctly in some special case. Sadly the commit messages in > > musl were not as good back at the time when the code was written. > > > > As far back as the first git version (2.6.12-rc2), the kernel checks this > condition. I haven't looked back any further... > > However, I note now that musl uses different values for MINSIGSTKSIZE than > the kernel does, on some architectures. > > The usual value in the kernel is 2048. Only a few architectures set a > differing value: > alpha:4096 > arm64:5120 > ia64:131027 > sparc:4096 > > Musl usually uses 2048 as well, but sets other values on these > architectures: > arm64:6144 > powerpc:4096 > powerpc64:4096 > s390x:4096 > > (Musl doesn't support alpha, ia64, or sparc, so it's not using a lower > value than the kernel anywhere, at least). > > If it's important that stacks smaller than musl's MINSIGSTKSIZE be > rejected, despite them being large enough for the kernel, then I suppose > the check should be retained. Let me know -- I'll make a new patch > implementing your suggestion if you still think that's the way to go. It is important. It's both a normative requirement of POSIX, and a matter of the smaller sizes accepted by the kernel being unsafe -- they don't actually fit a signal context due to the arch's register file being huge, or having a reservation that it might be huge in the future. Rich