Bug 157209

Summary: [ip6] [patch] locking error in rip6_input() (sys/netinet6/raw_ip6.c)
Product: Base System Reporter: Dmitrij Tejblum <tejblum>
Component: kernAssignee: Andrey V. Elsukov <ae>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 8.2-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Dmitrij Tejblum 2011-05-20 13:40:10 UTC
On a failure path in rip6_input(), the PCB is unlocked before the lock is taken.

Fix: A possible quick patch is attached; anothe quick possibility would be to remove the unlock.

Patch attached with submission follows:
Comment 1 Gleb Smirnoff freebsd_committer freebsd_triage 2011-05-20 14:34:35 UTC
  Dmitrij,

On Fri, May 20, 2011 at 12:33:35PM +0000, Dmitrij Tejblum wrote:
D> >Fix:
D> A possible quick patch is attached; anothe quick possibility would be to remove the unlock.

I think deleting INP_RUNLOCK would be more clean in the current code,
because in6p_cksum isn't actually protected by INP_RLOCK in the function
where it is written, the ip6_raw_ctloutput().

However, in_pcb.h says that in6p_cksum should be protected by inp lock.
So may be a thorough fix would be your patch + adding locking to the
ip6_raw_ctloutput().

D> D> 
D> --- sys/netinet6/raw_ip6.c	2010-08-31 19:52:12.000000000 +0400
D> +++ sys/netinet6/raw_ip6.c	2011-05-14 00:27:24.000000000 +0400
D> @@ -193,20 +193,20 @@
D>  			if (!IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) &&
D>  			    prison_check_ip6(in6p->inp_cred,
D>  			    &ip6->ip6_dst) != 0)
D>  				continue;
D>  		}
D> +		INP_RLOCK(in6p);
D>  		if (in6p->in6p_cksum != -1) {
D>  			V_rip6stat.rip6s_isum++;
D>  			if (in6_cksum(m, proto, *offp,
D>  			    m->m_pkthdr.len - *offp)) {
D>  				INP_RUNLOCK(in6p);
D>  				V_rip6stat.rip6s_badsum++;
D>  				continue;
D>  			}
D>  		}
D> -		INP_RLOCK(in6p);
D>  		/*
D>  		 * If this raw socket has multicast state, and we
D>  		 * have received a multicast, check if this socket
D>  		 * should receive it, as multicast filtering is now
D>  		 * the responsibility of the transport layer.
D> 
D> 

-- 
Totus tuus, Glebius.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2011-05-21 23:48:21 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-net

Over to maintainer(s).
Comment 3 Andrey V. Elsukov freebsd_committer freebsd_triage 2013-06-09 05:31:46 UTC
State Changed
From-To: open->closed

This was fixed in r248180 and merged to stable/9, stable/8. 


Comment 4 Andrey V. Elsukov freebsd_committer freebsd_triage 2013-06-09 05:31:46 UTC
Responsible Changed
From-To: freebsd-net->ae

Take.