From nobody Tue Nov 15 00:26:09 2022 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 4NB6RP5r0hz4hHZ3; Tue, 15 Nov 2022 00:26:09 +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 4NB6RP5F13z3x3w; Tue, 15 Nov 2022 00:26:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668471969; 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=NRGmuz6BrY5SNGhLiqnpaVkZ4AX393bX2wEtlQYSCzQ=; b=QL0g8DQ6ZBuyqXYduiUl8JIQOUsDKWohklDt9SJXqOFd/DzG8FZZjIh9YCi0r2Lq+VT6eI fIuSPTznX34z23lod63IyuWxdEbKREt/LswTItJNrR78T3Ivxs8smSlcX3uJpqej/zd/pX RkcWyP07+LvHKDFrrSpzCW8esEDtlDwv3mnqitjV96czmaYuo0gQBtSq4qUJjzUfMBozg7 9AXIhK94uc/amVRaZk7hp6B5r/AzuM4+q8/O2VG9LnV0G/q23La/YEUsuJvqJ+nYHHC4r3 bT5SBGxNJnSFt+V/ZqVK2wPNZNgOQfVV2NIW7WWvyrilhnKqQK3nBZD9+vw6oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668471969; 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=NRGmuz6BrY5SNGhLiqnpaVkZ4AX393bX2wEtlQYSCzQ=; b=EctnqaUR9o5PdrRN177vNr5i0SXvG+CD3NYaZpeIz2iix3xuVla9AYPf/PJyKywSF5d1Zj i4v/tMu0pb3+flLLtEemsHRJwwRjrUPTCrvGIzRQquBKwhajkx8sCF5/JmJFpuvMUQ6XTg rRcXbMJmqExCXIZFcyH8ccNgyA4BnPaNvTYJgqi1y8LQ1hEKGHS1J5ecRW1EfmT/3Axep+ JbmHmMTiJVPy5u6sksRL6oGfz4DCVHv/oX68ZibNTfWz7lf4lZPkhAsqGmxcmqEiucgQqD OZ6MS9MRNhjlIKN8xE0L5krMoWZ4r8Gp4L+X7s181ikPzX5+/6ufz+lCss6VOw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668471969; a=rsa-sha256; cv=none; b=lXbAfnVGQAtAhhcc6dVi8Zf2vSJtGBGDSuAgcPCbdegRjqRPYTkZ+n//L3oBpEo0HPgH8U /gcRFDnbw/faC9X87AwV4mCGFPHMWyFCeVAleK2ZCTqbXFFQuBvX6gOx9l1xfHqRriCoA7 S8Rt/CBKMdQY80N/pK5852q38EzAaMp0wpzLOdchW3At8Gryl7jtDVs/FqNyrWMTZHcrVt 2Ucrq9RcF837VXcB54yOaZnpGwdBTqMkN+ivZQ5YSwpujuyXHlysJdE/5f4XsYdq8dMapW EGPxEv5ShrIZWiysHhT6CkN0Yk22wPIGJKSyRfDJV6z3rTchq15yqdCN10FAIw== 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 4NB6RP4JRXz12FB; Tue, 15 Nov 2022 00:26:09 +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 2AF0Q9wH048758; Tue, 15 Nov 2022 00:26:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AF0Q9vH048757; Tue, 15 Nov 2022 00:26:09 GMT (envelope-from git) Date: Tue, 15 Nov 2022 00:26:09 GMT Message-Id: <202211150026.2AF0Q9vH048757@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: 40e0fa10f58d - main - Check alignment of fp in unwind_frame 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: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 40e0fa10f58d90744c2857b57adf0ddbce1a1e1c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=40e0fa10f58d90744c2857b57adf0ddbce1a1e1c commit 40e0fa10f58d90744c2857b57adf0ddbce1a1e1c Author: Dapeng Gao AuthorDate: 2022-11-15 00:21:38 +0000 Commit: Brooks Davis CommitDate: 2022-11-15 00:25:46 +0000 Check alignment of fp in unwind_frame A misaligned frame pointer is certainly not a valid frame pointer and with strict alignment enabled (as on CHERI) can cause panics when it is loaded from later in the code. Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D34646 --- sys/arm64/arm64/unwind.c | 3 ++- sys/riscv/riscv/unwind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/unwind.c b/sys/arm64/arm64/unwind.c index 470b64c00540..81431e109494 100644 --- a/sys/arm64/arm64/unwind.c +++ b/sys/arm64/arm64/unwind.c @@ -41,7 +41,8 @@ unwind_frame(struct thread *td, struct unwind_state *frame) fp = frame->fp; - if (!kstack_contains(td, fp, sizeof(uintptr_t) * 2)) + if (!is_aligned(fp, sizeof(fp)) || + !kstack_contains(td, fp, sizeof(fp) * 2)) return (false); /* FP to previous frame (X29) */ diff --git a/sys/riscv/riscv/unwind.c b/sys/riscv/riscv/unwind.c index 9efb1fef9451..a66ffebcdc35 100644 --- a/sys/riscv/riscv/unwind.c +++ b/sys/riscv/riscv/unwind.c @@ -47,7 +47,8 @@ unwind_frame(struct thread *td, struct unwind_state *frame) fp = frame->fp; - if (!kstack_contains(td, fp - sizeof(fp) * 2, sizeof(fp) * 2)) + if (!is_aligned(fp, sizeof(fp)) || + !kstack_contains(td, fp - sizeof(fp) * 2, sizeof(fp) * 2)) return (false); frame->sp = fp;