Unverified Commit f35cd256 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!7100 netfilter: nf_tables: Fix potential data-race in __nft_obj_type_get()

parents 19bb53ac fcbebb8e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -5073,7 +5073,7 @@ static const struct nft_object_type *__nft_obj_type_get(u32 objtype)
{
	const struct nft_object_type *type;

	list_for_each_entry(type, &nf_tables_objects, list) {
	list_for_each_entry_rcu(type, &nf_tables_objects, list) {
		if (objtype == type->type)
			return type;
	}
@@ -5085,9 +5085,13 @@ nft_obj_type_get(struct net *net, u32 objtype)
{
	const struct nft_object_type *type;

	rcu_read_lock();
	type = __nft_obj_type_get(objtype);
	if (type != NULL && try_module_get(type->owner))
	if (type != NULL && try_module_get(type->owner)) {
		rcu_read_unlock();
		return type;
	}
	rcu_read_unlock();

	lockdep_nfnl_nft_mutex_not_held();
#ifdef CONFIG_MODULES