From owner-freebsd-stable@freebsd.org Wed Oct 21 15:47:34 2020 Return-Path: Delivered-To: freebsd-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4CF3E44EF21 for ; Wed, 21 Oct 2020 15:47:34 +0000 (UTC) (envelope-from nikolay.kostirya@i11.co) Received: from mx.i11.co (mx.i11.co [159.69.78.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CGZd12j4mz4SC3 for ; Wed, 21 Oct 2020 15:47:33 +0000 (UTC) (envelope-from nikolay.kostirya@i11.co) Received: from [91.206.111.188] (helo=localhost) by mx.i11.co with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVGKp-0006BW-R6 for freebsd-stable@freebsd.org; Wed, 21 Oct 2020 15:47:31 +0000 Date: Wed, 21 Oct 2020 18:47:30 +0300 From: Nick Kostirya To: freebsd-stable@freebsd.org Subject: Re: mmap and MAP_STACK Message-ID: <20201021184730.080cecb3@i11.co> In-Reply-To: <20201021152844.GK2643@kib.kiev.ua> References: <20201021165311.186bd606@i11.co> <20201021141657.GJ2643@kib.kiev.ua> <20201021181850.49126cdf@i11.co> <20201021152844.GK2643@kib.kiev.ua> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i386-portbld-freebsd12.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4CGZd12j4mz4SC3 X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.16 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[i11.co:s=omicron]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:159.69.78.69:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_MEDIUM(-0.99)[-0.994]; DKIM_TRACE(0.00)[i11.co:+]; MID_RHS_MATCH_FROM(0.00)[]; DMARC_POLICY_ALLOW(-0.50)[i11.co,reject]; NEURAL_HAM_SHORT(-0.16)[-0.162]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:159.69.0.0/16, country:DE]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-stable] X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Oct 2020 15:47:34 -0000 On Wed, 21 Oct 2020 18:28:44 +0300 Konstantin Belousov wrote: > > > > kdump with MAP_STACK. > > > > 87183 polyimport CALL mmap(0,0x1000,0x3,0x1402,0xffffffff,0,0) > > 87183 polyimport RET mmap -1 errno 22 Invalid argument > So it is anything but 'insufficient memory' (I suspected ENOMEM). > EINVAL there is because sysctl security.bsd.stack_guard_page default value > is 1, which means that at least one page of the stack is reserved as guard. > Kernel does not allow to map stack that would have no data pages (all pages > are guard). > > Your mapping request is for one page, and one page is due to guard, so > you get EINVAL. Generally MAP_STACK is magic and requires caller to know > what it does. Thanks!