mirror of
https://github.com/torvalds/linux.git
synced 2026-06-06 21:45:45 +02:00
netfilter: nf_tables: stricter validation of element data
commit7e6bc1f6caupstream. Make sure element data type and length do not mismatch the one specified by the set declaration. Fixes:7d7402642e("netfilter: nf_tables: variable sized set element keys / data") Reported-by: Hugues ANGUELKOV <hanguelkov@randorisec.fr> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4a6430b99f
commit
0a5e36dbcb
|
|
@ -4886,13 +4886,20 @@ static int nft_setelem_parse_data(struct nft_ctx *ctx, struct nft_set *set,
|
||||||
struct nft_data *data,
|
struct nft_data *data,
|
||||||
struct nlattr *attr)
|
struct nlattr *attr)
|
||||||
{
|
{
|
||||||
|
u32 dtype;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = nft_data_init(ctx, data, NFT_DATA_VALUE_MAXLEN, desc, attr);
|
err = nft_data_init(ctx, data, NFT_DATA_VALUE_MAXLEN, desc, attr);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (desc->type != NFT_DATA_VERDICT && desc->len != set->dlen) {
|
if (set->dtype == NFT_DATA_VERDICT)
|
||||||
|
dtype = NFT_DATA_VERDICT;
|
||||||
|
else
|
||||||
|
dtype = NFT_DATA_VALUE;
|
||||||
|
|
||||||
|
if (dtype != desc->type ||
|
||||||
|
set->dlen != desc->len) {
|
||||||
nft_data_release(data, desc->type);
|
nft_data_release(data, desc->type);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user