From nobody Tue Nov 15 17:00:48 2022 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 4NBXWC3N4tz4hF6p; Tue, 15 Nov 2022 17:00:55 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4NBXWC19BPz3x23; Tue, 15 Nov 2022 17:00:55 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Authentication-Results: mx1.freebsd.org; none Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id DA2923C0199; Tue, 15 Nov 2022 17:00:48 +0000 (UTC) Date: Tue, 15 Nov 2022 17:00:48 +0000 From: Brooks Davis To: Andrew Turner Cc: Mateusz Guzik , "" , "" , dev-commits-src-main@freebsd.org Subject: Re: git: 40e0fa10f58d - main - Check alignment of fp in unwind_frame Message-ID: <20221115170048.GD49722@spindle.one-eyed-alien.net> References: <202211150026.2AF0Q9vH048757@gitrepo.freebsd.org> <30B11BD5-A1B5-4513-8C0D-8BA89C12C55A@fubar.geek.nz> 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: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="J5MfuwkIyy7RmF4Q" Content-Disposition: inline In-Reply-To: <30B11BD5-A1B5-4513-8C0D-8BA89C12C55A@fubar.geek.nz> User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 4NBXWC19BPz3x23 X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:36236, ipnet:199.48.128.0/22, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N --J5MfuwkIyy7RmF4Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Sorry, that's entierly on me. I should have done the trivial test. -- Brooks On Tue, Nov 15, 2022 at 12:42:03PM +0000, Andrew Turner wrote: > I???ve reverted for now & reopened the Phabricator review. >=20 > Andrew >=20 > > On 15 Nov 2022, at 08:22, Mateusz Guzik wrote: > >=20 > > this fails to build: > >=20 > > /usr/src/sys/riscv/riscv/unwind.c:50:7: error: implicit declaration of > > function 'is_aligned' is invalid in C99 > > [-Werror,-Wimplicit-function-declaration] > > if (!is_aligned(fp, sizeof(fp)) || > > ^ > > 1 error generated. > >=20 > > On 11/15/22, Brooks Davis wrote: > >> The branch main has been updated by brooks: > >>=20 > >> URL: > >> https://cgit.FreeBSD.org/src/commit/?id=3D40e0fa10f58d90744c2857b57adf= 0ddbce1a1e1c > >>=20 > >> commit 40e0fa10f58d90744c2857b57adf0ddbce1a1e1c > >> Author: Dapeng Gao > >> AuthorDate: 2022-11-15 00:21:38 +0000 > >> Commit: Brooks Davis > >> CommitDate: 2022-11-15 00:25:46 +0000 > >>=20 > >> Check alignment of fp in unwind_frame > >>=20 > >> A misaligned frame pointer is certainly not a valid frame pointer a= nd > >> with strict alignment enabled (as on CHERI) can cause panics when i= t is > >> loaded from later in the code. > >>=20 > >> 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(-) > >>=20 > >> 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) > >>=20 > >> fp =3D frame->fp; > >>=20 > >> - if (!kstack_contains(td, fp, sizeof(uintptr_t) * 2)) > >> + if (!is_aligned(fp, sizeof(fp)) || > >> + !kstack_contains(td, fp, sizeof(fp) * 2)) > >> return (false); > >>=20 > >> /* 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) > >>=20 > >> fp =3D frame->fp; > >>=20 > >> - 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); > >>=20 > >> frame->sp =3D fp; > >>=20 > >=20 > >=20 > > --=20 > > Mateusz Guzik > >=20 >=20 --J5MfuwkIyy7RmF4Q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJjc8XAAAoJEKzQXbSebgfAt2MH/3wvwBp6FTpiu0h45eYxrUgg FJavRgjPRVzLjHJMo2rgaZjyJjFwD2Wj043IlT/LW7/+wvUr6kQXAVguLcyoeL9E 3ktdU3C2a0eLQ+Bacj4FWc/w4FyCDW7XujGgsAF5DH6rGB5iwguvDsgs431GcDoC wwlmGwRUJqcGkd+XrH/kV/UJyHRphaiVMYiCdGcQoWTrLuDIuwUeQmBa9iasKEFR fNQd9KJyD4+epk7Z49TgpegZ2Px6bNpSr52brbTYDzldLfS9VwDGgbtlio2z/HYX O98arKjdqs+9dgomgcFDHd+eaauCrXQv9M6Kd3wskyXW4JcfmeqiYWOToHZbYb8= =5uza -----END PGP SIGNATURE----- --J5MfuwkIyy7RmF4Q--