From: Harald Welte <laforge@netfilter.org>
To: David Miller <davem@redhat.com>
Cc: Netfilter Development Mailinglist
<netfilter-devel@lists.netfilter.org>,
Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>
Subject: [PATCH 2.4] iptables AH/ESP fix (1/1)
Date: Sat, 2 Aug 2003 15:18:39 +0200 [thread overview]
Message-ID: <20030802131839.GI6894@naboo> (raw)
[-- Attachment #1: Type: text/plain, Size: 3511 bytes --]
Hi Davem!
The below patch (again by Patrick McHardy) is the 2.4 merge of the last
3 2.6 patches I've sent you. Obviously we cannot use the kernel's
ah/esp structures, since there are none.
Please apply, thanks.
diff -Nru a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
--- a/net/ipv4/netfilter/ipt_LOG.c Mon Jul 21 02:21:23 2003
+++ b/net/ipv4/netfilter/ipt_LOG.c Mon Jul 21 02:21:23 2003
@@ -3,15 +3,14 @@
*/
#include <linux/module.h>
#include <linux/skbuff.h>
-#include <linux/ip.h>
#include <linux/spinlock.h>
+#include <linux/ip.h>
#include <net/icmp.h>
#include <net/udp.h>
#include <net/tcp.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
-
-struct in_device;
#include <net/route.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ipt_LOG.h>
#if 0
@@ -20,10 +19,20 @@
#define DEBUGP(format, args...)
#endif
+/* FIXME: move to ip.h like in 2.5 */
+struct ahhdr {
+ __u8 nexthdr;
+ __u8 hdrlen;
+ __u16 reserved;
+ __u32 spi;
+ __u32 seq_no;
+};
+
struct esphdr {
__u32 spi;
-}; /* FIXME evil kludge */
-
+ __u32 seq_no;
+};
+
/* Use lock to serialize, so printks don't overlap */
static spinlock_t log_lock = SPIN_LOCK_UNLOCKED;
@@ -58,7 +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 != sizeof(struct iphdr)
+ && iph->ihl * 4 >= datalen) {
unsigned int i;
/* Max length: 127 "OPT (" 15*4*2chars ") " */
@@ -231,13 +241,30 @@
break;
}
/* Max Length */
- case IPPROTO_AH:
+ case IPPROTO_AH: {
+ struct ahhdr *ah = protoh;
+
+ /* Max length: 9 "PROTO=AH " */
+ printk("PROTO=AH ");
+
+ if (ntohs(iph->frag_off) & IP_OFFSET)
+ break;
+
+ /* Max length: 25 "INCOMPLETE [65535 bytes] " */
+ if (datalen < sizeof (*ah)) {
+ printk("INCOMPLETE [%u bytes] ", datalen);
+ break;
+ }
+
+ /* Length: 15 "SPI=0xF1234567 " */
+ printk("SPI=0x%x ", ntohl(ah->spi) );
+ break;
+ }
case IPPROTO_ESP: {
struct esphdr *esph = protoh;
- int esp= (iph->protocol==IPPROTO_ESP);
/* Max length: 10 "PROTO=ESP " */
- printk("PROTO=%s ",esp? "ESP" : "AH");
+ printk("PROTO=ESP ");
if (ntohs(iph->frag_off) & IP_OFFSET)
break;
diff -Nru a/net/ipv4/netfilter/ipt_ah.c b/net/ipv4/netfilter/ipt_ah.c
--- a/net/ipv4/netfilter/ipt_ah.c Mon Jul 21 02:20:52 2003
+++ b/net/ipv4/netfilter/ipt_ah.c Mon Jul 21 02:20:52 2003
@@ -15,7 +15,11 @@
#endif
struct ahhdr {
+ __u8 nexthdr;
+ __u8 hdrlen;
+ __u16 reserved;
__u32 spi;
+ __u32 seq_no;
};
/* Returns 1 if the spi is matched by the range, 0 otherwise */
diff -Nru a/net/ipv4/netfilter/ipt_esp.c b/net/ipv4/netfilter/ipt_esp.c
--- a/net/ipv4/netfilter/ipt_esp.c Mon Jul 21 02:22:20 2003
+++ b/net/ipv4/netfilter/ipt_esp.c Mon Jul 21 02:22:20 2003
@@ -16,6 +16,7 @@
struct esphdr {
__u32 spi;
+ __u32 seq_no;
};
/* Returns 1 if the spi is matched by the range, 0 otherwise */
--
- Harald Welte <laforge@netfilter.org> http://www.netfilter.org/
============================================================================
"Fragmentation is like classful addressing -- an interesting early
architectural error that shows how much experimentation was going
on while IP was being designed." -- Paul Vixie
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
reply other threads:[~2003-08-02 13:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030802131839.GI6894@naboo \
--to=laforge@netfilter.org \
--cc=davem@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®