stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Alexander Sverdlin <alexander.sverdlin@nokia.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Vlad Yasevich <vyasevich@gmail.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.1 21/56] sctp: Fix race between OOTB responce and route removal
Date: Wed,  8 Jul 2015 00:35:10 -0700	[thread overview]
Message-ID: <20150708073238.905656446@linuxfoundation.org> (raw)
In-Reply-To: <20150708073237.780280770@linuxfoundation.org>

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

------------------

From: Alexander Sverdlin <alexander.sverdlin@nokia.com>

[ Upstream commit 29c4afc4e98f4dc0ea9df22c631841f9c220b944 ]

There is NULL pointer dereference possible during statistics update if the route
used for OOTB responce is removed at unfortunate time. If the route exists when
we receive OOTB packet and we finally jump into sctp_packet_transmit() to send
ABORT, but in the meantime route is removed under our feet, we take "no_route"
path and try to update stats with IP_INC_STATS(sock_net(asoc->base.sk), ...).

But sctp_ootb_pkt_new() used to prepare responce packet doesn't call
sctp_transport_set_owner() and therefore there is no asoc associated with this
packet. Probably temporary asoc just for OOTB responces is overkill, so just
introduce a check like in all other places in sctp_packet_transmit(), where
"asoc" is dereferenced.

To reproduce this, one needs to
0. ensure that sctp module is loaded (otherwise ABORT is not generated)
1. remove default route on the machine
2. while true; do
     ip route del [interface-specific route]
     ip route add [interface-specific route]
   done
3. send enough OOTB packets (i.e. HB REQs) from another host to trigger ABORT
   responce

