1. 14 Dec, 2017 40 commits
    • Masahiro Yamada's avatar
      coccinelle: fix parallel build with CHECK=scripts/coccicheck · 394d0c93
      Masahiro Yamada authored
      
      [ Upstream commit d7059ca0 ]
      
      The command "make -j8 C=1 CHECK=scripts/coccicheck" produces
      lots of "coccicheck failed" error messages.
      
      Julia Lawall explained the Coccinelle behavior as follows:
      "The problem on the Coccinelle side is that it uses a subdirectory
      with the name of the semantic patch to store standard output and
      standard error for the different threads.  I didn't want to use a
      name with the pid, so that one could easily find this information
      while Coccinelle is running.  Normally the subdirectory is cleaned
      up when Coccinelle completes, so there is only one of them at a time.
      Maybe it is best to just add the pid.  There is the risk that these
      subdirectories will accumulate if Coccinelle crashes in a way such
      that they don't get cleaned up, but Coccinelle could print a warning
      if it detects this case, rather than failing."
      
      When scripts/coccicheck is used as CHECK tool and -j option is given
      to Make, the whole of build process runs in parallel.  So, multiple
      processes try to get access to the same subdirectory.
      
      I notice spatch creates the subdirectory only when it runs in parallel
      (i.e. --jobs <N> is given and <N> is greater than 1).
      
      Setting NPROC=1 is a reasonable solution; spatch does not create the
      subdirectory.  Besides, ONLINE=1 mode takes a single file input for
      each spatch invocation, so there is no reason to parallelize it in
      the first place.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
      Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      394d0c93
    • Masahiro Yamada's avatar
      kbuild: pkg: use --transform option to prefix paths in tar · 54a13eb7
      Masahiro Yamada authored
      
      [ Upstream commit 2dbc644a ]
      
      For rpm-pkg and deb-pkg, a source tar file is created.  All paths in
      the archive must be prefixed with the base name of the tar so that
      everything is contained in the directory when you extract it.
      
      Currently, scripts/package/Makefile uses a symlink for that, and
      removes it after the tar is created.
      
      If you terminate the build during the tar creation, the symlink is
      left over.  Then, at the next package build, you will see a warning
      like follows:
      
        ln: '.' and 'kernel-4.14.0+/.' are the same file
      
      It is possible to fix it by adding -n (--no-dereference) option to
      the "ln" command, but a cleaner way is to use --transform option
      of "tar" command.  This option is GNU extension, but it should not
      hurt to use it in the Linux build system.
      
      The 'S' flag is needed to exclude symlinks from the path fixup.
      Without it, symlinks in the kernel are broken.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      54a13eb7
    • Ursula Braun's avatar
      net/smc: use sk_rcvbuf as start for rmb creation · 4d0d1bc6
      Ursula Braun authored
      
      [ Upstream commit 4e1061f4 ]
      
      Commit 3e034725 ("net/smc: common functions for RMBs and send buffers")
      merged handling of SMC receive and send buffers. It introduced sk_buf_size
      as merged start value for size determination. But since sk_buf_size is not
      used at all, sk_sndbuf is erroneously used as start for rmb creation.
      This patch makes sure, sk_buf_size is really used as intended, and
      sk_rcvbuf is used as start value for rmb creation.
      
      Fixes: 3e034725 ("net/smc: common functions for RMBs and send buffers")
      Signed-off-by: default avatarUrsula Braun <ubraun@linux.vnet.ibm.com>
      Reviewed-by: default avatarHans Wippel <hwippel@linux.vnet.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d0d1bc6
    • Colin Ian King's avatar
      irqchip/qcom: Fix u32 comparison with value less than zero · f0d56423
      Colin Ian King authored
      
      [ Upstream commit e9990d70 ]
      
      The comparison of u32 nregs being less than zero is never true since
      nregs is unsigned. Fix this by making nregs a signed integer.
      
      Fixes: f20cc9b0 ("irqchip/qcom: Add IRQ combiner driver")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: kernel-janitors@vger.kernel.org
      Cc: Jason Cooper <jason@lakedaemon.net>
      Link: https://lkml.kernel.org/r/20171117183553.2739-1-colin.king@canonical.comSigned-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0d56423
    • Russell King's avatar
      ARM: avoid faulting on qemu · 14f13c9d
      Russell King authored
      commit 3aaf33be upstream.
      
      When qemu starts a kernel in a bare environment, the default SCR has
      the AW and FW bits clear, which means that the kernel can't modify
      the PSR A or PSR F bits, and means that FIQs and imprecise aborts are
      always masked.
      
      When running uboot under qemu, the AW and FW SCR bits are set, and the
      kernel functions normally - and this is how real hardware behaves.
      
      Fix this for qemu by ignoring the FIQ bit.
      
      Fixes: 8bafae20 ("ARM: BUG if jumping to usermode address in kernel mode")
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Cc: Alex Shi <alex.shi@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      14f13c9d
    • Russell King's avatar
      ARM: BUG if jumping to usermode address in kernel mode · 21e1e619
      Russell King authored
      commit 8bafae20 upstream.
      
      Detect if we are returning to usermode via the normal kernel exit paths
      but the saved PSR value indicates that we are in kernel mode.  This
      could occur due to corrupted stack state, which has been observed with
      "ftracetest".
      
      This ensures that we catch the problem case before we get to user code.
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Cc: Alex Shi <alex.shi@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21e1e619
    • LEROY Christophe's avatar
      crypto: talitos - fix ctr-aes-talitos · 077415ef
      LEROY Christophe authored
      commit 70d355cc upstream.
      
      ctr-aes-talitos test fails as follows on SEC2
      
      [    0.837427] alg: skcipher: Test 1 failed (invalid result) on encryption for ctr-aes-talitos
      [    0.845763] 00000000: 16 36 d5 ee 34 f8 06 25 d7 7f 8e 56 ca 88 43 45
      [    0.852345] 00000010: f9 3f f7 17 2a b2 12 23 30 43 09 15 82 dd e1 97
      [    0.858940] 00000020: a7 f7 32 b5 eb 25 06 13 9a ec f5 29 25 f8 4d 66
      [    0.865366] 00000030: b0 03 5b 8e aa 9a 42 b6 19 33 8a e2 9d 65 96 95
      
      This patch fixes the descriptor type which is special for CTR AES
      
      Fixes: 5e75ae1b ("crypto: talitos - add new crypto modes")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      077415ef
    • LEROY Christophe's avatar
      crypto: talitos - fix use of sg_link_tbl_len · 2040f8e8
      LEROY Christophe authored
      commit fbb22137 upstream.
      
      sg_link_tbl_len shall be used instead of cryptlen, otherwise
      SECs which perform HW CICV verification will fail.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2040f8e8
    • LEROY Christophe's avatar
      crypto: talitos - fix AEAD for sha224 on non sha224 capable chips · a2d93ada
      LEROY Christophe authored
      commit 6cda075a upstream.
      
      sha224 AEAD test fails with:
      
      [    2.803125] talitos ff020000.crypto: DEUISR 0x00000000_00000000
      [    2.808743] talitos ff020000.crypto: MDEUISR 0x80100000_00000000
      [    2.814678] talitos ff020000.crypto: DESCBUF 0x20731f21_00000018
      [    2.820616] talitos ff020000.crypto: DESCBUF 0x0628d64c_00000010
      [    2.826554] talitos ff020000.crypto: DESCBUF 0x0631005c_00000018
      [    2.832492] talitos ff020000.crypto: DESCBUF 0x0628d664_00000008
      [    2.838430] talitos ff020000.crypto: DESCBUF 0x061b13a0_00000080
      [    2.844369] talitos ff020000.crypto: DESCBUF 0x0631006c_00000080
      [    2.850307] talitos ff020000.crypto: DESCBUF 0x0631006c_00000018
      [    2.856245] talitos ff020000.crypto: DESCBUF 0x063100ec_00000000
      [    2.884972] talitos ff020000.crypto: failed to reset channel 0
      [    2.890503] talitos ff020000.crypto: done overflow, internal time out, or rngu error: ISR 0x20000000_00020000
      [    2.900652] alg: aead: encryption failed on test 1 for authenc-hmac-sha224-cbc-3des-talitos: ret=22
      
      This is due to SHA224 not being supported by the HW. Allthough for
      hash we are able to init the hash context by SW, it is not
      possible for AEAD. Therefore SHA224 AEAD has to be deactivated.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a2d93ada
    • LEROY Christophe's avatar
      crypto: talitos - fix setkey to check key weakness · 62744eba
      LEROY Christophe authored
      commit f384cdc4 upstream.
      
      Crypto manager test report the following failures:
      [    3.061081] alg: skcipher: setkey failed on test 5 for ecb-des-talitos: flags=100
      [    3.069342] alg: skcipher-ddst: setkey failed on test 5 for ecb-des-talitos: flags=100
      [    3.077754] alg: skcipher-ddst: setkey failed on test 5 for ecb-des-talitos: flags=100
      
      This is due to setkey being expected to detect weak keys.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      62744eba
    • LEROY Christophe's avatar
      crypto: talitos - fix memory corruption on SEC2 · 68b42647
      LEROY Christophe authored
      commit e04a61be upstream.
      
      On SEC2, when using the old descriptors type (hmac snoop no afeu)
      for doing IPsec, the CICV out pointeur points out of the allocated
      memory.
      
      [    2.502554] =============================================================================
      [    2.510740] BUG dma-kmalloc-256 (Not tainted): Redzone overwritten
      [    2.516907] -----------------------------------------------------------------------------
      [    2.516907]
      [    2.526535] Disabling lock debugging due to kernel taint
      [    2.531845] INFO: 0xde858108-0xde85810b. First byte 0xf8 instead of 0xcc
      [    2.538549] INFO: Allocated in 0x806181a9 age=0 cpu=0 pid=58
      [    2.544229] 	__kmalloc+0x374/0x564
      [    2.547649] 	talitos_edesc_alloc+0x17c/0x48c
      [    2.551929] 	aead_edesc_alloc+0x80/0x154
      [    2.555863] 	aead_encrypt+0x30/0xe0
      [    2.559368] 	__test_aead+0x5a0/0x1f3c
      [    2.563042] 	test_aead+0x2c/0x110
      [    2.566371] 	alg_test_aead+0x5c/0xf4
      [    2.569958] 	alg_test+0x1dc/0x5a0
      [    2.573305] 	cryptomgr_test+0x50/0x70
      [    2.576984] 	kthread+0xd8/0x134
      [    2.580155] 	ret_from_kernel_thread+0x5c/0x64
      [    2.584534] INFO: Freed in ipsec_esp_encrypt_done+0x130/0x240 age=6 cpu=0 pid=0
      [    2.591839] 	ipsec_esp_encrypt_done+0x130/0x240
      [    2.596395] 	flush_channel+0x1dc/0x488
      [    2.600161] 	talitos2_done_4ch+0x30/0x200
      [    2.604185] 	tasklet_action+0xa0/0x13c
      [    2.607948] 	__do_softirq+0x148/0x6cc
      [    2.611623] 	irq_exit+0xc0/0x124
      [    2.614869] 	call_do_irq+0x24/0x3c
      [    2.618292] 	do_IRQ+0x78/0x108
      [    2.621369] 	ret_from_except+0x0/0x14
      [    2.625055] 	finish_task_switch+0x58/0x350
      [    2.629165] 	schedule+0x80/0x134
      [    2.632409] 	schedule_preempt_disabled+0x38/0xc8
      [    2.637042] 	cpu_startup_entry+0xe4/0x190
      [    2.641074] 	start_kernel+0x3f4/0x408
      [    2.644741] 	0x3438
      [    2.646857] INFO: Slab 0xdffbdb00 objects=9 used=1 fp=0xde8581c0 flags=0x0080
      [    2.653978] INFO: Object 0xde858008 @offset=8 fp=0xca4395df
      [    2.653978]
      [    2.661032] Redzone de858000: cc cc cc cc cc cc cc cc                          ........
      [    2.669029] Object de858008: 00 00 00 02 00 00 00 02 00 6b 6b 6b 1e 83 ea 28  .........kkk...(
      [    2.677628] Object de858018: 00 00 00 70 1e 85 80 64 ff 73 1d 21 6b 6b 6b 6b  ...p...d.s.!kkkk
      [    2.686228] Object de858028: 00 20 00 00 1e 84 17 24 00 10 00 00 1e 85 70 00  . .....$......p.
      [    2.694829] Object de858038: 00 18 00 00 1e 84 17 44 00 08 00 00 1e 83 ea 28  .......D.......(
      [    2.703430] Object de858048: 00 80 00 00 1e 84 f0 00 00 80 00 00 1e 85 70 10  ..............p.
      [    2.712030] Object de858058: 00 20 6b 00 1e 85 80 f4 6b 6b 6b 6b 00 80 02 00  . k.....kkkk....
      [    2.720629] Object de858068: 1e 84 f0 00 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  ....kkkkkkkkkkkk
      [    2.729230] Object de858078: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      [    2.737830] Object de858088: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      [    2.746429] Object de858098: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      [    2.755029] Object de8580a8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      [    2.763628] Object de8580b8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      [    2.772229] Object de8580c8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      [    2.780829] Object de8580d8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      [    2.789430] Object de8580e8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 73 b0 ea 9f  kkkkkkkkkkkks...
      [    2.798030] Object de8580f8: e8 18 80 d6 56 38 44 c0 db e3 4f 71 f7 ce d1 d3  ....V8D...Oq....
      [    2.806629] Redzone de858108: f8 bd 3e 4f                                      ..>O
      [    2.814279] Padding de8581b0: 5a 5a 5a 5a 5a 5a 5a 5a                          ZZZZZZZZ
      [    2.822283] CPU: 0 PID: 0 Comm: swapper Tainted: G    B           4.9.50-g995be12679 #179
      [    2.831819] Call Trace:
      [    2.834301] [dffefd20] [c01aa9a8] check_bytes_and_report+0x100/0x194 (unreliable)
      [    2.841801] [dffefd50] [c01aac3c] check_object+0x200/0x530
      [    2.847306] [dffefd80] [c01ae584] free_debug_processing+0x290/0x690
      [    2.853585] [dffefde0] [c01aec8c] __slab_free+0x308/0x628
      [    2.859000] [dffefe80] [c05057f4] ipsec_esp_encrypt_done+0x130/0x240
      [    2.865378] [dffefeb0] [c05002c4] flush_channel+0x1dc/0x488
      [    2.870968] [dffeff10] [c05007a8] talitos2_done_4ch+0x30/0x200
      [    2.876814] [dffeff30] [c002fe38] tasklet_action+0xa0/0x13c
      [    2.882399] [dffeff60] [c002f118] __do_softirq+0x148/0x6cc
      [    2.887896] [dffeffd0] [c002f954] irq_exit+0xc0/0x124
      [    2.892968] [dffefff0] [c0013adc] call_do_irq+0x24/0x3c
      [    2.898213] [c0d4be00] [c000757c] do_IRQ+0x78/0x108
      [    2.903113] [c0d4be30] [c0015c08] ret_from_except+0x0/0x14
      [    2.908634] --- interrupt: 501 at finish_task_switch+0x70/0x350
      [    2.908634]     LR = finish_task_switch+0x58/0x350
      [    2.919327] [c0d4bf20] [c085e1d4] schedule+0x80/0x134
      [    2.924398] [c0d4bf50] [c085e2c0] schedule_preempt_disabled+0x38/0xc8
      [    2.930853] [c0d4bf60] [c007f064] cpu_startup_entry+0xe4/0x190
      [    2.936707] [c0d4bfb0] [c096c434] start_kernel+0x3f4/0x408
      [    2.942198] [c0d4bff0] [00003438] 0x3438
      [    2.946137] FIX dma-kmalloc-256: Restoring 0xde858108-0xde85810b=0xcc
      [    2.946137]
      [    2.954158] FIX dma-kmalloc-256: Object at 0xde858008 not freed
      
      This patch reworks the handling of the CICV out in order
      to properly handle all cases.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      68b42647
    • LEROY Christophe's avatar
      crypto: talitos - fix AEAD test failures · 7b9cf144
      LEROY Christophe authored
      commit ec8c7d14 upstream.
      
      AEAD tests fail when destination SG list has more than 1 element.
      
      [    2.058752] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-aes-talitos
      [    2.066965] 00000000: 53 69 6e 67 6c 65 20 62 6c 6f 63 6b 20 6d 73 67
      00000010: c0 43 ff 74 c0 43 ff e0 de 83 d1 20 de 84 8e 54
      00000020: de 83 d7 c4
      [    2.082138] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-aes-talitos
      [    2.090435] 00000000: 53 69 6e 67 6c 65 20 62 6c 6f 63 6b 20 6d 73 67
      00000010: de 84 ea 58 c0 93 1a 24 de 84 e8 59 de 84 f1 20
      00000020: 00 00 00 00
      [    2.105721] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-3des-talitos
      [    2.114259] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
      00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
      00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
      00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
      00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
      00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
      00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
      00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
      00000080: c0 50 f1 ac c0 50 f3 38 c0 50 f3 94 c0 50 f5 30
      00000090: c0 99 74 3c
      [    2.166410] alg: aead: Test 1 failed on encryption for authenc-hmac-sha1-cbc-3des-talitos
      [    2.174794] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
      00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
      00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
      00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
      00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
      00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
      00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
      00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
      00000080: c0 50 f1 ac c0 50 f3 38 c0 50 f3 94 c0 50 f5 30
      00000090: c0 99 74 3c
      [    2.226486] alg: No test for authenc(hmac(sha224),cbc(aes)) (authenc-hmac-sha224-cbc-aes-talitos)
      [    2.236459] alg: No test for authenc(hmac(sha224),cbc(aes)) (authenc-hmac-sha224-cbc-aes-talitos)
      [    2.247196] alg: aead: Test 1 failed on encryption for authenc-hmac-sha224-cbc-3des-talitos
      [    2.255555] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
      00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
      00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
      00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
      00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
      00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
      00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
      00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
      00000080: c0 50 f1 ac c0 50 f3 38 c0 50 f3 94 c0 50 f5 30
      00000090: c0 99 74 3c c0 96 e5 b8
      [    2.309004] alg: aead: Test 1 failed on encryption for authenc-hmac-sha224-cbc-3des-talitos
      [    2.317562] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
      00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
      00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
      00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
      00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
      00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
      00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
      00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
      00000080: c0 50 f1 ac c0 50 f3 38 c0 50 f3 94 c0 50 f5 30
      00000090: c0 99 74 3c c0 96 e5 b8
      [    2.370710] alg: aead: Test 1 failed on encryption for authenc-hmac-sha256-cbc-aes-talitos
      [    2.379177] 00000000: 53 69 6e 67 6c 65 20 62 6c 6f 63 6b 20 6d 73 67
      00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
      00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
      [    2.397863] alg: aead: Test 1 failed on encryption for authenc-hmac-sha256-cbc-aes-talitos
      [    2.406134] 00000000: 53 69 6e 67 6c 65 20 62 6c 6f 63 6b 20 6d 73 67
      00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
      00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
      [    2.424789] alg: aead: Test 1 failed on encryption for authenc-hmac-sha256-cbc-3des-talitos
      [    2.433491] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
      00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
      00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
      00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
      00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
      00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
      00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
      00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
      00000080: c0 50 f1 ac c0 50 f3 38 c0 50 f3 94 c0 50 f5 30
      00000090: c0 99 74 3c c0 96 e5 b8 c0 96 e9 20 c0 00 3d dc
      [    2.488832] alg: aead: Test 1 failed on encryption for authenc-hmac-sha256-cbc-3des-talitos
      [    2.497387] 00000000: 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72 73 74
      00000010: 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63 74 65
      00000020: 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65 65 72
      00000030: 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53 72 63
      00000040: 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20 63 65
      00000050: 65 72 73 74 54 20 6f 6f 4d 20 6e 61 20 79 65 53
      00000060: 72 63 74 65 20 73 6f 54 20 6f 61 4d 79 6e 53 20
      00000070: 63 65 65 72 73 74 54 20 6f 6f 4d 20 6e 61 0a 79
      00000080: c0 50 f1 ac c0 50 f3 38 c0 50 f3 94 c0 50 f5 30
      00000090: c0 99 74 3c c0 96 e5 b8 c0 96 e9 20 c0 00 3d dc
      
      This patch fixes that.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b9cf144
    • Daniel Jurgens's avatar
      IB/core: Only enforce security for InfiniBand · 796c9d1e
      Daniel Jurgens authored
      commit 315d160c upstream.
      
      For now the only LSM security enforcement mechanism available is
      specific to InfiniBand. Bypass enforcement for non-IB link types.
      
      This fixes a regression where modify_qp fails for iWARP because
      querying the PKEY returns -EINVAL.
      
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Don Dutile <ddutile@redhat.com>
      Reported-by: default avatarPotnuri Bharat Teja <bharat@chelsio.com>
      Fixes: d291f1a6("IB/core: Enforce PKey security on QPs")
      Fixes: 47a2b338("IB/core: Enforce security on management datagrams")
      Signed-off-by: default avatarDaniel Jurgens <danielj@mellanox.com>
      Reviewed-by: default avatarParav Pandit <parav@mellanox.com>
      Tested-by: default avatarPotnuri Bharat Teja <bharat@chelsio.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>
      796c9d1e
    • Parav Pandit's avatar
      IB/core: Avoid unnecessary return value check · 45f846ca
      Parav Pandit authored
      commit 2e4c85c6 upstream.
      
      Since there is nothing done with non zero return value, such check is
      avoided.
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45f846ca
    • Kim Phillips's avatar
      bus: arm-ccn: fix module unloading Error: Removing state 147 which has instances left. · 1cef55be
      Kim Phillips authored
      commit b69f63eb upstream.
      
      Unregistering the driver before calling cpuhp_remove_multi_state() removes
      any remaining hotplug cpu instances so __cpuhp_remove_state_cpuslocked()
      doesn't emit this warning:
      
      [  268.748362] Error: Removing state 147 which has instances left.
      [  268.748373] ------------[ cut here ]------------
      [  268.748386] WARNING: CPU: 2 PID: 5476 at kernel/cpu.c:1734 __cpuhp_remove_state_cpuslocked+0x454/0x4f0
      [  268.748389] Modules linked in: arm_ccn(-) [last unloaded: arm_ccn]
      [  268.748403] CPU: 2 PID: 5476 Comm: rmmod Tainted: G        W       4.14.0-rc4+ #3
      [  268.748406] Hardware name: AMD Seattle/Seattle, BIOS 10:18:39 Dec  8 2016
      [  268.748410] task: ffff8001a18ca000 task.stack: ffff80019c120000
      [  268.748416] PC is at __cpuhp_remove_state_cpuslocked+0x454/0x4f0
      [  268.748421] LR is at __cpuhp_remove_state_cpuslocked+0x448/0x4f0
      [  268.748425] pc : [<ffff2000081729ec>] lr : [<ffff2000081729e0>] pstate: 60000145
      [  268.748427] sp : ffff80019c127d30
      [  268.748430] x29: ffff80019c127d30 x28: ffff8001a18ca000
      [  268.748437] x27: ffff20000c2cb000 x26: 1fffe4000042d490
      [  268.748443] x25: ffff20000216a480 x24: 0000000000000000
      [  268.748449] x23: ffff20000b08e000 x22: 0000000000000001
      [  268.748455] x21: 0000000000000093 x20: 00000000000016f8
      [  268.748460] x19: ffff20000c2cbb80 x18: 0000ffffb5fe7c58
      [  268.748466] x17: 00000000004402d0 x16: 1fffe40001864f01
      [  268.748472] x15: ffff20000c4bf8b0 x14: 0000000000000000
      [  268.748477] x13: 0000000000007032 x12: ffff20000829ae48
      [  268.748483] x11: ffff20000c4bf000 x10: 0000000000000004
      [  268.748488] x9 : 0000000000006fbc x8 : ffff20000c318a40
      [  268.748494] x7 : 0000000000000000 x6 : ffff040001864f02
      [  268.748500] x5 : 0000000000000000 x4 : 0000000000000000
      [  268.748505] x3 : 0000000000000007 x2 : dfff200000000000
      [  268.748510] x1 : 000000000000ad3d x0 : 00000000000001f0
      [  268.748516] Call trace:
      [  268.748521] Exception stack(0xffff80019c127bf0 to 0xffff80019c127d30)
      [  268.748526] 7be0:                                   00000000000001f0 000000000000ad3d
      [  268.748531] 7c00: dfff200000000000 0000000000000007 0000000000000000 0000000000000000
      [  268.748535] 7c20: ffff040001864f02 0000000000000000 ffff20000c318a40 0000000000006fbc
      [  268.748539] 7c40: 0000000000000004 ffff20000c4bf000 ffff20000829ae48 0000000000007032
      [  268.748544] 7c60: 0000000000000000 ffff20000c4bf8b0 1fffe40001864f01 00000000004402d0
      [  268.748548] 7c80: 0000ffffb5fe7c58 ffff20000c2cbb80 00000000000016f8 0000000000000093
      [  268.748553] 7ca0: 0000000000000001 ffff20000b08e000 0000000000000000 ffff20000216a480
      [  268.748557] 7cc0: 1fffe4000042d490 ffff20000c2cb000 ffff8001a18ca000 ffff80019c127d30
      [  268.748562] 7ce0: ffff2000081729e0 ffff80019c127d30 ffff2000081729ec 0000000060000145
      [  268.748566] 7d00: 00000000000001f0 0000000000000000 0001000000000000 0000000000000000
      [  268.748569] 7d20: ffff80019c127d30 ffff2000081729ec
      [  268.748575] [<ffff2000081729ec>] __cpuhp_remove_state_cpuslocked+0x454/0x4f0
      [  268.748580] [<ffff200008172adc>] __cpuhp_remove_state+0x54/0x80
      [  268.748597] [<ffff20000215dd84>] arm_ccn_exit+0x2c/0x70 [arm_ccn]
      [  268.748604] [<ffff20000834cfbc>] SyS_delete_module+0x5a4/0x708
      [  268.748607] Exception stack(0xffff80019c127ec0 to 0xffff80019c128000)
      [  268.748612] 7ec0: 0000000019bb7258 0000000000000800 ba64d0fb3d26a800 00000000000000da
      [  268.748616] 7ee0: 0000ffffb6144e28 0000ffffcd95b409 fefefefefefefeff 7f7f7f7f7f7f7f7f
      [  268.748621] 7f00: 000000000000006a 1999999999999999 0000ffffb6179000 0000000000bbcc6d
      [  268.748625] 7f20: 0000ffffb6176b98 0000ffffcd95c2d0 0000ffffb5fe7b58 0000ffffb6163000
      [  268.748630] 7f40: 0000ffffb60ad3e0 00000000004402d0 0000ffffb5fe7c58 0000000019bb71f0
      [  268.748634] 7f60: 0000ffffcd95c740 0000000000000000 0000000019bb71f0 0000000000416700
      [  268.748639] 7f80: 0000000000000000 00000000004402e8 0000000019bb6010 0000ffffcd95c748
      [  268.748643] 7fa0: 0000000000000000 0000ffffcd95c460 00000000004113a8 0000ffffcd95c460
      [  268.748648] 7fc0: 0000ffffb60ad3e8 0000000080000000 0000000019bb7258 000000000000006a
      [  268.748652] 7fe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      [  268.748657] [<ffff200008084f9c>] __sys_trace_return+0x0/0x4
      [  268.748661] ---[ end trace a996d358dcaa7f9c ]---
      
      Fixes: 8df03872 ("bus/arm-ccn: Use cpu-hp's multi instance support instead custom list")
      Signed-off-by: default avatarKim Phillips <kim.phillips@arm.com>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarPawel Moll <pawel.moll@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1cef55be
    • Marc Zyngier's avatar
      bus: arm-ccn: Fix use of smp_processor_id() in preemptible context · 8741b5ab
      Marc Zyngier authored
      commit b18c2b94 upstream.
      
      Booting a DEBUG_PREEMPT enabled kernel on a CCN-based system
      results in the following splat:
      
      [...]
      arm-ccn e8000000.ccn: No access to interrupts, using timer.
      BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
      caller is debug_smp_processor_id+0x1c/0x28
      CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.13.0 #6111
      Hardware name: AMD Seattle/Seattle, BIOS 17:08:23 Jun 26 2017
      Call trace:
      [<ffff000008089e78>] dump_backtrace+0x0/0x278
      [<ffff00000808a22c>] show_stack+0x24/0x30
      [<ffff000008bc3bc4>] dump_stack+0x8c/0xb0
      [<ffff00000852b534>] check_preemption_disabled+0xfc/0x100
      [<ffff00000852b554>] debug_smp_processor_id+0x1c/0x28
      [<ffff000008551bd8>] arm_ccn_probe+0x358/0x4f0
      [...]
      
      as we use smp_processor_id() in the wrong context.
      
      Turn this into a get_cpu()/put_cpu() that extends over the CPU hotplug
      registration, making sure that we don't race against a CPU down operation.
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarPawel Moll <pawel.moll@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8741b5ab
    • Christophe JAILLET's avatar
      bus: arm-ccn: Check memory allocation failure · a724b569
      Christophe JAILLET authored
      commit 24771179 upstream.
      
      Check memory allocation failures and return -ENOMEM in such cases
      
      This avoids a potential NULL pointer dereference.
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Acked-by: default avatarScott Branden <scott.branden@broadcom.com>
      Signed-off-by: default avatarPawel Moll <pawel.moll@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a724b569
    • Marc Zyngier's avatar
      bus: arm-cci: Fix use of smp_processor_id() in preemptible context · 2ced9e2a
      Marc Zyngier authored
      commit 4608af8a upstream.
      
      The ARM CCI driver seem to be using smp_processor_id() in a
      preemptible context, which is likely to make a DEBUG_PREMPT
      kernel scream at boot time.
      
      Turn this into a get_cpu()/put_cpu() that extends over the CPU
      hotplug registration, making sure that we don't race against
      a CPU down operation.
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarPawel Moll <pawel.moll@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ced9e2a
    • Fabio Estevam's avatar
      Revert "ARM: dts: imx53: add srtc node" · 1d6c9240
      Fabio Estevam authored
      commit e501506d upstream.
      
      This reverts commit 5b725054.
      
      The rtc block on i.MX53 is a completely different hardware than the
      one found on i.MX25.
      Reported-by: default avatarNoel Vellemans <Noel.Vellemans@visionbms.com>
      Suggested-by: default avatarJuergen Borleis <jbe@pengutronix.de>
      Signed-off-by: default avatarFabio Estevam <fabio.estevam@nxp.com>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1d6c9240
    • Will Deacon's avatar
      arm64: SW PAN: Update saved ttbr0 value on enter_lazy_tlb · e7ef4e82
      Will Deacon authored
      commit d96cc49b upstream.
      
      enter_lazy_tlb is called when a kernel thread rides on the back of
      another mm, due to a context switch or an explicit call to unuse_mm
      where a call to switch_mm is elided.
      
      In these cases, it's important to keep the saved ttbr value up to date
      with the active mm, otherwise we can end up with a stale value which
      points to a potentially freed page table.
      
      This patch implements enter_lazy_tlb for arm64, so that the saved ttbr0
      is kept up-to-date with the active mm for kernel threads.
      
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Vinayak Menon <vinmenon@codeaurora.org>
      Fixes: 39bc88e5 ("arm64: Disable TTBR0_EL1 during normal kernel execution")
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reported-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e7ef4e82
    • Will Deacon's avatar
      arm64: SW PAN: Point saved ttbr0 at the zero page when switching to init_mm · a5347596
      Will Deacon authored
      commit 0adbdfde upstream.
      
      update_saved_ttbr0 mandates that mm->pgd is not swapper, since swapper
      contains kernel mappings and should never be installed into ttbr0. However,
      this means that callers must avoid passing the init_mm to update_saved_ttbr0
      which in turn can cause the saved ttbr0 value to be out-of-date in the context
      of the idle thread. For example, EFI runtime services may leave the saved ttbr0
      pointing at the EFI page table, and kernel threads may end up with stale
      references to freed page tables.
      
      This patch changes update_saved_ttbr0 so that the init_mm points the saved
      ttbr0 value to the empty zero page, which always exists and never contains
      valid translations. EFI and switch can then call into update_saved_ttbr0
      unconditionally.
      
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Vinayak Menon <vinmenon@codeaurora.org>
      Fixes: 39bc88e5 ("arm64: Disable TTBR0_EL1 during normal kernel execution")
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reported-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a5347596
    • Dave Martin's avatar
      arm64: fpsimd: Prevent registers leaking from dead tasks · d0e9c772
      Dave Martin authored
      commit 071b6d4a upstream.
      
      Currently, loading of a task's fpsimd state into the CPU registers
      is skipped if that task's state is already present in the registers
      of that CPU.
      
      However, the code relies on the struct fpsimd_state * (and by
      extension struct task_struct *) to unambiguously identify a task.
      
      There is a particular case in which this doesn't work reliably:
      when a task exits, its task_struct may be recycled to describe a
      new task.
      
      Consider the following scenario:
      
       1) Task P loads its fpsimd state onto cpu C.
              per_cpu(fpsimd_last_state, C) := P;
              P->thread.fpsimd_state.cpu := C;
      
       2) Task X is scheduled onto C and loads its fpsimd state on C.
              per_cpu(fpsimd_last_state, C) := X;
              X->thread.fpsimd_state.cpu := C;
      
       3) X exits, causing X's task_struct to be freed.
      
       4) P forks a new child T, which obtains X's recycled task_struct.
      	T == X.
      	T->thread.fpsimd_state.cpu == C (inherited from P).
      
       5) T is scheduled on C.
      	T's fpsimd state is not loaded, because
      	per_cpu(fpsimd_last_state, C) == T (== X) &&
      	T->thread.fpsimd_state.cpu == C.
      
              (This is the check performed by fpsimd_thread_switch().)
      
      So, T gets X's registers because the last registers loaded onto C
      were those of X, in (2).
      
      This patch fixes the problem by ensuring that the sched-in check
      fails in (5): fpsimd_flush_task_state(T) is called when T is
      forked, so that T->thread.fpsimd_state.cpu == C cannot be true.
      This relies on the fact that T is not schedulable until after
      copy_thread() completes.
      
      Once T's fpsimd state has been loaded on some CPU C there may still
      be other cpus D for which per_cpu(fpsimd_last_state, D) ==
      &X->thread.fpsimd_state.  But D is necessarily != C in this case,
      and the check in (5) must fail.
      
      An alternative fix would be to do refcounting on task_struct.  This
      would result in each CPU holding a reference to the last task whose
      fpsimd state was loaded there.  It's not clear whether this is
      preferable, and it involves higher overhead than the fix proposed
      in this patch.  It would also move all the task_struct freeing
      work into the context switch critical section, or otherwise some
      deferred cleanup mechanism would need to be introduced, neither of
      which seems obviously justified.
      
      Fixes: 005f78cd ("arm64: defer reloading a task's FPSIMD state to userland resume")
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      [will: word-smithed the comment so it makes more sense]
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0e9c772
    • Marc Zyngier's avatar
      KVM: arm/arm64: vgic-its: Check result of allocation before use · fdbc5f3c
      Marc Zyngier authored
      commit 686f294f upstream.
      
      We miss a test against NULL after allocation.
      
      Fixes: 6d03a68f ("KVM: arm64: vgic-its: Turn device_id validation into generic ID validation")
      Reported-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fdbc5f3c
    • Marc Zyngier's avatar
      KVM: arm/arm64: vgic: Preserve the revious read from the pending table · c6c0913b
      Marc Zyngier authored
      commit ddb4b010 upstream.
      
      The current pending table parsing code assumes that we keep the
      previous read of the pending bits, but keep that variable in
      the current block, making sure it is discarded on each loop.
      
      We end-up using whatever is on the stack. Who knows, it might
      just be the right thing...
      
      Fixes: 28077125 ("KVM: arm64: vgic-v3: KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES")
      Reported-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6c0913b
    • Marc Zyngier's avatar
      KVM: arm/arm64: vgic-irqfd: Fix MSI entry allocation · af85c1e0
      Marc Zyngier authored
      commit 150009e2 upstream.
      
      Using the size of the structure we're allocating is a good idea
      and avoids any surprise... In this case, we're happilly confusing
      kvm_kernel_irq_routing_entry and kvm_irq_routing_entry...
      
      Fixes: 95b110ab ("KVM: arm/arm64: Enable irqchip routing")
      Reported-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af85c1e0
    • Christoffer Dall's avatar
      KVM: arm/arm64: Fix broken GICH_ELRSR big endian conversion · 73c4af96
      Christoffer Dall authored
      commit fc396e06 upstream.
      
      We are incorrectly rearranging 32-bit words inside a 64-bit typed value
      for big endian systems, which would result in never marking a virtual
      interrupt as inactive on big endian systems (assuming 32 or fewer LRs on
      the hardware).  Fix this by not doing any word order manipulation for
      the typed values.
      Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73c4af96
    • Andrew Honig's avatar
      KVM: VMX: remove I/O port 0x80 bypass on Intel hosts · a52c2829
      Andrew Honig authored
      commit d59d51f0 upstream.
      
      This fixes CVE-2017-1000407.
      
      KVM allows guests to directly access I/O port 0x80 on Intel hosts.  If
      the guest floods this port with writes it generates exceptions and
      instability in the host kernel, leading to a crash.  With this change
      guest writes to port 0x80 on Intel will behave the same as they
      currently behave on AMD systems.
      
      Prevent the flooding by removing the code that sets port 0x80 as a
      passthrough port.  This is essentially the same as upstream patch
      99f85a28, except that patch was
      for AMD chipsets and this patch is for Intel.
      Signed-off-by: default avatarAndrew Honig <ahonig@google.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Fixes: fdef3ad1 ("KVM: VMX: Enable io bitmaps to avoid IO port 0x80 VMEXITs")
      Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a52c2829
    • Marc Zyngier's avatar
      arm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one · ba8cbedc
      Marc Zyngier authored
      commit 5553b142 upstream.
      
      VTTBR_BADDR_MASK is used to sanity check the size and alignment of the
      VTTBR address. It seems to currently be off by one, thereby only
      allowing up to 39-bit addresses (instead of 40-bit) and also
      insufficiently checking the alignment. This patch fixes it.
      
      This patch is the 32bit pendent of Kristina's arm64 fix, and
      she deserves the actual kudos for pinpointing that one.
      
      Fixes: f7ed45be ("KVM: ARM: World-switch implementation")
      Reported-by: default avatarKristina Martsenko <kristina.martsenko@arm.com>
      Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ba8cbedc
    • Kristina Martsenko's avatar
      arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one · c4e71b6f
      Kristina Martsenko authored
      commit 26aa7b3b upstream.
      
      VTTBR_BADDR_MASK is used to sanity check the size and alignment of the
      VTTBR address. It seems to currently be off by one, thereby only
      allowing up to 47-bit addresses (instead of 48-bit) and also
      insufficiently checking the alignment. This patch fixes it.
      
      As an example, with 4k pages, before this patch we have:
      
        PHYS_MASK_SHIFT = 48
        VTTBR_X = 37 - 24 = 13
        VTTBR_BADDR_SHIFT = 13 - 1 = 12
        VTTBR_BADDR_MASK = ((1 << 35) - 1) << 12 = 0x00007ffffffff000
      
      Which is wrong, because the mask doesn't allow bit 47 of the VTTBR
      address to be set, and only requires the address to be 12-bit (4k)
      aligned, while it actually needs to be 13-bit (8k) aligned because we
      concatenate two 4k tables.
      
      With this patch, the mask becomes 0x0000ffffffffe000, which is what we
      want.
      
      Fixes: 0369f6a3 ("arm64: KVM: EL2 register definitions")
      Reviewed-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarKristina Martsenko <kristina.martsenko@arm.com>
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c4e71b6f
    • Sean Young's avatar
      media: rc: partial revert of "media: rc: per-protocol repeat period" · f889ad87
      Sean Young authored
      commit 67f0f15a upstream.
      
      Since commit d57ea877 ("media: rc: per-protocol repeat period"), most
      IR protocols have a lower keyup timeout. This causes problems on the
      ite-cir, which has default IR timeout of 200ms.
      
      Since the IR decoders read the trailing space, with a IR timeout of 200ms,
      the last keydown will have at least a delay of 200ms. This is more than
      the protocol timeout of e.g. rc-6 (which is 164ms). As a result the last
      IR will be interpreted as a new keydown event, and we get two keypresses.
      
      Revert the protocol timeout to 250ms, except for cec which needs a timeout
      of 550ms.
      
      Fixes: d57ea877 ("media: rc: per-protocol repeat period")
      Reported-by: default avatarMatthias Reichl <hias@horus.com>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Tested-by: default avatarMatthias Reichl <hias@horus.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f889ad87
    • Sean Young's avatar
      media: rc: sir_ir: detect presence of port · 2f224108
      Sean Young authored
      commit 30b4e122 upstream.
      
      Without this test, sir_ir clumsy claims resources for a device which
      does not exist.
      
      The 0-day kernel test robot reports the following errors (in a loop):
      	sir_ir sir_ir.0: Trapped in interrupt
      	genirq: Flags mismatch irq 4. 00000000 (ttyS0) vs. 00000000 (sir_ir)
      
      When sir_ir is loaded with the default io and irq, the following happens:
       - sir_ir claims irq 4
       - user space opens /dev/ttyS0
       - in serial8250_do_startup(), some setup is done for ttyS0, which causes
         irq 4 to fire (in THRE test)
       - sir_ir does not realise it was not for it, and spins until the "trapped
         in interrupt"
       - now serial driver calls setup_irq() and fails and we get the
         "Flags mismatch" error.
      
      There is no port present at 0x3e8 so simply check for the presence of a
      port, as suggested by Linus.
      Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
      Tested-by: default avatarFengguang Wu <fengguang.wu@intel.com>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f224108
    • Laurent Caumont's avatar
    • Ville Syrjälä's avatar
      drm/i915: Fix vblank timestamp/frame counter jumps on gen2 · e547af25
      Ville Syrjälä authored
      commit a87e55f8 upstream.
      
      Previously I was under the impression that the scanline counter
      reads 0 when the pipe is off. Turns out that's not correct, and
      instead the scanline counter simply stops when the pipe stops, and
      it retains it's last value until the pipe starts up again, at which
      point the scanline counter jumps to vblank start.
      
      These jumps can cause the timestamp to jump backwards by one frame.
      Since we use the timestamps to guesstimage also the frame counter
      value on gen2, that would cause the frame counter to also jump
      backwards, which leads to a massice difference from the previous value.
      The end result is that flips/vblank events don't appear to complete as
      they're stuck waiting for the frame counter to catch up to that massive
      difference.
      
      Fix the problem properly by actually making sure the scanline counter
      has started to move before we assume that it's safe to enable vblank
      processing.
      
      v2: Less pointless duplication in the code (Chris)
      
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Fixes: b7792d8b ("drm/i915: Wait for pipe to start before sampling vblank timestamps on gen2")
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20171129153732.3612-1-ville.syrjala@linux.intel.com
      (cherry picked from commit 8fedd64d)
      Signed-off-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e547af25
    • Marek Szyprowski's avatar
      drm/exynos: gem: Drop NONCONTIG flag for buffers allocated without IOMMU · 4b929631
      Marek Szyprowski authored
      commit 120a264f upstream.
      
      When no IOMMU is available, all GEM buffers allocated by Exynos DRM driver
      are contiguous, because of the underlying dma_alloc_attrs() function
      provides only such buffers. In such case it makes no sense to keep
      BO_NONCONTIG flag for the allocated GEM buffers. This allows to avoid
      failures for buffer contiguity checks in the subsequent operations on GEM
      objects.
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b929631
    • Marek Szyprowski's avatar
      drm/bridge: analogix dp: Fix runtime PM state in get_modes() callback · 25df8b00
      Marek Szyprowski authored
      commit 510353a6 upstream.
      
      get_modes() callback might be called asynchronously from the DRM core and
      it is not synchronized with bridge_enable(), which sets proper runtime PM
      state of the main DP device. Fix this by calling pm_runtime_get_sync()
      before calling drm_get_edid(), which in turn calls drm_dp_i2c_xfer() and
      analogix_dp_transfer() to ensure that main DP device is runtime active
      when doing any access to its registers.
      
      This fixes the following kernel issue on Samsung Exynos5250 Snow board:
      Unhandled fault: imprecise external abort (0x406) at 0x00000000
      pgd = c0004000
      [00000000] *pgd=00000000
      Internal error: : 406 [#1] PREEMPT SMP ARM
      Modules linked in:
      CPU: 0 PID: 62 Comm: kworker/0:2 Not tainted 4.13.0-rc2-00364-g4a97a3da #3357
      Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
      Workqueue: events output_poll_execute
      task: edc14800 task.stack: edcb2000
      PC is at analogix_dp_transfer+0x15c/0x2fc
      LR is at analogix_dp_transfer+0x134/0x2fc
      pc : [<c0468538>]    lr : [<c0468510>]    psr: 60000013
      sp : edcb3be8  ip : 0000002a  fp : 00000001
      r10: 00000000  r9 : edcb3cd8  r8 : edcb3c40
      r7 : 00000000  r6 : edd3b380  r5 : edd3b010  r4 : 00000064
      r3 : 00000000  r2 : f0ad3000  r1 : edcb3c40  r0 : edd3b010
      Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
      Control: 10c5387d  Table: 4000406a  DAC: 00000051
      Process kworker/0:2 (pid: 62, stack limit = 0xedcb2210)
      Stack: (0xedcb3be8 to 0xedcb4000)
      [<c0468538>] (analogix_dp_transfer) from [<c0424ba4>] (drm_dp_i2c_do_msg+0x8c/0x2b4)
      [<c0424ba4>] (drm_dp_i2c_do_msg) from [<c0424e64>] (drm_dp_i2c_xfer+0x98/0x214)
      [<c0424e64>] (drm_dp_i2c_xfer) from [<c057b2d8>] (__i2c_transfer+0x140/0x29c)
      [<c057b2d8>] (__i2c_transfer) from [<c057b4a4>] (i2c_transfer+0x70/0xe4)
      [<c057b4a4>] (i2c_transfer) from [<c0441de4>] (drm_do_probe_ddc_edid+0xb4/0x114)
      [<c0441de4>] (drm_do_probe_ddc_edid) from [<c0441e5c>] (drm_probe_ddc+0x18/0x28)
      [<c0441e5c>] (drm_probe_ddc) from [<c0445728>] (drm_get_edid+0x124/0x2d4)
      [<c0445728>] (drm_get_edid) from [<c0465ea0>] (analogix_dp_get_modes+0x90/0x114)
      [<c0465ea0>] (analogix_dp_get_modes) from [<c0425e8c>] (drm_helper_probe_single_connector_modes+0x198/0x68c)
      [<c0425e8c>] (drm_helper_probe_single_connector_modes) from [<c04325d4>] (drm_setup_crtcs+0x1b4/0xd18)
      [<c04325d4>] (drm_setup_crtcs) from [<c04344a8>] (drm_fb_helper_hotplug_event+0x94/0xd0)
      [<c04344a8>] (drm_fb_helper_hotplug_event) from [<c0425a50>] (drm_kms_helper_hotplug_event+0x24/0x28)
      [<c0425a50>] (drm_kms_helper_hotplug_event) from [<c04263ec>] (output_poll_execute+0x6c/0x174)
      [<c04263ec>] (output_poll_execute) from [<c0136f18>] (process_one_work+0x188/0x3fc)
      [<c0136f18>] (process_one_work) from [<c01371f4>] (worker_thread+0x30/0x4b8)
      [<c01371f4>] (worker_thread) from [<c013daf8>] (kthread+0x128/0x164)
      [<c013daf8>] (kthread) from [<c0108510>] (ret_from_fork+0x14/0x24)
      Code: 0a000002 ea000009 e2544001 0a00004a (e59537c8)
      ---[ end trace cddc7919c79f7878 ]---
      Reported-by: default avatarMisha Komarovskiy <zombah@gmail.com>
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20171121074936.22520-1-m.szyprowski@samsung.com
      25df8b00
    • Song Liu's avatar
      md/r5cache: move mddev_lock() out of r5c_journal_mode_set() · 55b26ae2
      Song Liu authored
      commit ff35f58e upstream.
      
      r5c_journal_mode_set() is called by r5c_journal_mode_store() and
      raid_ctr() in dm-raid. We don't need mddev_lock() when calling from
      raid_ctr(). This patch fixes this by moves the mddev_lock() to
      r5c_journal_mode_store().
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarShaohua Li <shli@fb.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55b26ae2
    • Daniel Thompson's avatar
      kdb: Fix handling of kallsyms_symbol_next() return value · 425704be
      Daniel Thompson authored
      commit c07d3533 upstream.
      
      kallsyms_symbol_next() returns a boolean (true on success). Currently
      kdb_read() tests the return value with an inequality that
      unconditionally evaluates to true.
      
      This is fixed in the obvious way and, since the conditional branch is
      supposed to be unreachable, we also add a WARN_ON().
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: default avatarJason Wessel <jason.wessel@windriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      425704be
    • Arend Van Spriel's avatar
      brcmfmac: change driver unbind order of the sdio function devices · 01b43f2e
      Arend Van Spriel authored
      commit 5c3de777 upstream.
      
      In the function brcmf_sdio_firmware_callback() the driver is
      unbound from the sdio function devices in the error path.
      However, the order in which it is done resulted in a use-after-free
      issue (see brcmf_ops_sdio_remove() in bcmsdh.c). Hence change
      the order and first unbind sdio function #2 device and then
      unbind sdio function #1 device.
      
      Fixes: 7a51461f ("brcmfmac: unbind all devices upon failure in firmware callback")
      Reported-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Reviewed-by: default avatarHante Meuleman <hante.meuleman@broadcom.com>
      Reviewed-by: default avatarPieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
      Reviewed-by: default avatarFranky Lin <franky.lin@broadcom.com>
      Signed-off-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      01b43f2e
    • David Spinadel's avatar
      iwlwifi: mvm: enable RX offloading with TKIP and WEP · 15f36a5e
      David Spinadel authored
      commit 9d0fc5a5 upstream.
      
      Set the flag that indicates that ICV was stripped on if
      this option was enabled in the HW.
      
      [this is needed for the 9000-series HW to work properly]
      Signed-off-by: default avatarDavid Spinadel <david.spinadel@intel.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      15f36a5e
    • Emmanuel Grumbach's avatar
      iwlwifi: mvm: fix packet injection · 0d46809c
      Emmanuel Grumbach authored
      commit b13f43a4 upstream.
      
      We need to have a station and a queue for the monitor
      interface to be able to inject traffic. We used to have
      this traffic routed to the auxiliary queue, but this queue
      isn't scheduled for the station we had linked to the
      monitor vif.
      
      Allocate a new queue, link it to the monitor vif's station
      and make that queue use the BE fifo.
      
      This fixes https://bugzilla.kernel.org/show_bug.cgi?id=196715Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0d46809c