04 Feb, 2018

29 commits

  • commit c5313ae8e4e037bfaf5e56cb8d6efdb8e92ce437 upstream.

    Driver attempts to perform a device scan and device add after coming out
    of reset. At times when the kdump kernel loads and it tries to perform
    eh recovery, the device scan hangs since its commands are blocked because
    of the eh recovery. This should have shown up in normal eh recovery path
    (Should have been obvious)

    Remove the code that performs scanning.I can live without the rescanning
    support in the stable kernels but a hanging kdump/eh recovery needs to be
    fixed.

    Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after controller reset)
    Reported-by: Douglas Miller
    Tested-by: Guilherme G. Piccoli
    Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after controller reset)
    Signed-off-by: Raghava Aditya Renukunta
    Signed-off-by: Martin K. Petersen
    Signed-off-by: Greg Kroah-Hartman

    Raghava Aditya Renukunta
     
  • commit f4e8708d3104437fd7716e957f38c265b0c509ef upstream.

    When udev requests for a devices inquiry string, it might create multiple
    threads causing a race condition on the shared inquiry resource string.

    Created a buffer with the string for each thread.

    Fixes: 3bc8070fb75b3315 ([SCSI] aacraid: SMC vendor identification)
    Signed-off-by: Raghava Aditya Renukunta
    Signed-off-by: Martin K. Petersen
    Signed-off-by: Greg Kroah-Hartman

    Raghava Aditya Renukunta
     
  • commit 36447456e1cca853188505f2a964dbbeacfc7a7a upstream.

    The switch to uuid_t invereted the logic of verfication that &entry->fsuuid
    is zero during parsing of "fsuuid=" rule. Instead of making sure the
    &entry->fsuuid field is not attempted to be overwritten, we bail out for
    perfectly correct rule.

    Fixes: 787d8c530af7 ("ima/policy: switch to use uuid_t")
    Signed-off-by: Mike Rapoport
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Mike Rapoport
     
  • commit 888f22931478a05bc81ceb7295c626e1292bf0ed upstream.

    Recently I got a Caldigit TS3 Thunderbolt 3 dock, and noticed that upon
    hotplugging my kernel would immediately crash due to igb:

    [ 680.825801] kernel BUG at drivers/pci/msi.c:352!
    [ 680.828388] invalid opcode: 0000 [#1] SMP
    [ 680.829194] Modules linked in: igb(O) thunderbolt i2c_algo_bit joydev vfat fat btusb btrtl btbcm btintel bluetooth ecdh_generic hp_wmi sparse_keymap rfkill wmi_bmof iTCO_wdt intel_rapl x86_pkg_temp_thermal coretemp crc32_pclmul snd_pcm rtsx_pci_ms mei_me snd_timer memstick snd pcspkr mei soundcore i2c_i801 tpm_tis psmouse shpchp wmi tpm_tis_core tpm video hp_wireless acpi_pad rtsx_pci_sdmmc mmc_core crc32c_intel serio_raw rtsx_pci mfd_core xhci_pci xhci_hcd i2c_hid i2c_core [last unloaded: igb]
    [ 680.831085] CPU: 1 PID: 78 Comm: kworker/u16:1 Tainted: G O 4.15.0-rc3Lyude-Test+ #6
    [ 680.831596] Hardware name: HP HP ZBook Studio G4/826B, BIOS P71 Ver. 01.03 06/09/2017
    [ 680.832168] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
    [ 680.832687] RIP: 0010:free_msi_irqs+0x180/0x1b0
    [ 680.833271] RSP: 0018:ffffc9000030fbf0 EFLAGS: 00010286
    [ 680.833761] RAX: ffff8803405f9c00 RBX: ffff88033e3d2e40 RCX: 000000000000002c
    [ 680.834278] RDX: 0000000000000000 RSI: 00000000000000ac RDI: ffff880340be2178
    [ 680.834832] RBP: 0000000000000000 R08: ffff880340be1ff0 R09: ffff8803405f9c00
    [ 680.835342] R10: 0000000000000000 R11: 0000000000000040 R12: ffff88033d63a298
    [ 680.835822] R13: ffff88033d63a000 R14: 0000000000000060 R15: ffff880341959000
    [ 680.836332] FS: 0000000000000000(0000) GS:ffff88034f440000(0000) knlGS:0000000000000000
    [ 680.836817] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 680.837360] CR2: 000055e64044afdf CR3: 0000000001c09002 CR4: 00000000003606e0
    [ 680.837954] Call Trace:
    [ 680.838853] pci_disable_msix+0xce/0xf0
    [ 680.839616] igb_reset_interrupt_capability+0x5d/0x60 [igb]
    [ 680.840278] igb_remove+0x9d/0x110 [igb]
    [ 680.840764] pci_device_remove+0x36/0xb0
    [ 680.841279] device_release_driver_internal+0x157/0x220
    [ 680.841739] pci_stop_bus_device+0x7d/0xa0
    [ 680.842255] pci_stop_bus_device+0x2b/0xa0
    [ 680.842722] pci_stop_bus_device+0x3d/0xa0
    [ 680.843189] pci_stop_and_remove_bus_device+0xe/0x20
    [ 680.843627] trim_stale_devices+0xf3/0x140
    [ 680.844086] trim_stale_devices+0x94/0x140
    [ 680.844532] trim_stale_devices+0xa6/0x140
    [ 680.845031] ? get_slot_status+0x90/0xc0
    [ 680.845536] acpiphp_check_bridge.part.5+0xfe/0x140
    [ 680.846021] acpiphp_hotplug_notify+0x175/0x200
    [ 680.846581] ? free_bridge+0x100/0x100
    [ 680.847113] acpi_device_hotplug+0x8a/0x490
    [ 680.847535] acpi_hotplug_work_fn+0x1a/0x30
    [ 680.848076] process_one_work+0x182/0x3a0
    [ 680.848543] worker_thread+0x2e/0x380
    [ 680.848963] ? process_one_work+0x3a0/0x3a0
    [ 680.849373] kthread+0x111/0x130
    [ 680.849776] ? kthread_create_worker_on_cpu+0x50/0x50
    [ 680.850188] ret_from_fork+0x1f/0x30
    [ 680.850601] Code: 43 14 85 c0 0f 84 d5 fe ff ff 31 ed eb 0f 83 c5 01 39 6b 14 0f 86 c5 fe ff ff 8b 7b 10 01 ef e8 b7 e4 d2 ff 48 83 78 70 00 74 e3 0b 49 8d b5 a0 00 00 00 e8 62 6f d3 ff e9 c7 fe ff ff 48 8b
    [ 680.851497] RIP: free_msi_irqs+0x180/0x1b0 RSP: ffffc9000030fbf0

    As it turns out, normally the freeing of IRQs that would fix this is called
    inside of the scope of __igb_close(). However, since the device is
    already gone by the point we try to unregister the netdevice from the
    driver due to a hotplug we end up seeing that the netif isn't present
    and thus, forget to free any of the device IRQs.

    So: make sure that if we're in the process of dismantling the netdev, we
    always allow __igb_close() to be called so that IRQs may be freed
    normally. Additionally, only allow igb_close() to be called from
    __igb_close() if it hasn't already been called for the given adapter.

    Signed-off-by: Lyude Paul
    Fixes: 9474933caf21 ("igb: close/suspend race in netif_device_detach")
    Cc: Todd Fujinaka
    Cc: Stephen Hemminger
    Tested-by: Aaron Brown
    Signed-off-by: Jeff Kirsher
    Signed-off-by: Greg Kroah-Hartman

    Lyude Paul
     
  • commit d822401d1c6898a4a4ee03977b78b8cec402e88a upstream.

    This change resolves a new compile-time warning
    when built as a loadable module:

    WARNING: modpost: missing MODULE_LICENSE() in drivers/mtd/nand/denali_pci.o
    see include/linux/module.h for more information

    This adds the license as "GPL v2", which matches the header of the file.

    MODULE_DESCRIPTION and MODULE_AUTHOR are also added.

    Signed-off-by: Jesse Chan
    Acked-by: Masahiro Yamada
    Signed-off-by: Boris Brezillon
    Signed-off-by: Greg Kroah-Hartman

    Jesse Chan
     
  • commit 539340f37e6d6ed4cd93e8e18c9b2e4eafd4b842 upstream.

    This change resolves a new compile-time warning
    when built as a loadable module:

    WARNING: modpost: missing MODULE_LICENSE() in drivers/gpio/gpio-ath79.o
    see include/linux/module.h for more information

    This adds the license as "GPL v2", which matches the header of the file.

    MODULE_DESCRIPTION is also added.

    Signed-off-by: Jesse Chan
    Acked-by: Alban Bedel
    Signed-off-by: Linus Walleij
    Signed-off-by: Greg Kroah-Hartman

    Jesse Chan
     
  • commit 97b03136e1b637d7a9d2274c099e44ecf23f1103 upstream.

    This change resolves a new compile-time warning
    when built as a loadable module:

    WARNING: modpost: missing MODULE_LICENSE() in drivers/gpio/gpio-iop.o
    see include/linux/module.h for more information

    This adds the license as "GPL", which matches the header of the file.

    MODULE_DESCRIPTION and MODULE_AUTHOR are also added.

    Signed-off-by: Jesse Chan
    Signed-off-by: Linus Walleij
    Signed-off-by: Greg Kroah-Hartman

    Jesse Chan
     
  • commit 348c7cf5fcbcb68838255759d4cb45d039af36d2 upstream.

    This change resolves a new compile-time warning
    when built as a loadable module:

    WARNING: modpost: missing MODULE_LICENSE() in drivers/power/reset/zx-reboot.o
    see include/linux/module.h for more information

    This adds the license as "GPL v2", which matches the header of the file.

    MODULE_DESCRIPTION and MODULE_AUTHOR are also added.

    Signed-off-by: Jesse Chan
    Signed-off-by: Sebastian Reichel
    Signed-off-by: Greg Kroah-Hartman

    Jesse Chan
     
  • commit 403c0f681c1964ff1db8c2fb8de8c4067779d081 upstream.

    Touch toggle softkeys send a '1' while pressed and a '0' while released,
    requring the kernel to keep track of wether touch should be enabled or
    disabled. The code does not handle the state transitions properly,
    however. If the key is pressed repeatedly, the following four states
    of states are cycled through (assuming touch starts out enabled):

    Press: shared->is_touch_on => 0, SW_MUTE_DEVICE => 1
    Release: shared->is_touch_on => 0, SW_MUTE_DEVICE => 1
    Press: shared->is_touch_on => 1, SW_MUTE_DEVICE => 0
    Release: shared->is_touch_on => 1, SW_MUTE_DEVICE => 1

    The hardware always properly enables/disables touch when the key is
    pressed but applications that listen for SW_MUTE_DEVICE events to provide
    feedback about the state will only ever show touch as being enabled while
    the key is held, and only every-other time. This sequence occurs because
    the fallthrough WACOM_HID_WD_TOUCHONOFF case is always handled, and it
    uses the value of the *local* is_touch_on variable as the value to
    report to userspace. The local value is equal to the shared value when
    the button is pressed, but equal to zero when the button is released.

    Reporting the shared value to userspace fixes this problem, but the
    fallthrough case needs to update the shared value in an incompatible
    way (which is why the local variable was introduced in the first place).
    To work around this, we just handle both cases in a single block of code
    and update the shared variable as appropriate.

    Fixes: d793ff8187 ("HID: wacom: generic: support touch on/off softkey")
    Signed-off-by: Jason Gerecke
    Reviewed-by: Aaron Skomra
    Tested-by: Aaron Skomra
    Signed-off-by: Jiri Kosina
    Signed-off-by: Greg Kroah-Hartman

    Jason Gerecke
     
  • commit 791ae273731fa85d3332e45064dab177ae663e80 upstream.

    Background: ExpressKey Remotes communicate their events via usb dongle.
    Each dongle can hold up to 5 pairings at one time and one EKR (identified
    by its serial number) can unfortunately be paired with its dongle
    more than once. The pairing takes place in a round-robin fashion.

    Input devices are only created once per EKR, when a new serial number
    is seen in the list of pairings. However, if a device is created for
    a "higher" paring index and subsequently a second pairing occurs at a
    lower pairing index, unpairing the remote with that serial number from
    any pairing index will currently cause a driver crash. This occurs
    infrequently, as two remotes are necessary to trigger this bug and most
    users have only one remote.

    As an illustration, to trigger the bug you need to have two remotes,
    and pair them in this order:

    1. slot 0 -> remote 1 (input device created for remote 1)
    2. slot 1 -> remote 1 (duplicate pairing - no device created)
    3. slot 2 -> remote 1 (duplicate pairing - no device created)
    4. slot 3 -> remote 1 (duplicate pairing - no device created)
    5. slot 4 -> remote 2 (input device created for remote 2)

    6. slot 0 -> remote 2 (1 destroyed and recreated at slot 1)
    7. slot 1 -> remote 2 (1 destroyed and recreated at slot 2)
    8. slot 2 -> remote 2 (1 destroyed and recreated at slot 3)
    9. slot 3 -> remote 2 (1 destroyed and not recreated)
    10. slot 4 -> remote 2 (2 was already in this slot so no changes)

    11. slot 0 -> remote 1 (The current code sees remote 2 was paired over in
    one of the dongle slots it occupied and attempts
    to remove all information about remote 2 [1]. It
    calls wacom_remote_destroy_one for remote 2, but
    the destroy function assumes the lowest index is
    where the remote's input device was created. The
    code "cleans up" the other remote 2 pairings
    including the one which the input device was based
    on, assuming they were were just duplicate
    pairings. However, the cleanup doesn't call the
    devres release function for the input device that
    was created in slot 4).

    This issue is fixed by this commit.

    [1] Remote 2 should subsequently be re-created on the next packet from the
    EKR at the lowest numbered slot that it occupies (here slot 1).

    Fixes: f9036bd43602 ("HID: wacom: EKR: use devres groups to manage resources")
    Signed-off-by: Aaron Armstrong Skomra
    Signed-off-by: Jiri Kosina
    Signed-off-by: Greg Kroah-Hartman

    Aaron Armstrong Skomra
     
  • commit bb30b8848c85e18ca7e371d0a869e94b3e383bdf upstream.

    The user space interface allows specifying the type and mask field used
    to allocate the cipher. Only a subset of the possible flags are intended
    for user space. Therefore, white-list the allowed flags.

    In case the user space caller uses at least one non-allowed flag, EINVAL
    is returned.

    Reported-by: syzbot
    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Stephan Mueller
     
  • commit c013cee99d5a18aec8c71fee8f5f41369cd12595 upstream.

    Ensure that the input is byte swabbed before injecting it into the
    SHA3 transform. Use the get_unaligned() accessor for this so that
    we don't perform unaligned access inadvertently on architectures
    that do not support that.

    Fixes: 53964b9ee63b7075 ("crypto: sha3 - Add SHA-3 hash algorithm")
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     
  • commit c957f8b3e2e54b29f53ef69decc87bbc858c9b58 upstream.

    This patch adds a parameter in the SafeXcel ahash request structure to
    keep track of the number of SG entries mapped. This allows not to call
    dma_unmap_sg() when dma_map_sg() wasn't called in the first place. This
    also removes a warning when the debugging of the DMA-API is enabled in
    the kernel configuration: "DMA-API: device driver tries to free DMA
    memory it has not allocated".

    Fixes: 1b44c5a60c13 ("crypto: inside-secure - add SafeXcel EIP197 crypto engine driver")
    Signed-off-by: Antoine Tenart
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Antoine Tenart
     
  • commit 809778e02cd45d0625439fee67688f655627bb3c upstream.

    This patch fixes the hash support in the SafeXcel driver when the update
    size is a multiple of a block size, and when a final call is made just
    after with a size of 0. In such cases the driver should cache the last
    block from the update to avoid handling 0 length data on the final call
    (that's a hardware limitation).

    Fixes: 1b44c5a60c13 ("crypto: inside-secure - add SafeXcel EIP197 crypto engine driver")
    Signed-off-by: Antoine Tenart
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Antoine Tenart
     
  • commit 1ecdd37e308ca149dc378cce225068cbac54e3a6 upstream.

    The aesni_gcm_enc/dec functions can access memory after the end of
    the AAD buffer if the AAD length is not a multiple of 4 bytes.
    It didn't matter with rfc4106-gcm-aesni as in that case the AAD was
    always followed by the 8 byte IV, but that is no longer the case with
    generic-gcm-aesni. This can potentially result in accessing a page that
    is not mapped and thus causing the machine to crash. This patch fixes
    that by reading the last
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Junaid Shahid
     
  • commit b20209c91e23a9bbad9cac2f80bc16b3c259e10e upstream.

    The aesni_gcm_enc/dec functions can access memory before the start of
    the data buffer if the length of the data buffer is less than 16 bytes.
    This is because they perform the read via a single 16-byte load. This
    can potentially result in accessing a page that is not mapped and thus
    causing the machine to crash. This patch fixes that by reading the
    partial block byte-by-byte and optionally an via 8-byte load if the block
    was at least 8 bytes.

    Fixes: 0487ccac ("crypto: aesni - make non-AVX AES-GCM work with any aadlen")
    Signed-off-by: Junaid Shahid
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Junaid Shahid
     
  • commit fc8517bf627c9b834f80274a1bc9ecd39b27231b upstream.

    When I added generic-gcm-aes I didn't add a wrapper like the one
    provided for rfc4106(gcm(aes)). We need to add a cryptd wrapper to fall
    back on in case the FPU is not available, otherwise we might corrupt the
    FPU state.

    Fixes: cce2ea8d90fe ("crypto: aesni - add generic gcm(aes)")
    Reported-by: Ilya Lesokhin
    Signed-off-by: Sabrina Dubroca
    Reviewed-by: Stefano Brivio
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Sabrina Dubroca
     
  • commit 46d93748e5a3628f9f553832cd64d8a59d8bafde upstream.

    This patch replace GCM IV size value by their constant name.

    Signed-off-by: Corentin Labbe
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Corentin LABBE
     
  • commit ef780324592dd639e4bfbc5b9bf8934b234b7c99 upstream.

    Many GCM users use directly GCM IV size instead of using some constant.

    This patch add all IV size constant used by GCM.

    Signed-off-by: Corentin Labbe
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Corentin LABBE
     
  • commit 106840c41096a01079d3a2025225029c13713802 upstream.

    generic_gcmaes_decrypt needs to use generic_gcmaes_ctx, not
    aesni_rfc4106_gcm_ctx. This is actually harmless because the fields in
    struct generic_gcmaes_ctx share the layout of the same fields in
    aesni_rfc4106_gcm_ctx.

    Fixes: cce2ea8d90fe ("crypto: aesni - add generic gcm(aes)")
    Signed-off-by: Sabrina Dubroca
    Reviewed-by: Stefano Brivio
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Sabrina Dubroca
     
  • commit 9c674e1e2f9e24fa4392167efe343749008338e0 upstream.

    GCM can be invoked with a zero destination buffer. This is possible if
    the AAD and the ciphertext have zero lengths and only the tag exists in
    the source buffer (i.e. a source buffer cannot be zero). In this case,
    the GCM cipher only performs the authentication and no decryption
    operation.

    When the destination buffer has zero length, it is possible that no page
    is mapped to the SG pointing to the destination. In this case,
    sg_page(req->dst) is an invalid access. Therefore, page accesses should
    only be allowed if the req->dst->length is non-zero which is the
    indicator that a page must exist.

    This fixes a crash that can be triggered by user space via AF_ALG.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Stephan Mueller
     
  • commit b5b9007730ce1d90deaf25d7f678511550744bdc upstream.

    This fixes a typo in the CRYPTO_KPP dependency of CRYPTO_ECDH.

    Fixes: 3c4b23901a0c ("crypto: ecdh - Add ECDH software support")
    Signed-off-by: Hauke Mehrtens
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Hauke Mehrtens
     
  • commit 1c9609e3a8cf5997bd35205cfda1ff2218ee793b upstream.

    ALC256 has its own quirk to override the shutup call, and it contains
    the COEF update for pulling down the headset jack control. Currently,
    the COEF update is called after clearing the headphone pin, and this
    seems triggering a stall of the codec communication, and results in a
    long delay over a second at suspend.

    A quick resolution is to swap the calls: at first with the COEF
    update, then clear the headphone pin.

    Fixes: 4a219ef8f370 ("ALSA: hda/realtek - Add ALC256 HP depop function")
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=198503
    Reported-by: Paul Menzel
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Takashi Iwai
     
  • commit 24bd3efc9d1efb5f756a7c6f807a36ddb6adc671 upstream.

    The GPIO event descriptor was leaking kernel stack to
    userspace because we don't zero the variable before
    use. Ooops. Fix this.

    Reported-by: Arnd Bergmann
    Reviewed-by: Bartosz Golaszewski
    Reviewed-by: Arnd Bergmann
    Signed-off-by: Linus Walleij
    Signed-off-by: Greg Kroah-Hartman

    Linus Walleij
     
  • commit b888fb6f2a278442933e3bfab70262e9a5365fb3 upstream.

    Move the workaround from stmpe_gpio_irq_unmask() which is executed
    in atomic context to stmpe_gpio_irq_sync_unlock() which is not.

    It fixes the following issue:

    [ 1.500000] BUG: scheduling while atomic: swapper/1/0x00000002
    [ 1.500000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.15.0-rc2-00020-gbd4301f-dirty #28
    [ 1.520000] Hardware name: STM32 (Device Tree Support)
    [ 1.520000] [] (unwind_backtrace) from [] (show_stack+0xb/0xc)
    [ 1.530000] [] (show_stack) from [] (__schedule_bug+0x39/0x58)
    [ 1.530000] [] (__schedule_bug) from [] (__schedule+0x23/0x2b2)
    [ 1.550000] [] (__schedule) from [] (schedule+0x57/0x64)
    [ 1.550000] [] (schedule) from [] (schedule_timeout+0x137/0x164)
    [ 1.550000] [] (schedule_timeout) from [] (wait_for_common+0x8d/0xfc)
    [ 1.570000] [] (wait_for_common) from [] (stm32f4_i2c_xfer+0xe9/0xfe)
    [ 1.580000] [] (stm32f4_i2c_xfer) from [] (__i2c_transfer+0x111/0x148)
    [ 1.590000] [] (__i2c_transfer) from [] (i2c_transfer+0x53/0x70)
    [ 1.590000] [] (i2c_transfer) from [] (i2c_smbus_xfer+0x12f/0x36e)
    [ 1.600000] [] (i2c_smbus_xfer) from [] (i2c_smbus_read_byte_data+0x1f/0x2a)
    [ 1.610000] [] (i2c_smbus_read_byte_data) from [] (__stmpe_reg_read+0xd/0x24)
    [ 1.620000] [] (__stmpe_reg_read) from [] (stmpe_reg_read+0x19/0x24)
    [ 1.630000] [] (stmpe_reg_read) from [] (unmask_irq+0x17/0x22)
    [ 1.640000] [] (unmask_irq) from [] (irq_startup+0x6f/0x78)
    [ 1.650000] [] (irq_startup) from [] (__setup_irq+0x319/0x47c)
    [ 1.650000] [] (__setup_irq) from [] (request_threaded_irq+0x6b/0xe8)
    [ 1.660000] [] (request_threaded_irq) from [] (devm_request_threaded_irq+0x3b/0x6a)
    [ 1.670000] [] (devm_request_threaded_irq) from [] (mmc_gpiod_request_cd_irq+0x49/0x8a)
    [ 1.680000] [] (mmc_gpiod_request_cd_irq) from [] (mmc_start_host+0x49/0x60)
    [ 1.690000] [] (mmc_start_host) from [] (mmc_add_host+0x3b/0x54)
    [ 1.700000] [] (mmc_add_host) from [] (mmci_probe+0x4d1/0x60c)
    [ 1.710000] [] (mmci_probe) from [] (amba_probe+0x7b/0xbe)
    [ 1.720000] [] (amba_probe) from [] (driver_probe_device+0x169/0x1f8)
    [ 1.730000] [] (driver_probe_device) from [] (__driver_attach+0x43/0x5c)
    [ 1.740000] [] (__driver_attach) from [] (bus_for_each_dev+0x3d/0x46)
    [ 1.740000] [] (bus_for_each_dev) from [] (bus_add_driver+0xcd/0x124)
    [ 1.740000] [] (bus_add_driver) from [] (driver_register+0x4d/0x7a)
    [ 1.760000] [] (driver_register) from [] (do_one_initcall+0xbd/0xe8)
    [ 1.770000] [] (do_one_initcall) from [] (kernel_init_freeable+0xfb/0x134)
    [ 1.780000] [] (kernel_init_freeable) from [] (kernel_init+0x7/0x9c)
    [ 1.790000] [] (kernel_init) from [] (ret_from_fork+0x11/0x2c)

    Signed-off-by: Alexandre TORGUE
    Signed-off-by: Patrice Chotard
    Signed-off-by: Linus Walleij
    Signed-off-by: Greg Kroah-Hartman

    Patrice Chotard
     
  • commit 1696784eb7b52b13b62d160c028ef2c2c981d4f2 upstream.

    The GPIO tools build fails when using a buildroot toolchain that uses musl
    as it's C library:

    arm-broomstick-linux-musleabi-gcc -Wp,-MD,./.gpio-event-mon.o.d \
    -Wp,-MT,gpio-event-mon.o -O2 -Wall -g -D_GNU_SOURCE \
    -Iinclude -D"BUILD_STR(s)=#s" -c -o gpio-event-mon.o gpio-event-mon.c
    gpio-event-mon.c:30:6: error: unknown type name ‘u_int32_t’; did you mean ‘uint32_t’?
    u_int32_t handleflags,
    ^~~~~~~~~
    uint32_t

    The glibc headers installed on my laptop include sys/types.h in
    unistd.h, but it appears that musl does not.

    Fixes: 97f69747d8b1 ("tools/gpio: add the gpio-event-mon tool")
    Signed-off-by: Joel Stanley
    Signed-off-by: Linus Walleij
    Signed-off-by: Greg Kroah-Hartman

    Joel Stanley
     
  • commit 50a671d4d15b859f447fa527191073019b6ce9cb upstream.

    The function for CPUID 80000001 ECX is set to 0xc0000001. Set it to
    0x80000001.

    Signed-off-by: Janakarajan Natarajan
    Reviewed-by: Jim Mattson
    Reviewed-by: Krish Sadhukhan
    Reviewed-by: Borislav Petkov
    Fixes: d6321d493319 ("KVM: x86: generalize guest_cpuid_has_ helpers")
    Signed-off-by: Radim Krčmář
    Signed-off-by: Greg Kroah-Hartman

    Janakarajan Natarajan
     
  • commit ae6650163c66a7eff1acd6eb8b0f752dcfa8eba5 upstream.

    范龙飞 reports that KASAN can report a use-after-free in __lock_acquire.
    The reason is due to insufficient serialization in lo_release(), which
    will continue to use the loop device even after it has decremented the
    lo_refcnt to zero.

    In the meantime, another process can come in, open the loop device
    again as it is being shut down. Confusion ensues.

    Reported-by: 范龙飞
    Signed-off-by: Linus Torvalds
    Signed-off-by: Jens Axboe
    Cc: Ben Hutchings
    Signed-off-by: Greg Kroah-Hartman

    Linus Torvalds
     
  • commit a97cb0e7b3f4c6297fd857055ae8e895f402f501 upstream.

    Both Geert and DaveJ reported that the recent futex commit:

    c1e2f0eaf015 ("futex: Avoid violating the 10th rule of futex")

    introduced a problem with setting OWNER_DEAD. We set the bit on an
    uninitialized variable and then entirely optimize it away as a
    dead-store.

    Move the setting of the bit to where it is more useful.

    Reported-by: Geert Uytterhoeven
    Reported-by: Dave Jones
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: c1e2f0eaf015 ("futex: Avoid violating the 10th rule of futex")
    Link: http://lkml.kernel.org/r/20180122103947.GD2228@hirez.programming.kicks-ass.net
    Signed-off-by: Ingo Molnar
    Cc: Ozkan Sezer
    Signed-off-by: Greg Kroah-Hartman

    Peter Zijlstra
     

31 Jan, 2018

11 commits

  • Greg Kroah-Hartman
     
  • commit 1995266727fa8143897e89b55f5d3c79aa828420 upstream.

    Commit bdcf0a423ea1 ("kernel: make groups_sort calling a responsibility
    group_info allocators") appears to break nfsd rootsquash in a pretty
    major way.

    It adds a call to groups_sort() inside the loop that copies/squashes
    gids, which means the valid gids are sorted along with the following
    garbage. The net result is that the highest numbered valid gids are
    replaced with any lower-valued garbage gids, possibly including 0.

    We should sort only once, after filling in all the gids.

    Fixes: bdcf0a423ea1 ("kernel: make groups_sort calling a responsibility ...")
    Signed-off-by: Ben Hutchings
    Acked-by: J. Bruce Fields
    Signed-off-by: Linus Torvalds
    Cc: Wolfgang Walter
    Signed-off-by: Greg Kroah-Hartman

    Ben Hutchings
     
  • commit 56026645e2b6f11ede34a5e6ab69d3eb56f9c8fc upstream.

    After commit aa7519af450d (cpufreq: Use transition_delay_us for legacy
    governors as well) the sampling_rate field of struct dbs_data may be
    less than the tick period which causes dbs_update() to produce
    incorrect results, so make the code ensure that the value of that
    field will always be sufficiently large.

    Fixes: aa7519af450d (cpufreq: Use transition_delay_us for legacy governors as well)
    Reported-by: Andy Tang
    Reported-by: Doug Smythies
    Tested-by: Andy Tang
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Viresh Kumar
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • [ upstream commit a2284d912bfc865cdca4c00488e08a3550f9a405 ]

    Using dynamic stack_depth tracking in arm64 JIT is currently broken in
    combination with tail calls. In prologue, we cache ctx->stack_size and
    adjust SP reg for setting up function call stack, and tearing it down
    again in epilogue. Problem is that when doing a tail call, the cached
    ctx->stack_size might not be the same.

    One way to fix the problem with minimal overhead is to re-adjust SP in
    emit_bpf_tail_call() and properly adjust it to the current program's
    ctx->stack_size. Tested on Cavium ThunderX ARMv8.

    Fixes: f1c9eed7f437 ("bpf, arm64: take advantage of stack_depth tracking")
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Greg Kroah-Hartman

    Daniel Borkmann
     
  • [ upstream commit f37a8cb84cce18762e8f86a70bd6a49a66ab964c ]

    Alexei found that verifier does not reject stores into context
    via BPF_ST instead of BPF_STX. And while looking at it, we
    also should not allow XADD variant of BPF_STX.

    The context rewriter is only assuming either BPF_LDX_MEM- or
    BPF_STX_MEM-type operations, thus reject anything other than
    that so that assumptions in the rewriter properly hold. Add
    test cases as well for BPF selftests.

    Fixes: d691f9e8d440 ("bpf: allow programs to write to certain skb fields")
    Reported-by: Alexei Starovoitov
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Greg Kroah-Hartman

    Daniel Borkmann
     
  • [ upstream commit 68fda450a7df51cff9e5a4d4a4d9d0d5f2589153 ]

    due to some JITs doing if (src_reg == 0) check in 64-bit mode
    for div/mod operations mask upper 32-bits of src register
    before doing the check

    Fixes: 622582786c9e ("net: filter: x86: internal BPF JIT")
    Fixes: 7a12b5031c6b ("sparc64: Add eBPF JIT.")
    Reported-by: syzbot+48340bb518e88849e2e3@syzkaller.appspotmail.com
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Greg Kroah-Hartman

    Alexei Starovoitov
     
  • [ upstream commit c366287ebd698ef5e3de300d90cd62ee9ee7373e ]

    Divides by zero are not nice, lets avoid them if possible.

    Also do_div() seems not needed when dealing with 32bit operands,
    but this seems a minor detail.

    Fixes: bd4cf0ed331a ("net: filter: rework/optimize internal BPF interpreter's instruction set")
    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     
  • [ upstream commit be95a845cc4402272994ce290e3ad928aff06cb9 ]

    In addition to commit b2157399cc98 ("bpf: prevent out-of-bounds
    speculation") also change the layout of struct bpf_map such that
    false sharing of fast-path members like max_entries is avoided
    when the maps reference counter is altered. Therefore enforce
    them to be placed into separate cachelines.

    pahole dump after change:

    struct bpf_map {
    const struct bpf_map_ops * ops; /* 0 8 */
    struct bpf_map * inner_map_meta; /* 8 8 */
    void * security; /* 16 8 */
    enum bpf_map_type map_type; /* 24 4 */
    u32 key_size; /* 28 4 */
    u32 value_size; /* 32 4 */
    u32 max_entries; /* 36 4 */
    u32 map_flags; /* 40 4 */
    u32 pages; /* 44 4 */
    u32 id; /* 48 4 */
    int numa_node; /* 52 4 */
    bool unpriv_array; /* 56 1 */

    /* XXX 7 bytes hole, try to pack */

    /* --- cacheline 1 boundary (64 bytes) --- */
    struct user_struct * user; /* 64 8 */
    atomic_t refcnt; /* 72 4 */
    atomic_t usercnt; /* 76 4 */
    struct work_struct work; /* 80 32 */
    char name[16]; /* 112 16 */
    /* --- cacheline 2 boundary (128 bytes) --- */

    /* size: 128, cachelines: 2, members: 17 */
    /* sum members: 121, holes: 1, sum holes: 7 */
    };

    Now all entries in the first cacheline are read only throughout
    the life time of the map, set up once during map creation. Overall
    struct size and number of cachelines doesn't change from the
    reordering. struct bpf_map is usually first member and embedded
    in map structs in specific map implementations, so also avoid those
    members to sit at the end where it could potentially share the
    cacheline with first map values e.g. in the array since remote
    CPUs could trigger map updates just as well for those (easily
    dirtying members like max_entries intentionally as well) while
    having subsequent values in cache.

    Quoting from Google's Project Zero blog [1]:

    Additionally, at least on the Intel machine on which this was
    tested, bouncing modified cache lines between cores is slow,
    apparently because the MESI protocol is used for cache coherence
    [8]. Changing the reference counter of an eBPF array on one
    physical CPU core causes the cache line containing the reference
    counter to be bounced over to that CPU core, making reads of the
    reference counter on all other CPU cores slow until the changed
    reference counter has been written back to memory. Because the
    length and the reference counter of an eBPF array are stored in
    the same cache line, this also means that changing the reference
    counter on one physical CPU core causes reads of the eBPF array's
    length to be slow on other physical CPU cores (intentional false
    sharing).

    While this doesn't 'control' the out-of-bounds speculation through
    masking the index as in commit b2157399cc98, triggering a manipulation
    of the map's reference counter is really trivial, so lets not allow
    to easily affect max_entries from it.

    Splitting to separate cachelines also generally makes sense from
    a performance perspective anyway in that fast-path won't have a
    cache miss if the map gets pinned, reused in other progs, etc out
    of control path, thus also avoids unintentional false sharing.

    [1] https://googleprojectzero.blogspot.ch/2018/01/reading-privileged-memory-with-side.html

    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Greg Kroah-Hartman

    Daniel Borkmann
     
  • [ upstream commit 290af86629b25ffd1ed6232c4e9107da031705cb ]

    The BPF interpreter has been used as part of the spectre 2 attack CVE-2017-5715.

    A quote from goolge project zero blog:
    "At this point, it would normally be necessary to locate gadgets in
    the host kernel code that can be used to actually leak data by reading
    from an attacker-controlled location, shifting and masking the result
    appropriately and then using the result of that as offset to an
    attacker-controlled address for a load. But piecing gadgets together
    and figuring out which ones work in a speculation context seems annoying.
    So instead, we decided to use the eBPF interpreter, which is built into
    the host kernel - while there is no legitimate way to invoke it from inside
    a VM, the presence of the code in the host kernel's text section is sufficient
    to make it usable for the attack, just like with ordinary ROP gadgets."

    To make attacker job harder introduce BPF_JIT_ALWAYS_ON config
    option that removes interpreter from the kernel in favor of JIT-only mode.
    So far eBPF JIT is supported by:
    x64, arm64, arm32, sparc64, s390, powerpc64, mips64

    The start of JITed program is randomized and code page is marked as read-only.
    In addition "constant blinding" can be turned on with net.core.bpf_jit_harden

    v2->v3:
    - move __bpf_prog_ret0 under ifdef (Daniel)

    v1->v2:
    - fix init order, test_bpf and cBPF (Daniel's feedback)
    - fix offloaded bpf (Jakub's feedback)
    - add 'return 0' dummy in case something can invoke prog->bpf_func
    - retarget bpf tree. For bpf-next the patch would need one extra hunk.
    It will be sent when the trees are merged back to net-next

    Considered doing:
    int bpf_jit_enable __read_mostly = BPF_EBPF_JIT_DEFAULT;
    but it seems better to land the patch as-is and in bpf-next remove
    bpf_jit_enable global variable from all JITs, consolidate in one place
    and remove this jit_init() function.

    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Greg Kroah-Hartman

    Alexei Starovoitov
     
  • commit d5421ea43d30701e03cadc56a38854c36a8b4433 upstream.

    The hrtimer interrupt code contains a hang detection and mitigation
    mechanism, which prevents that a long delayed hrtimer interrupt causes a
    continous retriggering of interrupts which prevent the system from making
    progress. If a hang is detected then the timer hardware is programmed with
    a certain delay into the future and a flag is set in the hrtimer cpu base
    which prevents newly enqueued timers from reprogramming the timer hardware
    prior to the chosen delay. The subsequent hrtimer interrupt after the delay
    clears the flag and resumes normal operation.

    If such a hang happens in the last hrtimer interrupt before a CPU is
    unplugged then the hang_detected flag is set and stays that way when the
    CPU is plugged in again. At that point the timer hardware is not armed and
    it cannot be armed because the hang_detected flag is still active, so
    nothing clears that flag. As a consequence the CPU does not receive hrtimer
    interrupts and no timers expire on that CPU which results in RCU stalls and
    other malfunctions.

    Clear the flag along with some other less critical members of the hrtimer
    cpu base to ensure starting from a clean state when a CPU is plugged in.

    Thanks to Paul, Sebastian and Anna-Maria for their help to get down to the
    root cause of that hard to reproduce heisenbug. Once understood it's
    trivial and certainly justifies a brown paperbag.

    Fixes: 41d2e4949377 ("hrtimer: Tune hrtimer_interrupt hang logic")
    Reported-by: Paul E. McKenney
    Signed-off-by: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Sebastian Sewior
    Cc: Anna-Maria Gleixner
    Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801261447590.2067@nanos
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • commit 5beda7d54eafece4c974cfa9fbb9f60fb18fd20a upstream.

    Neil Berrington reported a double-fault on a VM with 768GB of RAM that uses
    large amounts of vmalloc space with PTI enabled.

    The cause is that load_new_mm_cr3() was never fixed to take the 5-level pgd
    folding code into account, so, on a 4-level kernel, the pgd synchronization
    logic compiles away to exactly nothing.

    Interestingly, the problem doesn't trigger with nopti. I assume this is
    because the kernel is mapped with global pages if we boot with nopti. The
    sequence of operations when we create a new task is that we first load its
    mm while still running on the old stack (which crashes if the old stack is
    unmapped in the new mm unless the TLB saves us), then we call
    prepare_switch_to(), and then we switch to the new stack.
    prepare_switch_to() pokes the new stack directly, which will populate the
    mapping through vmalloc_fault(). I assume that we're getting lucky on
    non-PTI systems -- the old stack's TLB entry stays alive long enough to
    make it all the way through prepare_switch_to() and switch_to() so that we
    make it to a valid stack.

    Fixes: b50858ce3e2a ("x86/mm/vmalloc: Add 5-level paging support")
    Reported-and-tested-by: Neil Berrington
    Signed-off-by: Andy Lutomirski
    Signed-off-by: Thomas Gleixner
    Cc: Konstantin Khlebnikov
    Cc: Dave Hansen
    Cc: Borislav Petkov
    Link: https://lkml.kernel.org/r/346541c56caed61abbe693d7d2742b4a380c5001.1516914529.git.luto@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Andy Lutomirski