]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nf_tables: don't use 'data_size' uninitialized
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 11 Jan 2022 03:33:36 +0000 (19:33 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 11 Jan 2022 03:33:36 +0000 (19:33 -0800)
commit761fe7ac9d9eb13e6433f707cf96ddd2642479e2
tree9bc1e9ee96f55274b9a8794da9c0f74cf76c03c2
parent318ca0a5fc22305ac5ff9d2d0408a5a75409b6fe
netfilter: nf_tables: don't use 'data_size' uninitialized

Commit b0580a6d24e4 ("netfilter: nf_tables: add rule blob layout") never
initialized the new 'data_size' variable.

I'm not sure how it ever worked, but it might have worked almost by
accident - gcc seems to occasionally miss these kinds of 'variable used
uninitialized' situations, but I've seen it do so because it ended up
zero-initializing them due to some other simplification.

But clang is very unhappy about it all, and correctly reports

    net/netfilter/nf_tables_api.c:8278:4: error: variable 'data_size' is uninitialized when used here [-Werror,-Wuninitialized]
                            data_size += sizeof(*prule) + rule->dlen;
                            ^~~~~~~~~
    net/netfilter/nf_tables_api.c:8263:30: note: initialize the variable 'data_size' to silence this warning
            unsigned int size, data_size;
                                        ^
                                         = 0
    1 error generated.

and this fix just initializes 'data_size' to zero before the loop.

Fixes: b0580a6d24e4 ("netfilter: nf_tables: add rule blob layout")
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
net/netfilter/nf_tables_api.c