mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-07 05:05:12 +02:00
psd: add basic validation of userspace matchinfo data
psd multiplies weight_thresh by HZ, so it could overflow. Userspace libxt_psd refuses values exceeding PSD_MAX_RATE, so check that on kernel side, too. Also, setting 0 weight for both privileged and highports will cause psd to never match at all. Reject 0 weight threshold, too because it makes no sense (triggers match for every initial packet).
This commit is contained in:

committed by
Jan Engelhardt

parent
ac58f2e94b
commit
f6b8767228
@@ -3,6 +3,8 @@ HEAD
|
|||||||
====
|
====
|
||||||
Fixes:
|
Fixes:
|
||||||
- xt_psd: avoid crash due to curr->next corruption
|
- xt_psd: avoid crash due to curr->next corruption
|
||||||
|
Changes:
|
||||||
|
- xt_psd: reject invalid match options
|
||||||
|
|
||||||
|
|
||||||
v1.42 (2012-04-05)
|
v1.42 (2012-04-05)
|
||||||
|
@@ -278,13 +278,35 @@ out_match:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int psd_mt_check(const struct xt_mtchk_param *par)
|
||||||
|
{
|
||||||
|
const struct xt_psd_info *info = par->matchinfo;
|
||||||
|
|
||||||
|
if (info->weight_threshold == 0)
|
||||||
|
/* 0 would match on every 1st packet */
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if ((info->lo_ports_weight | info->hi_ports_weight) == 0)
|
||||||
|
/* would never match */
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (info->delay_threshold > PSD_MAX_RATE ||
|
||||||
|
info->weight_threshold > PSD_MAX_RATE ||
|
||||||
|
info->lo_ports_weight > PSD_MAX_RATE ||
|
||||||
|
info->hi_ports_weight > PSD_MAX_RATE)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static struct xt_match xt_psd_reg __read_mostly = {
|
static struct xt_match xt_psd_reg __read_mostly = {
|
||||||
.name = "psd",
|
.name = "psd",
|
||||||
.family = NFPROTO_IPV4,
|
.family = NFPROTO_IPV4,
|
||||||
.revision = 1,
|
.revision = 1,
|
||||||
.match = xt_psd_match,
|
.checkentry = psd_mt_check,
|
||||||
.matchsize = sizeof(struct xt_psd_info),
|
.match = xt_psd_match,
|
||||||
.me = THIS_MODULE,
|
.matchsize = sizeof(struct xt_psd_info),
|
||||||
|
.me = THIS_MODULE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init xt_psd_init(void)
|
static int __init xt_psd_init(void)
|
||||||
|
Reference in New Issue
Block a user