From: Peteris Krumins Subject: Re[2]: ip_queue, is this safe: Date: Sun, 3 Aug 2003 00:33:58 +0300 Sender: netfilter-devel-admin@lists.netfilter.org Message-ID: <8229894986.20030803003358@lf.lv> References: Reply-To: Peteris Krumins Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: To: netfilter-devel@lists.netfilter.org In-Reply-To: Errors-To: netfilter-devel-admin@lists.netfilter.org List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: List-Id: netfilter-devel.vger.kernel.org Friday, August 1, 2003, 6:25:18 PM, you wrote: JM> On Fri, 1 Aug 2003, Peteris Krumins wrote: >> i am doubting: >> tcp = (struct tcphdr *)(packet->payload + ip->ihl*4); JM> To start with, this pointer arithmetic is incorrect, you need something JM> like: JM> tcph = (void *) iph + iph->ihl * 4; >> >> because ip->ihl could be faked, couldnt it? The packet would get queued >> and if ip->ihl is something faked, using the tcp pointer i'd get a >> segfault, wouldn't i? JM> The kernel drops received packets with a too-large ihl before the JM> prerouting hook. For locally generated packets of this type (e.g. root is JM> playing games with raw sockets), iptables 'accepts' them without JM> traversing any more rules on the chain -- they won't make it to the JM> QUEUE target. JM> You will however need to validate any transport+ header lengths against JM> the length of the packet. Thanks for the answer! P.Krumins