[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 06/10] stubdom/xenstored: Fix uninitialised variables in lu_read_state()
- To: Jürgen Groß <jgross@xxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Fri, 12 Feb 2021 17:01:25 +0000
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vnW0b30z1hZxcDTtu+jo26HtPh1/6e5wL35MPxOOP64=; b=dkGlL1UYsAJJvCv8PnO0bDqpgosHcBJA1MMo0o0BcaG8rz2dm3P1uQGm6zfhBQvdNfZpOOXSlNVE1BngXWzYQAfLvxPRBFylou9x7L74ckZTLo5O6e7n2vm2/NnSkfqIWSS/eBQOpggqedaEf73j+sya+P4n97cX7MOtQm4flWtr9pKaXnoM0jyd5z6yrLKLDU7aacHNwNTnQTaCUieUH1Ci/2yKTQLQmt1sovaXuAB9qDA8DZY0fVCog4nEKMfz3xBHQk8v+JJqDHkkEdtXNobpaIPq7+N9ADxM4ZPhvJfLY4OMfO26w7vlKzpD6SVTeD1PzbGKLKY4b+NpRuetRg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYZhlOvM4l5a+AsIA50e4QQ5aHgqv9GSh7M1C45w+3+woYUn6OQ+hu3CAYLVtmhlIiYvVYVUtLCIfdvc64QtNrg/4G4BwTUS/F8Pv7ttowcmFF8QTkpJTxUq7RSy2VL582PmwjQE8wilgi388He3ofO7zlg8rhqIawkmbbzvD8aYNuN/gN1KKZbuQWD79mXKLOxVtlMCzW6fsnpHho5YPxquuDLw8Fz1s1JUVlFW/a5TmBmtDMyk1x4TN44lxj4ZHq1gAZkJibh93qgTsK6u1/K9R1CCpKiKNRmgwWTCIXT18dqqkp4NNt2wPHoS4mPBOF7ubji4eJhFQJGPbgzfcA==
- Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Fri, 12 Feb 2021 17:01:53 +0000
- Ironport-sdr: gdn48AqrquRY5iJo6FIf8CWvWhUa1x1/Tp+xPr+N5yZJHiW16WT/k+0N61wMLpdwt3mqKUXRB/ /CrEJryussyGex1YHluldO485Cf2sd1BImLDCzejhB/BlUe7oFjmWUoZ1LL+Yusk7wEJb8I9T1 ZadScgLWRjvGDG4F7SxHtXG7UULWAddGcwfMCR1+qsQN0Z2OfBDYqPU080fJNmrEFLqAppZUp5 /I9Jbk0n6mb+my9if5gXcOUILKHYfD4uZUIk27DNaZLE8F/ngJZekYoeAvQ2AhNmeuqMbaqDiY cQ0=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 12/02/2021 16:08, Jürgen Groß wrote:
> On 12.02.21 16:39, Andrew Cooper wrote:
>> Various version of gcc, when compiling with -Og, complain:
>>
>> xenstored_control.c: In function ‘lu_read_state’:
>> xenstored_control.c:540:11: error: ‘state.size’ is used
>> uninitialized in this
>> function [-Werror=uninitialized]
>> if (state.size == 0)
>> ~~~~~^~~~~
>> xenstored_control.c:543:6: error: ‘state.buf’ may be used
>> uninitialized in
>> this function [-Werror=maybe-uninitialized]
>> pre = state.buf;
>> ~~~~^~~~~~~~~~~
>> xenstored_control.c:550:23: error: ‘state.buf’ may be used
>> uninitialized in
>> this function [-Werror=maybe-uninitialized]
>> (void *)head - state.buf < state.size;
>> ~~~~~^~~~
>> xenstored_control.c:550:35: error: ‘state.size’ may be used
>> uninitialized in
>> this function [-Werror=maybe-uninitialized]
>> (void *)head - state.buf < state.size;
>> ~~~~~^~~~~
>>
>> Interestingly, this is only in the stubdom build. I can't identify any
>> relevant differences vs the regular tools build.
>
> But me. :-)
>
> lu_get_dump_state() is empty for the stubdom case (this will change when
> LU is implemented for stubdom, too). In the daemon case this function is
> setting all the fields which are relevant.
So I spotted that. This instance of lu_read_state() is already within
the ifdefary, so doesn't get to see the empty stub (I think).
Also, I'd expect the compiler to complain at -O2 if it spotted that code.
>
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>
> Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
Thanks,
~Andrew
|