Skip to content

Commit b7e8590

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: ipset: use nla_strcmp for IPSET_ATTR_NAME attr
IPSET_ATTR_NAME and IPSET_ATTR_NAMEREF are of NLA_STRING type, they cannot be treated like a c-string. They either have to be switched to NLA_NUL_STRING, or the compare operations need to use the nla functions. Fixes: f830837 ("netfilter: ipset: list:set set type support") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent a958a4f commit b7e8590

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

include/linux/netfilter/ipset/ip_set.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ enum {
309309

310310
/* register and unregister set references */
311311
extern ip_set_id_t ip_set_get_byname(struct net *net,
312-
const char *name, struct ip_set **set);
312+
const struct nlattr *name, struct ip_set **set);
313313
extern void ip_set_put_byindex(struct net *net, ip_set_id_t index);
314314
extern void ip_set_name_byindex(struct net *net, ip_set_id_t index, char *name);
315315
extern ip_set_id_t ip_set_nfnl_get_byindex(struct net *net, ip_set_id_t index);

net/netfilter/ipset/ip_set_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ EXPORT_SYMBOL_GPL(ip_set_del);
821821
*
822822
*/
823823
ip_set_id_t
824-
ip_set_get_byname(struct net *net, const char *name, struct ip_set **set)
824+
ip_set_get_byname(struct net *net, const struct nlattr *name, struct ip_set **set)
825825
{
826826
ip_set_id_t i, index = IPSET_INVALID_ID;
827827
struct ip_set *s;
@@ -830,7 +830,7 @@ ip_set_get_byname(struct net *net, const char *name, struct ip_set **set)
830830
rcu_read_lock();
831831
for (i = 0; i < inst->ip_set_max; i++) {
832832
s = rcu_dereference(inst->ip_set_list)[i];
833-
if (s && STRNCMP(s->name, name)) {
833+
if (s && nla_strcmp(name, s->name) == 0) {
834834
__ip_set_get(s);
835835
index = i;
836836
*set = s;

net/netfilter/ipset/ip_set_list_set.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ list_set_uadt(struct ip_set *set, struct nlattr *tb[],
367367
ret = ip_set_get_extensions(set, tb, &ext);
368368
if (ret)
369369
return ret;
370-
e.id = ip_set_get_byname(map->net, nla_data(tb[IPSET_ATTR_NAME]), &s);
370+
e.id = ip_set_get_byname(map->net, tb[IPSET_ATTR_NAME], &s);
371371
if (e.id == IPSET_INVALID_ID)
372372
return -IPSET_ERR_NAME;
373373
/* "Loop detection" */
@@ -389,7 +389,7 @@ list_set_uadt(struct ip_set *set, struct nlattr *tb[],
389389

390390
if (tb[IPSET_ATTR_NAMEREF]) {
391391
e.refid = ip_set_get_byname(map->net,
392-
nla_data(tb[IPSET_ATTR_NAMEREF]),
392+
tb[IPSET_ATTR_NAMEREF],
393393
&s);
394394
if (e.refid == IPSET_INVALID_ID) {
395395
ret = -IPSET_ERR_NAMEREF;

0 commit comments

Comments
 (0)