OSDN Git Service

coverity: physmem: use simple assertions instead of modelling
authorVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Thu, 5 Oct 2023 14:03:26 +0000 (17:03 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 24 Nov 2023 11:07:47 +0000 (12:07 +0100)
commitadff55b520ef9ad2907a91409b152220c1ba8051
treee12e99d09d7669d7620e0950e986f0c4ab5d4930
parent6ef164188d005d7636f7ed8a1033cc4083498301
coverity: physmem: use simple assertions instead of modelling

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: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Acked-by: David Hildenbrand <david@redhat.com>
Message-ID: <20231005140326.332830-1-vsementsov@yandex-team.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scripts/coverity-scan/model.c
system/physmem.c