Skip to content

Commit dceb48d

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: x_tables: check name length in find_match/target, too
ebtables uses find_match() rather than find_request_match in one case (see bcf4934, "netfilter: ebtables: Fix extension lookup with identical name"), so extend the check on name length to those functions too. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 72d4d3e commit dceb48d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/netfilter/x_tables.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ struct xt_match *xt_find_match(u8 af, const char *name, u8 revision)
183183
struct xt_match *m;
184184
int err = -ENOENT;
185185

186+
if (strnlen(name, XT_EXTENSION_MAXNAMELEN) == XT_EXTENSION_MAXNAMELEN)
187+
return ERR_PTR(-EINVAL);
188+
186189
mutex_lock(&xt[af].mutex);
187190
list_for_each_entry(m, &xt[af].match, list) {
188191
if (strcmp(m->name, name) == 0) {
@@ -229,6 +232,9 @@ struct xt_target *xt_find_target(u8 af, const char *name, u8 revision)
229232
struct xt_target *t;
230233
int err = -ENOENT;
231234

235+
if (strnlen(name, XT_EXTENSION_MAXNAMELEN) == XT_EXTENSION_MAXNAMELEN)
236+
return ERR_PTR(-EINVAL);
237+
232238
mutex_lock(&xt[af].mutex);
233239
list_for_each_entry(t, &xt[af].target, list) {
234240
if (strcmp(t->name, name) == 0) {

0 commit comments

Comments
 (0)