From nobody Sun Dec 12 14:30:36 2021 X-Original-To: dev-commits-src-all@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 DFF7318E8D22; Sun, 12 Dec 2021 14:30:38 +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 4JBn9n1fN5z4mM3; Sun, 12 Dec 2021 14:30:37 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 64B1722A33; Sun, 12 Dec 2021 14:30:36 +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 1BCEUas5066719; Sun, 12 Dec 2021 14:30:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BCEUa0j066718; Sun, 12 Dec 2021 14:30:36 GMT (envelope-from git) Date: Sun, 12 Dec 2021 14:30:36 GMT Message-Id: <202112121430.1BCEUa0j066718@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 36df8f540fa3 - main - imgact_elf: check that the alignment of PT_LOAD segment is power of two List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 36df8f540fa3802e3d7ccf9d71a13750a72b33ff Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639319438; 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=uHoN+yoUNAnzgN8eL+wav8ftYfaubeFPkH2zJUl3GMQ=; b=SpLKkS/pPo9xlHPcqKlhwQFY8XdJzV+VHeIGKxDH+cYJWWj+P1/4/s9UHID5mYvr083zFG FPRW/I+3yGYi2usG+KBtNQJp6kAeR04vkbiqrTaw5xVpFUYFBeMKxUFr44cLa3ZLICnZru dok51tpm0d+c531roBzhoCCkZKGdvb1oPtEnWBhZmwO26xwSLw6juiOq2UoQNAQLxDootT lScXnPZQpFfqMf8UbpgTPNW0D01dVW5EZopk0eoeD96l4TPjQn/PZsA2Iy2MYhsHNKVgzm qnPaos/hLd/+AiVY1Evrrjv/hTTfcHqMUc/vzhVbLr09V9jtjz449nv76uansA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639319438; a=rsa-sha256; cv=none; b=pBRRDaRghfpFjydAI9ZGzG8QyDfymWXyOrBsDs03B68pFhZmf3OAW1NzvXgthazRxD3mXf 4GOeinJQDrSCqLF2vS3kQoEoAkExe35F2HU0jN2Ym0FvfC0VrIXmPzoGKf+nVeq7XEI1R+ 3BWfyJ9ktGU9dtR3bJHBDL40pdyow7eIkcnbS8X4LOEJFWfwce10u8TbZhkjpVAYbhvBsz 8JQoRfsyPExCMWuoLPZmA0PUTxG65jm/n33d8ZJseUHWZ5ryiU+4aDKl3Pi5eTk9HCkCqC r4qUGsKpFwK7olldtaB5KPXfBf2O09x4MkK8w4ut72pQUYds0YiXeG25n4r9KA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=36df8f540fa3802e3d7ccf9d71a13750a72b33ff commit 36df8f540fa3802e3d7ccf9d71a13750a72b33ff Author: Konstantin Belousov AuthorDate: 2021-12-09 15:27:24 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-12 14:28:38 +0000 imgact_elf: check that the alignment of PT_LOAD segment is power of two and stop recalculating alignment for PIE base, which was off by one power of two. Suggested and reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33359 --- sys/kern/imgact_elf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 3b05b38f3ed1..d4c5a6341ee6 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1174,7 +1174,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) case PT_LOAD: if (n == 0) baddr = phdr[i].p_vaddr; - if (phdr[i].p_align > maxsalign) { + if (!powerof2(phdr[i].p_align) || + phdr[i].p_align > maxsalign) { uprintf("Invalid segment alignment\n"); error = ENOEXEC; goto ret; @@ -1316,7 +1317,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) error = __CONCAT(rnd_, __elfN(base))(map, vm_map_min(map) + mapsz + lim_max(td, RLIMIT_DATA), /* reserve half of the address space to interpreter */ - maxv / 2, 1UL << flsl(maxalign), &et_dyn_addr); + maxv / 2, maxalign, &et_dyn_addr); } vn_lock(imgp->vp, LK_SHARED | LK_RETRY);