1. 13 Jul, 2013 10 commits
  2. 03 Jul, 2013 13 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.4.52 · ad7d5b07
      Greg Kroah-Hartman authored
      ad7d5b07
    • Peter Zijlstra's avatar
      perf: Fix mmap() accounting hole · 703197b6
      Peter Zijlstra authored
      commit 9bb5d40c upstream.
      
      Vince's fuzzer once again found holes. This time it spotted a leak in
      the locked page accounting.
      
      When an event had redirected output and its close() was the last
      reference to the buffer we didn't have a vm context to undo accounting.
      
      Change the code to destroy the buffer on the last munmap() and detach
      all redirected events at that time. This provides us the right context
      to undo the vm accounting.
      
      [Backporting for 3.4-stable.
      VM_RESERVED flag was replaced with pair 'VM_DONTEXPAND | VM_DONTDUMP' in
      314e51b9 since 3.7.0-rc1, and 314e51b9 comes from a big patchset, we didn't
      backport the patchset, so I restored 'VM_DNOTEXPAND | VM_DONTDUMP' as before:
      -	vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND | VM_DONTDUMP;
      +	vma->vm_flags |= VM_DONTCOPY | VM_RESERVED;
       -- zliu]
      Reported-and-tested-by: default avatarVince Weaver <vincent.weaver@maine.edu>
      Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20130604084421.GI8923@twins.programming.kicks-ass.net
      Cc: <stable@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarZhouping Liu <zliu@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      703197b6
    • Peter Zijlstra's avatar
      perf: Fix perf mmap bugs · 535fad87
      Peter Zijlstra authored
      commit 26cb63ad upstream.
      
      Vince reported a problem found by his perf specific trinity
      fuzzer.
      
      Al noticed 2 problems with perf's mmap():
      
       - it has issues against fork() since we use vma->vm_mm for accounting.
       - it has an rb refcount leak on double mmap().
      
      We fix the issues against fork() by using VM_DONTCOPY; I don't
      think there's code out there that uses this; we didn't hear
      about weird accounting problems/crashes. If we do need this to
      work, the previously proposed VM_PINNED could make this work.
      
      Aside from the rb reference leak spotted by Al, Vince's example
      prog was indeed doing a double mmap() through the use of
      perf_event_set_output().
      
      This exposes another problem, since we now have 2 events with
      one buffer, the accounting gets screwy because we account per
      event. Fix this by making the buffer responsible for its own
      accounting.
      
      [Backporting for 3.4-stable.
      VM_RESERVED flag was replaced with pair 'VM_DONTEXPAND | VM_DONTDUMP' in
      314e51b9 since 3.7.0-rc1, and 314e51b9 comes from a big patchset, we didn't
      backport the patchset, so I restored 'VM_DNOTEXPAND | VM_DONTDUMP' as before:
      -       vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND | VM_DONTDUMP;
      +       vma->vm_flags |= VM_DONTCOPY | VM_RESERVED;
       -- zliu]
      Reported-by: default avatarVince Weaver <vincent.weaver@maine.edu>
      Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
      Link: http://lkml.kernel.org/r/20130528085548.GA12193@twins.programming.kicks-ass.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarZhouping Liu <zliu@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      535fad87
    • Liang Li's avatar
      pch_uart: fix a deadlock when pch_uart as console · 5d2a2c71
      Liang Li authored
      commit 384e301e upstream.
      
      When we use pch_uart as system console like 'console=ttyPCH0,115200',
      then 'send break' to it. We'll encounter the deadlock on a cpu/core,
      with interrupts disabled on the core. When we happen to have all irqs
      affinity to cpu0 then the deadlock on cpu0 actually deadlock whole
      system.
      
      In pch_uart_interrupt, we have spin_lock_irqsave(&priv->lock, flags)
      then call pch_uart_err_ir when break is received. Then the call to
      dev_err would actually call to pch_console_write then we'll run into
      another spin_lock(&priv->lock), with interrupts disabled.
      
      So in the call sequence lead by pch_uart_interrupt, we should be
      carefully to call functions that will 'print message to console' only
      in case the uart port is not being used as serial console.
      Signed-off-by: default avatarLiang Li <liang.li@windriver.com>
      Cc: Yijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5d2a2c71
    • Artem Bityutskiy's avatar
      UBIFS: fix a horrid bug · 4e3010bf
      Artem Bityutskiy authored
      commit 605c912b upstream.
      
      Al Viro pointed me to the fact that '->readdir()' and '->llseek()' have no
      mutual exclusion, which means the 'ubifs_dir_llseek()' can be run while we are
      in the middle of 'ubifs_readdir()'.
      
      This means that 'file->private_data' can be freed while 'ubifs_readdir()' uses
      it, and this is a very bad bug: not only 'ubifs_readdir()' can return garbage,
      but this may corrupt memory and lead to all kinds of problems like crashes an
      security holes.
      
      This patch fixes the problem by using the 'file->f_version' field, which
      '->llseek()' always unconditionally sets to zero. We set it to 1 in
      'ubifs_readdir()' and whenever we detect that it became 0, we know there was a
      seek and it is time to clear the state saved in 'file->private_data'.
      
      I tested this patch by writing a user-space program which runds readdir and
      seek in parallell. I could easily crash the kernel without these patches, but
      could not crash it with these patches.
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e3010bf
    • Artem Bityutskiy's avatar
      UBIFS: prepare to fix a horrid bug · eafde0bc
      Artem Bityutskiy authored
      commit 33f1a63a upstream.
      
      Al Viro pointed me to the fact that '->readdir()' and '->llseek()' have no
      mutual exclusion, which means the 'ubifs_dir_llseek()' can be run while we are
      in the middle of 'ubifs_readdir()'.
      
      First of all, this means that 'file->private_data' can be freed while
      'ubifs_readdir()' uses it.  But this particular patch does not fix the problem.
      This patch is only a preparation, and the fix will follow next.
      
      In this patch we make 'ubifs_readdir()' stop using 'file->f_pos' directly,
      because 'file->f_pos' can be changed by '->llseek()' at any point. This may
      lead 'ubifs_readdir()' to returning inconsistent data: directory entry names
      may correspond to incorrect file positions.
      
      So here we introduce a local variable 'pos', read 'file->f_pose' once at very
      the beginning, and then stick to 'pos'. The result of this is that when
      'ubifs_dir_llseek()' changes 'file->f_pos' while we are in the middle of
      'ubifs_readdir()', the latter "wins".
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eafde0bc
    • Stephane Eranian's avatar
      perf: Disable monitoring on setuid processes for regular users · f57f135a
      Stephane Eranian authored
      commit 2976b10f upstream.
      
      There was a a bug in setup_new_exec(), whereby
      the test to disabled perf monitoring was not
      correct because the new credentials for the
      process were not yet committed and therefore
      the get_dumpable() test was never firing.
      
      The patch fixes the problem by moving the
      perf_event test until after the credentials
      are committed.
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Tested-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f57f135a
    • Zefan Li's avatar
      dlci: validate the net device in dlci_del() · 7e693230
      Zefan Li authored
      commit 578a1310 upstream.
      
      We triggered an oops while running trinity with 3.4 kernel:
      
      BUG: unable to handle kernel paging request at 0000000100000d07
      IP: [<ffffffffa0109738>] dlci_ioctl+0xd8/0x2d4 [dlci]
      PGD 640c0d067 PUD 0
      Oops: 0000 [#1] PREEMPT SMP
      CPU 3
      ...
      Pid: 7302, comm: trinity-child3 Not tainted 3.4.24.09+ 40 Huawei Technologies Co., Ltd. Tecal RH2285          /BC11BTSA
      RIP: 0010:[<ffffffffa0109738>]  [<ffffffffa0109738>] dlci_ioctl+0xd8/0x2d4 [dlci]
      ...
      Call Trace:
        [<ffffffff8137c5c3>] sock_ioctl+0x153/0x280
        [<ffffffff81195494>] do_vfs_ioctl+0xa4/0x5e0
        [<ffffffff8118354a>] ? fget_light+0x3ea/0x490
        [<ffffffff81195a1f>] sys_ioctl+0x4f/0x80
        [<ffffffff81478b69>] system_call_fastpath+0x16/0x1b
      ...
      
      It's because the net device is not a dlci device.
      Reported-by: default avatarLi Jinyue <lijinyue@huawei.com>
      Signed-off-by: default avatarLi Zefan <lizefan@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e693230
    • Zefan Li's avatar
      dlci: acquire rtnl_lock before calling __dev_get_by_name() · eadc8331
      Zefan Li authored
      commit 11eb2645 upstream.
      
      Otherwise the net device returned can be freed at anytime.
      Signed-off-by: default avatarLi Zefan <lizefan@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eadc8331
    • Oleg Nesterov's avatar
      hw_breakpoint: Use cpu_possible_mask in {reserve,release}_bp_slot() · ed0b72ac
      Oleg Nesterov authored
      commit c790b0ad upstream.
      
      fetch_bp_busy_slots() and toggle_bp_slot() use
      for_each_online_cpu(), this is obviously wrong wrt cpu_up() or
      cpu_down(), we can over/under account the per-cpu numbers.
      
      For example:
      
      	# echo 0 >> /sys/devices/system/cpu/cpu1/online
      	# perf record -e mem:0x10 -p 1 &
      	# echo 1 >> /sys/devices/system/cpu/cpu1/online
      	# perf record -e mem:0x10,mem:0x10,mem:0x10,mem:0x10 -C1 -a &
      	# taskset -p 0x2 1
      
      triggers the same WARN_ONCE("Can't find any breakpoint slot") in
      arch_install_hw_breakpoint().
      Reported-by: default avatarVince Weaver <vincent.weaver@maine.edu>
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Link: http://lkml.kernel.org/r/20130620155009.GA6327@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ed0b72ac
    • Anderson Lizardo's avatar
      Bluetooth: Fix crash in l2cap_build_cmd() with small MTU · 630493e2
      Anderson Lizardo authored
      commit 300b962e upstream.
      
      If a too small MTU value is set with ioctl(HCISETACLMTU) or by a bogus
      controller, memory corruption happens due to a memcpy() call with
      negative length.
      
      Fix this crash on either incoming or outgoing connections with a MTU
      smaller than L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE:
      
      [   46.885433] BUG: unable to handle kernel paging request at f56ad000
      [   46.888037] IP: [<c03d94cd>] memcpy+0x1d/0x40
      [   46.888037] *pdpt = 0000000000ac3001 *pde = 00000000373f8067 *pte = 80000000356ad060
      [   46.888037] Oops: 0002 [#1] SMP DEBUG_PAGEALLOC
      [   46.888037] Modules linked in: hci_vhci bluetooth virtio_balloon i2c_piix4 uhci_hcd usbcore usb_common
      [   46.888037] CPU: 0 PID: 1044 Comm: kworker/u3:0 Not tainted 3.10.0-rc1+ #12
      [   46.888037] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
      [   46.888037] Workqueue: hci0 hci_rx_work [bluetooth]
      [   46.888037] task: f59b15b0 ti: f55c4000 task.ti: f55c4000
      [   46.888037] EIP: 0060:[<c03d94cd>] EFLAGS: 00010212 CPU: 0
      [   46.888037] EIP is at memcpy+0x1d/0x40
      [   46.888037] EAX: f56ac1c0 EBX: fffffff8 ECX: 3ffffc6e EDX: f55c5cf2
      [   46.888037] ESI: f55c6b32 EDI: f56ad000 EBP: f55c5c68 ESP: f55c5c5c
      [   46.888037]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
      [   46.888037] CR0: 8005003b CR2: f56ad000 CR3: 3557d000 CR4: 000006f0
      [   46.888037] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      [   46.888037] DR6: ffff0ff0 DR7: 00000400
      [   46.888037] Stack:
      [   46.888037]  fffffff8 00000010 00000003 f55c5cac f8c6a54c ffffffff f8c69eb2 00000000
      [   46.888037]  f4783cdc f57f0070 f759c590 1001c580 00000003 0200000a 00000000 f5a88560
      [   46.888037]  f5ba2600 f5a88560 00000041 00000000 f55c5d90 f8c6f4c7 00000008 f55c5cf2
      [   46.888037] Call Trace:
      [   46.888037]  [<f8c6a54c>] l2cap_send_cmd+0x1cc/0x230 [bluetooth]
      [   46.888037]  [<f8c69eb2>] ? l2cap_global_chan_by_psm+0x152/0x1a0 [bluetooth]
      [   46.888037]  [<f8c6f4c7>] l2cap_connect+0x3f7/0x540 [bluetooth]
      [   46.888037]  [<c019b37b>] ? trace_hardirqs_off+0xb/0x10
      [   46.888037]  [<c01a0ff8>] ? mark_held_locks+0x68/0x110
      [   46.888037]  [<c064ad20>] ? mutex_lock_nested+0x280/0x360
      [   46.888037]  [<c064b9d9>] ? __mutex_unlock_slowpath+0xa9/0x150
      [   46.888037]  [<c01a118c>] ? trace_hardirqs_on_caller+0xec/0x1b0
      [   46.888037]  [<c064ad08>] ? mutex_lock_nested+0x268/0x360
      [   46.888037]  [<c01a125b>] ? trace_hardirqs_on+0xb/0x10
      [   46.888037]  [<f8c72f8d>] l2cap_recv_frame+0xb2d/0x1d30 [bluetooth]
      [   46.888037]  [<c01a0ff8>] ? mark_held_locks+0x68/0x110
      [   46.888037]  [<c064b9d9>] ? __mutex_unlock_slowpath+0xa9/0x150
      [   46.888037]  [<c01a118c>] ? trace_hardirqs_on_caller+0xec/0x1b0
      [   46.888037]  [<f8c754f1>] l2cap_recv_acldata+0x2a1/0x320 [bluetooth]
      [   46.888037]  [<f8c491d8>] hci_rx_work+0x518/0x810 [bluetooth]
      [   46.888037]  [<f8c48df2>] ? hci_rx_work+0x132/0x810 [bluetooth]
      [   46.888037]  [<c0158979>] process_one_work+0x1a9/0x600
      [   46.888037]  [<c01588fb>] ? process_one_work+0x12b/0x600
      [   46.888037]  [<c015922e>] ? worker_thread+0x19e/0x320
      [   46.888037]  [<c015922e>] ? worker_thread+0x19e/0x320
      [   46.888037]  [<c0159187>] worker_thread+0xf7/0x320
      [   46.888037]  [<c0159090>] ? rescuer_thread+0x290/0x290
      [   46.888037]  [<c01602f8>] kthread+0xa8/0xb0
      [   46.888037]  [<c0656777>] ret_from_kernel_thread+0x1b/0x28
      [   46.888037]  [<c0160250>] ? flush_kthread_worker+0x120/0x120
      [   46.888037] Code: c3 90 8d 74 26 00 e8 63 fc ff ff eb e8 90 55 89 e5 83 ec 0c 89 5d f4 89 75 f8 89 7d fc 3e 8d 74 26 00 89 cb 89 c7 c1 e9 02 89 d6 <f3> a5 89 d9 83 e1 03 74 02 f3 a4 8b 5d f4 8b 75 f8 8b 7d fc 89
      [   46.888037] EIP: [<c03d94cd>] memcpy+0x1d/0x40 SS:ESP 0068:f55c5c5c
      [   46.888037] CR2: 00000000f56ad000
      [   46.888037] ---[ end trace 0217c1f4d78714a9 ]---
      Signed-off-by: default avatarAnderson Lizardo <anderson.lizardo@openbossa.org>
      Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      630493e2
    • Simon Baatz's avatar
      ARM: 7772/1: Fix missing flush_kernel_dcache_page() for noMMU · a5f9dc0a
      Simon Baatz authored
      commit 63384fd0 upstream.
      
      Commit 1bc39742 (ARM: 7755/1: handle user space mapped pages in
      flush_kernel_dcache_page) moved the implementation of
      flush_kernel_dcache_page() into mm/flush.c but did not implement it
      on noMMU ARM.
      Signed-off-by: default avatarSimon Baatz <gmbnomis@gmail.com>
      Acked-by: default avatarKevin Hilman <khilman@linaro.org>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a5f9dc0a
    • Simon Baatz's avatar
      ARM: 7755/1: handle user space mapped pages in flush_kernel_dcache_page · 5fca91fe
      Simon Baatz authored
      commit 1bc39742 upstream.
      
      Commit f8b63c18 made flush_kernel_dcache_page a no-op assuming that
      the pages it needs to handle are kernel mapped only.  However, for
      example when doing direct I/O, pages with user space mappings may
      occur.
      
      Thus, continue to do lazy flushing if there are no user space
      mappings.  Otherwise, flush the kernel cache lines directly.
      Signed-off-by: default avatarSimon Baatz <gmbnomis@gmail.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5fca91fe
  3. 27 Jun, 2013 17 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.4.51 · 8a987612
      Greg Kroah-Hartman authored
      8a987612
    • Zhao Hongjiang's avatar
      inotify: invalid mask should return a error number but not set it · 3c103fee
      Zhao Hongjiang authored
      commit 04df32fa upstream.
      
      When we run the crackerjack testsuite, the inotify_add_watch test is
      stalled.
      
      This is caused by the invalid mask 0 - the task is waiting for the event
      but it never comes.  inotify_add_watch() should return -EINVAL as it did
      before commit 676a0675 ("inotify: remove broken mask checks causing
      unmount to be EINVAL").  That commit removes the invalid mask check, but
      that check is needed.
      
      Check the mask's ALL_INOTIFY_BITS before the inotify_arg_to_mask() call.
      If none are set, just return -EINVAL.
      
      Because IN_UNMOUNT is in ALL_INOTIFY_BITS, this change will not trigger
      the problem that above commit fixed.
      
      [akpm@linux-foundation.org: fix build]
      Signed-off-by: default avatarZhao Hongjiang <zhaohongjiang@huawei.com>
      Acked-by: default avatarJim Somerville <Jim.Somerville@windriver.com>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Jerome Marchand <jmarchan@redhat.com>
      Cc: Eric Paris <eparis@parisplace.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      3c103fee
    • Joern Engel's avatar
      target/iscsi: don't corrupt bh_count in iscsit_stop_time2retain_timer() · 4c3017e4
      Joern Engel authored
      commit 574780fd upstream.
      
      Here is a fun one.  Bug seems to have been introduced by commit 140854cb,
      almost two years ago.  I have no idea why we only started seeing it now,
      but we did.
      
      Rough callgraph:
      core_tpg_set_initiator_node_queue_depth()
      `-> spin_lock_irqsave(&tpg->session_lock, flags);
      `-> lio_tpg_shutdown_session()
          `-> iscsit_stop_time2retain_timer()
              `-> spin_unlock_bh(&se_tpg->session_lock);
              `-> spin_lock_bh(&se_tpg->session_lock);
      `-> spin_unlock_irqrestore(&tpg->session_lock, flags);
      
      core_tpg_set_initiator_node_queue_depth() used to call spin_lock_bh(),
      but 140854cb changed that to spin_lock_irqsave().  However,
      lio_tpg_shutdown_session() still claims to be called with spin_lock_bh()
      held, as does iscsit_stop_time2retain_timer():
       *      Called with spin_lock_bh(&struct se_portal_group->session_lock) held
      
      Stale documentation is mostly annoying, but in this case the dropping
      the lock with the _bh variant is plain wrong.  It is also wrong to drop
      locks two functions below the lock-holder, but I will ignore that bit
      for now.
      
      After some more locking and unlocking we eventually hit this backtrace:
      ------------[ cut here ]------------
      WARNING: at kernel/softirq.c:159 local_bh_enable_ip+0xe8/0x100()
      Pid: 24645, comm: lio_helper.py Tainted: G           O 3.6.11+
      Call Trace:
       [<ffffffff8103e5ff>] warn_slowpath_common+0x7f/0xc0
       [<ffffffffa040ae37>] ? iscsit_inc_conn_usage_count+0x37/0x50 [iscsi_target_mod]
       [<ffffffff8103e65a>] warn_slowpath_null+0x1a/0x20
       [<ffffffff810472f8>] local_bh_enable_ip+0xe8/0x100
       [<ffffffff815b8365>] _raw_spin_unlock_bh+0x15/0x20
       [<ffffffffa040ae37>] iscsit_inc_conn_usage_count+0x37/0x50 [iscsi_target_mod]
       [<ffffffffa041149a>] iscsit_stop_session+0xfa/0x1c0 [iscsi_target_mod]
       [<ffffffffa0417fab>] lio_tpg_shutdown_session+0x7b/0x90 [iscsi_target_mod]
       [<ffffffffa033ede4>] core_tpg_set_initiator_node_queue_depth+0xe4/0x290 [target_core_mod]
       [<ffffffffa0409032>] iscsit_tpg_set_initiator_node_queue_depth+0x12/0x20 [iscsi_target_mod]
       [<ffffffffa0415c29>] lio_target_nacl_store_cmdsn_depth+0xa9/0x180 [iscsi_target_mod]
       [<ffffffffa0331b49>] target_fabric_nacl_base_attr_store+0x39/0x40 [target_core_mod]
       [<ffffffff811b857d>] configfs_write_file+0xbd/0x120
       [<ffffffff81148f36>] vfs_write+0xc6/0x180
       [<ffffffff81149251>] sys_write+0x51/0x90
       [<ffffffff815c0969>] system_call_fastpath+0x16/0x1b
      ---[ end trace 3747632b9b164652 ]---
      
      As a pure band-aid, this patch drops the _bh.
      Signed-off-by: default avatarJoern Engel <joern@logfs.org>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      4c3017e4
    • Anders Hammarquist's avatar
      USB: serial: ti_usb_3410_5052: new device id for Abbot strip port cable · 14a940f5
      Anders Hammarquist authored
      commit 35a2fbc9 upstream.
      
      Add product id for Abbott strip port cable for Precision meter which
      uses the TI 3410 chip.
      Signed-off-by: default avatarAnders Hammarquist <iko@iko.pp.se>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      14a940f5
    • Ferruh Yigit's avatar
      Input: cyttsp - fix memcpy size param · 8c428c19
      Ferruh Yigit authored
      commit d2983cdb upstream.
      
      memcpy param is wrong because of offset in bl_cmd, this may corrupt the
      stack which may cause a crash.
      
      Tested-by: Ferruh Yigit <fery@cypress.com> on TMA300-DVK
      Signed-off-by: default avatarFerruh Yigit <fery@cypress.com>
      Acked-by: default avatarJavier Martinez Canillas <javier@dowhile0.org>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c428c19
    • Zheng Li's avatar
      bonding: rlb mode of bond should not alter ARP originating via bridge · 322130de
      Zheng Li authored
      [ Upstream commit 567b871e ]
      
      Do not modify or load balance ARP packets passing through balance-alb
      mode (wherein the ARP did not originate locally, and arrived via a bridge).
      
      Modifying pass-through ARP replies causes an incorrect MAC address
      to be placed into the ARP packet, rendering peers unable to communicate
      with the actual destination from which the ARP reply originated.
      
      Load balancing pass-through ARP requests causes an entry to be
      created for the peer in the rlb table, and bond_alb_monitor will
      occasionally issue ARP updates to all peers in the table instrucing them
      as to which MAC address they should communicate with; this occurs when
      some event sets rx_ntt.  In the bridged case, however, the MAC address
      used for the update would be the MAC of the slave, not the actual source
      MAC of the originating destination.  This would render peers unable to
      communicate with the destinations beyond the bridge.
      Signed-off-by: default avatarZheng Li <zheng.x.li@oracle.com>
      Signed-off-by: default avatarJay Vosburgh <fubar@us.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarMatthew O'Connor <liquidhorse@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      322130de
    • Guillaume Nault's avatar
      l2tp: Fix sendmsg() return value · 137b5d87
      Guillaume Nault authored
      [ Upstream commit a6f79d0f ]
      
      PPPoL2TP sockets should comply with the standard send*() return values
      (i.e. return number of bytes sent instead of 0 upon success).
      Signed-off-by: default avatarGuillaume Nault <g.nault@alphalink.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      137b5d87
    • Guillaume Nault's avatar
      l2tp: Fix PPP header erasure and memory leak · 3bf35eb3
      Guillaume Nault authored
      [ Upstream commit 55b92b7a ]
      
      Copy user data after PPP framing header. This prevents erasure of the
      added PPP header and avoids leaking two bytes of uninitialised memory
      at the end of skb's data buffer.
      Signed-off-by: default avatarGuillaume Nault <g.nault@alphalink.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3bf35eb3
    • Daniel Borkmann's avatar
      packet: packet_getname_spkt: make sure string is always 0-terminated · 991e73cc
      Daniel Borkmann authored
      [ Upstream commit 2dc85bf3 ]
      
      uaddr->sa_data is exactly of size 14, which is hard-coded here and
      passed as a size argument to strncpy(). A device name can be of size
      IFNAMSIZ (== 16), meaning we might leave the destination string
      unterminated. Thus, use strlcpy() and also sizeof() while we're
      at it. We need to memset the data area beforehand, since strlcpy
      does not padd the remaining buffer with zeroes for user space, so
      that we do not possibly leak anything.
      Signed-off-by: default avatarDaniel Borkmann <dborkman@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      991e73cc
    • Jiri Pirko's avatar
      team: check return value of team_get_port_by_index_rcu() for NULL · a50ebefd
      Jiri Pirko authored
      [ Upstream commit 76c455de ]
      
      team_get_port_by_index_rcu() might return NULL due to race between port
      removal and skb tx path. Panic is easily triggeable when txing packets
      and adding/removing port in a loop.
      
      introduced by commit 3d249d4c "net: introduce ethernet teaming device"
      and commit 753f9939 "team: introduce random mode" (for random mode)
      Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a50ebefd
    • Daniel Borkmann's avatar
      net: sctp: fix NULL pointer dereference in socket destruction · 93f75344
      Daniel Borkmann authored
      [ Upstream commit 1abd165e ]
      
      While stress testing sctp sockets, I hit the following panic:
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
      IP: [<ffffffffa0490c4e>] sctp_endpoint_free+0xe/0x40 [sctp]
      PGD 7cead067 PUD 7ce76067 PMD 0
      Oops: 0000 [#1] SMP
      Modules linked in: sctp(F) libcrc32c(F) [...]
      CPU: 7 PID: 2950 Comm: acc Tainted: GF            3.10.0-rc2+ #1
      Hardware name: Dell Inc. PowerEdge T410/0H19HD, BIOS 1.6.3 02/01/2011
      task: ffff88007ce0e0c0 ti: ffff88007b568000 task.ti: ffff88007b568000
      RIP: 0010:[<ffffffffa0490c4e>]  [<ffffffffa0490c4e>] sctp_endpoint_free+0xe/0x40 [sctp]
      RSP: 0018:ffff88007b569e08  EFLAGS: 00010292
      RAX: 0000000000000000 RBX: ffff88007db78a00 RCX: dead000000200200
      RDX: ffffffffa049fdb0 RSI: ffff8800379baf38 RDI: 0000000000000000
      RBP: ffff88007b569e18 R08: ffff88007c230da0 R09: 0000000000000001
      R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
      R13: ffff880077990d00 R14: 0000000000000084 R15: ffff88007db78a00
      FS:  00007fc18ab61700(0000) GS:ffff88007fc60000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 0000000000000020 CR3: 000000007cf9d000 CR4: 00000000000007e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Stack:
       ffff88007b569e38 ffff88007db78a00 ffff88007b569e38 ffffffffa049fded
       ffffffff81abf0c0 ffff88007db78a00 ffff88007b569e58 ffffffff8145b60e
       0000000000000000 0000000000000000 ffff88007b569eb8 ffffffff814df36e
      Call Trace:
       [<ffffffffa049fded>] sctp_destroy_sock+0x3d/0x80 [sctp]
       [<ffffffff8145b60e>] sk_common_release+0x1e/0xf0
       [<ffffffff814df36e>] inet_create+0x2ae/0x350
       [<ffffffff81455a6f>] __sock_create+0x11f/0x240
       [<ffffffff81455bf0>] sock_create+0x30/0x40
       [<ffffffff8145696c>] SyS_socket+0x4c/0xc0
       [<ffffffff815403be>] ? do_page_fault+0xe/0x10
       [<ffffffff8153cb32>] ? page_fault+0x22/0x30
       [<ffffffff81544e02>] system_call_fastpath+0x16/0x1b
      Code: 0c c9 c3 66 2e 0f 1f 84 00 00 00 00 00 e8 fb fe ff ff c9 c3 66 0f
            1f 84 00 00 00 00 00 55 48 89 e5 53 48 83 ec 08 66 66 66 66 90 <48>
            8b 47 20 48 89 fb c6 47 1c 01 c6 40 12 07 e8 9e 68 01 00 48
      RIP  [<ffffffffa0490c4e>] sctp_endpoint_free+0xe/0x40 [sctp]
       RSP <ffff88007b569e08>
      CR2: 0000000000000020
      ---[ end trace e0d71ec1108c1dd9 ]---
      
      I did not hit this with the lksctp-tools functional tests, but with a
      small, multi-threaded test program, that heavily allocates, binds,
      listens and waits in accept on sctp sockets, and then randomly kills
      some of them (no need for an actual client in this case to hit this).
      Then, again, allocating, binding, etc, and then killing child processes.
      
      This panic then only occurs when ``echo 1 > /proc/sys/net/sctp/auth_enable''
      is set. The cause for that is actually very simple: in sctp_endpoint_init()
      we enter the path of sctp_auth_init_hmacs(). There, we try to allocate
      our crypto transforms through crypto_alloc_hash(). In our scenario,
      it then can happen that crypto_alloc_hash() fails with -EINTR from
      crypto_larval_wait(), thus we bail out and release the socket via
      sk_common_release(), sctp_destroy_sock() and hit the NULL pointer
      dereference as soon as we try to access members in the endpoint during
      sctp_endpoint_free(), since endpoint at that time is still NULL. Now,
      if we have that case, we do not need to do any cleanup work and just
      leave the destruction handler.
      Signed-off-by: default avatarDaniel Borkmann <dborkman@redhat.com>
      Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Acked-by: default avatarVlad Yasevich <vyasevich@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93f75344
    • Gao feng's avatar
      ipv6: assign rt6_info to inet6_ifaddr in init_loopback · 2f4997c9
      Gao feng authored
      [ Upstream commit 534c8779 ]
      
      Commit 25fb6ca4
      "net IPv6 : Fix broken IPv6 routing table after loopback down-up"
      forgot to assign rt6_info to the inet6_ifaddr.
      When disable the net device, the rt6_info which allocated
      in init_loopback will not be destroied in __ipv6_ifa_notify.
      
      This will trigger the waring message below
      [23527.916091] unregister_netdevice: waiting for tap0 to become free. Usage count = 1
      Reported-by: default avatarArkadiusz Miskiewicz <a.miskiewicz@gmail.com>
      Signed-off-by: default avatarGao feng <gaofeng@cn.fujitsu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f4997c9
    • Eric Dumazet's avatar
      net: force a reload of first item in hlist_nulls_for_each_entry_rcu · 689ec122
      Eric Dumazet authored
      [ Upstream commit c87a124a ]
      
      Roman Gushchin discovered that udp4_lib_lookup2() was not reloading
      first item in the rcu protected list, in case the loop was restarted.
      
      This produced soft lockups as in https://lkml.org/lkml/2013/4/16/37
      
      rcu_dereference(X)/ACCESS_ONCE(X) seem to not work as intended if X is
      ptr->field :
      
      In some cases, gcc caches the value or ptr->field in a register.
      
      Use a barrier() to disallow such caching, as documented in
      Documentation/atomic_ops.txt line 114
      
      Thanks a lot to Roman for providing analysis and numerous patches.
      Diagnosed-by: default avatarRoman Gushchin <klamm@yandex-team.ru>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarBoris Zhmurov <zhmurov@yandex-team.ru>
      Signed-off-by: default avatarRoman Gushchin <klamm@yandex-team.ru>
      Acked-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      689ec122
    • Andy Lutomirski's avatar
      net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg · c0cc94f2
      Andy Lutomirski authored
      [ Upstream commits 1be374a0 and
        a7526eb5 ]
      
      MSG_CMSG_COMPAT is (AFAIK) not intended to be part of the API --
      it's a hack that steals a bit to indicate to other networking code
      that a compat entry was used.  So don't allow it from a non-compat
      syscall.
      
      This prevents an oops when running this code:
      
      int main()
      {
      	int s;
      	struct sockaddr_in addr;
      	struct msghdr *hdr;
      
      	char *highpage = mmap((void*)(TASK_SIZE_MAX - 4096), 4096,
      	                      PROT_READ | PROT_WRITE,
      	                      MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
      	if (highpage == MAP_FAILED)
      		err(1, "mmap");
      
      	s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
      	if (s == -1)
      		err(1, "socket");
      
              addr.sin_family = AF_INET;
              addr.sin_port = htons(1);
              addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
      	if (connect(s, (struct sockaddr*)&addr, sizeof(addr)) != 0)
      		err(1, "connect");
      
      	void *evil = highpage + 4096 - COMPAT_MSGHDR_SIZE;
      	printf("Evil address is %p\n", evil);
      
      	if (syscall(__NR_sendmmsg, s, evil, 1, MSG_CMSG_COMPAT) < 0)
      		err(1, "sendmmsg");
      
      	return 0;
      }
      Signed-off-by: default avatarAndy Lutomirski <luto@amacapital.net>
      Cc: David S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c0cc94f2
    • Eric Dumazet's avatar
      ip_tunnel: fix kernel panic with icmp_dest_unreach · 3c353df4
      Eric Dumazet authored
      [ Upstream commit a6222602 ]
      
      Daniel Petre reported crashes in icmp_dst_unreach() with following call
      graph:
      
      Daniel found a similar problem mentioned in
       http://lkml.indiana.edu/hypermail/linux/kernel/1007.0/00961.html
      
      And indeed this is the root cause : skb->cb[] contains data fooling IP
      stack.
      
      We must clear IPCB in ip_tunnel_xmit() sooner in case dst_link_failure()
      is called. Or else skb->cb[] might contain garbage from GSO segmentation
      layer.
      
      A similar fix was tested on linux-3.9, but gre code was refactored in
      linux-3.10. I'll send patches for stable kernels as well.
      
      Many thanks to Daniel for providing reports, patches and testing !
      Reported-by: default avatarDaniel Petre <daniel.petre@rcs-rds.ro>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3c353df4
    • Eric Dumazet's avatar
      tcp: xps: fix reordering issues · fa17eb75
      Eric Dumazet authored
      [ Upstream commit 547669d4 ]
      
      commit 3853b584 ("xps: Improvements in TX queue selection")
      introduced ooo_okay flag, but the condition to set it is slightly wrong.
      
      In our traces, we have seen ACK packets being received out of order,
      and RST packets sent in response.
      
      We should test if we have any packets still in host queue.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Tom Herbert <therbert@google.com>
      Cc: Yuchung Cheng <ycheng@google.com>
      Cc: Neal Cardwell <ncardwell@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fa17eb75
    • Nandita Dukkipati's avatar
      tcp: bug fix in proportional rate reduction. · 2d73733f
      Nandita Dukkipati authored
      [ Upstream commit 35f079eb ]
      
      This patch is a fix for a bug triggering newly_acked_sacked < 0
      in tcp_ack(.).
      
      The bug is triggered by sacked_out decreasing relative to prior_sacked,
      but packets_out remaining the same as pior_packets. This is because the
      snapshot of prior_packets is taken after tcp_sacktag_write_queue() while
      prior_sacked is captured before tcp_sacktag_write_queue(). The problem
      is: tcp_sacktag_write_queue (tcp_match_skb_to_sack() -> tcp_fragment)
      adjusts the pcount for packets_out and sacked_out (MSS change or other
      reason). As a result, this delta in pcount is reflected in
      (prior_sacked - sacked_out) but not in (prior_packets - packets_out).
      
      This patch does the following:
      1) initializes prior_packets at the start of tcp_ack() so as to
      capture the delta in packets_out created by tcp_fragment.
      2) introduces a new "previous_packets_out" variable that snapshots
      packets_out right before tcp_clean_rtx_queue, so pkts_acked can be
      correctly computed as before.
      3) Computes pkts_acked using previous_packets_out, and computes
      newly_acked_sacked using prior_packets.
      Signed-off-by: default avatarNandita Dukkipati <nanditad@google.com>
      Acked-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2d73733f