]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfilter: ipset: use nla_strcmp for IPSET_ATTR_NAME attr
authorFlorian Westphal <fw@strlen.de>
Mon, 30 Mar 2026 12:16:34 +0000 (14:16 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 1 Apr 2026 09:55:29 +0000 (11:55 +0200)
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: f830837f0eed ("netfilter: ipset: list:set set type support")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter/ipset/ip_set.h
net/netfilter/ipset/ip_set_core.c
net/netfilter/ipset/ip_set_list_set.c

index e9f4f845d760afafbfb6e45b220dfb6919a29779..b98331572ad2989258e803fe111f7c900151003f 100644 (file)
@@ -309,7 +309,7 @@ enum {
 
 /* register and unregister set references */
 extern ip_set_id_t ip_set_get_byname(struct net *net,
-                                    const char *name, struct ip_set **set);
+                                    const struct nlattr *name, struct ip_set **set);
 extern void ip_set_put_byindex(struct net *net, ip_set_id_t index);
 extern void ip_set_name_byindex(struct net *net, ip_set_id_t index, char *name);
 extern ip_set_id_t ip_set_nfnl_get_byindex(struct net *net, ip_set_id_t index);
index a2fe711cb5e3672198dcef86af54aa6964b63318..d0c9fe59c67d2a81ef498e2340b5d7f79c31a883 100644 (file)
@@ -821,7 +821,7 @@ EXPORT_SYMBOL_GPL(ip_set_del);
  *
  */
 ip_set_id_t
-ip_set_get_byname(struct net *net, const char *name, struct ip_set **set)
+ip_set_get_byname(struct net *net, const struct nlattr *name, struct ip_set **set)
 {
        ip_set_id_t i, index = IPSET_INVALID_ID;
        struct ip_set *s;
@@ -830,7 +830,7 @@ ip_set_get_byname(struct net *net, const char *name, struct ip_set **set)
        rcu_read_lock();
        for (i = 0; i < inst->ip_set_max; i++) {
                s = rcu_dereference(inst->ip_set_list)[i];
-               if (s && STRNCMP(s->name, name)) {
+               if (s && nla_strcmp(name, s->name) == 0) {
                        __ip_set_get(s);
                        index = i;
                        *set = s;
index 98b91b34c3146cca5021681eaf7964b1812c849f..1cef84f15e8c75f51b59724314eb31afe3a6ac4f 100644 (file)
@@ -367,7 +367,7 @@ list_set_uadt(struct ip_set *set, struct nlattr *tb[],
        ret = ip_set_get_extensions(set, tb, &ext);
        if (ret)
                return ret;
-       e.id = ip_set_get_byname(map->net, nla_data(tb[IPSET_ATTR_NAME]), &s);
+       e.id = ip_set_get_byname(map->net, tb[IPSET_ATTR_NAME], &s);
        if (e.id == IPSET_INVALID_ID)
                return -IPSET_ERR_NAME;
        /* "Loop detection" */
@@ -389,7 +389,7 @@ list_set_uadt(struct ip_set *set, struct nlattr *tb[],
 
        if (tb[IPSET_ATTR_NAMEREF]) {
                e.refid = ip_set_get_byname(map->net,
-                                           nla_data(tb[IPSET_ATTR_NAMEREF]),
+                                           tb[IPSET_ATTR_NAMEREF],
                                            &s);
                if (e.refid == IPSET_INVALID_ID) {
                        ret = -IPSET_ERR_NAMEREF;