From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 17E8E5A0279 for ; Fri, 12 Apr 2024 05:43:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1712893408; bh=XKtY1gKUgWs2CKUIFd3pwX1nz08WpuExaB/sPy3LMbM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NdE0kj6yMJvPFcVgS2fpdt7MdmjyYNVuZk99WihXw5TEAhkASEFpqffCne3PSdL2n 15baiXxBKRvutmvYoUKDFXrMLd0oudwV15ffK1022dTz59VR2oIOCVzOD1RpXEZMUd KRsOrXQYkYwrlMi4Z6NadkBjei4jbYzKLDgpLZ3wJPLPl24vcHuWoRLjZ2EGLkbXzB zZlr7XdT6V20Kc7r2Hhkv8N0663VARnPRhYGishVRtLxpDirRif86gVBd0m+fNosIy UyPUhVim3DAkcErp9Q/7+ivKhd85ZM/qTQd4/A5qqXYqCdKrbDJs5seZXrpxH/DZ0p Q+TM7Hri3ZDbg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4VG2Tr6pHwz4wx5; Fri, 12 Apr 2024 13:43:28 +1000 (AEST) Date: Fri, 12 Apr 2024 12:00:30 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] pasta, util: Align stack area for clones to maximum natural alignment Message-ID: References: <20240411221800.548140-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5K2+rDtmPOP8i2IO" Content-Disposition: inline In-Reply-To: <20240411221800.548140-1-sbrivio@redhat.com> Message-ID-Hash: 5GBSA4JD3NTPMON27722MZ4X5Y6WBVES X-Message-ID-Hash: 5GBSA4JD3NTPMON27722MZ4X5Y6WBVES X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, runsisi X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --5K2+rDtmPOP8i2IO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 12, 2024 at 12:18:00AM +0200, Stefano Brivio wrote: > Given that we use this stack pointer as a location to store arbitrary > data types from the cloned process, we need to guarantee that its > alignment matches any of those possible data types. >=20 > runsisi reports that pasta gets a SIGBUS in pasta_open_ns() on > aarch64, where the alignment requirement for stack pointers is a > 16 bytes (same as the size of a long double), and similar requirements > actually apply to most architectures we run on. >=20 > Reported-by: runsisi > Link: https://bugs.passt.top/show_bug.cgi?id=3D85 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > pasta.c | 3 ++- > util.h | 4 +++- > 2 files changed, 5 insertions(+), 2 deletions(-) >=20 > diff --git a/pasta.c b/pasta.c > index e73b5af..31e1e00 100644 > --- a/pasta.c > +++ b/pasta.c > @@ -211,12 +211,13 @@ static int pasta_spawn_cmd(void *arg) > void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, > int argc, char *argv[]) > { > + char ns_fn_stack[NS_FN_STACK_SIZE] > + __attribute__ ((aligned(__alignof__(max_align_t)))); > struct pasta_spawn_cmd_arg arg =3D { > .exe =3D argv[0], > .argv =3D argv, > }; > char uidmap[BUFSIZ], gidmap[BUFSIZ]; > - char ns_fn_stack[NS_FN_STACK_SIZE]; > char *sh_argv[] =3D { NULL, NULL }; > char sh_arg0[PATH_MAX + 1]; > sigset_t set; > diff --git a/util.h b/util.h > index 7c261d7..8c37729 100644 > --- a/util.h > +++ b/util.h > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > =20 > @@ -116,7 +117,8 @@ int do_clone(int (*fn)(void *), char *stack_area, siz= e_t stack_size, int flags, > void *arg); > #define NS_CALL(fn, arg) \ > do { \ > - char ns_fn_stack[NS_FN_STACK_SIZE]; \ > + char ns_fn_stack[NS_FN_STACK_SIZE] \ > + __attribute__ ((aligned(__alignof__(max_align_t)))); \ > \ > do_clone((fn), ns_fn_stack, sizeof(ns_fn_stack), \ > CLONE_VM | CLONE_VFORK | CLONE_FILES | SIGCHLD,\ --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --5K2+rDtmPOP8i2IO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmYYlbkACgkQzQJF27ox 2Geqww/+O7aV4YUAthO0Bsh4gpGj8Av31y8yU7OxvCDlOV4RLex9kgI47BDOwI6T yIRBzIRcKL3/TESonwsVNTfJ1tYgZ6OJXIeTJwdCzi1RVh7ZdAr19RqJMNRNav7A Is49d3qOauxrNu+5F9NWzff37Br0ETbqLHWpXvzKs8fB3xO9ilmyBkS6yQ+C/PV2 URQr+fp1Nd2F3gKgpcPLcO4BEJLWCC83UnZV/+SnSt26bB3jx4tCMHFes70LAR3L vXWz7RcWxIvUWRynfCdCCKQFWLs+HA4kuaH67juvvANFTiO7SKB2uqJoiJzOSMeH Nh7k53Yb4SkhIZG4Halyee+vgdZK+UkCNvujFR1lcUqPTG8bMNbK423IIpxNrHKG 8n+Q+W1o2kEcjzZami6KEVVjbJ4K/DMwKcRUscZwHu2RCP9RjnzdxrSdeOHG2gd+ pEy7fejJo48VFY5eevtbaMptY3NJ8kOxNy3HiesmrR3ddbDfUo63NquB03Y+rIK0 JQ/PCtOQ3dIWIbjsBCpLz1lM8hm1eSvTHq4tfb0vZXJn4k9J9WzFQHg17gL2Sesm 1GkROe2jE54mdZ78uvJBQdlxa2IsGT9ilBDVlL0lWCLqi+bPx3pWstXZ7DT3GA0b FucDkkPUO9RK1GZk4loQsqshxPoNvrxD7kvH+2wUfLdO8BzL4G4= =f0hy -----END PGP SIGNATURE----- --5K2+rDtmPOP8i2IO--