Small SMP-race found in ip_conntrack_proto_tcp.c
Subsystems (2)
PATCH 1/1 Small SMP-race found in ip_conntrack_proto_tcp.c
Hi,
I just found a small SMP-race when looking at an ugly lock (tcp_lock) in ip_conntrack_proto_tcp.c
we use conntrack->proto.tcp.handshake_ack without holding the lock. This is a very small race as it only applies to the ACK-packet in the three-way handshake and there will probably only be one of those.
Patch to move the unlock further down is attached, I unlock before calling ip_ct_refresh as it is unfriendly to hold the lock longer than neccessary.
I believe this lock can be removed completely in Rusty's optmization-patches, I'll send a patch for that aswell later.
Signature · 4 lines
/Martin Never argue with an idiot. They drag you down to their level, then beat you with experience.
Quoted 3 lines · Martin Josefsson
Patch to move the unlock further down is attached, I unlock before calling
ip_ct_refreshas it is unfriendly to hold the lock longer than neccessary.
I can't see a patch :)
Quoted 1 line
/Martin
Signature · 5 lines
Live long and prosper - Harald Welte / [email protected] http://www.gnumonks.org/ ============================================================================ "If this were a dictatorship, it'd be a heck of a lot easier, just so long as I'm the dictator." -- George W. Bush Dec 18, 2000
Quoted 6 lines · Harald Welte
Quoted 3 lines · Martin Josefsson
Patch to move the unlock further down is attached, I unlock before calling
ip_ct_refreshas it is unfriendly to hold the lock longer than neccessary.I can't see a patch :)
Damn, I was sure I attached it... well well...
Here it is.
Signature · 4 lines
/Martin Never argue with an idiot. They drag you down to their level, then beat you with experience.
net/ipv4/netfilter/ip_conntrack_proto_tcp.c renamed from net/ipv4/netfilter/ip_conntrack_proto_tcp.c.meep +2 -1
@@ -186,13 +186,13 @@ && tcph->syn && tcph->ack) conntrack->proto.tcp.handshake_ack =htonl (ntohl (tcph->seq) +1 ); -WRITE_UNLOCK (&tcp_lock);/* If only reply is a RST, we can consider ourselves not to have an established connection: this is a fairly common problem case, so we can delete the conntrack immediately. --RR */ if (!(conntrack->status &IPS_SEEN_REPLY ) && tcph->rst) { +WRITE_UNLOCK (&tcp_lock);if (del_timer (&conntrack->timeout)) conntrack->timeout.function ((unsigned long )conntrack); }else {
@@ -203,6 +203,7 @@ && tcph->ack_seq == conntrack->proto.tcp.handshake_ack)set_bit (IPS_ASSURED_BIT , &conntrack->status); +WRITE_UNLOCK (&tcp_lock);ip_ct_refresh (conntrack, tcp_timeouts[newconntrack]); }