From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZMrB-0001Pw-RB for qemu-devel@nongnu.org; Tue, 18 Dec 2018 16:24:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZMrA-0004b6-NR for qemu-devel@nongnu.org; Tue, 18 Dec 2018 16:24:49 -0500 References: <20181218175122.3229-1-philmd@redhat.com> <20181218175122.3229-6-philmd@redhat.com> <42d9f6f7-617d-db80-1cda-b079416ec995@redhat.com> From: Paolo Bonzini Message-ID: <427fa674-304d-74eb-ff8b-9f5fac9d98ca@redhat.com> Date: Tue, 18 Dec 2018 22:24:19 +0100 MIME-Version: 1.0 In-Reply-To: <42d9f6f7-617d-db80-1cda-b079416ec995@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 5/5] migration: Use strnlen() for fixed-size string List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Juan Quintela , qemu-block@nongnu.org, 1803872@bugs.launchpad.net, =?UTF-8?Q?Daniel_P=2e_Berrang=c3=a9?= , =?UTF-8?Q?C=c3=a9dric_Le_Goater?= , "Dr. David Alan Gilbert" , Howard Spoelstra , Jeff Cody , David Hildenbrand , Stefan Weil , Markus Armbruster , Kevin Wolf , Ben Pye , =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , Thomas Huth , Igor Mammedov , Liu Yuan , David Gibson , Max Reitz On 18/12/18 20:33, Eric Blake wrote: >> diff --git a/migration/global_state.c b/migration/global_state.c >> index 6e19333422..c19030ef62 100644 >> --- a/migration/global_state.c >> +++ b/migration/global_state.c >> @@ -106,7 +106,7 @@ static int global_state_pre_save(void *opaque) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 GlobalState *s =3D opaque; >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 trace_migrate_global_state_pre_s= ave((char *)s->runstate); >> -=C2=A0=C2=A0=C2=A0 s->size =3D strlen((char *)s->runstate) + 1; >=20 > The old code sets s->size to the string length + space for the NUL byte > (by assuming that a NUL byte was present), and accidentally sets it > beyond the s->runstate array if there was no NUL byte (our existing > runstate names are shorter than 100 bytes, so this could only happen on > a malicious stream). It cannot---this is a pre_save hook. A possible overflow bug exists, but it is in the call to qapi_enum_parse. Paolo