Skip to content

Commit 6b74034

Browse files
committed
netfilter: nf_tables: fix out of memory error handling
jira VUlN-597 subsystem-sync netfilter:nf_tables 4.18.0-511 commit-author Florian Westphal <[email protected]> commit 5e1be4c upstream-diff Using the branch 8_10 code as an example, I ignore an initial line of the upstream commit. Several instances of pipapo_resize() don't propagate allocation failures, this causes a crash when fault injection is enabled for gfp_kernel slabs. Fixes: 3c4287f ("nf_tables: Add set type for arbitrary concatenation of ranges") Signed-off-by: Florian Westphal <[email protected]> Reviewed-by: Stefano Brivio <[email protected]> (cherry picked from commit 5e1be4c) Signed-off-by: Greg Rose <[email protected]>
1 parent 80a00ed commit 6b74034

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

net/netfilter/nft_set_pipapo.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,12 @@ static int pipapo_insert(struct nft_pipapo_field *f, const uint8_t *k,
852852
{
853853
int rule = f->rules++, group, ret;
854854

855-
ret = pipapo_resize(f, f->rules - 1, f->rules);
855+
ret = pipapo_resize(f, f->rules, f->rules + 1);
856856
if (ret)
857857
return ret;
858858

859+
f->rules++;
860+
859861
for (group = 0; group < f->groups; group++) {
860862
int i, v;
861863
u8 mask;
@@ -995,7 +997,9 @@ static int pipapo_expand(struct nft_pipapo_field *f,
995997
step++;
996998
if (step >= len) {
997999
if (!masks) {
998-
pipapo_insert(f, base, 0);
1000+
err = pipapo_insert(f, base, 0);
1001+
if (err < 0)
1002+
return err;
9991003
masks = 1;
10001004
}
10011005
goto out;
@@ -1151,6 +1155,9 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
11511155
f->groups * NFT_PIPAPO_GROUP_BITS);
11521156
}
11531157

1158+
if (ret < 0)
1159+
return ret;
1160+
11541161
if (f->bsize > bsize_max)
11551162
bsize_max = f->bsize;
11561163

0 commit comments

Comments
 (0)