kern/157209: [patch] locking error in rip6_input() (sys/netinet6/raw_ip6.c)

Gleb Smirnoff glebius at FreeBSD.org
Fri May 20 13:40:03 UTC 2011


The following reply was made to PR kern/157209; it has been noted by GNATS.

From: Gleb Smirnoff <glebius at FreeBSD.org>
To: Dmitrij Tejblum <tejblum at yandex-team.ru>
Cc: freebsd-gnats-submit at FreeBSD.org
Subject: Re: kern/157209: [patch] locking error in rip6_input()
 (sys/netinet6/raw_ip6.c)
Date: Fri, 20 May 2011 17:34:35 +0400

   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> Patch attached with submission follows:
 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.


More information about the freebsd-bugs mailing list