Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50b2ff1b authored by Paul Moore's avatar Paul Moore Committed by David S. Miller
Browse files

netlabel: Always remove the correct address selector



The NetLabel address selector mechanism has a problem where it can get
mistakenly remove the wrong selector when similar addresses are used.  The
problem is caused when multiple addresses are configured that have different
netmasks but the same address, e.g. 127.0.0.0/8 and 127.0.0.0/24.  This patch
fixes the problem.

Reported-by: default avatarEtienne Basset <etienne.basset@numericable.fr>
Signed-off-by: default avatarPaul Moore <paul.moore@hp.com>
Acked-by: default avatarJames Morris <jmorris@namei.org>
Tested-by: default avatarEtienne Basset <etienne.basset@numericable.fr>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cef309cf
Loading
Loading
Loading
Loading
+10 −16
Original line number Original line Diff line number Diff line
@@ -256,15 +256,13 @@ struct netlbl_af4list *netlbl_af4list_remove(__be32 addr, __be32 mask,
{
{
	struct netlbl_af4list *entry;
	struct netlbl_af4list *entry;


	entry = netlbl_af4list_search(addr, head);
	entry = netlbl_af4list_search_exact(addr, mask, head);
	if (entry != NULL && entry->addr == addr && entry->mask == mask) {
	if (entry == NULL)
		return NULL;
	netlbl_af4list_remove_entry(entry);
	netlbl_af4list_remove_entry(entry);
	return entry;
	return entry;
}
}


	return NULL;
}

#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
/**
/**
 * netlbl_af6list_remove_entry - Remove an IPv6 address entry
 * netlbl_af6list_remove_entry - Remove an IPv6 address entry
@@ -299,16 +297,12 @@ struct netlbl_af6list *netlbl_af6list_remove(const struct in6_addr *addr,
{
{
	struct netlbl_af6list *entry;
	struct netlbl_af6list *entry;


	entry = netlbl_af6list_search(addr, head);
	entry = netlbl_af6list_search_exact(addr, mask, head);
	if (entry != NULL &&
	if (entry == NULL)
	    ipv6_addr_equal(&entry->addr, addr) &&
		return NULL;
	    ipv6_addr_equal(&entry->mask, mask)) {
	netlbl_af6list_remove_entry(entry);
	netlbl_af6list_remove_entry(entry);
	return entry;
	return entry;
}
}

	return NULL;
}
#endif /* IPv6 */
#endif /* IPv6 */


/*
/*