kern/95559: [RELENG_6] write(2) fails with EPERM on TCP socket under certain situations

Gleb Smirnoff glebius at FreeBSD.org
Wed Apr 19 10:40:20 UTC 2006


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

From: Gleb Smirnoff <glebius at FreeBSD.org>
To: Xin LI <delphij at FreeBSD.org>
Cc: dhartmei at FreeBSD.org, FreeBSD-gnats-submit at FreeBSD.org
Subject: Re: kern/95559: [RELENG_6] write(2) fails with EPERM on TCP socket under certain situations
Date: Wed, 19 Apr 2006 14:38:35 +0400

   Hi, Xin!
 
 On Mon, Apr 10, 2006 at 09:49:18AM +0800, Xin LI wrote:
 X> >How-To-Repeat:
 X> 
 X> 	First, one should load the following ruleset onto pf(4)
 X> 
 X> --- pf.conf begins here ---
 X> scrub reassemble tcp random-id
 X> set skip on lo0
 X> --- pf.conf ends here ---
 X> 
 X> 	Second, run a cvsupd daemon from the host.
 X> 
 X> 	Third, set up a jail and try to transfer some big data
 X> from the host.
 X> 
 X> 	A ktrace dump is available at:
 X> 		http://www.delphij.net/kdump.txt.bz2
 X> 
 X> 	Please note that the dump is big (about 7MB).
 X> 
 X> >Fix:
 X> 
 X> 	By removing either rule from the pf.conf seems to work
 X> around the issue.  However, we have grep'ed EPERM from netinet
 X> and pf code and found that there is not a reasonable reason
 X> why write(2) would return EPERM in the code path.
 
 I think this behavior is correct. The traffic from host to jail
 is routed through lo0, however within a jail the hosts address
 is a foreign one, and thus is routed via some interface, not lo0.
 
 So traffic from host to jail runs through lo0 and traffic from
 jail to host doesn't.
 
 With the above rules you establish TCP scurbbing in pf, which
 requires inspecting and normalizing TCP packets in both
 directions. However, you skip pf processing for one direction,
 and pf sees only half of TCP connection and assumes connection
 bogus and thus denies it.
 
 P.S. May be Daniel can comment on this.
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE


More information about the freebsd-bugs mailing list