From nobody Sun Dec 19 02:44:31 2021 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 7278918E48E1; Sun, 19 Dec 2021 02:44:32 +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 4JGn9q5rQvz4q9d; Sun, 19 Dec 2021 02:44:31 +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 83CE41AE9E; Sun, 19 Dec 2021 02:44:31 +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 1BJ2iV3H012662; Sun, 19 Dec 2021 02:44:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BJ2iVJF012661; Sun, 19 Dec 2021 02:44:31 GMT (envelope-from git) Date: Sun, 19 Dec 2021 02:44:31 GMT Message-Id: <202112190244.1BJ2iVJF012661@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: f1f4d58a6bf8 - stable/13 - imgact_elf: check that the alignment of PT_LOAD segment is power of two 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f1f4d58a6bf828fc418071edfbc5d5462069c3d8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639881871; 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=lAmEPojQAREvN4kAg8UaPb4yFD/AxWId2PYs3+XJWCs=; b=g2acAiVeMfZd6JuU9IsvbEdYBSr2sqtHj33UEuTp8kxHW4cuO+ayWRCpE0/cQAeri+67wb EHd9hNjePMJA+uS300/Qu4uEMiEqo9xOCtUzJKPvF3KR90jnIQZUObxx1wH4sVIxTQZAa4 7o+ZOaKaADFIKm6ucKVj0u9GZyUBPHVijaZEq7m0s5Zyvqgo4xUpq/ABYxzNffnEKy2qOV QCvK6Zt/raIRPurcvZQtueZzuazhAsT7X+LR5CTvJPdCvjCrhaZcCKDva2IUqzTIqnf2Bq p1p7xVuAwODEvmlb7FY6/982bgT0PxYwyaLjcTaSP7mPMI+OdzWBRITYvcjqrg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639881871; a=rsa-sha256; cv=none; b=CK0dd4B8Bno6phSDTaKT76SbK8XdTzvYLFWtTAL5TAuCqUwrniAL5LAvH+BR1AeTBgM9NS ghE3e4UwJOWY2mE7LCSJo7YtFmL4T3IOQS4XdrAE46fhfWJotfgtNW/ckOTUdfx7Fu9ycY miqpuQ25udLz1/Ba1TmWPR3c84YdeGnLe4aNBMYNbONNqFjS2YAYjv/RyOfSd3fd0dzA9z LAjv1nr/r66/n2RlPWS5nzrG1cXmcNl6hCDl/r8IxLZnSimQ4gk4/5MKV854PEutD/Zq56 yNr1BxcgpmEoptWx+gQfpYXMzawtJU4d4yFVU5Yk2XLdxEMA/1nM4vG7yFfm2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f1f4d58a6bf828fc418071edfbc5d5462069c3d8 commit f1f4d58a6bf828fc418071edfbc5d5462069c3d8 Author: Konstantin Belousov AuthorDate: 2021-12-09 15:27:24 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-19 02:42:51 +0000 imgact_elf: check that the alignment of PT_LOAD segment is power of two (cherry picked from commit 36df8f540fa3802e3d7ccf9d71a13750a72b33ff) --- 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 e0dd2b13c143..17c0752c35fa 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1154,7 +1154,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; @@ -1295,7 +1296,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);