Subject: Re: CVS commit: src/sys
To: None <tech-net@netbsd.org>
From: Quentin Garnier <cube@cubidou.net>
List: tech-net
Date: 05/30/2007 00:32:08
--z1IV5Hkp0Z/sUao3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, May 29, 2007 at 05:20:33PM -0500, David Young wrote:
> On Tue, May 29, 2007 at 09:32:31PM +0000, Christos Zoulas wrote:
> >=20
> > Module Name:	src
> > Committed By:	christos
> > Date:		Tue May 29 21:32:31 UTC 2007
> >=20
> > Modified Files:
> > 	src/sys/compat/common: Makefile uipc_syscalls_43.c
> > 	src/sys/compat/freebsd: freebsd_ioctl.c freebsd_ioctl.h
> > 	src/sys/compat/ibcs2: ibcs2_socksys.h
> > 	src/sys/compat/linux/common: linux_socket.c
> > 	src/sys/compat/sunos: sunos_ioctl.c
> > 	src/sys/compat/sunos32: sunos32_ioctl.c
> > 	src/sys/compat/svr4: svr4_sockio.c
> > 	src/sys/compat/svr4_32: svr4_32_sockio.c
> > 	src/sys/compat/sys: socket.h
> > 	src/sys/compat/ultrix: ultrix_ioctl.c
> > 	src/sys/conf: files
> > 	src/sys/net: bpf.c if.c if.h if_etherip.c if_ethersubr.c if_gre.c
> > 	    if_media.c if_tap.c
> > 	src/sys/net80211: ieee80211_ioctl.c
> > 	src/sys/sys: ioccom.h sockio.h
> > Added Files:
> > 	src/sys/compat/common: uipc_syscalls_40.c
> > 	src/sys/compat/sys: sockio.h
> >=20
> > Log Message:
> > Add a sockaddr_storage member to "struct ifreq" maintaining backwards
> > compatibility with the older ioctls. This avoids stack smashing and
> > abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" t=
hat
> > were longer than "struct sockaddr".
> > XXX: Some of the emulations might be broken; I tried to add code for
> > them but I did not test them.
>=20
> This seems like an awful lot of #ifdef'age to achieve very limited
> protection against stack smashing.  Suppose the kernel copies to ifreq
> a sockaddr whose sa_len > sizeof(struct sockaddr_storage) ?

Stack smashing is only a side effect of the issue of having a sockaddr
in ifreq when it's meant to hold a larger, AF-dependent, structure.

As for the length, sockaddr_storage now essentially works as the maximum
size a sockaddr object is allowed to be.

--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"You could have made it, spitting out benchmarks
Owe it to yourself not to fail"
Amplifico, Spitting Out Benchmarks, Hometakes Vol. 2, 2005.

--z1IV5Hkp0Z/sUao3
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)

iQEVAwUBRlyp6NgoQloHrPnoAQJZPQf/c6b2poTRhXs4s1wkSb6FEEP662lrf789
Nfl2ipD0XGTctyQ6/tZhNuw4L/hU6zkh2uOg8uUkTLmZIuU+l6tlMHoPrbRJleei
7dGPNAx3uQLvXDw4hBcSxOWtpZRXhN7TXlaTjPvfIlne8B9+sMhZtOWvvDVj9BBs
4FFQi4Eof1T19SDA6lY3NvumuMKGZ4mLLweIhV69D/Cqqbv8qBWh5el/OPRERcbj
qFL+BCgO1DfY0XQ6N06BABcDVEapUAmdnusSRS+0u7+6WK/x+UDt7oepisEhAUYX
cZiXc3eItK4S86yFRYT9rySb4/4bnjbr2fBj9WBl3SoSopXSAgtnUw==
=6iig
-----END PGP SIGNATURE-----

--z1IV5Hkp0Z/sUao3--