]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Coverity model file update
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Tue, 18 Oct 2022 18:06:35 +0000 (14:06 -0400)
committerGitHub <noreply@github.com>
Tue, 18 Oct 2022 18:06:35 +0000 (11:06 -0700)
commitd10bd7d288eb44bbdef686a0255271a174200701
tree073fb6a625701b908f0d259c6282ca500959edd3
parent27218a32fc5eb6661996204af3d43fd97c9bda4d
Coverity model file update

Upon review, it was found that the model for malloc() was incorrect.

In addition, several general purpose memory allocation functions were
missing models:

 * kmem_vasprintf()
 * kmem_asprintf()
 * kmem_strdup()
 * kmem_strfree()
 * spl_vmem_alloc()
 * spl_vmem_zalloc()
 * spl_vmem_free()
 * calloc()

As an experiment to try to find more bugs, some less than general
purpose memory allocation functions were also given models:

 * zfsvfs_create()
 * zfsvfs_free()
 * nvlist_alloc()
 * nvlist_dup()
 * nvlist_free()
 * nvlist_pack()
 * nvlist_unpack()

Finally, the models were improved using additional coverity primitives:

 * __coverity_negative_sink__()
 * __coverity_writeall0__()
 * __coverity_mark_as_uninitialized_buffer__()
 * __coverity_mark_as_afm_allocated__()

In addition, an attempt to inform coverity that certain modelled
functions read entire buffers was used by adding the following to
certain models:

int first = buf[0];
int last = buf[buflen-1];

It was inspired by the QEMU model file.

No additional false positives were found by this, but it is believed
that the more accurate model file will help to catch false positives in
the future.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14048
contrib/coverity/model.c