Skip to content

Commit a958a4f

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: x_tables: ensure names are nul-terminated
Reject names that lack a \0 character before feeding them to functions that expect c-strings. Fixes tag is the most recent commit that needs this change. Fixes: c38c459 ("netfilter: implement xt_cgroup cgroup2 path match") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 6d52a4a commit a958a4f

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

net/netfilter/xt_cgroup.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_param *par)
6565

6666
info->priv = NULL;
6767
if (info->has_path) {
68+
if (strnlen(info->path, sizeof(info->path)) >= sizeof(info->path))
69+
return -ENAMETOOLONG;
70+
6871
cgrp = cgroup_get_from_path(info->path);
6972
if (IS_ERR(cgrp)) {
7073
pr_info_ratelimited("invalid path, errno=%ld\n",
@@ -102,6 +105,9 @@ static int cgroup_mt_check_v2(const struct xt_mtchk_param *par)
102105

103106
info->priv = NULL;
104107
if (info->has_path) {
108+
if (strnlen(info->path, sizeof(info->path)) >= sizeof(info->path))
109+
return -ENAMETOOLONG;
110+
105111
cgrp = cgroup_get_from_path(info->path);
106112
if (IS_ERR(cgrp)) {
107113
pr_info_ratelimited("invalid path, errno=%ld\n",

net/netfilter/xt_rateest.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ static int xt_rateest_mt_checkentry(const struct xt_mtchk_param *par)
9191
goto err1;
9292
}
9393

94+
if (strnlen(info->name1, sizeof(info->name1)) >= sizeof(info->name1))
95+
return -ENAMETOOLONG;
96+
if (strnlen(info->name2, sizeof(info->name2)) >= sizeof(info->name2))
97+
return -ENAMETOOLONG;
98+
9499
ret = -ENOENT;
95100
est1 = xt_rateest_lookup(par->net, info->name1);
96101
if (!est1)

0 commit comments

Comments
 (0)