Mail Archives: cygwin/2014/05/07/10:58:00
--CZb08McUREi1kVi+
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On May 7 14:22, Corinna Vinschen wrote:
> On May 6 20:49, Corinna Vinschen wrote:
> > On May 6 11:49, Eric Blake wrote:
> > > On 05/06/2014 10:39 AM, Corinna Vinschen wrote:
> > >=20
> > > > The problem, which I totally not realized since I started implement=
ing
> > > > this stuff is, that by propagating this cache to child processes, s=
aid
> > > > child processes suffer from what the parent process does to the pas=
swd
> > > > structures in the cache.
> > > >=20
> > > > Screen seems to call getpwuid and then sets some of the pointers in=
the
> > > > passwd structure it got from the call to NULL, apparently for some =
sort
> > > > of security, this way overwriting the cached passwd struct for the
> > >=20
> > > Bug in screen. POSIX states:
> > >=20
> > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwuid.ht=
ml
> > >=20
> > > The application shall not modify the structure to which the return va=
lue
> > > points, nor any storage areas pointed to by pointers within the
> > > structure. The returned pointer, and pointers within the structure,
> > > might be invalidated or the structure or the storage areas might be
> > > overwritten by a subsequent call to getpwent(), getpwnam(), or getpwu=
id().
> >=20
> > Oh, wow. However, what if screen (thinks it) never calls getpwuid or
> > getpwnam again. In that case it may do whatever it wants with the
> > pointers inside the returned passwd structure, doesn't it? It certainly
> > doesn't have to expect sharing with another process.
> >=20
> > > > current user. Ssh on the other hand tries to copy the passwd struc=
ture,
> > > > but it never checks for NULL pointers because, well, the passwd
> > > > structure never contains NULL pointers.
> > > >=20
> > > > This annihilates every advantage the cygheap caching has.
> > >=20
> > > Caching still sounds correct, let's fix the bug in screen instead of
> > > bloating cygwin to work around it. Or maybe find a way to cause a SE=
GV
> > > in any process that tries to write into the pointer returned by getpw=
uid
> > > and friends, to help them realize their bug, rather than the current
> > > state of propagating the broken memory to other processes.
> >=20
> > Hmm, I'd have to allocate a full 4K page for this. Also, ssh called
> > from screen works fine on Linux, even if the above behaviour is buggy...
> >=20
> > > Maybe you
> > > just memcpy the result out of the cache into local memory, instead of
> > > returning a pointer into the actual cygheap cache.
> >=20
> > Yes, that's what I was coming to realize, too. I'm going to copy the
> > entire entry to local storage and return a pointer to that.
>=20
> I created a matching patch. Please give the today's developer snapshot
> from http://cygwin.com/snapshots/ a try.
I just created another snapshot. The former snapshot had an off
by one bug so the passwd buffer given to the application was one
byte short. Please make sure to try the snapshot with timestamp
14:55:24 (x86) or 14:55:06 (x86_64).
Sorry,
Corinna
--=20
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
--CZb08McUREi1kVi+
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBAgAGBQJTakngAAoJEPU2Bp2uRE+gXKIP/2bgusZWKNYTiDjeLeMuc6Dn
HLUl9JyENrKyouEDKHi0elJXTMMqNQ+3sTdbn2O6BIRNQc78k8L9sF6VaWNAhc9u
Mf8pMmiRDca87hdCpyXBGIo83A9VAaOG2YgX49ZoHPVQYEPuq40l183yh9imgKb/
bTmk0r4fg4PsYsS9iy9uKTHvdVNhU8LT+5lMiyno0ZR7Moiq84orMnjpYvtSnj3C
6Ws2EO7XuFJQSLM8HXzLUpVWqOBc5R5LgkuMx2UgPgy2kT6QIi0erzIZ54UEDGor
hFEacL53wmDjceOTtru/yzxbd6NAKZA7GrvRNrPz0LtDwJcLIuhLm4VdtuI6FcY1
q7BMzsasbGyZ3PhPIbG/tDRS4n+yXxGiY9AZeBmWZQ9MuASGGtcxINJ4jt2ci4V9
mRLF8tBQ0FIJ57loAT7ofxgDyPzQwl/clddDBwtqZod9L3gm0O8Z85+95GjWAxVq
v+4OXN7+/CLlKJCazCEkIjlE6flnwCxUTH534N64ErE0pE/LMg5q5LEqIpHz+w2a
ruvtHoYT7nm9IWE9tdToEk7zBxxbV5eLaYtakZRdjRUk8d8og7b2wW4G95VhdquJ
xkXug0yNbYhnn1XlCNUyvlfgs27qkcp5Du2As1vxdhQIXYCyONR/TzyL2xoYho+T
nxieJDg52x6Nvd7k4QPO
=znz9
-----END PGP SIGNATURE-----
--CZb08McUREi1kVi+--
- Raw text -