From nobody Thu Aug 17 22:26:43 2023 X-Original-To: dev-commits-src-main@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 4RRfkC461kz4qFSB; Thu, 17 Aug 2023 22:26:43 +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 4RRfkC3YmKz4bxP; Thu, 17 Aug 2023 22:26:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692311203; 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=w7k3ns03Q+IcJRrf0kso7RvT4O8HpXmNNLMQKORYfaA=; b=Jp9jx8LKIOKV/TqdXam/QGAYAsQPyDOsSprRAxG65jfzZqAdG4cDTv3I08j+12wmxdy839 UmpdRn19fe7oYoI01+FN746oUZXWK96tRM2acJoCbuoBqH/D62U/VMjzxooLO7+6Ribr7K wzgWX6gtY86HJr5vulVlnSf/j3XG6hYSjbAXz8X4fQVOSLR6Ly8kGpCxltNUZlNSnFCP6M oaWekwGjGZBEAQFnCok5wPFmwBykSc1UmV/G8AlBob8IC5GYXiscozNj7l1zhn/Plbrwdj b+/vfHvIW0Pk/V/yfZFrqfu+ezPD1Cz2owYPV1VBWhdyrnkVWvcERp4vgUBfQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692311203; 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=w7k3ns03Q+IcJRrf0kso7RvT4O8HpXmNNLMQKORYfaA=; b=o7SEtD43ENdxtQt9Mpa8NshfvPTkDZi6BKspFT+57kQnDLLdrfjLf/0iatsOCG6f0v8Ulq umMv00yy4ro6YcUOzwGulDFtrzEAWFPiAR8skrY2rvVO0K1JsZLwr/EEBPwZcwU0KvJDIW nhSF5b06KXkaUZE60H4rMr/+ODrE8LBsajDUfpfKWVE9pQ5UBx2y3LCKhSAWeihkBLPWKa 5F0fbDqP2CntabUbj5Pn9zR94+OgiODYiACakJ+5ruh2jQZQmoGVg80xq/Qhl7V5vdMq0u gR8g1UuN1s1LKFKAkX6N80CnQL48zpYgKR3DMct6NkSLeftxZrlvd0Ea/GLVMA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692311203; a=rsa-sha256; cv=none; b=sFfa2hnUmJS/LDmccOdQ0TgUVlyec+uPPpfr3smBEl6ltOBw2fQNdFHi9t/NRldWog6FcE zezgCbBJGVp42mlelIDDhoNPR2KCm2+9fWTSj8qdEyxY2MpMQuT8n6zi/Cn5W7rF7SD/ji MSwcfiCORy82e7W+QPnnX1M6pIGRe2ZiQ1S1rsPxY24nA7tOs2gT2SwIMv4Shvy1FWScZo /w5SEtBaBcDIp4B1T2UAXTnmF1f7s/YVyyYWF7GOrPmoQqz+hgv3a5zViPJCgBb/3MBBZL VQWcIwOh1H4e2fHnm16LfahrQ+9Z9bHvOdSyiPG6ZyMcoEzqGi4xXZIHI0hsyw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RRfkC2d3VzrG2; Thu, 17 Aug 2023 22:26:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37HMQhLq030692; Thu, 17 Aug 2023 22:26:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37HMQhDW030689; Thu, 17 Aug 2023 22:26:43 GMT (envelope-from git) Date: Thu, 17 Aug 2023 22:26:43 GMT Message-Id: <202308172226.37HMQhDW030689@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 91d0876a20ce - main - arm64 makectx: Fix overflow of tf_x array List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 91d0876a20cee993f3cd17b4638e779c6975d15b Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=91d0876a20cee993f3cd17b4638e779c6975d15b commit 91d0876a20cee993f3cd17b4638e779c6975d15b Author: John Baldwin AuthorDate: 2023-08-17 22:26:16 +0000 Commit: John Baldwin CommitDate: 2023-08-17 22:26:16 +0000 arm64 makectx: Fix overflow of tf_x array PCB_LR isn't stored in tf_x, so trying to store it as pcb_x[PCB_LR] = tf->tf_x[PCB_LR + PCB_X_START] overflowed the tf_x array. Reported by: Morello (bounds check crash) Reviewed by: jrtc27, andrew, markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D41485 --- sys/arm64/arm64/machdep.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 2a26da3d65b6..4bfbfcaa91bd 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -359,11 +359,14 @@ makectx(struct trapframe *tf, struct pcb *pcb) { int i; - for (i = 0; i < nitems(pcb->pcb_x); i++) - pcb->pcb_x[i] = tf->tf_x[i + PCB_X_START]; - /* NB: pcb_x[PCB_LR] is the PC, see PC_REGS() in db_machdep.h */ - pcb->pcb_x[PCB_LR] = tf->tf_elr; + for (i = 0; i < nitems(pcb->pcb_x); i++) { + if (i == PCB_LR) + pcb->pcb_x[i] = tf->tf_elr; + else + pcb->pcb_x[i] = tf->tf_x[i + PCB_X_START]; + } + pcb->pcb_sp = tf->tf_sp; }