Skip to content
  • Vladimir Sementsov-Ogievskiy's avatar
    adff55b5
    coverity: physmem: use simple assertions instead of modelling · adff55b5
    Vladimir Sementsov-Ogievskiy authored
    
    
    Unfortunately Coverity doesn't follow the logic aroung "len" and "l"
    variables in stacks finishing with flatview_{read,write}_continue() and
    generate a lot of OVERRUN false-positives. When small buffer (2 or 4
    bytes) is passed to mem read/write path, Coverity assumes the worst
    case of sz=8 in stn_he_p()/ldn_he_p() (defined in
    include/qemu/bswap.h), and reports buffer overrun.
    
    To silence these false-positives we have model functions, which hide
    real logic from Coverity.
    
    However, it turned out that these new two assertions are enough to
    quiet Coverity.
    
    Assertions are better than hiding the logic, so let's drop the
    modelling and move to assertions for memory r/w call stacks.
    
    After patch, the sequence
    
     cov-make-library --output-file /tmp/master.xmldb \
        scripts/coverity-scan/model.c
     cov-build --dir ~/covtmp/master make -j9
     cov-analyze --user-model-file /tmp/master.xmldb \
        --dir ~/covtmp/master --all --strip-path "$(pwd)
     cov-format-errors --dir ~/covtmp/master \
        --html-output ~/covtmp/master_html_report
    
    Generate for me the same big set of CIDs excepept for 6 disappeared (so
    it becomes even better).
    
    Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
    Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
    Message-ID: <20231005140326.332830-1-vsementsov@yandex-team.ru>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    adff55b5
    coverity: physmem: use simple assertions instead of modelling
    Vladimir Sementsov-Ogievskiy authored
    
    
    Unfortunately Coverity doesn't follow the logic aroung "len" and "l"
    variables in stacks finishing with flatview_{read,write}_continue() and
    generate a lot of OVERRUN false-positives. When small buffer (2 or 4
    bytes) is passed to mem read/write path, Coverity assumes the worst
    case of sz=8 in stn_he_p()/ldn_he_p() (defined in
    include/qemu/bswap.h), and reports buffer overrun.
    
    To silence these false-positives we have model functions, which hide
    real logic from Coverity.
    
    However, it turned out that these new two assertions are enough to
    quiet Coverity.
    
    Assertions are better than hiding the logic, so let's drop the
    modelling and move to assertions for memory r/w call stacks.
    
    After patch, the sequence
    
     cov-make-library --output-file /tmp/master.xmldb \
        scripts/coverity-scan/model.c
     cov-build --dir ~/covtmp/master make -j9
     cov-analyze --user-model-file /tmp/master.xmldb \
        --dir ~/covtmp/master --all --strip-path "$(pwd)
     cov-format-errors --dir ~/covtmp/master \
        --html-output ~/covtmp/master_html_report
    
    Generate for me the same big set of CIDs excepept for 6 disappeared (so
    it becomes even better).
    
    Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
    Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
    Message-ID: <20231005140326.332830-1-vsementsov@yandex-team.ru>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Loading