linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Florian Westphal <fw@strlen.de>,
	Daniel Borkmann <dborkman@redhat.com>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Zhiqiang Zhang <zhangzhiqiang.zhang@huawei.com>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 78/83] netfilter: conntrack: disable generic tracking for known protocols
Date: Mon, 27 Apr 2015 23:32:49 +0200	[thread overview]
Message-ID: <2fb11da9d9016f6c0a4fcb99b8ebd63495c79005.1430159990.git.jslaby@suse.cz> (raw)
In-Reply-To: <3426bb8de3a655aa6668e92ee92eb35f0db86582.1430159990.git.jslaby@suse.cz>
In-Reply-To: <cover.1430159990.git.jslaby@suse.cz>

From: Florian Westphal <fw@strlen.de>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

commit db29a9508a9246e77087c5531e45b2c88ec6988b upstream.

Given following iptables ruleset:

-P FORWARD DROP
-A FORWARD -m sctp --dport 9 -j ACCEPT
-A FORWARD -p tcp --dport 80 -j ACCEPT
-A FORWARD -p tcp -m conntrack -m state ESTABLISHED,RELATED -j ACCEPT

One would assume that this allows SCTP on port 9 and TCP on port 80.
Unfortunately, if the SCTP conntrack module is not loaded, this allows
*all* SCTP communication, to pass though, i.e. -p sctp -j ACCEPT,
which we think is a security issue.

This is because on the first SCTP packet on port 9, we create a dummy
"generic l4" conntrack entry without any port information (since
conntrack doesn't know how to extract this information).

All subsequent packets that are unknown will then be in established
state since they will fallback to proto_generic and will match the
'generic' entry.

Our originally proposed version [1] completely disabled generic protocol
tracking, but Jozsef suggests to not track protocols for which a more
suitable helper is available, hence we now mitigate the issue for in
tree known ct protocol helpers only, so that at least NAT and direction
information will still be preserved for others.

 [1] http://www.spinics.net/lists/netfilter-devel/msg33430.html

Joint work with Daniel Borkmann.

Fixes CVE-2014-8160.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Zhiqiang Zhang <zhangzhiqiang.zhang@huawei.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/netfilter/nf_conntrack_proto_generic.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
index d25f29377648..957c1db66652 100644
--- a/net/netfilter/nf_conntrack_proto_generic.c
+++ b/net/netfilter/nf_conntrack_proto_generic.c
@@ -14,6 +14,30 @@
 
 static unsigned int nf_ct_generic_timeout __read_mostly = 600*HZ;
 
+static bool nf_generic_should_process(u8 proto)
+{
+	switch (proto) {
+#ifdef CONFIG_NF_CT_PROTO_SCTP_MODULE
+	case IPPROTO_SCTP:
+		return false;
+#endif
+#ifdef CONFIG_NF_CT_PROTO_DCCP_MODULE
+	case IPPROTO_DCCP:
+		return false;
+#endif
+#ifdef CONFIG_NF_CT_PROTO_GRE_MODULE
+	case IPPROTO_GRE:
+		return false;
+#endif
+#ifdef CONFIG_NF_CT_PROTO_UDPLITE_MODULE
+	case IPPROTO_UDPLITE:
+		return false;
+#endif
+	default:
+		return true;
+	}
+}
+
 static inline struct nf_generic_net *generic_pernet(struct net *net)
 {
 	return &net->ct.nf_ct_proto.generic;
@@ -67,7 +91,7 @@ static int generic_packet(struct nf_conn *ct,
 static bool generic_new(struct nf_conn *ct, const struct sk_buff *skb,
 			unsigned int dataoff, unsigned int *timeouts)
 {
-	return true;
+	return nf_generic_should_process(nf_ct_protonum(ct));
 }
 
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
-- 
2.3.5


  parent reply	other threads:[~2015-04-27 21:34 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 21:31 [PATCH 3.12 00/83] 3.12.41-stable review Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 01/83] core, nfqueue, openvswitch: fix compilation warning Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 02/83] arm64: Use the reserved TTBR0 if context switching to the init_mm Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 03/83] powerpc/pseries: Little endian fixes for post mobility device tree update Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 04/83] net: ethernet: pcnet32: Setup the SRAM and NOUFLO on Am79C97{3, 5} Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 05/83] mfd: kempld-core: Fix callback return value check Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 06/83] x86/reboot: Remove the duplicate C6100 entry in the reboot quirks list Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 07/83] x86/reboot: Sort reboot DMI quirks by vendor Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 08/83] x86/reboot: Add reboot quirk for Certec BPC600 Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 09/83] n_tty: Merge .receive_buf() flavors Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 10/83] conditionally define U32_MAX Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 11/83] kernel.h: define u8, s8, u32, etc. limits Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 12/83] remove extra definitions of U32_MAX Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 13/83] ALSA: hda - Add one more node in the EAPD supporting candidate list Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 14/83] ALSA: usb - Creative USB X-Fi Pro SB1095 volume knob support Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 15/83] ALSA: hda/realtek - Make more stable to get pin sense for ALC283 Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 16/83] ALSA: hda - Fix headphone pin config for Lifebook T731 Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 17/83] ARC: SA_SIGINFO ucontext regs off-by-one Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 18/83] selinux: fix sel_write_enforce broken return value Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 19/83] tcp: Fix crash in TCP Fast Open Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 20/83] IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 21/83] iwlwifi: dvm: run INIT firmware again upon .start() Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 22/83] nbd: fix possible memory leak Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 23/83] mm/memory hotplug: postpone the reset of obsolete pgdat Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 24/83] sched: Fix RLIMIT_RTTIME when PI-boosting to RT Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 25/83] writeback: add missing INITIAL_JIFFIES init in global_update_bandwidth() Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 26/83] writeback: fix possible underflow in write bandwidth calculation Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 27/83] radeon: Do not directly dereference pointers to BIOS area Jiri Slaby
