summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJiayuan Chen <jiayuan.chen@linux.dev>2026-06-10 11:02:59 +0800
committerFlorian Westphal <fw@strlen.de>2026-07-02 12:17:14 +0200
commit43ae85af154b27f9a0ff602f7a01e3a7583ffdab (patch)
treeb14f498f6c6b4d53106230bfaeba4ad078ac451e /include
parent78217fb2ccf9d3963dd32d86712ba42e7fd619a8 (diff)
netfilter: ebtables: bound num_counters like nentries in do_replace()
do_replace_finish() allocates the counter buffer before it is validated: counterstmp = vmalloc_array(repl->num_counters, sizeof(*counterstmp)); do_replace() only checks num_counters against INT_MAX / sizeof(struct ebt_counter), so vmalloc_array() can be asked for up to 134217726 * 16 = 2147483616 bytes (~2 GiB). num_counters must in fact equal nentries: do_replace_finish() later rejects the request when repl->num_counters != t->private->nentries. get_counters() folds the per-CPU counters back into one entry per rule, so what userspace gets is bounded by nentries, never by nentries * nr_cpus. Apply the same upper bound used for nentries (MAX_EBT_ENTRIES) to the incoming num_counters so the over-sized allocation can no longer be requested. The allocation is still kept outside the ebt_mutex, since vmalloc() may sleep and trigger reclaim; only the bound is tightened. Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions