Skip to contentSkip to conversation

locking issue in __unexpect_related

PATCH In review Pablo Neira 2 participants 2 messages Apr 21, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 locking issue in __unexpect_related

Hi Harald and list,

In the function __unexpect_related:

        /* delete from global and local lists */
        list_del(&expect->list);
        list_del(&expect->expected_list);

If an entry of the global list of expectation is erased, shouldn't this operation be write_lock'ed? If missing something, please let me know.

regards,
Pablo

net/ipv4/netfilter/ip_conntrack_core.c +2 -0
@@ -226,7 +226,9 @@
 	IP_NF_ASSERT(!expect->sibling);
 
 	/* delete from global and local lists */
+	WRITE_LOCK(&ip_conntrack_expect_list);
 	list_del(&expect->list);
+	WRITE_UNLOCK(&ip_conntrack_expect_list);
 	list_del(&expect->expected_list);
 
 	/* decrement expect-count of master conntrack */
#1 lore raw
Quoted 9 lines · Pablo Neira

Hi Harald and list,

In the function __unexpect_related:

        /* delete from global and local lists */
        list_del(&expect->list);
        list_del(&expect->expected_list);

If an entry of the global list of expectation is erased, shouldn't this operation be write_lock'ed? If missing something, please let me know.

Your patch will deadlock, the function should only be called under write-locked ip_conntrack_lock, which you can see by the MUST_BE_WRITE_LOCKED assertion. Check the callers ..

Regards
Patrick

Quoted 19 lines

regards,
Pablo

------------------------------------------------------------------------

net/ipv4/netfilter/ip_conntrack_core.c +2 -0
@@ -226,7 +226,9 @@
 	IP_NF_ASSERT(!expect->sibling);
 
 	/* delete from global and local lists */
+	WRITE_LOCK(&ip_conntrack_expect_list);
 	list_del(&expect->list);
+	WRITE_UNLOCK(&ip_conntrack_expect_list);
 	list_del(&expect->expected_list);
 
 	/* decrement expect-count of master conntrack */