2015-04-27 21:31 ` [PATCH 3.12 28/83] USB: ftdi_sio: Added custom PID for Synapse Wireless product Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 29/83] USB: ftdi_sio: Use jtag quirk for SNAP Connect E10 Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 30/83] Defer processing of REQ_PREEMPT requests for blocked devices Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 31/83] iio: inv_mpu6050: Clear timestamps fifo while resetting hardware fifo Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 32/83] iio: imu: Use iio_trigger_get for indio_dev->trig assignment Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 33/83] dmaengine: omap-dma: Fix memory leak when terminating running transfer Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 34/83] x86/reboot: Add ASRock Q1900DC-ITX mainboard reboot quirk Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 35/83] can: flexcan: Deferred on Regulator return EPROBE_DEFER Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 36/83] usb: xhci: handle Config Error Change (CEC) in xhci driver Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 37/83] usb: xhci: apply XHCI_AVOID_BEI quirk to all Intel xHCI controllers Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 38/83] tty: serial: fsl_lpuart: clear receive flag on FIFO flush Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 39/83] n_tty: Fix read buffer overwrite when no newline Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 40/83] cifs: fix use-after-free bug in find_writable_file Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 41/83] be2iscsi: Fix kernel panic when device initialization fails Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 42/83] ocfs2: _really_ sync the right range Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 43/83] ioctx_alloc(): fix vma (and file) leak on failure Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 44/83] iscsi target: fix oops when adding reject pdu Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 45/83] sh_veu: v4l2_dev wasn't set Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 46/83] media: s5p-mfc: fix mmap support for 64bit arch Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 47/83] net: rds: use correct size for max unacked packets and bytes Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 48/83] net: llc: use correct size for sysctl timeout entries Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 49/83] IB/mlx4: Saturate RoCE port PMA counters in case of overflow Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 50/83] [media] drivers: media: usb: b2c2: use usb_*_coherent() instead of pci_*_consistent() in flexcop-usb.c Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 51/83] video: vgacon: Don't build on arm64 Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 52/83] tcp: prevent fetching dst twice in early demux code Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 53/83] ipv6: Don't reduce hop limit for an interface Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 54/83] tcp: fix FRTO undo on cumulative ACK of SACKed range Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 55/83] tcp: tcp_make_synack() should clear skb->tstamp Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 56/83] 8139cp: Call dev_kfree_skby_any instead of kfree_skb Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 57/83] 8139too: Call dev_kfree_skby_any instead of dev_kfree_skb Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 58/83] r8169: " Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 59/83] bonding: Call dev_kfree_skby_any instead of kfree_skb Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 60/83] bnx2: Call dev_kfree_skby_any instead of dev_kfree_skb Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 61/83] tg3: " Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 62/83] ixgb: " Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 63/83] benet: Call dev_kfree_skby_any instead of kfree_skb Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 64/83] crypto: testmgr - fix 3.12.40 regression Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 65/83] sb_edac: Fix erroneous bytes->gigabytes conversion Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 66/83] sb_edac: avoid INTERNAL ERROR message in EDAC with unspecified channel Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 67/83] cpufreq: fix a NULL pointer dereference in __cpufreq_governor() Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 68/83] libata: Blacklist queued TRIM on Samsung SSD 850 Pro Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 69/83] nick kvfree() from apparmor Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 70/83] KVM: remove redundant assignments in __kvm_set_memory_region Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 71/83] kvm: commonize allocation of the new memory slots Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 72/83] kvm: avoid page allocation failure in kvm_set_memory_region() Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 73/83] Input: sirfsoc-onkey - fix GPL v2 license string typo Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 74/83] Input: twl4030-pwrbutton - ensure a wakeup event is recorded Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 75/83] Bluetooth: ath3k: Add support of MCI 13d3:3408 bt device Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 76/83] Bluetooth: ath3k: Add support of AR3012 bluetooth 13d3:3423 device Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 77/83] Bluetooth: Add USB device 04ca:3010 as Atheros AR3012 Jiri Slaby
2015-04-27 21:32 ` Jiri Slaby [this message]
2015-04-27 21:32 ` [PATCH 3.12 79/83] KVM: x86: SYSENTER emulation is broken Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 80/83] mm: softdirty: unmapped addresses between VMAs are clean Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 81/83] proc/pagemap: walk page tables under pte lock Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 82/83] Input: elantech - fix crc_enabled for Fujitsu H730 Jiri Slaby
2015-04-27 21:32 ` [PATCH 3.12 83/83] Input: elantech - add more Fujtisu notebooks to force crc_enabled Jiri Slaby
2015-04-28  0:32 ` [PATCH 3.12 00/83] 3.12.41-stable review Shuah Khan
2015-04-30 12:11   ` Jiri Slaby
2015-04-28  1:43 ` Guenter Roeck

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=2fb11da9d9016f6c0a4fcb99b8ebd63495c79005.1430159990.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=dborkman@redhat.com \
    --cc=fw@strlen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=stable@vger.kernel.org \
    --cc=zhangzhiqiang.zhang@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).