RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1119486 - Coverity reports STACK_USE error at qemu-kvm-x86.c:1546
Summary: Coverity reports STACK_USE error at qemu-kvm-x86.c:1546
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Eduardo Habkost
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-14 21:29 UTC by Jeff Nelson
Modified: 2014-07-24 19:42 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-07-24 19:42:17 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Jeff Nelson 2014-07-14 21:29:59 UTC
Description of problem:
   Coverity reports STACK_USE error at qemu-kvm-x86.c:1546

Version-Release number of selected component (if applicable):
    6.6.0

How reproducible:
    100%

Steps to Reproduce:
1. make -C redhat rh-test-patch             then
2. make -C redhat rh-brew-covscan           then
3. review patch results.

Actual results:
   A Coverity error appears, looking like this:

       Error: STACK_USE: [#def12]
       qemu-kvm-0.12.1.2/qemu-kvm-x86.c:1546: stack_use_local_overflow:
          Local variable "copy" uses 57376 bytes of stack space,
          which exceeds the maximum single use of 10000 bytes.

Expected results:
   No Coverity error.

Additional info:
   The line in question was introduced by commit 3e7e951d way back in 2007. I believe a newer version of Coverity was recently installed, and that is why this error hasn't been reported before.

   The actual line reported by Coverity may be different than 1546. The error occurs in routine kvm_arch_init_vcpu(CPUState *cenv). The code leading up to and including the line with the error looks like:

    int kvm_arch_init_vcpu(CPUState *cenv)
    {
        struct kvm_cpuid_entry2 cpuid_ent[100];
        struct kvm_cpuid_entry2 *c;
    #ifdef KVM_CPUID_SIGNATURE
        struct kvm_cpuid_entry2 *pv_ent;
        uint32_t signature[3];
    #endif
        int cpuid_nent = 0;
--->    CPUState copy;

Comment 2 Eduardo Habkost 2014-07-15 18:54:47 UTC
The 10000 bytes limit seems arbitrary, what's the reason for that limit?

Using 57k of the stack in a single function is not nice, but that's code in the initialization path which runs only once for each VCPU, so I don't see any potential for trouble.

Does anybody have any argument for treating this as a real bug and not closing this BZ as NOTABUG?

Comment 3 Eric Blake 2014-07-15 20:32:38 UTC
(In reply to Eduardo Habkost from comment #2)
> The 10000 bytes limit seems arbitrary, what's the reason for that limit?
> 
> Using 57k of the stack in a single function is not nice, but that's code in
> the initialization path which runs only once for each VCPU, so I don't see
> any potential for trouble.
> 
> Does anybody have any argument for treating this as a real bug and not
> closing this BZ as NOTABUG?

Any function that uses more than 4k of stack risks missing the guard page that the OS uses to auto-grow the stack, which can lead to all sorts of obscure behavior.  It would be nice if upstream qemu could take a leaf from libvirt and be fixed to compile with -Wframe-larger-than=4096.

Comment 4 Eduardo Habkost 2014-07-16 00:34:34 UTC
Reopening.


Note You need to log in before you can comment on or make changes to this bug.