From owner-freebsd-stable@freebsd.org Sat Aug 24 22:40:28 2019 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 1AE68CD57A for ; Sat, 24 Aug 2019 22:40:28 +0000 (UTC) (envelope-from trond.endrestol@ximalas.info) Received: from enterprise.ximalas.info (enterprise.ximalas.info [IPv6:2001:700:1100:1::8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "ximalas.info", Issuer "Hostmaster ximalas.info" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 46GCs72ph5z4FSH for ; Sat, 24 Aug 2019 22:40:26 +0000 (UTC) (envelope-from trond.endrestol@ximalas.info) Received: from enterprise.ximalas.info (Ximalas@localhost [127.0.0.1]) by enterprise.ximalas.info (8.15.2/8.15.2) with ESMTPS id x7OMeMbT050133 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 25 Aug 2019 00:40:22 +0200 (CEST) (envelope-from trond.endrestol@ximalas.info) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ximalas.info; s=default; t=1566686422; bh=eSd9VsU1x85KleYNG+ehvWXnoTgf9vClcOGCJNu4X34=; h=Date:From:To:cc:Subject:In-Reply-To:References; b=qFJANxhMnDdGVTJBp2Cl4JWMb4+aUM3dPFUsJK/vYhzEj0+TZcPzXNvXUAcBVIP0L MKFJ/VLa1Lp5vYkj/D1OvJuHG6jDcWloui9jnC/bTvCMtF1M7lJTVfDF3TSTC8fawJ +A0EEvRo6nM03RwnMHvvulhzqPOdX9T+NBzLvxWsfWQYf7RMTxw3Vb8E/CdKjp4JK6 Odafn+HaQJnP80bFNbM0KpATlJD/sd9H+PT6AMRmpZ/GGHXdTcQmw2TYuMrV7gMdPN 4Wpna8N1jN4pd8dehi18Evga5KI48j9HlZhgawsdWmvV05+o9Kc91vQOq4CeyKKt/q ytW31G2gIL9iQ== Received: from localhost (trond@localhost) by enterprise.ximalas.info (8.15.2/8.15.2/Submit) with ESMTP id x7OMeMFL050130; Sun, 25 Aug 2019 00:40:22 +0200 (CEST) (envelope-from trond.endrestol@ximalas.info) X-Authentication-Warning: enterprise.ximalas.info: trond owned process doing -bs Date: Sun, 25 Aug 2019 00:40:22 +0200 (CEST) From: =?UTF-8?Q?Trond_Endrest=C3=B8l?= Sender: Trond.Endrestol@ximalas.info To: Konstantin Belousov cc: freebsd-stable@freebsd.org Subject: Re: ntpd doesn't like ASLR on stable/12 post-r350672 In-Reply-To: <20190824222817.GJ71821@kib.kiev.ua> Message-ID: References: <20190824204114.GG71821@kib.kiev.ua> <20190824222817.GJ71821@kib.kiev.ua> User-Agent: Alpine 2.21.99999 (BSF 352 2019-06-22) OpenPGP: url=http://ximalas.info/about/tronds-openpgp-public-key MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on enterprise.ximalas.info X-Rspamd-Queue-Id: 46GCs72ph5z4FSH X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=ximalas.info header.s=default header.b=qFJANxhM; dmarc=pass (policy=none) header.from=ximalas.info; spf=pass (mx1.freebsd.org: domain of trond.endrestol@ximalas.info designates 2001:700:1100:1::8 as permitted sender) smtp.mailfrom=trond.endrestol@ximalas.info X-Spamd-Result: default: False [-4.77 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[ximalas.info:s=default]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:c]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; HAS_XAW(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[ximalas.info:+]; CTYPE_MIXED_BOGUS(1.00)[]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.99)[-0.993,0]; DMARC_POLICY_ALLOW(-0.50)[ximalas.info,none]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:224, ipnet:2001:700::/32, country:NO]; IP_SCORE(-1.78)[ip: (-7.90), ipnet: 2001:700::/32(-0.58), asn: 224(-0.41), country: NO(-0.01)] Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Aug 2019 22:40:28 -0000 On Sun, 25 Aug 2019 01:28+0300, Konstantin Belousov wrote: > On Sun, Aug 25, 2019 at 12:19:43AM +0200, Trond Endrestøl wrote: > > On Sat, 24 Aug 2019 23:41+0300, Konstantin Belousov wrote: > > > > I tried changing command="/usr/sbin/${name}" to > > > > command="/usr/bin/proccontrol -m aslr -s disable /usr/sbin/${name}" in > > > > /etc/rc.d/ntpd, but that didn't go well. > > > > > > If you set kern.elf64.aslr.stack_gap to zero, does it help ? > > > > That helped. Thank you again. > > Can you verify is ntpd sets new rlimit(RLIMIT_STACK) for the main thread, > and if yes, what this new limit is ? (gdb) 5265 if (-1 == setrlimit(RLIMIT_STACK, &rl)) { (gdb) print rl $1 = {rlim_cur = 204800, rlim_max = 536870912} > aslr.stack_gap is the percentage for the gap on that stack, and since > default size of the main stack limit is quite large 512M, even 3% > (default gap upper limit) are whole 15M. If the new limit is less than > 15M, there is a likely probability that only the gap is left after the > rlimit(2) call, leaving no space for the program frames. > > At least this looks like a nice theory. -- Trond.