Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Nov 2011 21:45:53 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Mikolaj Golub <trociny@freebsd.org>
Cc:        freebsd-hackers@freebsd.org, Robert Watson <rwatson@freebsd.org>
Subject:   Re: "ps -e" without procfs(5)
Message-ID:  <20111105194553.GK50300@deviant.kiev.zoral.com.ua>
In-Reply-To: <86ehxmjsza.fsf@kopusha.home.net>
References:  <20111016171005.GB50300@deviant.kiev.zoral.com.ua> <86aa8qozyx.fsf@kopusha.home.net> <20111025082451.GO50300@deviant.kiev.zoral.com.ua> <86aa8k2im0.fsf@kopusha.home.net> <20111031094948.GB50300@deviant.kiev.zoral.com.ua> <86vcr21agm.fsf@kopusha.home.net> <20111105135801.GT50300@deviant.kiev.zoral.com.ua> <86ehxmpogp.fsf@kopusha.home.net> <20111105154443.GB50300@deviant.kiev.zoral.com.ua> <86ehxmjsza.fsf@kopusha.home.net>

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

--Epf9GrANMtiMvSmS
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Nov 05, 2011 at 08:59:21PM +0200, Mikolaj Golub wrote:
>=20
> On Sat, 5 Nov 2011 17:44:43 +0200 Kostik Belousov wrote:
>=20
>  >>  KB> I think that the aux vector must be naturally aligned. You can r=
eturn
>  >>  KB> ENOEXEC early if vptr is not aligned.
>  >>=20
>  >> Not sure I see what you mean. vptr for auxv is calculated just couple=
 lines
>  >> above, and I check the result here, in the part common for all vector=
 types.
>  KB> You do not check for the alignment. Am I wrong ?
>=20
> I see now. If natural alignment means "addr % sizeof(aux) =3D=3D 0" then =
the aux
> vectors are not naturally aligned. After adding this check:
>=20
>     if (vptr % sizeof(aux) !=3D 0)
>     	return (ENOEXEC);
No, the natural alignment of the structure is the alignment of the most
demanding member. So it is 4 bytes on 32bit, and 8 bytes on 64.

>=20
> I started to observe many ENOEXEC errors. Adding printf showed that the
> vectors are half size aligned.
>=20
> On i386:
>=20
> get_proc_vector(pid =3D getty[3442], type =3D 2): vptr (2143284876) % siz=
eof(aux) (8) =3D 4)
>=20
> On amd64:
>=20
> get_proc_vector(pid =3D getty[2425], type =3D 2): vptr (140737488346568) =
% sizeof(aux) (16) =3D 8)
>=20
> Looking at exec_copyout_strings() from kern_exec.c, how destp is calculat=
ed, I
> think they are sizeof(char *) aligned.
>=20
> Do you think it is worth adding the check for sizeof(char *) alignment?
>=20
>     if (vptr % (sizeof(char *) !=3D 0)
>     	return (ENOEXEC);
I suggest to use #if __ELF_WORD_SIZE =3D=3D 32 or 64.

--Epf9GrANMtiMvSmS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (FreeBSD)

iEYEARECAAYFAk61knAACgkQC3+MBN1Mb4jTLwCeN7ZGTs3fkzi2O2u4ekESbzyP
xrMAni700mDgj4WYfQb0ZWWHVWGPkWeG
=DPWn
-----END PGP SIGNATURE-----

--Epf9GrANMtiMvSmS--



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