Content-Type: multipart/mixed; boundary="===============3729495746025003524==" MIME-Version: 1.0 From: Kees Cook To: kbuild-all@lists.01.org Subject: Re: [kbuild] [kees:kspp/uninit/macro 9/10] drivers/virtio/virtio_ring.c:1197 virtqueue_add_packed() error: uninitialized symbol 'prev'. Date: Fri, 05 Jun 2020 14:20:12 -0700 Message-ID: <202006051415.B06DA6D600@keescook> In-Reply-To: <20200605103820.GJ22511@kadam> List-Id: --===============3729495746025003524== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On Fri, Jun 05, 2020 at 01:38:20PM +0300, kernel test robot wrote: > Hey Kees, > = > Some of these introduce static checker false positives. Which is fine. > The question is, will they eventually introduce GCC warnings or will > the automatic initialization code always zero them out? Well, I think the issue is mainly with the compilers/checkers. Using uninitialized_var() means we can't ever get them correctly analyzed, so we have to remove them. The best way to silence them is to explicitly initialize them, and that's really up to the individual code use. The auto-init code does force-initialize them, though the value is different between the GCC plugin and Clang (currently). I expect to switch the kernel to always zero with Clang, but there is some debate about feature naming, etc[1]. > I have been seeing a ton of uninitialized variable bugs recently. Quite > often it's fine because zero is correct, but sometimes it leads to a > NULL pointer dereference. Right -- but better it be a deterministic failure than something under the influence of stale stack contents. > tree: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git ks= pp/uninit/macro > head: 806e8c03bcab6ac1f1ea142980de222fa021a75c > commit: fc9fcebe481c0e849a8141281411613eae76bd29 [9/10] treewide: Remove = uninitialized_var() usage > config: x86_64-randconfig-m001-20200604 (attached as .config) > compiler: gcc-9 (Debian 9.3.0-13) 9.3.0 > = > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > Reported-by: Dan Carpenter > = > smatch warnings: > drivers/virtio/virtio_ring.c:1197 virtqueue_add_packed() error: uninitial= ized symbol 'prev'. > drivers/virtio/virtio_ring.c:1205 virtqueue_add_packed() error: uninitial= ized symbol 'head_flags'. > drivers/virtio/virtio_ring.c:508 virtqueue_add_split() error: uninitializ= ed symbol 'prev'. Regardless, I'll see if I can get this explicitly initialized to avoid the new smatch warnings. Thanks for the report! :) -Kees [1] https://lists.llvm.org/pipermail/cfe-dev/2020-April/065221.html -- = Kees Cook --===============3729495746025003524==--