Uninitialized variables in hvm_event_breakpoint (Re: New Defects reported by Coverity Scan for XenProject)
Quoted 9 lines · On Wed, 2016-02-17 at 16:02 -0800, [email protected] wrote:
Hi,
Please find the latest report on new defect(s) introduced to XenProject found with Coverity Scan.
1 new defect(s) introduced to XenProject found with Coverity Scan. 4 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
Quoted 6 lines
New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)** CID 1353192: Uninitialized variables (UNINIT) /xen/arch/x86/hvm/event.c: 176 in
hvm_event_breakpoint()
This appears to have been introduced by:
commit
557c7873f35aa39bd84977b28948457b1b342f92
Author: Corneliu ZUZU <czuzu@bitdef
ender.com>
Date: Mon Feb 15 14:14:16 2016 +0100
x86: merge 2 hvm_event_... functions into 1
This patch merges almost identical functions hvm_event_int3 and hvm_event_single_step into a single function called hvm_event_breakpoint. Also fixes event.c file header comment in the process.
hvm_event_breakpoint calls hvm_event_traps(&req) and if sync is true that ors some bits into req->flags which was never initialised.
Quoted 27 lines
_________________________________________________________________________
_______________________________
*** CID 1353192: Uninitialized variables (UNINIT) /xen/arch/x86/hvm/event.c: 176 inhvm_event_breakpoint()170
171 int hvm_event_breakpoint(unsigned long rip,
172 enumhvm_event_breakpoint_typetype) 173 {
174 struct vcpu *curr = current;
175 structarch_domain*ad =&curr->domain->arch;Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1353192: Uninitialized variables (UNINIT) Declaring variable "req" without initializer.
176 vm_event_request_t req;
177
178 switch ( type )
179 {
180 caseHVM_EVENT_SOFTWARE_BREAKPOINT:
181 if ( !ad->monitor.software_breakpoint_enabled )_________________________________________________________________________
_______________________________
To view the defects in Coverity Scan visit, https://scan.coverity.com/pro
jects/xenproject?tab=overview
Quoted 5 lines
To manage Coverity Scan email notifications for "[email protected]", click https://scan.coverity.com/subscriptions/
edit?email=ian.campbell%40citrix.com&token=1ce0fc428b9f94f66fd8d1ecf6cbb7 6a
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 29 lines · Ian Campbell
Quoted 9 lines · On Wed, 2016-02-17 at 16:02 -0800, [email protected] wrote:
Hi,
Please find the latest report on new defect(s) introduced to XenProject found with Coverity Scan.
1 new defect(s) introduced to XenProject found with Coverity Scan. 4 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
Quoted 6 lines
New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)** CID 1353192: Uninitialized variables (UNINIT) /xen/arch/x86/hvm/event.c: 176 in
hvm_event_breakpoint()This appears to have been introduced by:
commit
557c7873f35aa39bd84977b28948457b1b342f92
Author: Corneliu ZUZU <czuzu@bitdef
ender.com>
Date: Mon Feb 15 14:14:16 2016 +0100x86: merge 2
hvm_event_... functions into 1This patch merges almost identical functions
hvm_event_int3andhvm_event_single_stepinto a single function calledhvm_event_breakpoint. Also fixesevent.cfile header comment in the process.
Quoted 39 lines
Signed-off-by Corneliu ZUZU < [email protected] >Acked-by Jan Beulich < [email protected] >
hvm_event_breakpointcallshvm_event_traps(&req)and if sync is true that ors some bits intoreq->flagswhich was never initialised.Quoted 31 lines
_________________________________________________________________________
_______________________________
*** CID 1353192: Uninitialized variables (UNINIT) /xen/arch/x86/hvm/event.c: 176 inhvm_event_breakpoint()170
171 int hvm_event_breakpoint(unsigned long rip,
172 enumhvm_event_breakpoint_typetype)
173 {
174 struct vcpu *curr = current;
175 structarch_domain*ad =&curr->domain->arch;Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1353192: Uninitialized variables (UNINIT) Declaring variable "req" without initializer.
176
vm_event_request_treq;
177178 switch ( type ) 179 { 180 case HVM_EVENT_SOFTWARE_BREAKPOINT:181 if ( !ad->monitor.software_breakpoint_enabled )
_________________________________________________________________________
_______________________________
To view the defects in Coverity Scan visit, https://scan.coverity.com/pro
jects/xenproject?tab=overviewTo manage Coverity Scan email notifications for "[email protected]", click https://scan.coverity.com/subscriptions/
edit?email=ian.campbell%40citrix.com&token=1ce0fc428b9f94f66fd8d1ecf6cbb7 6a
Sorry, my bad, I didn't know struct-initialization using labels sets all the other fields to zero. Shall I submit a fix for this issue?
Corneliu.
Quoted 30 lines · Ian Campbell
Quoted 9 lines · On Wed, 2016-02-17 at 16:02 -0800, [email protected] wrote:
Hi,
Please find the latest report on new defect(s) introduced to XenProject found with Coverity Scan.
1 new defect(s) introduced to XenProject found with Coverity Scan. 4 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
Quoted 6 lines
New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)** CID 1353192: Uninitialized variables (UNINIT) /xen/arch/x86/hvm/event.c: 176 in
hvm_event_breakpoint()This appears to have been introduced by:
commit
557c7873f35aa39bd84977b28948457b1b342f92
Author: Corneliu ZUZU <czuzu@bitdef
ender.com>
Date: Mon Feb 15 14:14:16 2016 +0100x86: merge 2
hvm_event_... functions into 1This patch merges almost identical functions
hvm_event_int3andhvm_event_single_stepinto a single function calledhvm_event_breakpoint. Also fixesevent.cfile header comment in the process.
Quoted 28 lines
Signed-off-by Corneliu ZUZU < [email protected] >Acked-by Jan Beulich < [email protected] >
hvm_event_breakpointcallshvm_event_traps(&req)and if sync is true that ors some bits intoreq->flagswhich was never initialised.Quoted 20 lines
_________________________________________________________________________
_______________________________
*** CID 1353192: Uninitialized variables (UNINIT) /xen/arch/x86/hvm/event.c: 176 inhvm_event_breakpoint()170
171 int hvm_event_breakpoint(unsigned long rip,
172 enumhvm_event_breakpoint_typetype)
173 {
174 struct vcpu *curr = current;
175 structarch_domain*ad =&curr->domain->arch;Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1353192: Uninitialized variables (UNINIT) Declaring variable "req" without initializer.
176
vm_event_request_treq;
177178 switch ( type ) 179 { 180 case HVM_EVENT_SOFTWARE_BREAKPOINT:181 if ( !ad->monitor.software_breakpoint_enabled )
But the structure is being initialized in both cases (HVM_EVENT_SOFTWARE_BREAKPOINT and HVM_EVENT_SINGLESTEP_BREAKPOINT), and the default case returns, so it's not possible to get to the hvm_event_traps(&req) call with an uninitialized req. Am I missing something?
Thanks,
Razvan
Quoted 73 lines · Corneliu ZUZU
Quoted 72 lines · Ian Campbell
Quoted 9 lines · On Wed, 2016-02-17 at 16:02 -0800, [email protected] wrote:
Hi,
Please find the latest report on new defect(s) introduced to XenProject found with Coverity Scan.
1 new defect(s) introduced to XenProject found with Coverity Scan. 4 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
Quoted 6 lines
New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)** CID 1353192: Uninitialized variables (UNINIT) /xen/arch/x86/hvm/event.c: 176 in
hvm_event_breakpoint()This appears to have been introduced by:
commit
557c7873f35aa39bd84977b28948457b1b342f92
Author: Corneliu ZUZU <czuzu@bitdef
ender.com>
Date: Mon Feb 15 14:14:16 2016 +0100x86: merge 2
hvm_event_... functions into 1
This patch merges almost identical functionshvm_event_int3and
hvm_event_single_stepinto a single function calledhvm_event_breakpoint.
Also fixesevent.cfile header comment in the process.
Signed-off-by: Corneliu ZUZU <
[email protected] >Acked-by Jan Beulich < [email protected] >
hvm_event_breakpointcallshvm_event_traps(&req)and if sync is true that ors some bits intoreq->flagswhich was never initialised.Quoted 34 lines
_________________________________________________________________________
_______________________________
*** CID 1353192: Uninitialized variables (UNINIT) /xen/arch/x86/hvm/event.c: 176 inhvm_event_breakpoint()170
171 int hvm_event_breakpoint(unsigned long rip,
172 enumhvm_event_breakpoint_typetype)
173 {
174 struct vcpu *curr = current;
175 structarch_domain*ad =&curr->domain->arch;Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1353192: Uninitialized variables (UNINIT) Declaring variable "req" without initializer.
176
vm_event_request_treq;
177178 switch ( type ) 179 { 180 case HVM_EVENT_SOFTWARE_BREAKPOINT:181 if ( !ad->monitor.software_breakpoint_enabled )
_________________________________________________________________________
_______________________________
To view the defects in Coverity Scan visit,
https://scan.coverity.com/pro
jects/xenproject?tab=overviewTo manage Coverity Scan email notifications for "[email protected]", click
https://scan.coverity.com/subscriptions/
edit?email=ian.campbell%40citrix.com&token=1ce0fc428b9f94f66fd8d1ecf6cbb7
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
6a
Sorry, my bad, I didn't know struct-initialization using labels sets all the other fields to zero.
Shall I submit a fix for this issue?
Right, req->flags. Good catch. Yes, please do, req = {}; should do.
Thanks,
Razvan