From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 710EF3858431 for ; Wed, 8 Feb 2023 17:27:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 710EF3858431 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from r6.localdomain (82-217-174-174.cable.dynamic.v4.ziggo.nl [82.217.174.174]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 217CE30067CA; Wed, 8 Feb 2023 18:27:47 +0100 (CET) Received: by r6.localdomain (Postfix, from userid 1000) id DF4C03402C6; Wed, 8 Feb 2023 18:27:46 +0100 (CET) Message-ID: Subject: Re: [PATCH RFC 06/11] Initialize reglocs for VMCOREINFO From: Mark Wielaard To: Ilya Leoshkevich , elfutils-devel@sourceware.org Date: Wed, 08 Feb 2023 18:27:46 +0100 In-Reply-To: <20230206222513.1773039-7-iii@linux.ibm.com> References: <20230206222513.1773039-1-iii@linux.ibm.com> <20230206222513.1773039-7-iii@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-3036.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Ilya, On Mon, 2023-02-06 at 23:25 +0100, Ilya Leoshkevich via Elfutils-devel wrote: > MSan complains: >=20 > Uninitialized value was created by an allocation of 'reglocs' in the = stack frame > #0 0x562d35c686f0 in handle_core_note elfutils/src/readelf.c:12674= :3 > #const Ebl_Register_Location *reglocs; > =3D=3D1006199=3D=3DWARNING: MemorySanitizer: use-of-uninitialized-val= ue > #0 0x562d35c68a2a in handle_core_note elfutils/src/readelf.c:12692= :11 > #colno =3D handle_core_registers (ebl, ebl->elf, desc + regs_offse= t, > # reglocs, nregloc); >=20 > Strictly speaking, this is not a problem, because nregloc =3D=3D 0, but f= or > other note types we initialize it anyway, so do it here as well. Yeah, this is something valgrind wouldn't complain about since it doesn't see passing of an undefined value as "use". But I think msan is technically correct that passing an indeterminate value to a function provokes undefined behavior. Also it is of course more consistent with the rest of the code which does initialize reglocs even when nregloc is zero. Pushed as is. Thanks, Mark > Signed-off-by: Ilya Leoshkevich > --- > backends/linux-core-note.c | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/backends/linux-core-note.c b/backends/linux-core-note.c > index 9faae4c3..238ec16d 100644 > --- a/backends/linux-core-note.c > +++ b/backends/linux-core-note.c > @@ -239,6 +239,7 @@ EBLHOOK(core_note) (const GElf_Nhdr *nhdr, const char= *name, > return 0; > *regs_offset =3D 0; > *nregloc =3D 0; > + *reglocs =3D NULL; > *nitems =3D 1; > *items =3D vmcoreinfo_items; > return 1;