--log-ip-options broken in 2.4
Subsystems (2)
PATCH 1/1 --log-ip-options broken in 2.4
It looks like --log-ip-options is broken in 2.4, i.e. the OPT field never appears in Netfilter logs even when packets contain IP options. I have attached a small patch that fixes this. It removes the "iph->ihl * 4 >= datalen" condition, which rarely happens ("ping -T tsonly -s 1 <host>" will trigger it for example). The resulting code is analogous to the code in the 2.6 kernel.
This is for Netfilter bugzilla # 288.
Thanks,
--Mike
Michael Rash
http://www.cipherdyne.org/
Key fingerprint = 53EA 13EA 472E 3771 894F AC69 95D8 5D6B A742 839F
net/ipv4/netfilter/ipt_LOG.c 2005-01-29 01:50:36.000000000 -0500 renamed from net/ipv4/netfilter/ipt_LOG.c 2005-01-29 01:55:29.000000000 -0500 +1 -2
@@ -67,8 +67,7 @@ printk("FRAG:%u ", ntohs(iph->frag_off) & IP_OFFSET); if ((info->logflags & IPT_LOG_IPOPT) - && iph->ihl * 4 != sizeof(struct iphdr) - && iph->ihl * 4 >= datalen) { + && iph->ihl * 4 > sizeof(struct iphdr)) { unsigned int i; /* Max length: 127 "OPT (" 15*4*2chars ") " */
Quoted 6 lines · Michael Rash
It looks like --log-ip-options is broken in 2.4, i.e. the OPT field never appears in Netfilter logs even when packets contain IP options. I have attached a small patch that fixes this. It removes the "
iph->ihl* 4 >= datalen" condition, which rarely happens ("ping -T tsonly -s 1 <host>" will trigger it for example). The resulting code is analogous to the code in the 2.6 kernel.
In 2.6 the size of the area is verfied by skb_header_pointer, we need to do this manually in 2.4. I'm going to submit the attached patch for this problem.
Regards
Patrick
# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2005/03/04 11:36:23+01:00 [email protected]
# [NETFILTER]: Fix IP/TCP option logging
#
# Signed-off-by: Patrick McHardy <[email protected]>
#
# net/ipv4/netfilter/ipt_LOG.c
# 2005/03/04 11:35:42+01:00 [email protected] +4 -3
# [NETFILTER]: Fix IP/TCP option logging
#
# Signed-off-by: Patrick McHardy <[email protected]>
#
net/ipv4/netfilter/ipt_LOG.c +4 -3
@@ -67,8 +67,8 @@printk ("FRAG:%u " ,ntohs (iph->frag_off) &IP_OFFSET );if ((info->logflags &IPT_LOG_IPOPT ) - && iph->ihl *4 !=sizeof (struct iphdr ) - && iph->ihl *4 >= datalen) { + && iph->ihl *4 >sizeof (struct iphdr ) + && iph->ihl *4 <= len) {unsigned int i;/* Max length: 127 "OPT (" 15*4*2chars ") " */
@@ -126,7 +126,8 @@printk ("URGP=%u " ,ntohs (tcph->urg_ptr));if ((info->logflags &IPT_LOG_TCPOPT ) - && tcph->doff *4 !=sizeof (struct tcphdr )) { + && tcph->doff *4 >sizeof (struct tcphdr ) + && tcph->doff *4 <= datalen) {unsigned int i;/* Max length: 127 "OPT (" 15*4*2chars ") " */