1. 18 Mar, 2018 40 commits
    • Florian Westphal's avatar
      netfilter: x_tables: pack percpu counter allocations · db6a0cbe
      Florian Westphal authored
      commit ae0ac0ed upstream.
      
      instead of allocating each xt_counter individually, allocate 4k chunks
      and then use these for counter allocation requests.
      
      This should speed up rule evaluation by increasing data locality,
      also speeds up ruleset loading because we reduce calls to the percpu
      allocator.
      
      As Eric points out we can't use PAGE_SIZE, page_allocator would fail on
      arches with 64k page size.
      Suggested-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      db6a0cbe
    • Florian Westphal's avatar
      netfilter: x_tables: pass xt_counters struct to counter allocator · dac4448f
      Florian Westphal authored
      commit f28e15ba upstream.
      
      Keeps some noise away from a followup patch.
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dac4448f
    • Florian Westphal's avatar
      netfilter: x_tables: pass xt_counters struct instead of packet counter · 61346e20
      Florian Westphal authored
      commit 4d31eef5 upstream.
      
      On SMP we overload the packet counter (unsigned long) to contain
      percpu offset.  Hide this from callers and pass xt_counters address
      instead.
      
      Preparation patch to allocate the percpu counters in page-sized batch
      chunks.
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      61346e20
    • Florian Westphal's avatar
      netfilter: ipv6: fix use-after-free Write in nf_nat_ipv6_manip_pkt · 60962e98
      Florian Westphal authored
      commit b078556a upstream.
      
      l4proto->manip_pkt() can cause reallocation of skb head so pointer
      to the ipv6 header must be reloaded.
      
      Reported-and-tested-by: <syzbot+10005f4292fc9cc89de7@syzkaller.appspotmail.com>
      Fixes: 58a317f1 ("netfilter: ipv6: add IPv6 NAT support")
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      60962e98
    • Florian Westphal's avatar
      netfilter: bridge: ebt_among: add missing match size checks · 280ef7b8
      Florian Westphal authored
      commit c4585a28 upstream.
      
      ebt_among is special, it has a dynamic match size and is exempt
      from the central size checks.
      
      Therefore it must check that the size of the match structure
      provided from userspace is sane by making sure em->match_size
      is at least the minimum size of the expected structure.
      
      The module has such a check, but its only done after accessing
      a structure that might be out of bounds.
      
      tested with: ebtables -A INPUT ... \
      --among-dst fe:fe:fe:fe:fe:fe
      --among-dst fe:fe:fe:fe:fe:fe --among-src fe:fe:fe:fe:ff:f,fe:fe:fe:fe:fe:fb,fe:fe:fe:fe:fc:fd,fe:fe:fe:fe:fe:fd,fe:fe:fe:fe:fe:fe
      --among-src fe:fe:fe:fe:ff:f,fe:fe:fe:fe:fe:fa,fe:fe:fe:fe:fe:fd,fe:fe:fe:fe:fe:fe,fe:fe:fe:fe:fe:fe
      
      Reported-by: <syzbot+fe0b19af568972814355@syzkaller.appspotmail.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      280ef7b8
    • Florian Westphal's avatar
      netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets · 21ff1471
      Florian Westphal authored
      commit b7181216 upstream.
      
      We need to make sure the offsets are not out of range of the
      total size.
      Also check that they are in ascending order.
      
      The WARN_ON triggered by syzkaller (it sets panic_on_warn) is
      changed to also bail out, no point in continuing parsing.
      
      Briefly tested with simple ruleset of
      -A INPUT --limit 1/s' --log
      plus jump to custom chains using 32bit ebtables binary.
      
      Reported-by: <syzbot+845a53d13171abf8bf29@syzkaller.appspotmail.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21ff1471
    • Eric Dumazet's avatar
      netfilter: IDLETIMER: be syzkaller friendly · 034ad9d2
      Eric Dumazet authored
      commit cfc2c740 upstream.
      
      We had one report from syzkaller [1]
      
      First issue is that INIT_WORK() should be done before mod_timer()
      or we risk timer being fired too soon, even with a 1 second timer.
      
      Second issue is that we need to reject too big info->timeout
      to avoid overflows in msecs_to_jiffies(info->timeout * 1000), or
      risk looping, if result after overflow is 0.
      
      [1]
      WARNING: CPU: 1 PID: 5129 at kernel/workqueue.c:1444 __queue_work+0xdf4/0x1230 kernel/workqueue.c:1444
      Kernel panic - not syncing: panic_on_warn set ...
      
      CPU: 1 PID: 5129 Comm: syzkaller159866 Not tainted 4.16.0-rc1+ #230
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       <IRQ>
       __dump_stack lib/dump_stack.c:17 [inline]
       dump_stack+0x194/0x257 lib/dump_stack.c:53
       panic+0x1e4/0x41c kernel/panic.c:183
       __warn+0x1dc/0x200 kernel/panic.c:547
       report_bug+0x211/0x2d0 lib/bug.c:184
       fixup_bug.part.11+0x37/0x80 arch/x86/kernel/traps.c:178
       fixup_bug arch/x86/kernel/traps.c:247 [inline]
       do_error_trap+0x2d7/0x3e0 arch/x86/kernel/traps.c:296
       do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:315
       invalid_op+0x22/0x40 arch/x86/entry/entry_64.S:988
      RIP: 0010:__queue_work+0xdf4/0x1230 kernel/workqueue.c:1444
      RSP: 0018:ffff8801db507538 EFLAGS: 00010006
      RAX: ffff8801aeb46080 RBX: ffff8801db530200 RCX: ffffffff81481404
      RDX: 0000000000000100 RSI: ffffffff86b42640 RDI: 0000000000000082
      RBP: ffff8801db507758 R08: 1ffff1003b6a0de5 R09: 000000000000000c
      R10: ffff8801db5073f0 R11: 0000000000000020 R12: 1ffff1003b6a0eb6
      R13: ffff8801b1067ae0 R14: 00000000000001f8 R15: dffffc0000000000
       queue_work_on+0x16a/0x1c0 kernel/workqueue.c:1488
       queue_work include/linux/workqueue.h:488 [inline]
       schedule_work include/linux/workqueue.h:546 [inline]
       idletimer_tg_expired+0x44/0x60 net/netfilter/xt_IDLETIMER.c:116
       call_timer_fn+0x228/0x820 kernel/time/timer.c:1326
       expire_timers kernel/time/timer.c:1363 [inline]
       __run_timers+0x7ee/0xb70 kernel/time/timer.c:1666
       run_timer_softirq+0x4c/0x70 kernel/time/timer.c:1692
       __do_softirq+0x2d7/0xb85 kernel/softirq.c:285
       invoke_softirq kernel/softirq.c:365 [inline]
       irq_exit+0x1cc/0x200 kernel/softirq.c:405
       exiting_irq arch/x86/include/asm/apic.h:541 [inline]
       smp_apic_timer_interrupt+0x16b/0x700 arch/x86/kernel/apic/apic.c:1052
       apic_timer_interrupt+0xa9/0xb0 arch/x86/entry/entry_64.S:829
       </IRQ>
      RIP: 0010:arch_local_irq_restore arch/x86/include/asm/paravirt.h:777 [inline]
      RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline]
      RIP: 0010:_raw_spin_unlock_irqrestore+0x5e/0xba kernel/locking/spinlock.c:184
      RSP: 0018:ffff8801c20173c8 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff12
      RAX: dffffc0000000000 RBX: 0000000000000282 RCX: 0000000000000006
      RDX: 1ffffffff0d592cd RSI: 1ffff10035d68d23 RDI: 0000000000000282
      RBP: ffff8801c20173d8 R08: 1ffff10038402e47 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff8820e5c8
      R13: ffff8801b1067ad8 R14: ffff8801aea7c268 R15: ffff8801aea7c278
       __debug_object_init+0x235/0x1040 lib/debugobjects.c:378
       debug_object_init+0x17/0x20 lib/debugobjects.c:391
       __init_work+0x2b/0x60 kernel/workqueue.c:506
       idletimer_tg_create net/netfilter/xt_IDLETIMER.c:152 [inline]
       idletimer_tg_checkentry+0x691/0xb00 net/netfilter/xt_IDLETIMER.c:213
       xt_check_target+0x22c/0x7d0 net/netfilter/x_tables.c:850
       check_target net/ipv6/netfilter/ip6_tables.c:533 [inline]
       find_check_entry.isra.7+0x935/0xcf0 net/ipv6/netfilter/ip6_tables.c:575
       translate_table+0xf52/0x1690 net/ipv6/netfilter/ip6_tables.c:744
       do_replace net/ipv6/netfilter/ip6_tables.c:1160 [inline]
       do_ip6t_set_ctl+0x370/0x5f0 net/ipv6/netfilter/ip6_tables.c:1686
       nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
       nf_setsockopt+0x67/0xc0 net/netfilter/nf_sockopt.c:115
       ipv6_setsockopt+0x10b/0x130 net/ipv6/ipv6_sockglue.c:927
       udpv6_setsockopt+0x45/0x80 net/ipv6/udp.c:1422
       sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2976
       SYSC_setsockopt net/socket.c:1850 [inline]
       SyS_setsockopt+0x189/0x360 net/socket.c:1829
       do_syscall_64+0x282/0x940 arch/x86/entry/common.c:287
      
      Fixes: 0902b469 ("netfilter: xtables: idletimer target implementation")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      034ad9d2
    • Paolo Abeni's avatar
      netfilter: nat: cope with negative port range · 7d105756
      Paolo Abeni authored
      commit db57ccf0 upstream.
      
      syzbot reported a division by 0 bug in the netfilter nat code:
      
      divide error: 0000 [#1] SMP KASAN
      Dumping ftrace buffer:
          (ftrace buffer empty)
      Modules linked in:
      CPU: 1 PID: 4168 Comm: syzkaller034710 Not tainted 4.16.0-rc1+ #309
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      RIP: 0010:nf_nat_l4proto_unique_tuple+0x291/0x530
      net/netfilter/nf_nat_proto_common.c:88
      RSP: 0018:ffff8801b2466778 EFLAGS: 00010246
      RAX: 000000000000f153 RBX: ffff8801b2466dd8 RCX: ffff8801b2466c7c
      RDX: 0000000000000000 RSI: ffff8801b2466c58 RDI: ffff8801db5293ac
      RBP: ffff8801b24667d8 R08: ffff8801b8ba6dc0 R09: ffffffff88af5900
      R10: ffff8801b24666f0 R11: 0000000000000000 R12: 000000002990f153
      R13: 0000000000000001 R14: 0000000000000000 R15: ffff8801b2466c7c
      FS:  00000000017e3880(0000) GS:ffff8801db500000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000208fdfe4 CR3: 00000001b5340002 CR4: 00000000001606e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
        dccp_unique_tuple+0x40/0x50 net/netfilter/nf_nat_proto_dccp.c:30
        get_unique_tuple+0xc28/0x1c10 net/netfilter/nf_nat_core.c:362
        nf_nat_setup_info+0x1c2/0xe00 net/netfilter/nf_nat_core.c:406
        nf_nat_redirect_ipv6+0x306/0x730 net/netfilter/nf_nat_redirect.c:124
        redirect_tg6+0x7f/0xb0 net/netfilter/xt_REDIRECT.c:34
        ip6t_do_table+0xc2a/0x1a30 net/ipv6/netfilter/ip6_tables.c:365
        ip6table_nat_do_chain+0x65/0x80 net/ipv6/netfilter/ip6table_nat.c:41
        nf_nat_ipv6_fn+0x594/0xa80 net/ipv6/netfilter/nf_nat_l3proto_ipv6.c:302
        nf_nat_ipv6_local_fn+0x33/0x5d0
      net/ipv6/netfilter/nf_nat_l3proto_ipv6.c:407
        ip6table_nat_local_fn+0x2c/0x40 net/ipv6/netfilter/ip6table_nat.c:69
        nf_hook_entry_hookfn include/linux/netfilter.h:120 [inline]
        nf_hook_slow+0xba/0x1a0 net/netfilter/core.c:483
        nf_hook include/linux/netfilter.h:243 [inline]
        NF_HOOK include/linux/netfilter.h:286 [inline]
        ip6_xmit+0x10ec/0x2260 net/ipv6/ip6_output.c:277
        inet6_csk_xmit+0x2fc/0x580 net/ipv6/inet6_connection_sock.c:139
        dccp_transmit_skb+0x9ac/0x10f0 net/dccp/output.c:142
        dccp_connect+0x369/0x670 net/dccp/output.c:564
        dccp_v6_connect+0xe17/0x1bf0 net/dccp/ipv6.c:946
        __inet_stream_connect+0x2d4/0xf00 net/ipv4/af_inet.c:620
        inet_stream_connect+0x58/0xa0 net/ipv4/af_inet.c:684
        SYSC_connect+0x213/0x4a0 net/socket.c:1639
        SyS_connect+0x24/0x30 net/socket.c:1620
        do_syscall_64+0x282/0x940 arch/x86/entry/common.c:287
        entry_SYSCALL_64_after_hwframe+0x26/0x9b
      RIP: 0033:0x441c69
      RSP: 002b:00007ffe50cc0be8 EFLAGS: 00000217 ORIG_RAX: 000000000000002a
      RAX: ffffffffffffffda RBX: ffffffffffffffff RCX: 0000000000441c69
      RDX: 000000000000001c RSI: 00000000208fdfe4 RDI: 0000000000000003
      RBP: 00000000006cc018 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000538 R11: 0000000000000217 R12: 0000000000403590
      R13: 0000000000403620 R14: 0000000000000000 R15: 0000000000000000
      Code: 48 89 f0 83 e0 07 83 c0 01 38 d0 7c 08 84 d2 0f 85 46 02 00 00 48 8b
      45 c8 44 0f b7 20 e8 88 97 04 fd 31 d2 41 0f b7 c4 4c 89 f9 <41> f7 f6 48
      c1 e9 03 48 b8 00 00 00 00 00 fc ff df 0f b6 0c 01
      RIP: nf_nat_l4proto_unique_tuple+0x291/0x530
      net/netfilter/nf_nat_proto_common.c:88 RSP: ffff8801b2466778
      
      The problem is that currently we don't have any check on the
      configured port range. A port range == -1 triggers the bug, while
      other negative values may require a very long time to complete the
      following loop.
      
      This commit addresses the issue swapping the two ends on negative
      ranges. The check is performed in nf_nat_l4proto_unique_tuple() since
      the nft nat loads the port values from nft registers at runtime.
      
      v1 -> v2: use the correct 'Fixes' tag
      v2 -> v3: update commit message, drop unneeded READ_ONCE()
      
      Fixes: 5b1158e9 ("[NETFILTER]: Add NAT support for nf_conntrack")
      Reported-by: syzbot+8012e198bd037f4871e5@syzkaller.appspotmail.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7d105756
    • Paolo Abeni's avatar
      netfilter: x_tables: fix missing timer initialization in xt_LED · af4b424a
      Paolo Abeni authored
      commit 10414014 upstream.
      
      syzbot reported that xt_LED may try to use the ledinternal->timer
      without previously initializing it:
      
      ------------[ cut here ]------------
      kernel BUG at kernel/time/timer.c:958!
      invalid opcode: 0000 [#1] SMP KASAN
      Dumping ftrace buffer:
          (ftrace buffer empty)
      Modules linked in:
      CPU: 1 PID: 1826 Comm: kworker/1:2 Not tainted 4.15.0+ #306
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      Workqueue: ipv6_addrconf addrconf_dad_work
      RIP: 0010:__mod_timer kernel/time/timer.c:958 [inline]
      RIP: 0010:mod_timer+0x7d6/0x13c0 kernel/time/timer.c:1102
      RSP: 0018:ffff8801d24fe9f8 EFLAGS: 00010293
      RAX: ffff8801d25246c0 RBX: ffff8801aec6cb50 RCX: ffffffff816052c6
      RDX: 0000000000000000 RSI: 00000000fffbd14b RDI: ffff8801aec6cb68
      RBP: ffff8801d24fec98 R08: 0000000000000000 R09: 1ffff1003a49fd6c
      R10: ffff8801d24feb28 R11: 0000000000000005 R12: dffffc0000000000
      R13: ffff8801d24fec70 R14: 00000000fffbd14b R15: ffff8801af608f90
      FS:  0000000000000000(0000) GS:ffff8801db500000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000206d6fd0 CR3: 0000000006a22001 CR4: 00000000001606e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
        led_tg+0x1db/0x2e0 net/netfilter/xt_LED.c:75
        ip6t_do_table+0xc2a/0x1a30 net/ipv6/netfilter/ip6_tables.c:365
        ip6table_raw_hook+0x65/0x80 net/ipv6/netfilter/ip6table_raw.c:42
        nf_hook_entry_hookfn include/linux/netfilter.h:120 [inline]
        nf_hook_slow+0xba/0x1a0 net/netfilter/core.c:483
        nf_hook.constprop.27+0x3f6/0x830 include/linux/netfilter.h:243
        NF_HOOK include/linux/netfilter.h:286 [inline]
        ndisc_send_skb+0xa51/0x1370 net/ipv6/ndisc.c:491
        ndisc_send_ns+0x38a/0x870 net/ipv6/ndisc.c:633
        addrconf_dad_work+0xb9e/0x1320 net/ipv6/addrconf.c:4008
        process_one_work+0xbbf/0x1af0 kernel/workqueue.c:2113
        worker_thread+0x223/0x1990 kernel/workqueue.c:2247
        kthread+0x33c/0x400 kernel/kthread.c:238
        ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:429
      Code: 85 2a 0b 00 00 4d 8b 3c 24 4d 85 ff 75 9f 4c 8b bd 60 fd ff ff e8 bb
      57 10 00 65 ff 0d 94 9a a1 7e e9 d9 fc ff ff e8 aa 57 10 00 <0f> 0b e8 a3
      57 10 00 e9 14 fb ff ff e8 99 57 10 00 4c 89 bd 70
      RIP: __mod_timer kernel/time/timer.c:958 [inline] RSP: ffff8801d24fe9f8
      RIP: mod_timer+0x7d6/0x13c0 kernel/time/timer.c:1102 RSP: ffff8801d24fe9f8
      ---[ end trace f661ab06f5dd8b3d ]---
      
      The ledinternal struct can be shared between several different
      xt_LED targets, but the related timer is currently initialized only
      if the first target requires it. Fix it by unconditionally
      initializing the timer struct.
      
      v1 -> v2: call del_timer_sync() unconditionally, too.
      
      Fixes: 268cb38e ("netfilter: x_tables: add LED trigger target")
      Reported-by: syzbot+10c98dc5725c6c8fc7fb@syzkaller.appspotmail.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af4b424a
    • Florian Westphal's avatar
      netfilter: add back stackpointer size checks · f506da51
      Florian Westphal authored
      commit 57ebd808 upstream.
      
      The rationale for removing the check is only correct for rulesets
      generated by ip(6)tables.
      
      In iptables, a jump can only occur to a user-defined chain, i.e.
      because we size the stack based on number of user-defined chains we
      cannot exceed stack size.
      
      However, the underlying binary format has no such restriction,
      and the validation step only ensures that the jump target is a
      valid rule start point.
      
      IOW, its possible to build a rule blob that has no user-defined
      chains but does contain a jump.
      
      If this happens, no jump stack gets allocated and crash occurs
      because no jumpstack was allocated.
      
      Fixes: 7814b6ec ("netfilter: xtables: don't save/restore jumpstack offset")
      Reported-by: syzbot+e783f671527912cd9403@syzkaller.appspotmail.com
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f506da51
    • Philipp Zabel's avatar
      tc358743: fix register i2c_rd/wr function fix · b323768e
      Philipp Zabel authored
      commit f2c61f98 upstream.
      
      The below mentioned fix contains a small but severe bug,
      fix it to make the driver work again.
      
      Fixes: 3538aa6e ("[media] tc358743: fix register i2c_rd/wr functions")
      
      Cc: Hans Verkuil <hans.verkuil@cisco.com>
      Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarHans Verkuil <hansverk@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b323768e
    • Dmitry Torokhov's avatar
      Input: tca8418_keypad - remove double read of key event register · c9763bfc
      Dmitry Torokhov authored
      commit 9dd46c02 upstream.
      
      There is no need to tread the same register twice in a row.
      
      Fixes: ea4348c8 ("Input: tca8418_keypad - hide gcc-4.9 -Wmaybe-un ...")
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c9763bfc
    • Arnd Bergmann's avatar
      ARM: omap2: hide omap3_save_secure_ram on non-OMAP3 builds · c20eb490
      Arnd Bergmann authored
      commit 863204cf upstream.
      
      In configurations without CONFIG_OMAP3 but with secure RAM support,
      we now run into a link failure:
      
      arch/arm/mach-omap2/omap-secure.o: In function `omap3_save_secure_ram':
      omap-secure.c:(.text+0x130): undefined reference to `save_secure_ram_context'
      
      The omap3_save_secure_ram() function is only called from the OMAP34xx
      power management code, so we can simply hide that function in the
      appropriate #ifdef.
      
      Fixes: d09220a8 ("ARM: OMAP2+: Fix SRAM virt to phys translation for save_secure_ram_context")
      Acked-by: default avatarTony Lindgren <tony@atomide.com>
      Tested-by: default avatarDan Murphy <dmurphy@ti.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c20eb490
    • Jerry Hoemann's avatar
      watchdog: hpwdt: Remove legacy NMI sourcing. · 25d57673
      Jerry Hoemann authored
      commit 2b3d89b4 upstream.
      
      Gen8 and prior Proliant systems supported the "CRU" interface
      to firmware.  This interfaces allows linux to "call back" into firmware
      to source the cause of an NMI.  This feature isn't fully utilized
      as the actual source of the NMI isn't printed, the driver only
      indicates that the source couldn't be determined when the call
      fails.
      
      With the advent of Gen9, iCRU replaces the CRU. The call back
      feature is no longer available in firmware.  To be compatible and
      not attempt to call back into firmware on system not supporting CRU,
      the SMBIOS table is consulted to determine if it is safe to
      make the call back or not.
      
      This results in about half of the driver code being devoted
      to either making CRU calls or determing if it is safe to make
      CRU calls.  As noted, the driver isn't really using the results of
      the CRU calls.
      
      Furthermore, as a consequence of the Spectre security issue, the
      BIOS/EFI calls are being wrapped into Spectre-disabling section.
      Removing the call back in hpwdt_pretimeout assists in this effort.
      
      As the CRU sourcing of the NMI isn't required for handling the
      NMI and there are security concerns with making the call back, remove
      the legacy (pre Gen9) NMI sourcing and the DMI code to determine if
      the system had the CRU interface.
      Signed-off-by: default avatarJerry Hoemann <jerry.hoemann@hpe.com>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25d57673
    • Arnd Bergmann's avatar
      watchdog: hpwdt: fix unused variable warning · 6cda76dc
      Arnd Bergmann authored
      commit aeebc6ba upstream.
      
      The new hpwdt_my_nmi() function is used conditionally, which produces
      a harmless warning in some configurations:
      
      drivers/watchdog/hpwdt.c:478:12: error: 'hpwdt_my_nmi' defined but not used [-Werror=unused-function]
      
      This moves it inside of the #ifdef that protects its caller, to silence
      the warning.
      
      Fixes: 621174a92851 ("watchdog: hpwdt: Check source of NMI")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarJerry Hoemann <jerry.hoemann@hpe.com>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6cda76dc
    • Jerry Hoemann's avatar
      watchdog: hpwdt: Check source of NMI · c3872313
      Jerry Hoemann authored
      commit 838534e5 upstream.
      
      Do not claim the NMI (i.e. return NMI_DONE) if the source of
      the NMI isn't the iLO watchdog or debug.
      Signed-off-by: default avatarJerry Hoemann <jerry.hoemann@hpe.com>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c3872313
    • Jerry Hoemann's avatar
      watchdog: hpwdt: SMBIOS check · 3f55635c
      Jerry Hoemann authored
      commit c42cbe41 upstream.
      
      This corrects:
      commit cce78da7 ("watchdog: hpwdt: Add check for UEFI bits")
      
      The test on HPE SMBIOS extension type 219 record "Misc Features"
      bits for UEFI support is incorrect.  The definition of the Misc Features
      bits in the HPE SMBIOS OEM Extensions specification (and related
      firmware) was changed to use a different pair of bits to
      represent UEFI supported.  Howerver, a corresponding change
      to Linux was missed.
      
      Current code/platform work because the iCRU test is working.
      But purpose of cce78da7 is to ensure correct functionality
      on future systems where iCRU isn't supported.
      Signed-off-by: default avatarJerry Hoemann <jerry.hoemann@hpe.com>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f55635c
    • Peter Zijlstra's avatar
      x86/paravirt, objtool: Annotate indirect calls · bb615512
      Peter Zijlstra authored
      commit 3010a066 upstream.
      
      Paravirt emits indirect calls which get flagged by objtool retpoline
      checks, annotate it away because all these indirect calls will be
      patched out before we start userspace.
      
      This patching happens through alternative_instructions() ->
      apply_paravirt() -> pv_init_ops.patch() which will eventually end up
      in paravirt_patch_default(). This function _will_ write direct
      alternatives.
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb615512
    • Ingo Molnar's avatar
      x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP · e21257ad
      Ingo Molnar authored
      commit d72f4e29 upstream.
      
      firmware_restrict_branch_speculation_*() recently started using
      preempt_enable()/disable(), but those are relatively high level
      primitives and cause build failures on some 32-bit builds.
      
      Since we want to keep <asm/nospec-branch.h> low level, convert
      them to macros to avoid header hell...
      
      Cc: David Woodhouse <dwmw@amazon.co.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: arjan.van.de.ven@intel.com
      Cc: bp@alien8.de
      Cc: dave.hansen@intel.com
      Cc: jmattson@google.com
      Cc: karahmed@amazon.de
      Cc: kvm@vger.kernel.org
      Cc: pbonzini@redhat.com
      Cc: rkrcmar@redhat.com
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e21257ad
    • Peter Zijlstra's avatar
      x86/boot, objtool: Annotate indirect jump in secondary_startup_64() · f7d3a80f
      Peter Zijlstra authored
      commit bd89004f upstream.
      
      The objtool retpoline validation found this indirect jump. Seeing how
      it's on CPU bringup before we run userspace it should be safe, annotate
      it.
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7d3a80f
    • Peter Zijlstra's avatar
      x86/speculation, objtool: Annotate indirect calls/jumps for objtool · a65655d4
      Peter Zijlstra authored
      commit 9e0e3c51 upstream.
      
      Annotate the indirect calls/jumps in the CALL_NOSPEC/JUMP_NOSPEC
      alternatives.
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a65655d4
    • David Woodhouse's avatar
      x86/retpoline: Support retpoline builds with Clang · 6123a6be
      David Woodhouse authored
      commit 87358710 upstream.
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: arjan.van.de.ven@intel.com
      Cc: bp@alien8.de
      Cc: dave.hansen@intel.com
      Cc: jmattson@google.com
      Cc: karahmed@amazon.de
      Cc: kvm@vger.kernel.org
      Cc: pbonzini@redhat.com
      Cc: rkrcmar@redhat.com
      Link: http://lkml.kernel.org/r/1519037457-7643-5-git-send-email-dwmw@amazon.co.ukSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6123a6be
    • David Woodhouse's avatar
      x86/speculation: Use IBRS if available before calling into firmware · a27ede1b
      David Woodhouse authored
      commit dd84441a upstream.
      
      Retpoline means the kernel is safe because it has no indirect branches.
      But firmware isn't, so use IBRS for firmware calls if it's available.
      
      Block preemption while IBRS is set, although in practice the call sites
      already had to be doing that.
      
      Ignore hpwdt.c for now. It's taking spinlocks and calling into firmware
      code, from an NMI handler. I don't want to touch that with a bargepole.
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: arjan.van.de.ven@intel.com
      Cc: bp@alien8.de
      Cc: dave.hansen@intel.com
      Cc: jmattson@google.com
      Cc: karahmed@amazon.de
      Cc: kvm@vger.kernel.org
      Cc: pbonzini@redhat.com
      Cc: rkrcmar@redhat.com
      Link: http://lkml.kernel.org/r/1519037457-7643-2-git-send-email-dwmw@amazon.co.ukSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a27ede1b
    • David Woodhouse's avatar
      Revert "x86/retpoline: Simplify vmexit_fill_RSB()" · afb9851d
      David Woodhouse authored
      commit d1c99108 upstream.
      
      This reverts commit 1dde7415. By putting
      the RSB filling out of line and calling it, we waste one RSB slot for
      returning from the function itself, which means one fewer actual function
      call we can make if we're doing the Skylake abomination of call-depth
      counting.
      
      It also changed the number of RSB stuffings we do on vmexit from 32,
      which was correct, to 16. Let's just stop with the bikeshedding; it
      didn't actually *fix* anything anyway.
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: arjan.van.de.ven@intel.com
      Cc: bp@alien8.de
      Cc: dave.hansen@intel.com
      Cc: jmattson@google.com
      Cc: karahmed@amazon.de
      Cc: kvm@vger.kernel.org
      Cc: pbonzini@redhat.com
      Cc: rkrcmar@redhat.com
      Link: http://lkml.kernel.org/r/1519037457-7643-4-git-send-email-dwmw@amazon.co.ukSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      afb9851d
    • Dan Williams's avatar
      nospec: Include <asm/barrier.h> dependency · 6310a11f
      Dan Williams authored
      commit eb6174f6 upstream.
      
      The nospec.h header expects the per-architecture header file
      <asm/barrier.h> to optionally define array_index_mask_nospec(). Include
      that dependency to prevent inadvertent fallback to the default
      array_index_mask_nospec() implementation.
      
      The default implementation may not provide a full mitigation
      on architectures that perform data value speculation.
      Reported-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-arch@vger.kernel.org
      Link: http://lkml.kernel.org/r/151881605404.17395.1341935530792574707.stgit@dwillia2-desk3.amr.corp.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6310a11f
    • Dan Williams's avatar
      nospec: Kill array_index_nospec_mask_check() · 244a6d39
      Dan Williams authored
      commit 1d91c1d2 upstream.
      
      There are multiple problems with the dynamic sanity checking in
      array_index_nospec_mask_check():
      
      * It causes unnecessary overhead in the 32-bit case since integer sized
        @index values will no longer cause the check to be compiled away like
        in the 64-bit case.
      
      * In the 32-bit case it may trigger with user controllable input when
        the expectation is that should only trigger during development of new
        kernel enabling.
      
      * The macro reuses the input parameter in multiple locations which is
        broken if someone passes an expression like 'index++' to
        array_index_nospec().
      Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-arch@vger.kernel.org
      Link: http://lkml.kernel.org/r/151881604278.17395.6605847763178076520.stgit@dwillia2-desk3.amr.corp.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      244a6d39
    • Dennis Wassenberg's avatar
      ALSA: hda: add dock and led support for HP ProBook 640 G2 · 5b8dce74
      Dennis Wassenberg authored
      commit 099fd6ca upstream.
      
      This patch adds missing initialisation for HP 2013 UltraSlim Dock
      Line-In/Out PINs and activates keyboard mute/micmute leds
      for HP ProBook 640 G2
      Signed-off-by: default avatarDennis Wassenberg <dennis.wassenberg@secunet.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5b8dce74
    • Dennis Wassenberg's avatar
      ALSA: hda: add dock and led support for HP EliteBook 820 G3 · 5614f3a6
      Dennis Wassenberg authored
      commit aea80817 upstream.
      
      This patch adds missing initialisation for HP 2013 UltraSlim Dock
      Line-In/Out PINs and activates keyboard mute/micmute leds
      for HP EliteBook 820 G3
      Signed-off-by: default avatarDennis Wassenberg <dennis.wassenberg@secunet.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5614f3a6
    • Takashi Iwai's avatar
      ALSA: seq: More protection for concurrent write and ioctl races · ec001162
      Takashi Iwai authored
      commit 7bd80091 upstream.
      
      This patch is an attempt for further hardening against races between
      the concurrent write and ioctls.  The previous fix d15d662e
      ("ALSA: seq: Fix racy pool initializations") covered the race of the
      pool initialization at writer and the pool resize ioctl by the
      client->ioctl_mutex (CVE-2018-1000004).  However, basically this mutex
      should be applied more widely to the whole write operation for
      avoiding the unexpected pool operations by another thread.
      
      The only change outside snd_seq_write() is the additional mutex
      argument to helper functions, so that we can unlock / relock the given
      mutex temporarily during schedule() call for blocking write.
      
      Fixes: d15d662e ("ALSA: seq: Fix racy pool initializations")
      Reported-by: default avatar范龙飞 <long7573@126.com>
      Reported-by: default avatarNicolai Stange <nstange@suse.de>
      Reviewed-and-tested-by: default avatarNicolai Stange <nstange@suse.de>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec001162
    • Takashi Iwai's avatar
      ALSA: seq: Don't allow resizing pool in use · 0d7252d3
      Takashi Iwai authored
      commit d8573936 upstream.
      
      This is a fix for a (sort of) fallout in the recent commit
      d15d662e ("ALSA: seq: Fix racy pool initializations") for
      CVE-2018-1000004.
      As the pool resize deletes the existing cells, it may lead to a race
      when another thread is writing concurrently, eventually resulting a
      UAF.
      
      A simple workaround is not to allow the pool resizing when the pool is
      in use.  It's an invalid behavior in anyway.
      
      Fixes: d15d662e ("ALSA: seq: Fix racy pool initializations")
      Reported-by: default avatar范龙飞 <long7573@126.com>
      Reported-by: default avatarNicolai Stange <nstange@suse.de>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0d7252d3
    • Dennis Wassenberg's avatar
      ALSA: hda/realtek - Make dock sound work on ThinkPad L570 · 5191f417
      Dennis Wassenberg authored
      commit e4c07b3b upstream.
      
      One version of Lenovo Thinkpad T570 did not use ALC298
      (like other Kaby Lake devices). Instead it uses ALC292.
      In order to make the Lenovo dock working with that codec
      the dock quirk for ALC292 will be used.
      Signed-off-by: default avatarDennis Wassenberg <dennis.wassenberg@secunet.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5191f417
    • Takashi Iwai's avatar
      ALSA: hda/realtek - Fix dock line-out volume on Dell Precision 7520 · b992e8f5
      Takashi Iwai authored
      commit e312a869 upstream.
      
      The dock line-out pin (NID 0x17 of ALC3254 codec) on Dell Precision
      7520 may route to three different DACs, 0x02, 0x03 and 0x06.  The
      first two DACS have the volume amp controls while the last one
      doesn't.  And unfortunately, the auto-parser assigns this pin to DAC3,
      resulting in the non-working volume control for the line out.
      
      Fix it by disabling the routing to DAC3 on the corresponding pin.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199029
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b992e8f5
    • Benjamin Berg's avatar
      ALSA: hda/realtek: Limit mic boost on T480 · f8521dba
      Benjamin Berg authored
      commit 85981dfd upstream.
      
      The internal mic boost on the T480 is too high. Fix this by applying the
      ALC269_FIXUP_LIMIT_INT_MIC_BOOST fixup to the machine to limit the gain.
      Signed-off-by: default avatarBenjamin Berg <bberg@redhat.com>
      Tested-by: default avatarBenjamin Berg <bberg@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8521dba
    • Konrad Rzeszutek Wilk's avatar
      x86/spectre_v2: Don't check microcode versions when running under hypervisors · 502a2780
      Konrad Rzeszutek Wilk authored
      commit 36268223 upstream.
      
      As:
      
       1) It's known that hypervisors lie about the environment anyhow (host
          mismatch)
      
       2) Even if the hypervisor (Xen, KVM, VMWare, etc) provided a valid
          "correct" value, it all gets to be very murky when migration happens
          (do you provide the "new" microcode of the machine?).
      
      And in reality the cloud vendors are the ones that should make sure that
      the microcode that is running is correct and we should just sing lalalala
      and trust them.
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Cc: Wanpeng Li <kernellwp@gmail.com>
      Cc: kvm <kvm@vger.kernel.org>
      Cc: Krčmář <rkrcmar@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      CC: "H. Peter Anvin" <hpa@zytor.com>
      CC: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20180226213019.GE9497@char.us.oracle.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      502a2780
    • Adrian Hunter's avatar
      perf tools: Fix trigger class trigger_on() · 9ed6e56e
      Adrian Hunter authored
      commit de19e5c3 upstream.
      
      trigger_on() means that the trigger is available but not ready, however
      trigger_on() was making it ready. That can segfault if the signal comes
      before trigger_ready(). e.g. (USR2 signal delivery not shown)
      
        $ perf record -e intel_pt//u -S sleep 1
        perf: Segmentation fault
        Obtained 16 stack frames.
        /home/ahunter/bin/perf(sighandler_dump_stack+0x40) [0x4ec550]
        /lib/x86_64-linux-gnu/libc.so.6(+0x36caf) [0x7fa76411acaf]
        /home/ahunter/bin/perf(perf_evsel__disable+0x26) [0x4b9dd6]
        /home/ahunter/bin/perf() [0x43a45b]
        /lib/x86_64-linux-gnu/libc.so.6(+0x36caf) [0x7fa76411acaf]
        /lib/x86_64-linux-gnu/libc.so.6(__xstat64+0x15) [0x7fa7641d2cc5]
        /home/ahunter/bin/perf() [0x4ec6c9]
        /home/ahunter/bin/perf() [0x4ec73b]
        /home/ahunter/bin/perf() [0x4ec73b]
        /home/ahunter/bin/perf() [0x4ec73b]
        /home/ahunter/bin/perf() [0x4eca15]
        /home/ahunter/bin/perf(machine__create_kernel_maps+0x257) [0x4f0b77]
        /home/ahunter/bin/perf(perf_session__new+0xc0) [0x4f86f0]
        /home/ahunter/bin/perf(cmd_record+0x722) [0x43c132]
        /home/ahunter/bin/perf() [0x4a11ae]
        /home/ahunter/bin/perf(main+0x5d4) [0x427fb4]
      
      Note, for testing purposes, this is hard to hit unless you add some sleep()
      in builtin-record.c before record__open().
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: stable@vger.kernel.org
      Fixes: 3dcc4436 ("perf tools: Introduce trigger class")
      Link: http://lkml.kernel.org/r/1519807144-30694-1-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ed6e56e
    • Seunghun Han's avatar
      x86/MCE: Serialize sysfs changes · 2cc98fdd
      Seunghun Han authored
      commit b3b7c479 upstream.
      
      The check_interval file in
      
        /sys/devices/system/machinecheck/machinecheck<cpu number>
      
      directory is a global timer value for MCE polling. If it is changed by one
      CPU, mce_restart() broadcasts the event to other CPUs to delete and restart
      the MCE polling timer and __mcheck_cpu_init_timer() reinitializes the
      mce_timer variable.
      
      If more than one CPU writes a specific value to the check_interval file
      concurrently, mce_timer is not protected from such concurrent accesses and
      all kinds of explosions happen. Since only root can write to those sysfs
      variables, the issue is not a big deal security-wise.
      
      However, concurrent writes to these configuration variables is void of
      reason so the proper thing to do is to serialize the access with a mutex.
      
      Boris:
      
       - Make store_int_with_restart() use device_store_ulong() to filter out
         negative intervals
       - Limit min interval to 1 second
       - Correct locking
       - Massage commit message
      Signed-off-by: default avatarSeunghun Han <kkamagui@gmail.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: linux-edac <linux-edac@vger.kernel.org>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180302202706.9434-1-kkamagui@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2cc98fdd
    • Michael Lyle's avatar
      bcache: don't attach backing with duplicate UUID · d4f80945
      Michael Lyle authored
      commit 86755b7a upstream.
      
      This can happen e.g. during disk cloning.
      
      This is an incomplete fix: it does not catch duplicate UUIDs earlier
      when things are still unattached.  It does not unregister the device.
      Further changes to cope better with this are planned but conflict with
      Coly's ongoing improvements to handling device errors.  In the meantime,
      one can manually stop the device after this has happened.
      
      Attempts to attach a duplicate device result in:
      
      [  136.372404] loop: module loaded
      [  136.424461] bcache: register_bdev() registered backing device loop0
      [  136.424464] bcache: bch_cached_dev_attach() Tried to attach loop0 but duplicate UUID already attached
      
      My test procedure is:
      
        dd if=/dev/sdb1 of=imgfile bs=1024 count=262144
        losetup -f imgfile
      Signed-off-by: default avatarMichael Lyle <mlyle@lyle.org>
      Reviewed-by: default avatarTang Junhui <tang.junhui@zte.com.cn>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d4f80945
    • Tang Junhui's avatar
      bcache: fix crashes in duplicate cache device register · 35d9c9ea
      Tang Junhui authored
      commit cc40daf9 upstream.
      
      Kernel crashed when register a duplicate cache device, the call trace is
      bellow:
      [  417.643790] CPU: 1 PID: 16886 Comm: bcache-register Tainted: G
         W  OE    4.15.5-amd64-preempt-sysrq-20171018 #2
      [  417.643861] Hardware name: LENOVO 20ERCTO1WW/20ERCTO1WW, BIOS
      N1DET41W (1.15 ) 12/31/2015
      [  417.643870] RIP: 0010:bdevname+0x13/0x1e
      [  417.643876] RSP: 0018:ffffa3aa9138fd38 EFLAGS: 00010282
      [  417.643884] RAX: 0000000000000000 RBX: ffff8c8f2f2f8000 RCX: ffffd6701f8
      c7edf
      [  417.643890] RDX: ffffa3aa9138fd88 RSI: ffffa3aa9138fd88 RDI: 00000000000
      00000
      [  417.643895] RBP: ffffa3aa9138fde0 R08: ffffa3aa9138fae8 R09: 00000000000
      1850e
      [  417.643901] R10: ffff8c8eed34b271 R11: ffff8c8eed34b250 R12: 00000000000
      00000
      [  417.643906] R13: ffffd6701f78f940 R14: ffff8c8f38f80000 R15: ffff8c8ea7d
      90000
      [  417.643913] FS:  00007fde7e66f500(0000) GS:ffff8c8f61440000(0000) knlGS:
      0000000000000000
      [  417.643919] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  417.643925] CR2: 0000000000000314 CR3: 00000007e6fa0001 CR4: 00000000003
      606e0
      [  417.643931] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 00000000000
      00000
      [  417.643938] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 00000000000
      00400
      [  417.643946] Call Trace:
      [  417.643978]  register_bcache+0x1117/0x1270 [bcache]
      [  417.643994]  ? slab_pre_alloc_hook+0x15/0x3c
      [  417.644001]  ? slab_post_alloc_hook.isra.44+0xa/0x1a
      [  417.644013]  ? kernfs_fop_write+0xf6/0x138
      [  417.644020]  kernfs_fop_write+0xf6/0x138
      [  417.644031]  __vfs_write+0x31/0xcc
      [  417.644043]  ? current_kernel_time64+0x10/0x36
      [  417.644115]  ? __audit_syscall_entry+0xbf/0xe3
      [  417.644124]  vfs_write+0xa5/0xe2
      [  417.644133]  SyS_write+0x5c/0x9f
      [  417.644144]  do_syscall_64+0x72/0x81
      [  417.644161]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      [  417.644169] RIP: 0033:0x7fde7e1c1974
      [  417.644175] RSP: 002b:00007fff13009a38 EFLAGS: 00000246 ORIG_RAX: 0000000
      000000001
      [  417.644183] RAX: ffffffffffffffda RBX: 0000000001658280 RCX: 00007fde7e1c
      1974
      [  417.644188] RDX: 000000000000000a RSI: 0000000001658280 RDI: 000000000000
      0001
      [  417.644193] RBP: 000000000000000a R08: 0000000000000003 R09: 000000000000
      0077
      [  417.644198] R10: 000000000000089e R11: 0000000000000246 R12: 000000000000
      0001
      [  417.644203] R13: 000000000000000a R14: 7fffffffffffffff R15: 000000000000
      0000
      [  417.644213] Code: c7 c2 83 6f ee 98 be 20 00 00 00 48 89 df e8 6c 27 3b 0
      0 48 89 d8 5b c3 0f 1f 44 00 00 48 8b 47 70 48 89 f2 48 8b bf 80 00 00 00 <8
      b> b0 14 03 00 00 e9 73 ff ff ff 0f 1f 44 00 00 48 8b 47 40 39
      [  417.644302] RIP: bdevname+0x13/0x1e RSP: ffffa3aa9138fd38
      [  417.644306] CR2: 0000000000000314
      
      When registering duplicate cache device in register_cache(), after failure
      on calling register_cache_set(), bch_cache_release() will be called, then
      bdev will be freed, so bdevname(bdev, name) caused kernel crash.
      
      Since bch_cache_release() will free bdev, so in this patch we make sure
      bdev being freed if register_cache() fail, and do not free bdev again in
      register_bcache() when register_cache() fail.
      Signed-off-by: default avatarTang Junhui <tang.junhui@zte.com.cn>
      Reported-by: default avatarMarc MERLIN <marc@merlins.org>
      Tested-by: default avatarMichael Lyle <mlyle@lyle.org>
      Reviewed-by: default avatarMichael Lyle <mlyle@lyle.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35d9c9ea
    • Sergey Gorenko's avatar
      IB/mlx5: Fix incorrect size of klms in the memory region · e749262f
      Sergey Gorenko authored
      commit da343b6d upstream.
      
      The value of mr->ndescs greater than mr->max_descs is set in the
      function mlx5_ib_sg_to_klms() if sg_nents is greater than
      mr->max_descs. This is an invalid value and it causes the
      following error when registering mr:
      
      mlx5_0:dump_cqe:276:(pid 193): dump error cqe
      00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000030: 00 00 00 00 0f 00 78 06 25 00 00 8b 08 1e 8f d3
      
      Cc: <stable@vger.kernel.org> # 4.5
      Fixes: b005d316 ("mlx5: Add arbitrary sg list support")
      Signed-off-by: default avatarSergey Gorenko <sergeygo@mellanox.com>
      Tested-by: default avatarLaurence Oberman <loberman@redhat.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e749262f
    • James Hogan's avatar
      kbuild: Handle builtin dtb file names containing hyphens · 333cdd17
      James Hogan authored
      commit 55fe6da9 upstream.
      
      cmd_dt_S_dtb constructs the assembly source to incorporate a devicetree
      FDT (that is, the .dtb file) as binary data in the kernel image. This
      assembly source contains labels before and after the binary data. The
      label names incorporate the file name of the corresponding .dtb file.
      Hyphens are not legal characters in labels, so .dtb files built into the
      kernel with hyphens in the file name result in errors like the
      following:
      
      bcm3368-netgear-cvg834g.dtb.S: Assembler messages:
      bcm3368-netgear-cvg834g.dtb.S:5: Error: : no such section
      bcm3368-netgear-cvg834g.dtb.S:5: Error: junk at end of line, first unrecognized character is `-'
      bcm3368-netgear-cvg834g.dtb.S:6: Error: unrecognized opcode `__dtb_bcm3368-netgear-cvg834g_begin:'
      bcm3368-netgear-cvg834g.dtb.S:8: Error: unrecognized opcode `__dtb_bcm3368-netgear-cvg834g_end:'
      bcm3368-netgear-cvg834g.dtb.S:9: Error: : no such section
      bcm3368-netgear-cvg834g.dtb.S:9: Error: junk at end of line, first unrecognized character is `-'
      
      Fix this by updating cmd_dt_S_dtb to transform all hyphens from the file
      name to underscores when constructing the labels.
      
      As of v4.16-rc2, 1139 .dts files across ARM64, ARM, MIPS and PowerPC
      contain hyphens in their names, but the issue only currently manifests
      on Broadcom MIPS platforms, as that is the only place where such files
      are built into the kernel. For example when CONFIG_DT_NETGEAR_CVG834G=y,
      or on BMIPS kernels when the dtbs target is used (in the latter case it
      admittedly shouldn't really build all the dtb.o files, but thats a
      separate issue).
      
      Fixes: 69583551 ("MIPS: BMIPS: rename bcm96358nb4ser to bcm6358-neufbox4-sercom")
      Signed-off-by: default avatarJames Hogan <jhogan@kernel.org>
      Reviewed-by: default avatarFrank Rowand <frowand.list@gmail.com>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Michal Marek <michal.lkml@markovi.net>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: <stable@vger.kernel.org> # 4.9+
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      333cdd17