On x86_64 the crash looks like this:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
IP: [<ffffffffa05ec9ac>] sctp_packet_transmit+0x63c/0x730 [sctp]
PGD 0
Oops: 0000 [#1] PREEMPT SMP
Modules linked in: ...
CPU: 0 PID: 0 Comm: swapper/0 Tainted: G           O    4.0.5-1-ARCH #1
Hardware name: ...
task: ffffffff818124c0 ti: ffffffff81800000 task.ti: ffffffff81800000
RIP: 0010:[<ffffffffa05ec9ac>]  [<ffffffffa05ec9ac>] sctp_packet_transmit+0x63c/0x730 [sctp]
RSP: 0018:ffff880127c037b8  EFLAGS: 00010296
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00000015ff66b480
RDX: 00000015ff66b400 RSI: ffff880127c17200 RDI: ffff880123403700
RBP: ffff880127c03888 R08: 0000000000017200 R09: ffffffff814625af
R10: ffffea00047e4680 R11: 00000000ffffff80 R12: ffff8800b0d38a28
R13: ffff8800b0d38a28 R14: ffff8800b3e88000 R15: ffffffffa05f24e0
FS:  0000000000000000(0000) GS:ffff880127c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000000020 CR3: 00000000c855b000 CR4: 00000000000007f0
Stack:
 ffff880127c03910 ffff8800b0d38a28 ffffffff8189d240 ffff88011f91b400
 ffff880127c03828 ffffffffa05c94c5 0000000000000000 ffff8800baa1c520
 0000000000000000 0000000000000001 0000000000000000 0000000000000000
Call Trace:
 <IRQ>
 [<ffffffffa05c94c5>] ? sctp_sf_tabort_8_4_8.isra.20+0x85/0x140 [sctp]
 [<ffffffffa05d6b42>] ? sctp_transport_put+0x52/0x80 [sctp]
 [<ffffffffa05d0bfc>] sctp_do_sm+0xb8c/0x19a0 [sctp]
 [<ffffffff810b0e00>] ? trigger_load_balance+0x90/0x210
 [<ffffffff810e0329>] ? update_process_times+0x59/0x60
 [<ffffffff812c7a40>] ? timerqueue_add+0x60/0xb0
 [<ffffffff810e0549>] ? enqueue_hrtimer+0x29/0xa0
 [<ffffffff8101f599>] ? read_tsc+0x9/0x10
 [<ffffffff8116d4b5>] ? put_page+0x55/0x60
 [<ffffffff810ee1ad>] ? clockevents_program_event+0x6d/0x100
 [<ffffffff81462b68>] ? skb_free_head+0x58/0x80
 [<ffffffffa029a10b>] ? chksum_update+0x1b/0x27 [crc32c_generic]
 [<ffffffff81283f3e>] ? crypto_shash_update+0xce/0xf0
 [<ffffffffa05d3993>] sctp_endpoint_bh_rcv+0x113/0x280 [sctp]
 [<ffffffffa05dd4e6>] sctp_inq_push+0x46/0x60 [sctp]
 [<ffffffffa05ed7a0>] sctp_rcv+0x880/0x910 [sctp]
 [<ffffffffa05ecb50>] ? sctp_packet_transmit_chunk+0xb0/0xb0 [sctp]
 [<ffffffffa05ecb70>] ? sctp_csum_update+0x20/0x20 [sctp]
 [<ffffffff814b05a5>] ? ip_route_input_noref+0x235/0xd30
 [<ffffffff81051d6b>] ? ack_ioapic_level+0x7b/0x150
 [<ffffffff814b27be>] ip_local_deliver_finish+0xae/0x210
 [<ffffffff814b2e15>] ip_local_deliver+0x35/0x90
 [<ffffffff814b2a15>] ip_rcv_finish+0xf5/0x370
 [<ffffffff814b3128>] ip_rcv+0x2b8/0x3a0
 [<ffffffff81474193>] __netif_receive_skb_core+0x763/0xa50
 [<ffffffff81476c28>] __netif_receive_skb+0x18/0x60
 [<ffffffff81476cb0>] netif_receive_skb_internal+0x40/0xd0
 [<ffffffff814776c8>] napi_gro_receive+0xe8/0x120
 [<ffffffffa03946aa>] rtl8169_poll+0x2da/0x660 [r8169]
 [<ffffffff8147896a>] net_rx_action+0x21a/0x360
 [<ffffffff81078dc1>] __do_softirq+0xe1/0x2d0
 [<ffffffff8107912d>] irq_exit+0xad/0xb0
 [<ffffffff8157d158>] do_IRQ+0x58/0xf0
 [<ffffffff8157b06d>] common_interrupt+0x6d/0x6d
 <EOI>
 [<ffffffff810e1218>] ? hrtimer_start+0x18/0x20
 [<ffffffffa05d65f9>] ? sctp_transport_destroy_rcu+0x29/0x30 [sctp]
 [<ffffffff81020c50>] ? mwait_idle+0x60/0xa0
 [<ffffffff810216ef>] arch_cpu_idle+0xf/0x20
 [<ffffffff810b731c>] cpu_startup_entry+0x3ec/0x480
 [<ffffffff8156b365>] rest_init+0x85/0x90
 [<ffffffff818eb035>] start_kernel+0x48b/0x4ac
 [<ffffffff818ea120>] ? early_idt_handlers+0x120/0x120
 [<ffffffff818ea339>] x86_64_start_reservations+0x2a/0x2c
 [<ffffffff818ea49c>] x86_64_start_kernel+0x161/0x184
Code: 90 48 8b 80 b8 00 00 00 48 89 85 70 ff ff ff 48 83 bd 70 ff ff ff 00 0f 85 cd fa ff ff 48 89 df 31 db e8 18 63 e7 e0 48 8b 45 80 <48> 8b 40 20 48 8b 40 30 48 8b 80 68 01 00 00 65 48 ff 40 78 e9
RIP  [<ffffffffa05ec9ac>] sctp_packet_transmit+0x63c/0x730 [sctp]
 RSP <ffff880127c037b8>
CR2: 0000000000000020
---[ end trace 5aec7fd2dc983574 ]---
Kernel panic - not syncing: Fatal exception in interrupt
Kernel Offset: 0x0 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffff9fffffff)
drm_kms_helper: panic occurred, switching back to text console
---[ end Kernel panic - not syncing: Fatal exception in interrupt

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/sctp/output.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -599,7 +599,9 @@ out:
 	return err;
 no_route:
 	kfree_skb(nskb);
-	IP_INC_STATS(sock_net(asoc->base.sk), IPSTATS_MIB_OUTNOROUTES);
+
+	if (asoc)
+		IP_INC_STATS(sock_net(asoc->base.sk), IPSTATS_MIB_OUTNOROUTES);
 
 	/* FIXME: Returning the 'err' will effect all the associations
 	 * associated with a socket, although only one of the paths of the



  parent reply	other threads:[~2015-07-08  7:36 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08  7:34 [PATCH 4.1 00/56] 4.1.2-stable review Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 01/56] ARM: dts: sunxi: Adjust touchscreen compatible for sun5i and later Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 02/56] ARM: clk-imx6q: refine satas parent Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 03/56] KVM: nSVM: Check for NRIPS support before updating control field Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 04/56] can: fix loss of CAN frames in raw_rcv Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 05/56] sctp: fix ASCONF list handling Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 06/56] bridge: fix br_stp_set_bridge_priority race conditions Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 07/56] packet: read num_members once in packet_rcv_fanout() Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 08/56] packet: avoid out of bounds read in round robin fanout Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 09/56] neigh: do not modify unlinked entries Greg Kroah-Hartman
2015-07-08  7:34 ` [PATCH 4.1 10/56] mac80211: fix locking in update_vlan_tailroom_need_count() Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 11/56] mvneta: add forgotten initialization of autonegotiation bits Greg Kroah-Hartman
2015-07-08 17:10   ` Stas Sergeev
2015-07-08 17:36     ` Greg Kroah-Hartman
2015-07-08 18:36       ` Stas Sergeev
2015-07-08 19:36         ` Arnaud Ebalard
2015-07-08 20:15           ` Stas Sergeev
2015-07-08 21:31         ` Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 12/56] tcp: Do not call tcp_fastopen_reset_cipher from interrupt context Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 13/56] xen-netback: fix a BUG() during initialization Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 14/56] ip: report the original address of ICMP messages Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 15/56] net/mlx4_en: Release TX QP when destroying TX ring Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 16/56] net/mlx4_en: Wake TX queues only when theres enough room Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 17/56] net/mlx4_en: Fix wrong csum complete report when rxvlan offload is disabled Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 18/56] mlx4: Disable HA for SRIOV PF RoCE devices Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 19/56] net: phy: fix phy link up when limiting speed via device tree Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 20/56] bnx2x: fix lockdep splat Greg Kroah-Hartman
2015-07-08  7:35 ` Greg Kroah-Hartman [this message]
2015-07-08  7:35 ` [PATCH 4.1 22/56] amd-xgbe: Add the __GFP_NOWARN flag to Rx buffer allocation Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 23/56] net: mvneta: introduce compatible string "marvell, armada-xp-neta" Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 24/56] ARM: mvebu: update Ethernet compatible string for Armada XP Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 25/56] net: mvneta: disable IP checksum with jumbo frames for Armada 370 Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 26/56] usb: gadget: f_fs: add extra check before unregister_gadget_item Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 27/56] crypto: talitos - avoid memleak in talitos_alg_alloc() Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 28/56] Revert "crypto: talitos - convert to use be16_add_cpu()" Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 29/56] iommu/arm-smmu: Fix broken ATOS check Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 30/56] iommu/amd: Handle large pages correctly in free_pagetable Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 31/56] mmc: sdhci: fix low memory corruption Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 32/56] intel_pstate: set BYT MSR with wrmsrl_on_cpu() Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 33/56] selinux: fix setting of security labels on NFS Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 34/56] arm: KVM: force execution of HCPTR access on VM exit Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 35/56] ARM: kvm: psci: fix handling of unimplemented functions Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 36/56] ARM: tegra20: Store CPU "resettable" status in IRAM Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 37/56] ARM: mvebu: fix suspend to RAM on big-endian configurations Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 38/56] tick/idle/powerpc: Do not register idle states with CPUIDLE_FLAG_TIMER_STOP set in periodic mode Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 39/56] powerpc/perf: Fix book3s kernel to userspace backtraces Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 40/56] x86/PCI: Use host bridge _CRS info on systems with >32 bit addressing Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 41/56] x86/PCI: Use host bridge _CRS info on Foxconn K8M890-8237A Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 42/56] KVM: mips: use id_to_memslot correctly Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 43/56] MIPS: Fix KVM guest fixmap address Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 44/56] KVM: s390: fix external call injection without sigp interpretation Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 45/56] KVM: s390: clear floating interrupt bitmap and parameters Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 46/56] s390/bpf: Fix backward jumps Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 47/56] s390/kdump: fix REGSET_VX_LOW vector register ELF notes Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 48/56] KVM: s390: virtio-ccw: dont overwrite config space values Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 49/56] KVM: arm/arm64: vgic: Avoid injecting reserved IRQ numbers Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 52/56] fs: Fix S_NOSEC handling Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 53/56] fs/ufs: revert "ufs: fix deadlocks introduced by sb mutex merge" Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 54/56] fs/ufs: restore s_lock mutex Greg Kroah-Hartman
2015-07-08 16:28   ` Fabian Frederick
2015-07-08 17:32     ` Greg Kroah-Hartman
2015-07-08 21:32       ` Greg Kroah-Hartman
2015-07-09 14:37         ` Luis Henriques
2015-07-10 17:38           ` Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 55/56] vfs: Remove incorrect debugging WARN in prepend_path Greg Kroah-Hartman
2015-07-08  7:35 ` [PATCH 4.1 56/56] vfs: Ignore unlocked mounts in fs_fully_visible Greg Kroah-Hartman
2015-07-08 14:11 ` [PATCH 4.1 00/56] 4.1.2-stable review Guenter Roeck
2015-07-10 17:30   ` Greg Kroah-Hartman
2015-07-08 16:34 ` Shuah Khan
2015-07-10 17:30   ` Greg Kroah-Hartman
2015-07-09  4:57 ` Sudip Mukherjee
2015-07-10 17:31   ` Greg Kroah-Hartman
2015-07-10 16:08 ` Kevin Hilman
2015-07-10 17:33   ` Greg Kroah-Hartman

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=20150708073238.905656446@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.sverdlin@nokia.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=nhorman@tuxdriver.com \
    --cc=stable@vger.kernel.org \
    --cc=vyasevich@gmail.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).