From nobody Sun Sep 4 23:59:17 2022 X-Original-To: dev-commits-src-branches@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 4MLTCB0xHsz4c3fc; Sun, 4 Sep 2022 23:59:18 +0000 (UTC) (envelope-from git@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 4MLTCB0GVcz3hwF; Sun, 4 Sep 2022 23:59:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662335958; 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; bh=4UqZggzj8+6dAe0qYo6shYUmD9uDYitsdlbnXLOJAZo=; b=DHhhvZ+T82RMTRk6sKFAr6gch2FLvOEhEaQ0jCZ9/M6+cA9vsiyx12zurdxpvd4ND5swKL xOWmtL2AevxynuCuqPVCpyHDNMUuDyyI6R8qibbxHOLcu1e01XZloU20SDKXbuO4jGPfPR kaee69mrica66i0+Mgqe2AoueiqqwaeKq9lpfe/YwyptfUiMQA6/7NiaiEmNmjmfqZuLMS g86xJz+A4DaHcD5ubmcIIVDtIsn6do1nHdtqW3LlBwZhhbWvzPFXsWDiHsKb936r84eAbK Cjg/otKNOse1KBkGAw+vwQJW8x9zDKOro2xiFQDZfFABTTUfO4hvp7PfIlEQ1A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4MLTC96R65zf9l; Sun, 4 Sep 2022 23:59:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 284NxHYp082827; Sun, 4 Sep 2022 23:59:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 284NxHuo082826; Sun, 4 Sep 2022 23:59:17 GMT (envelope-from git) Date: Sun, 4 Sep 2022 23:59:17 GMT Message-Id: <202209042359.284NxHuo082826@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 36a757de23ac - stable/13 - Disallow invalid PT_GNU_STACK List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 36a757de23ace0bedd20c83635281427cfc7da30 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662335958; 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; bh=4UqZggzj8+6dAe0qYo6shYUmD9uDYitsdlbnXLOJAZo=; b=QFFpVVLC1OoojcWTdcL5KTswvROsmONvLpZTTQNLX0YqQ//TXM5VSNrVd/7ixyni129PaL NGW4ftNeTrDd9t0BnHlDJa1fKh0N4+BjtfbLvOLssAvp6WeZyf3dNBZoNoY/cOnOsj4Q1d 91hCoTZwDBsRfnbquTCL5idpZAtNWJZk8uqQhOaE+KD9HJgSs7dZh4lfIs9G72GvHZVJ5F 9e1qCRKpE4CDt2TLKvarTDu0OzK1VkTIhSJ+H0I5zOZwKbmq2RWfFdhPNoyEbPYXS6/upS iev2FpTmTkbQaH85ooKKPa826h3XBNLGngJZeGpiTyCbAbp0GFdMdpAzhtGg8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662335958; a=rsa-sha256; cv=none; b=vhuyFzAKuB4GKozs+7RRMs3ZOmAQKRsIbXdSS9s+f/8XPRB2hkn2UqW7LvcNaUyl+f20VW aIM1cXPOAXNeu8oUyx2mK/+nZSwQYDzsrOHTZ28F13gRXlz0Dw+Wl11kqx+MBJRbpav7t2 UcoooOyVx0hcuAJ6XD1V+ygkF8lQm7uLGoLjGX0FUP5REryrMN1FBEdTe1riFhfl2GkO6Q xdWzxLMlB9MmeZMCRJi9ce8gBfgHuHJxD31W4bvFaGBfKHX1cgBRShk0spHcKz+dOZogu+ mMMzqrTT2rH1rorpXViHmk1N3c1AKq7CiMN4PAHu+F++jdh5qL7haBNiRnJEMw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=36a757de23ace0bedd20c83635281427cfc7da30 commit 36a757de23ace0bedd20c83635281427cfc7da30 Author: Ed Maste AuthorDate: 2022-03-18 17:56:32 +0000 Commit: Ed Maste CommitDate: 2022-09-04 23:55:58 +0000 Disallow invalid PT_GNU_STACK Stack must be at least readable and writable. PR: 242570 Reviewed by: kib, markj MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35867 (cherry picked from commit fbafa98a94cc7f4f30d71003c230d1b5d4c5960b) --- sys/kern/imgact_elf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 11ab46767fce..548a65a6f677 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1216,9 +1216,16 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) goto ret; break; case PT_GNU_STACK: - if (__elfN(nxstack)) + if (__elfN(nxstack)) { imgp->stack_prot = __elfN(trans_prot)(phdr[i].p_flags); + if ((imgp->stack_prot & VM_PROT_RW) != + VM_PROT_RW) { + uprintf("Invalid PT_GNU_STACK\n"); + error = ENOEXEC; + goto ret; + } + } imgp->stack_sz = phdr[i].p_memsz; break; case PT_PHDR: /* Program header table info */