From: Chris Wright <chrisw@sous-sol.org>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
Zwane Mwaikambo <zwane@arm.linux.org.uk>,
"Theodore Ts'o" <tytso@mit.edu>,
Randy Dunlap <rdunlap@xenotime.net>,
Dave Jones <davej@redhat.com>,
Chuck Wolber <chuckw@quantumlinux.com>,
Chris Wedgwood <reviews@ml.cw.f00f.org>,
Michael Krufky <mkrufky@linuxtv.org>,
Chuck Ebbert <cebbert@redhat.com>,
Domenico Andreoli <cavokz@gmail.com>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Patrick McHardy <kaber@trash.net>,
"David S. Miller" <davem@davemloft.net>,
Adrian Bunk <bunk@stusta.de>, Jorge Boncompte <jorge@dti2.net>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [patch 06/32] [NETFILTER]: {ip, nf}_nat_proto_gre: do not modify/corrupt GREv0 packets through NAT
Date: Fri, 08 Jun 2007 00:15:17 -0700 [thread overview]
Message-ID: <20070608071535.477108000@sous-sol.org> (raw)
In-Reply-To: 20070608071511.159309000@sous-sol.org
[-- Attachment #1: ip-nf-_nat_proto_gre-do-not-modify-corrupt-grev0-packets-through-nat.patch --]
[-- Type: text/plain, Size: 5362 bytes --]
-stable review patch. If anyone has any objections, please let us know.
---------------------
From: Jorge Boncompte <jorge@dti2.net>
While porting some changes of the 2.6.21-rc7 pptp/proto_gre conntrack
and nat modules to a 2.4.32 kernel I noticed that the gre_key function
returns a wrong pointer to the GRE key of a version 0 packet thus
corrupting the packet payload.
The intended behaviour for GREv0 packets is to act like
nf_conntrack_proto_generic/nf_nat_proto_unknown so I have ripped the
offending functions (not used anymore) and modified the
nf_nat_proto_gre modules to not touch version 0 (non PPTP) packets.
Signed-off-by: Jorge Boncompte <jorge@dti2.net>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
commit 244c67aee5750eb3a79c727d09c01a500e68bbbe
tree 29bbce944bba681886a6d58c0c6b7bca3858c0e1
parent 8d8b10482fffcb72b15515231bb942e2ad6395c9
author Jorge Boncompte <jorge@dti2.net> Thu, 03 May 2007 02:50:51 +0200
committer Patrick McHardy <kaber@trash.net> Thu, 03 May 2007 02:50:51 +0200
include/linux/netfilter/nf_conntrack_proto_gre.h | 18 ----------------
include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h | 19 -----------------
net/ipv4/netfilter/ip_nat_proto_gre.c | 20 +++++++-----------
net/ipv4/netfilter/nf_nat_proto_gre.c | 20 +++++++-----------
4 files changed, 16 insertions(+), 61 deletions(-)
--- linux-2.6.20.13.orig/include/linux/netfilter/nf_conntrack_proto_gre.h
+++ linux-2.6.20.13/include/linux/netfilter/nf_conntrack_proto_gre.h
@@ -87,24 +87,6 @@ int nf_ct_gre_keymap_add(struct nf_conn
/* delete keymap entries */
void nf_ct_gre_keymap_destroy(struct nf_conn *ct);
-/* get pointer to gre key, if present */
-static inline __be32 *gre_key(struct gre_hdr *greh)
-{
- if (!greh->key)
- return NULL;
- if (greh->csum || greh->routing)
- return (__be32 *)(greh+sizeof(*greh)+4);
- return (__be32 *)(greh+sizeof(*greh));
-}
-
-/* get pointer ot gre csum, if present */
-static inline __sum16 *gre_csum(struct gre_hdr *greh)
-{
- if (!greh->csum)
- return NULL;
- return (__sum16 *)(greh+sizeof(*greh));
-}
-
extern void nf_ct_gre_keymap_flush(void);
extern void nf_nat_need_gre(void);
--- linux-2.6.20.13.orig/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h
+++ linux-2.6.20.13/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h
@@ -90,25 +90,6 @@ int ip_ct_gre_keymap_add(struct ip_connt
/* delete keymap entries */
void ip_ct_gre_keymap_destroy(struct ip_conntrack *ct);
-
-/* get pointer to gre key, if present */
-static inline __be32 *gre_key(struct gre_hdr *greh)
-{
- if (!greh->key)
- return NULL;
- if (greh->csum || greh->routing)
- return (__be32 *) (greh+sizeof(*greh)+4);
- return (__be32 *) (greh+sizeof(*greh));
-}
-
-/* get pointer ot gre csum, if present */
-static inline __sum16 *gre_csum(struct gre_hdr *greh)
-{
- if (!greh->csum)
- return NULL;
- return (__sum16 *) (greh+sizeof(*greh));
-}
-
#endif /* __KERNEL__ */
#endif /* _CONNTRACK_PROTO_GRE_H */
--- linux-2.6.20.13.orig/net/ipv4/netfilter/ip_nat_proto_gre.c
+++ linux-2.6.20.13/net/ipv4/netfilter/ip_nat_proto_gre.c
@@ -70,6 +70,11 @@ gre_unique_tuple(struct ip_conntrack_tup
__be16 *keyptr;
unsigned int min, i, range_size;
+ /* If there is no master conntrack we are not PPTP,
+ do not change tuples */
+ if (!conntrack->master)
+ return 0;
+
if (maniptype == IP_NAT_MANIP_SRC)
keyptr = &tuple->src.u.gre.key;
else
@@ -122,18 +127,9 @@ gre_manip_pkt(struct sk_buff **pskb,
if (maniptype == IP_NAT_MANIP_DST) {
/* key manipulation is always dest */
switch (greh->version) {
- case 0:
- if (!greh->key) {
- DEBUGP("can't nat GRE w/o key\n");
- break;
- }
- if (greh->csum) {
- /* FIXME: Never tested this code... */
- nf_proto_csum_replace4(gre_csum(greh), *pskb,
- *(gre_key(greh)),
- tuple->dst.u.gre.key, 0);
- }
- *(gre_key(greh)) = tuple->dst.u.gre.key;
+ case GRE_VERSION_1701:
+ /* We do not currently NAT any GREv0 packets.
+ * Try to behave like "ip_nat_proto_unknown" */
break;
case GRE_VERSION_PPTP:
DEBUGP("call_id -> 0x%04x\n",
--- linux-2.6.20.13.orig/net/ipv4/netfilter/nf_nat_proto_gre.c
+++ linux-2.6.20.13/net/ipv4/netfilter/nf_nat_proto_gre.c
@@ -72,6 +72,11 @@ gre_unique_tuple(struct nf_conntrack_tup
__be16 *keyptr;
unsigned int min, i, range_size;
+ /* If there is no master conntrack we are not PPTP,
+ do not change tuples */
+ if (!conntrack->master)
+ return 0;
+
if (maniptype == IP_NAT_MANIP_SRC)
keyptr = &tuple->src.u.gre.key;
else
@@ -122,18 +127,9 @@ gre_manip_pkt(struct sk_buff **pskb, uns
if (maniptype != IP_NAT_MANIP_DST)
return 1;
switch (greh->version) {
- case 0:
- if (!greh->key) {
- DEBUGP("can't nat GRE w/o key\n");
- break;
- }
- if (greh->csum) {
- /* FIXME: Never tested this code... */
- nf_proto_csum_replace4(gre_csum(greh), *pskb,
- *(gre_key(greh)),
- tuple->dst.u.gre.key, 0);
- }
- *(gre_key(greh)) = tuple->dst.u.gre.key;
+ case GRE_VERSION_1701:
+ /* We do not currently NAT any GREv0 packets.
+ * Try to behave like "nf_nat_proto_unknown" */
break;
case GRE_VERSION_PPTP:
DEBUGP("call_id -> 0x%04x\n", ntohs(tuple->dst.u.gre.key));
--
next prev parent reply other threads:[~2007-06-08 7:29 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-08 7:15 [patch 00/32] 2.6.20-stable review Chris Wright
2007-06-08 7:15 ` [patch 01/32] pv6: track device renames in snmp6 Chris Wright
2007-06-08 7:15 ` [patch 02/32] oom: kill all threads that share mm with killed task Chris Wright
2007-06-08 7:15 ` [patch 03/32] x86-64: Always flush all pages in change_page_attr Chris Wright
2007-06-08 7:15 ` [patch 04/32] smc911x: fix compilation breakage wjen debug is on Chris Wright
2007-06-08 7:15 ` [patch 05/32] iop13xx: fix i/o address translation Chris Wright
2007-06-08 7:15 ` Chris Wright [this message]
2007-06-08 7:15 ` [patch 07/32] sata_via: add missing PM hooks Chris Wright
2007-06-08 7:15 ` [patch 08/32] driver-core: dont free devt_attr till the device is released Chris Wright
2007-06-08 7:15 ` [patch 09/32] JFS: Fix race waking up jfsIO kernel thread Chris Wright
2007-06-08 7:15 ` [patch 10/32] CRYPTO: api: Read module pointer before freeing algorithm Chris Wright
2007-06-08 7:15 ` [patch 11/32] fuse: fix mknod of regular file Chris Wright
2007-06-08 7:15 ` [patch 12/32] acpi-thermal: fix mod_timer() interval Chris Wright
2007-06-08 7:15 ` [patch 13/32] ALSA: usb-audio: explicitly match Logitech QuickCam Chris Wright
2007-06-08 7:15 ` [patch 14/32] s390: Fix TCP/UDP pseudo header checksum computation Chris Wright
2007-06-08 7:15 ` [patch 15/32] s390: page_mkclean data corruption Chris Wright
2007-06-08 7:15 ` [patch 16/32] V4L/DVB (5593): Budget-ci: Fix tuning for TDM 1316 (160..200 MHz) Chris Wright
2007-06-08 7:15 ` [patch 17/32] kbuild: fixdep segfault on pathological string-o-death Chris Wright
2007-06-08 7:15 ` [patch 18/32] ntfs_init_locked_inode(): fix array indexing Chris Wright
2007-06-08 7:15 ` [patch 19/32] ICMP: Fix icmp_errors_use_inbound_ifaddr sysctl Chris Wright
2007-06-08 7:15 ` [patch 20/32] NET: parse ip:port strings correctly in in4_pton Chris Wright
2007-06-08 7:15 ` [patch 21/32] IPSEC: Fix panic when using inter address familiy IPsec on loopback Chris Wright
2007-06-08 7:15 ` [patch 22/32] NET: Fix BMSR_100{HALF,FULL}2 defines in linux/mii.h Chris Wright
2007-06-08 7:15 ` [patch 23/32] IPV4: Correct rp_filter help text Chris Wright
2007-06-09 1:20 ` Herbert Xu
2007-06-09 1:22 ` Herbert Xu
2007-06-08 7:15 ` [patch 24/32] SPARC: Linux always started with 9600 8N1 Chris Wright
2007-06-08 7:15 ` [patch 25/32] NET: "wrong timeout value" in sk_wait_data() v2 Chris Wright
2007-06-08 7:15 ` [patch 26/32] SPARC64: Fix two bugs wrt. kernel 4MB TSB Chris Wright
2007-06-08 7:15 ` [patch 27/32] SPARC64: Fix _PAGE_EXEC_4U check in sun4u I-TLB miss handler Chris Wright
2007-06-08 7:15 ` [patch 28/32] TCP: Use default 32768-61000 outgoing port range in all cases Chris Wright
2007-06-08 7:15 ` [patch 29/32] NET: Fix race condition about network device name allocation Chris Wright
2007-06-08 7:15 ` [patch 30/32] Fix AF_UNIX OOPS Chris Wright
2007-06-08 7:15 ` [patch 31/32] IPV6 ROUTE: No longer handle ::/0 specially Chris Wright
2007-06-08 7:15 ` [patch 32/32] SPARC64: Dont be picky about virtual-dma values on sun4v Chris Wright
2007-06-08 7:29 ` [stable] [patch 00/32] 2.6.20-stable review Chris Wright
2007-06-08 16:51 ` Chris Wright
2007-06-08 12:21 ` Fortier,Vincent [Montreal]
2007-06-08 15:45 ` Chris Wright
2007-06-08 20:56 ` Chuck Ebbert
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=20070608071535.477108000@sous-sol.org \
--to=chrisw@sous-sol.org \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bunk@stusta.de \
--cc=cavokz@gmail.com \
--cc=cebbert@redhat.com \
--cc=chuckw@quantumlinux.com \
--cc=davej@redhat.com \
--cc=davem@davemloft.net \
--cc=gregkh@suse.de \
--cc=jmforbes@linuxtx.org \
--cc=jorge@dti2.net \
--cc=kaber@trash.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mkrufky@linuxtv.org \
--cc=rdunlap@xenotime.net \
--cc=reviews@ml.cw.f00f.org \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=zwane@arm.linux.org.uk \
/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