]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netfilter: nf_tables: reject expiration higher than timeout
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 2 Sep 2024 23:06:58 +0000 (01:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:07:40 +0000 (15:07 +0200)
[ Upstream commit c0f38a8c60174368aed1d0f9965d733195f15033 ]

Report ERANGE to userspace if user specifies an expiration larger than
the timeout.

Fixes: 8e1102d5a159 ("netfilter: nf_tables: support timeouts larger than 23 days")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nf_tables_api.c

index a788f3e8fe2bb68c265067a9f9b5711f4a4bdc55..9e2695bedd2cec9f563ed08b0f1cccfa230cf979 100644 (file)
@@ -5635,6 +5635,9 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
                                            &expiration);
                if (err)
                        return err;
+
+               if (expiration > timeout)
+                       return -ERANGE;
        }
 
        if (nla[NFTA_SET_ELEM_EXPR] != NULL) {