Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1582772

[PATCH 4.9 23/32] sit: fix a double free on error path

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.9 23/32] sit: fix a double free on error path
Date 2017-02-16 19:10 +0100
Message-ID <tbyFb-1Cv-1@gated-at.bofh.it> (permalink)
References <tbyvw-1iO-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

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

From: WANG Cong <xiyou.wangcong@gmail.com>


[ Upstream commit d7426c69a1942b2b9b709bf66b944ff09f561484 ]

Dmitry reported a double free in sit_init_net():

  kernel BUG at mm/percpu.c:689!
  invalid opcode: 0000 [#1] SMP KASAN
  Dumping ftrace buffer:
     (ftrace buffer empty)
  Modules linked in:
  CPU: 0 PID: 15692 Comm: syz-executor1 Not tainted 4.10.0-rc6-next-20170206 #1
  Hardware name: Google Google Compute Engine/Google Compute Engine,
  BIOS Google 01/01/2011
  task: ffff8801c9cc27c0 task.stack: ffff88017d1d8000
  RIP: 0010:pcpu_free_area+0x68b/0x810 mm/percpu.c:689
  RSP: 0018:ffff88017d1df488 EFLAGS: 00010046
  RAX: 0000000000010000 RBX: 00000000000007c0 RCX: ffffc90002829000
  RDX: 0000000000010000 RSI: ffffffff81940efb RDI: ffff8801db841d94
  RBP: ffff88017d1df590 R08: dffffc0000000000 R09: 1ffffffff0bb3bdd
  R10: dffffc0000000000 R11: 00000000000135dd R12: ffff8801db841d80
  R13: 0000000000038e40 R14: 00000000000007c0 R15: 00000000000007c0
  FS:  00007f6ea608f700(0000) GS:ffff8801dbe00000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 000000002000aff8 CR3: 00000001c8d44000 CR4: 00000000001426f0
  DR0: 0000000020000000 DR1: 0000000020000000 DR2: 0000000000000000
  DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
  Call Trace:
   free_percpu+0x212/0x520 mm/percpu.c:1264
   ipip6_dev_free+0x43/0x60 net/ipv6/sit.c:1335
   sit_init_net+0x3cb/0xa10 net/ipv6/sit.c:1831
   ops_init+0x10a/0x530 net/core/net_namespace.c:115
   setup_net+0x2ed/0x690 net/core/net_namespace.c:291
   copy_net_ns+0x26c/0x530 net/core/net_namespace.c:396
   create_new_namespaces+0x409/0x860 kernel/nsproxy.c:106
   unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:205
   SYSC_unshare kernel/fork.c:2281 [inline]
   SyS_unshare+0x64e/0xfc0 kernel/fork.c:2231
   entry_SYSCALL_64_fastpath+0x1f/0xc2

This is because when tunnel->dst_cache init fails, we free dev->tstats
once in ipip6_tunnel_init() and twice in sit_init_net(). This looks
redundant but its ndo_uinit() does not seem enough to clean up everything
here. So avoid this by setting dev->tstats to NULL after the first free,
at least for -net.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv6/sit.c |    1 +
 1 file changed, 1 insertion(+)

--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1390,6 +1390,7 @@ static int ipip6_tunnel_init(struct net_
 	err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL);
 	if (err) {
 		free_percpu(dev->tstats);
+		dev->tstats = NULL;
 		return err;
 	}
 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.9 00/32] 4.9.11-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 08/32] net: use a work queue to defer net_disable_timestamp() work Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 27/32] net: dsa: Do not destroy invalid network devices Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 24/32] net: introduce device min_header_len Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 17/32] rtl8150: Use heap buffers for all register access Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 21/32] sctp: avoid BUG_ON on sctp_wait_for_sndbuf Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 04/32] ipv6: fix ip6_tnl_parse_tlv_enc_lim() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 07/32] stmmac: Discard masked flags in interrupt status register Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 05/32] ipv6: pointer math error in ip6_tnl_parse_tlv_enc_lim() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 32/32] net/mlx5: Dont unlock fte while still using it Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 09/32] ipv4: keep skb->dst around in presence of IP options Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 29/32] mld: do not remove mld souce list info when set link down Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 06/32] tcp: fix 0 divide in __tcp_select_window() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:00 +0100
  [PATCH 4.9 23/32] sit: fix a double free on error path Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 03/32] net/sched: matchall: Fix configuration race Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 19/32] catc: Use heap buffer for memory size test Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 22/32] lwtunnel: valid encap attr check should return 0 when lwtunnel is disabled Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 11/32] ip6_gre: fix ip6gre_err() invalid reads Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 15/32] macvtap: read vnet_hdr_size once Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 20/32] mlx4: Invoke softirqs after napi_reschedule Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 14/32] tun: read vnet_hdr_sz once Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 13/32] tcp: avoid infinite loop in tcp_splice_read() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 18/32] catc: Combine failure cleanup code in catc_probe() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 02/32] net/mlx5e: Fix update of hash function/key via ethtool Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 12/32] ipv6: tcp: add a missing tcp_v6_restore_cb() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 28/32] l2tp: do not use udp_ioctl() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 25/32] packet: round up linear to header len Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 10/32] netlabel: out of bound access in cipso_v4_validate() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  [PATCH 4.9 01/32] can: Fix kernel panic at security_sock_rcv_skb Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-16 19:10 +0100
  Re: [PATCH 4.9 00/32] 4.9.11-stable review Guenter Roeck <linux@roeck-us.net> - 2017-02-17 11:40 +0100
    Re: [PATCH 4.9 00/32] 4.9.11-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-17 19:20 +0100
  Re: [PATCH 4.9 00/32] 4.9.11-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-18 00:50 +0100
    Re: [PATCH 4.9 00/32] 4.9.11-stable review Kevin Hilman <khilman@baylibre.com> - 2017-02-20 23:40 +0100

csiph-web