There appears to be a bug in Sun's IP stack that is confusing
ipfilter's state table.  While I think there is a bug in Sun's
stack, I think ipfilter should be able to handle it.

I have the following rule in my ipf.conf:

pass in  proto tcp from any to any port = 25 flags S/SA keep state

This works most of the time.  However, Sun's IP stack sometimes
responds incorrectly to a new connection and this messes up ipfilter's state
table.

Here is a sequence to demonstrate the problem. It is output from
snoop.

At some point in the past, a machine (207.xxx.xxx.xxx) connected to
mailhost port 25 from port 1128.  The connection was normal and closed
normally.

  1   0.00000 207.xxx.xxx.xxx -> mailhost       TCP D=25 S=1128 Syn Seq=3160181085 
Len=0 Win=16384 Options=<mss 1460,nop,nop,sackOK>
  2   0.00043       mailhost -> 207.xxx.xxx.xxx TCP D=1128 S=25 Syn Ack=3160181086 
Seq=3339352365 Len=0 Win=24820 Options=<nop,nop,sackOK,mss 1460>
  3   0.02192 207.xxx.xxx.xxx -> mailhost       TCP D=25 S=1128     Ack=3339352366 
Seq=3160181086 Len=0 Win=17520
  4   0.00345       mailhost -> 207.xxx.xxx.xxx TCP D=1128 S=25     Ack=3160181086 
Seq=3339352366 Len=11 Win=24820
...
 21   0.00036       mailhost -> 207.xxx.xxx.xxx TCP D=1128 S=25 Fin Ack=3160181792 
Seq=3339352498 Len=0 Win=24820
 22   0.01982 207.xxx.xxx.xxx -> mailhost       TCP D=25 S=1128     Ack=3339352499 
Seq=3160181793 Len=0 Win=17388
 23   0.00018 207.xxx.xxx.xxx -> mailhost       TCP D=25 S=1128 Fin Ack=3339352498 
Seq=3160181792 Len=0 Win=17388
 24   0.00016       mailhost -> 207.xxx.xxx.xxx TCP D=1128 S=25     Ack=3160181793 
Seq=3339352499 Len=0 Win=24820

There are other connections between the two machine at this point.
Then about 3 minutes after the connection above closed, another
connection is made from 207.xxx.xxx.xxx port 1128 to mailhost port 25.

 68  63.19083 207.xxx.xxx.xxx -> mailhost       TCP D=25 S=1128 Syn Seq=2137755130 
Len=0 Win=16384 Options=<mss 1460,nop,nop,sackOK>
 69   0.00039       mailhost -> 207.xxx.xxx.xxx TCP D=1128 S=25     Ack=3160181793 
Seq=3339352499 Len=0 Win=24820
 70   0.02161 207.xxx.xxx.xxx -> mailhost       TCP D=25 S=1128 Rst Seq=3160181793 
Len=0 Win=0

As you can see, mailhost responded incorrectly (with an Ack whose number
was from the previously closed connection between ports 1128 and 25).
Then 207.xxx.xxx.xxx correctly (I think) responds with a RST.  This
seems like a bug in Sun's IP stack.

Since 207.xxx.xxx.xxx never got a response to it's SYN, it sends it again.

 71   3.22245 207.xxx.xxx.xxx -> mailhost       TCP D=25 S=1128 Syn Seq=2137755130 
Len=0 Win=16384 Options=<mss 1460,nop,nop,sackOK>
 72   0.00036       mailhost -> 207.xxx.xxx.xxx TCP D=1128 S=25 Syn Ack=2137755131 
Seq=3362275709 Len=0 Win=24820 Options=<nop,nop,sackOK,mss 1460>

This time, mailhost tries to respond correctly, however the packet is blocked
by ifpilter.

It seems to me that packet number 71 should have created a new state
table entry and packet 72 should have went through.  This seems like
a bug in ipfilter.

Comments?

Dan

Reply via email to