]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netfilter: nft_dynset: report EOPNOTSUPP on missing set feature
authorPablo Neira Ayuso <pablo@netfilter.org>
Sun, 27 Dec 2020 11:33:44 +0000 (12:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jan 2021 19:16:24 +0000 (20:16 +0100)
commit 95cd4bca7b1f4a25810f3ddfc5e767fb46931789 upstream.

If userspace requests a feature which is not available the original set
definition, then bail out with EOPNOTSUPP. If userspace sends
unsupported dynset flags (new feature not supported by this kernel),
then report EOPNOTSUPP to userspace. EINVAL should be only used to
report malformed netlink messages from userspace.

Fixes: 22fe54d5fefc ("netfilter: nf_tables: add support for dynamic set updates")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/nft_dynset.c

index 217fd1bdc55e7503777d6003e864d7a1bd4a3c6f..60236cc316d03667cd1cb16304a75cb3b4266ac2 100644 (file)
@@ -146,7 +146,7 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
                u32 flags = ntohl(nla_get_be32(tb[NFTA_DYNSET_FLAGS]));
 
                if (flags & ~NFT_DYNSET_F_INV)
-                       return -EINVAL;
+                       return -EOPNOTSUPP;
                if (flags & NFT_DYNSET_F_INV)
                        priv->invert = true;
        }
@@ -179,7 +179,7 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
        timeout = 0;
        if (tb[NFTA_DYNSET_TIMEOUT] != NULL) {
                if (!(set->flags & NFT_SET_TIMEOUT))
-                       return -EINVAL;
+                       return -EOPNOTSUPP;
 
                err = nf_msecs_to_jiffies64(tb[NFTA_DYNSET_TIMEOUT], &timeout);
                if (err)
@@ -193,7 +193,7 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
 
        if (tb[NFTA_DYNSET_SREG_DATA] != NULL) {
                if (!(set->flags & NFT_SET_MAP))
-                       return -EINVAL;
+                       return -EOPNOTSUPP;
                if (set->dtype == NFT_DATA_VERDICT)
                        return -EOPNOTSUPP;