Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Nov 2022 17:00:48 +0000
From:      Brooks Davis <brooks@freebsd.org>
To:        Andrew Turner <andrew@fubar.geek.nz>
Cc:        Mateusz Guzik <mjguzik@gmail.com>, "<src-committers@freebsd.org>" <src-committers@freebsd.org>, "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, 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>
In-Reply-To: <30B11BD5-A1B5-4513-8C0D-8BA89C12C55A@fubar.geek.nz>
References:  <202211150026.2AF0Q9vH048757@gitrepo.freebsd.org> <CAGudoHGZhUjOs4a-A8mW7oo49HcfxbvVDx5CfULQTF-GN6OkuA@mail.gmail.com> <30B11BD5-A1B5-4513-8C0D-8BA89C12C55A@fubar.geek.nz>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <mjguzik@gmail.com> 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 <brooks@freebsd.org> 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 <dapeng@dpgao.cn>
> >> AuthorDate: 2022-11-15 00:21:38 +0000
> >> Commit:     Brooks Davis <brooks@FreeBSD.org>
> >> 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 <mjguzik gmail.com>
> >=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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20221115170048.GD49722>