Commit 1f27e251 authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

netfilter: xt_hashlimit: use _ALL macro to reject unknown flag bits

David Miller says:
     The canonical way to validate if the set bits are in a valid
     range is to have a "_ALL" macro, and test:
     if (val & ~XT_HASHLIMIT_ALL)
         goto err;"

make it so.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 6d8823db
...@@ -22,10 +22,12 @@ enum { ...@@ -22,10 +22,12 @@ enum {
XT_HASHLIMIT_HASH_SPT = 1 << 3, XT_HASHLIMIT_HASH_SPT = 1 << 3,
XT_HASHLIMIT_INVERT = 1 << 4, XT_HASHLIMIT_INVERT = 1 << 4,
XT_HASHLIMIT_BYTES = 1 << 5, XT_HASHLIMIT_BYTES = 1 << 5,
};
#ifdef __KERNEL__ #ifdef __KERNEL__
XT_HASHLIMIT_MAX = 1 << 6, #define XT_HASHLIMIT_ALL (XT_HASHLIMIT_HASH_DIP | XT_HASHLIMIT_HASH_DPT | \
XT_HASHLIMIT_HASH_SIP | XT_HASHLIMIT_HASH_SPT | \
XT_HASHLIMIT_INVERT | XT_HASHLIMIT_BYTES)
#endif #endif
};
struct hashlimit_cfg { struct hashlimit_cfg {
__u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */ __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
......
...@@ -647,7 +647,7 @@ static int hashlimit_mt_check(const struct xt_mtchk_param *par) ...@@ -647,7 +647,7 @@ static int hashlimit_mt_check(const struct xt_mtchk_param *par)
return -EINVAL; return -EINVAL;
} }
if (info->cfg.mode >= XT_HASHLIMIT_MAX) { if (info->cfg.mode & ~XT_HASHLIMIT_ALL) {
pr_info("Unknown mode mask %X, kernel too old?\n", pr_info("Unknown mode mask %X, kernel too old?\n",
info->cfg.mode); info->cfg.mode);
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment