From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
kernel-team@lists.ubuntu.com
Cc: Holger Eitzenberger <holger@eitzenberger.org>,
"David S. Miller" <davem@davemloft.net>,
Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 3.8 120/124] net: Fix memory leak if TPROXY used with TCP early demux
Date: Mon, 10 Feb 2014 11:41:00 -0800 [thread overview]
Message-ID: <1392061264-28124-121-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1392061264-28124-1-git-send-email-kamal@canonical.com>
3.8.13.18 -stable review patch. If anyone has any objections, please let me know.
------------------
From: Holger Eitzenberger <holger@eitzenberger.org>
[ Upstream commit a452ce345d63ddf92cd101e4196569f8718ad319 ]
I see a memory leak when using a transparent HTTP proxy using TPROXY
together with TCP early demux and Kernel v3.8.13.15 (Ubuntu stable):
unreferenced object 0xffff88008cba4a40 (size 1696):
comm "softirq", pid 0, jiffies 4294944115 (age 8907.520s)
hex dump (first 32 bytes):
0a e0 20 6a 40 04 1b 37 92 be 32 e2 e8 b4 00 00 .. j@..7..2.....
02 00 07 01 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff810b710a>] kmem_cache_alloc+0xad/0xb9
[<ffffffff81270185>] sk_prot_alloc+0x29/0xc5
[<ffffffff812702cf>] sk_clone_lock+0x14/0x283
[<ffffffff812aaf3a>] inet_csk_clone_lock+0xf/0x7b
[<ffffffff8129a893>] netlink_broadcast+0x14/0x16
[<ffffffff812c1573>] tcp_create_openreq_child+0x1b/0x4c3
[<ffffffff812c033e>] tcp_v4_syn_recv_sock+0x38/0x25d
[<ffffffff812c13e4>] tcp_check_req+0x25c/0x3d0
[<ffffffff812bf87a>] tcp_v4_do_rcv+0x287/0x40e
[<ffffffff812a08a7>] ip_route_input_noref+0x843/0xa55
[<ffffffff812bfeca>] tcp_v4_rcv+0x4c9/0x725
[<ffffffff812a26f4>] ip_local_deliver_finish+0xe9/0x154
[<ffffffff8127a927>] __netif_receive_skb+0x4b2/0x514
[<ffffffff8127aa77>] process_backlog+0xee/0x1c5
[<ffffffff8127c949>] net_rx_action+0xa7/0x200
[<ffffffff81209d86>] add_interrupt_randomness+0x39/0x157
But there are many more, resulting in the machine going OOM after some
days.
>From looking at the TPROXY code, and with help from Florian, I see
that the memory leak is introduced in tcp_v4_early_demux():
void tcp_v4_early_demux(struct sk_buff *skb)
{
/* ... */
iph = ip_hdr(skb);
th = tcp_hdr(skb);
if (th->doff < sizeof(struct tcphdr) / 4)
return;
sk = __inet_lookup_established(dev_net(skb->dev), &tcp_hashinfo,
iph->saddr, th->source,
iph->daddr, ntohs(th->dest),
skb->skb_iif);
if (sk) {
skb->sk = sk;
where the socket is assigned unconditionally to skb->sk, also bumping
the refcnt on it. This is problematic, because in our case the skb
has already a socket assigned in the TPROXY target. This then results
in the leak I see.
The very same issue seems to be with IPv6, but haven't tested.
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
net/ipv4/ip_input.c | 2 +-
net/ipv6/ip6_input.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index e1e5a6a..9bf55b6 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -318,7 +318,7 @@ static int ip_rcv_finish(struct sk_buff *skb)
const struct iphdr *iph = ip_hdr(skb);
struct rtable *rt;
- if (sysctl_ip_early_demux && !skb_dst(skb)) {
+ if (sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) {
const struct net_protocol *ipprot;
int protocol = iph->protocol;
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 5345300..8b7f50c 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -49,7 +49,7 @@
int ip6_rcv_finish(struct sk_buff *skb)
{
- if (sysctl_ip_early_demux && !skb_dst(skb)) {
+ if (sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) {
const struct inet6_protocol *ipprot;
ipprot = rcu_dereference(inet6_protos[ipv6_hdr(skb)->nexthdr]);
--
1.8.3.2
next prev parent reply other threads:[~2014-02-10 19:41 UTC|newest]
Thread overview: 126+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-10 19:39 [3.8.y.z extended stable] Linux 3.8.13.18 stable review Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 001/124] KVM: s390: kvm/sigp.c: fix memory leakage Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 002/124] KVM: s390: Always store status during SIGP STOP_AND_STORE_STATUS Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 003/124] KVM: s390: fix diagnose code extraction Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 004/124] rtlwifi: rtl8192cu: Fix W=1 build warning Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 005/124] rtlwifi: rtl8192cu: Add new firmware Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 006/124] rtlwifi: Set the link state Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 007/124] rtlwifi: rtl8192cu: Fix duplicate if test Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 008/124] rtlwifi: rtl8192cu: Fix some code in RF handling Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 009/124] NFSv4: OPEN must handle the NFS4ERR_IO return code correctly Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 010/124] parport: parport_pc: remove double PCI ID for NetMos Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 011/124] staging: vt6656: [BUG] BBvUpdatePreEDThreshold Always set sensitivity on bScanning Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 012/124] [SCSI] bfa: Chinook quad port 16G FC HBA claim issue Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 013/124] usb: option: add new zte 3g modem pids to option driver Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 014/124] [media] dib8000: make 32 bits read atomic Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 015/124] serial: add support for 200 v3 series Titan card Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 016/124] usb: xhci: Check for XHCI_PLAT in xhci_cleanup_msix() Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 017/124] [media] anysee: fix non-working E30 Combo Plus DVB-T Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 018/124] x86/efi: Fix off-by-one bug in EFI Boot Services reservation Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 019/124] perf kvm: Fix kvm report without guestmount Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 020/124] rtc-cmos: Add an alarm disable quirk Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 021/124] slub: Fix calculation of cpu slabs Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 022/124] mtd: mxc_nand: remove duplicated ecc_stats counting Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 023/124] xen/pvhvm: If xen_platform_pci=0 is set don't blow up (v4) Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 024/124] USB: pl2303: fix data corruption on termios updates Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 025/124] USB: serial: add support for iBall 3.5G connect usb modem Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 026/124] USB: Nokia 502 is an unusual device Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 027/124] USB: cypress_m8: fix ring-indicator detection and reporting Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 028/124] ALSA: rme9652: fix a missing comma in channel_map_9636_ds[] Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 029/124] SUNRPC: don't map EKEYEXPIRED to EACCES in call_refreshresult Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 030/124] sunrpc: Fix infinite loop in RPC state machine Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 031/124] tpm/tpm_ppi: Do not compare strcmp(a,b) == -1 Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 032/124] dm thin: initialize dm_thin_new_mapping returned by get_next_mapping Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 033/124] dm thin: fix discard support to a previously shared block Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 034/124] dm thin: fix set_pool_mode exposed pool operation races Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 035/124] SELinux: Fix memory leak upon loading policy Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 036/124] drm/radeon: warn users when hw_i2c is enabled (v2) Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 037/124] USB: fix race between hub_disconnect and recursively_mark_NOTATTACHED Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 038/124] ext4: avoid clearing beyond i_blocks when truncating an inline data file Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 039/124] USB: ftdi_sio: added CS5 quirk for broken smartcard readers Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 040/124] dm: wait until embedded kobject is released before destroying a device Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 041/124] dm space map common: make sure new space is used during extend Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 042/124] ASoC: adau1701: Fix ADAU1701_SEROCTL_WORD_LEN_16 constant Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 043/124] radeon/pm: Guard access to rdev->pm.power_state array Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 044/124] drm/radeon: skip colorbuffer checking if COLOR_INFO.FORMAT is set to INVALID Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 045/124] staging: r8712u: Set device type to wlan Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 046/124] ALSA: Enable CONFIG_ZONE_DMA for smaller PCI DMA masks Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 047/124] [media] media: s5p_mfc: remove s5p_mfc_get_node_type() function Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 048/124] mmc: atmel-mci: fix timeout errors in SDIO mode when using DMA Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 049/124] ftrace: Check module functions being traced on reload Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 050/124] ftrace: Fix function graph with loading of modules Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 051/124] ftrace: Use schedule_on_each_cpu() as a heavy synchronize_sched() Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 052/124] ftrace: Fix synchronization location disabling and freeing ftrace_ops Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 053/124] rtlwifi: rtl8192cu: Add new device ID Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 054/124] mwifiex: add missing endian conversion for fw_tsf Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 055/124] b43: Fix lockdep splat Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 056/124] b43: Fix unload oops if firmware is not available Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 057/124] b43legacy: " Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 058/124] nfs4.1: properly handle ENOTSUP in SECINFO_NO_NAME Kamal Mostafa
2014-02-10 19:39 ` [PATCH 3.8 059/124] usb: ehci: add freescale imx28 special write register method Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 060/124] audit: reset audit backlog wait time after error recovery Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 061/124] audit: correct a type mismatch in audit_syscall_exit() Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 062/124] xtensa: xtfpga: fix definitions of platform devices Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 063/124] dm sysfs: fix a module unload race Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 064/124] KVM: x86: limit PIT timer frequency Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 065/124] ata: sata_mv: introduce compatible string "marvell, armada-370-sata" Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 066/124] ata: sata_mv: fix disk hotplug for Armada 370/XP SoCs Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 067/124] arm: mvebu: fix length of SATA registers area in .dtsi Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 068/124] ARM: mvebu: update the SATA compatible string for Armada 370/XP Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 069/124] md/raid5: fix long-standing problem with bitmap handling on write failure Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 070/124] x86: Add check for number of available vectors before CPU down Kamal Mostafa
[not found] ` <52F973E0.7030400@redhat.com>
2014-02-11 22:29 ` Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 071/124] libata: disable LPM for some WD SATA-I devices Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 072/124] mmc: sdhci: fix lockdep error in tuning routine Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 073/124] turbostat: Don't put unprocessed uapi headers in the include path Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 074/124] turbostat: Use GCC's CPUID functions to support PIC Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 075/124] drm/radeon: disable ss on DP for DCE3.x Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 076/124] nfs4: fix discover_server_trunking use after free Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 077/124] drm/radeon: fix surface sync in fence on cayman (v2) Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 078/124] drm/radeon: set the full cache bit for fences on r7xx+ Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 079/124] mfd: max77686: Fix regmap resource leak on driver remove Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 080/124] hp_accel: Add a new PnP ID HPQ6007 for new HP laptops Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 081/124] ASoC: wm5110: Extend SYSCLK patch file for rev D Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 082/124] intel-iommu: fix off-by-one in pagetable freeing Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 083/124] arch/sh/kernel/kgdb.c: add missing #include <linux/sched.h> Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 084/124] fuse: fix pipe_buf_operations Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 085/124] drm/cirrus: correct register values for 16bpp Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 086/124] IB/qib: Fix QP check when looping back to/from QP1 Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 087/124] ore: Fix wrong math in allocation of per device BIO Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 088/124] drm/i915: VLV2 - Fix hotplug detect bits Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 089/124] b43: fix the wrong assignment of status.freq in b43_rx() Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 090/124] rtc: max8907: weekday encoding fixes Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 091/124] vfs: Is mounted should be testing mnt_ns for NULL or error Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 092/124] Btrfs: handle EAGAIN case properly in btrfs_drop_snapshot() Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 093/124] btrfs: restrict snapshotting to own subvolumes Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 094/124] ACPI / init: Flag use of ACPI and ACPI idioms for power supplies to regulator API Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 095/124] drm/ast: do not attempt to acquire a reservation while in an interrupt handler Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 096/124] drm/cirrus: " Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 097/124] drm/mgag200: " Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 098/124] drm: ast,cirrus,mgag200: use drm_can_sleep Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 099/124] powerpc: Make sure "cache" directory is removed when offlining cpu Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 100/124] drm/radeon/DCE4+: clear bios scratch dpms bit (v2) Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 101/124] mm/page-writeback.c: fix dirty_balance_reserve subtraction from dirtyable memory Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 102/124] mm/page-writeback.c: do not count anon pages as " Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 103/124] mm: numa: initialise numa balancing after jump label initialisation Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 104/124] target/iscsi: Fix network portal creation race Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 105/124] mm/mempolicy.c: fix mempolicy printing in numa_maps Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 106/124] mm, oom: base root bonus on current usage Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 107/124] alpha: fix broken network checksum Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 108/124] hpfs: remember free space Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 109/124] drm/nouveau/bios: fix offset calculation for BMPv1 bioses Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 110/124] e752x_edac: Fix pci_dev usage count Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 111/124] bnx2x: fix DMA unmapping of TSO split BDs Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 112/124] inet_diag: fix inet_diag_dump_icsk() timewait socket state logic Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 113/124] ieee802154: Fix memory leak in ieee802154_add_iface() Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 114/124] net: avoid reference counter overflows on fib_rules in multicast forwarding Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 115/124] net,via-rhine: Fix tx_timeout handling Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 116/124] tcp: metrics: Avoid duplicate entries with the same destination-IP Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 117/124] bpf: do not use reciprocal divide Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 118/124] s390/bpf,jit: fix 32 bit divisions, use unsigned divide instructions Kamal Mostafa
2014-02-10 19:40 ` [PATCH 3.8 119/124] fib_frontend: fix possible NULL pointer dereference Kamal Mostafa
2014-02-10 19:41 ` Kamal Mostafa [this message]
2014-02-10 19:41 ` [PATCH 3.8 121/124] xen-netfront: fix resource leak in netfront Kamal Mostafa
2014-02-10 19:41 ` [PATCH 3.8 122/124] sit: fix double free of fb_tunnel_dev on exit Kamal Mostafa
2014-02-10 19:41 ` [PATCH 3.8 123/124] Revert "ip6tnl: fix use after free of fb_tnl_dev" Kamal Mostafa
2014-02-10 19:41 ` [PATCH 3.8 124/124] ip6tnl: fix double free of fb_tnl_dev on exit Kamal Mostafa
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=1392061264-28124-121-git-send-email-kamal@canonical.com \
--to=kamal@canonical.com \
--cc=davem@davemloft.net \
--cc=holger@eitzenberger.org \
--cc=kernel-team@lists.ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.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