summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2022-08-08 20:30:06 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-08-17 16:13:59 +0300
commit92c07fdb6b58c7b1c9f3f6c9f67ee3be139f836d (patch)
treecf9da1286bed5556e72d1b8fe488a8b03c720c2d /include
parentc921bd1a7f00e1a05dadaac80339fb5be2687efb (diff)
downloadlinux-92c07fdb6b58c7b1c9f3f6c9f67ee3be139f836d.tar.xz
netfilter: nf_tables: upfront validation of data via nft_data_init()
commit 341b6941608762d8235f3fd1e45e4d7114ed8c2c upstream. Instead of parsing the data and then validate that type and length are correct, pass a description of the expected data so it can be validated upfront before parsing it to bail out earlier. This patch adds a new .size field to specify the maximum size of the data area. The .len field is optional and it is used as an input/output field, it provides the specific length of the expected data in the input path. If then .len field is not specified, then obtained length from the netlink attribute is stored. This is required by cmp, bitwise, range and immediate, which provide no netlink attribute that describes the data length. The immediate expression uses the destination register type to infer the expected data type. Relying on opencoded validation of the expected data might lead to subtle bugs as described in 7e6bc1f6cabc ("netfilter: nf_tables: stricter validation of element data"). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/netfilter/nf_tables.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 64cf655c818c..1ad11f5e53f3 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -208,11 +208,11 @@ struct nft_ctx {
struct nft_data_desc {
enum nft_data_types type;
+ unsigned int size;
unsigned int len;
};
-int nft_data_init(const struct nft_ctx *ctx,
- struct nft_data *data, unsigned int size,
+int nft_data_init(const struct nft_ctx *ctx, struct nft_data *data,
struct nft_data_desc *desc, const struct nlattr *nla);
void nft_data_hold(const struct nft_data *data, enum nft_data_types type);
void nft_data_release(const struct nft_data *data, enum nft_data_types type);