From nobody Fri Dec 10 20:41:23 2021 X-Original-To: ports-bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 485EF18CB54E for ; Fri, 10 Dec 2021 20:41:23 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J9jVV6Mbkz4jZ3 for ; Fri, 10 Dec 2021 20:41:22 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BAB1C21118 for ; Fri, 10 Dec 2021 20:41:22 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 1BAKfMBa005301 for ; Fri, 10 Dec 2021 20:41:22 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1BAKfMOq005300 for ports-bugs@FreeBSD.org; Fri, 10 Dec 2021 20:41:22 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 260303] lang/sdcc: seg fault during build (ASLR fallout) Date: Fri, 10 Dec 2021 20:41:23 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: markj@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: ports-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Ports bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-ports-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports-bugs@freebsd.org X-BeenThere: freebsd-ports-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639168882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fh3I75oOJv1J0ZSPf6aYc1qNvKkwuLB9VrjzdcfzfQ4=; b=Mxb7SZChUPu+3zOY2VrxMiocItATQBzsz/eDsL2eWsi7eN3UXIGQNJVZ+3fTEAdhZmcbF0 M04BNX/mCdcMZ7QBykGw4w0SJvWsK3GDoVJLJPG243xdeHH8fzkUQFTlkQ6pp7nYC2gWKF 7NsX0Rrve0dPczfSgxCod20PZxlyxTDM/RPXoMpOJyhDUPhU3VQ99e4MoHGyGBw3T3J8M6 mEG1//ZtKpHvubdvtgT1PnEGeUW9LvETKgZvG3bCYZzB0gqAz2VkOLpj3ZsZiFmUA2c9Zf VCMdtCJK5etOAvQXsqmADBy7IOJ2iZfLYyTre8hU0We5R3MzhuJmUyh1nvqVVQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639168882; a=rsa-sha256; cv=none; b=mK/bV3ZM7nyviBDCGtS7dAO1OVhrkVq+NoqWhXvNX8/3MHThpNOM1lCDwPOe7Ah1Zb9IKj OmlrSESfkEFRtWxExBqt3H/Dcijd8kjR/Er3jdWFVbEn45oI7xo0wtLhzkiEfvf2T3227W RasUemTN1r2p2HJ9X3HJ+puJSRzqPP3+f3HJj9J4lFclGaELvYkuRNFVV+Htmn905CKZYi kpsEEcyASWCXOq6osRhe+tvqSjkPr1tdh+wRZ95uKzeKv8Nu7yv13gGlQYy4LFl7XjZ/It X00RDAlJtdgp2vYX2Ul5eYSbig2oyPnFkrC0FIMND4zwCl8QMXLNhkrJci6dvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260303 Mark Johnston changed: What |Removed |Added ---------------------------------------------------------------------------- Status|New |Open CC| |markj@FreeBSD.org --- Comment #4 from Mark Johnston --- (In reply to Dawid Gorecki from comment #2) I did some digging into this earlier this week, and I think the problems go deeper. I believe the stack gap randomization should be disabled in main u= ntil this is sorted out properly. Right now on amd64 we have --------- <---- top of user memory VDSO page --------- <---- address returned by KERN_USRSTACK sysctl ps_strings auxv --------- stack gap --------- <---- address returned by KERN_STACKTOP sysctl argv, envv main process stack ... --------- <----=20 bottom of stack Some problems: 1. The stack gap is still mapped, just unused. So mlockall() will wire the stack gap region, wasting megabytes of memory. 2. The default RLIMIT_STACK value of 512 MB includes the stack gap. But setrlimit(RLIMIT_STACK) adds the size of the gap to the soft limit. So: 2a. The hard limit is clamped to the soft limit, so setting rlim_cur =3D rl= im_max doesn't work. That is the problem reported in this PR. 2b. The stack gap adjustment is visible to userspace. The simplest example, getrlimit(RLIMIT_STACK, &lim); setrlimit(RLIMIT_STACK, &lim); does not work as expected, i.e., it actually changes the stored limit (assuming 2a) is fixed. 3. The changes made recently to singlethread_map_stacks_exec() and init_private() in libthr don't make sense to me. In the former, we grab the KERN_STACKTOP and then mprotect() a region of size RLIMIT_STACK, but part of that region is unmapped (or mapped for something other than the stack) since RLIMIT_STACK includes the stack gap but KERN_STACKTOP is already adjusted by the stack gap. Meanwhile, __libc_map_stacks_exec() was not similarly modif= ied. Moreover, old copies of libthr.so will continue to use KERN_USRSTACK. Rather than including the gap in RLIMIT_STACK, can we map the full 512MB st= ack starting at the (randomized) argv/envv location (creating a separate mapping for ps_strings/auxv), or include ps_strings/auxv at the beginning of the randomized region? The latter is more work, since the kernel uses the ABI-defined ps_strings address in some places. It would break very old binaries that hard-code the ps_strings address, but aren't they effectively= all 32-bit binaries anyway? In any case, I propose disabling the stack gap randomization for now to add= ress the regressions. sdcc is not the only affected program. --=20 You are receiving this mail because: You are the assignee for the bug.=