1. 19 Sep, 2018 11 commits
    • Pierre Morel's avatar
      KVM: s390: vsie: copy wrapping keys to right place · d5fca531
      Pierre Morel authored
      commit 204c9724 upstream.
      
      Copy the key mask to the right offset inside the shadow CRYCB
      
      Fixes: bbeaa58b ("KVM: s390: vsie: support aes dea wrapping keys")
      Signed-off-by: default avatarPierre Morel <pmorel@linux.ibm.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      Reviewed-by: default avatarJanosch Frank <frankja@linux.ibm.com>
      Cc: stable@vger.kernel.org # v4.8+
      Message-Id: <1535019956-23539-2-git-send-email-pmorel@linux.ibm.com>
      Signed-off-by: default avatarJanosch Frank <frankja@linux.ibm.com>
      Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5fca531
    • Filipe Manana's avatar
      Btrfs: fix data corruption when deduplicating between different files · ae3968b4
      Filipe Manana authored
      commit de02b9f6 upstream.
      
      If we deduplicate extents between two different files we can end up
      corrupting data if the source range ends at the size of the source file,
      the source file's size is not aligned to the filesystem's block size
      and the destination range does not go past the size of the destination
      file size.
      
      Example:
      
        $ mkfs.btrfs -f /dev/sdb
        $ mount /dev/sdb /mnt
      
        $ xfs_io -f -c "pwrite -S 0x6b 0 2518890" /mnt/foo
        # The first byte with a value of 0xae starts at an offset (2518890)
        # which is not a multiple of the sector size.
        $ xfs_io -c "pwrite -S 0xae 2518890 102398" /mnt/foo
      
        # Confirm the file content is full of bytes with values 0x6b and 0xae.
        $ od -t x1 /mnt/foo
        0000000 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
        *
        11467540 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b ae ae ae ae ae ae
        11467560 ae ae ae ae ae ae ae ae ae ae ae ae ae ae ae ae
        *
        11777540 ae ae ae ae ae ae ae ae
        11777550
      
        # Create a second file with a length not aligned to the sector size,
        # whose bytes all have the value 0x6b, so that its extent(s) can be
        # deduplicated with the first file.
        $ xfs_io -f -c "pwrite -S 0x6b 0 557771" /mnt/bar
      
        # Now deduplicate the entire second file into a range of the first file
        # that also has all bytes with the value 0x6b. The destination range's
        # end offset must not be aligned to the sector size and must be less
        # then the offset of the first byte with the value 0xae (byte at offset
        # 2518890).
        $ xfs_io -c "dedupe /mnt/bar 0 1957888 557771" /mnt/foo
      
        # The bytes in the range starting at offset 2515659 (end of the
        # deduplication range) and ending at offset 2519040 (start offset
        # rounded up to the block size) must all have the value 0xae (and not
        # replaced with 0x00 values). In other words, we should have exactly
        # the same data we had before we asked for deduplication.
        $ od -t x1 /mnt/foo
        0000000 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
        *
        11467540 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b ae ae ae ae ae ae
        11467560 ae ae ae ae ae ae ae ae ae ae ae ae ae ae ae ae
        *
        11777540 ae ae ae ae ae ae ae ae
        11777550
      
        # Unmount the filesystem and mount it again. This guarantees any file
        # data in the page cache is dropped.
        $ umount /dev/sdb
        $ mount /dev/sdb /mnt
      
        $ od -t x1 /mnt/foo
        0000000 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
        *
        11461300 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 00 00 00 00 00
        11461320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        *
        11470000 ae ae ae ae ae ae ae ae ae ae ae ae ae ae ae ae
        *
        11777540 ae ae ae ae ae ae ae ae
        11777550
      
        # The bytes in range 2515659 to 2519040 have a value of 0x00 and not a
        # value of 0xae, data corruption happened due to the deduplication
        # operation.
      
      So fix this by rounding down, to the sector size, the length used for the
      deduplication when the following conditions are met:
      
        1) Source file's range ends at its i_size;
        2) Source file's i_size is not aligned to the sector size;
        3) Destination range does not cross the i_size of the destination file.
      
      Fixes: e1d227a4 ("btrfs: Handle unaligned length in extent_same")
      CC: stable@vger.kernel.org # 4.2+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ae3968b4
    • Steve French's avatar
      smb3: check for and properly advertise directory lease support · 55bcfe01
      Steve French authored
      commit f8015683 upstream.
      
      Although servers will typically ignore unsupported features,
      we should advertise the support for directory leases (as
      Windows e.g. does) in the negotiate protocol capabilities we
      pass to the server, and should check for the server capability
      (CAP_DIRECTORY_LEASING) before sending a lease request for an
      open of a directory.  This will prevent us from accidentally
      sending directory leases to SMB2.1 or SMB2 server for example.
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55bcfe01
    • Steve French's avatar
      SMB3: Backup intent flag missing for directory opens with backupuid mounts · b0b69369
      Steve French authored
      commit 5e19697b upstream.
      
      When "backup intent" is requested on the mount (e.g. backupuid or
      backupgid mount options), the corresponding flag needs to be set
      on opens of directories (and files) but was missing in some
      places causing access denied trying to enumerate and backup
      servers.
      
      Fixes kernel bugzilla #200953
      https://bugzilla.kernel.org/show_bug.cgi?id=200953
      
      Reported-and-tested-by: <whh@rubrik.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Reviewed-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b0b69369
    • Paul Burton's avatar
      MIPS: VDSO: Match data page cache colouring when D$ aliases · 9efcaa7c
      Paul Burton authored
      commit 0f02cfbc upstream.
      
      When a system suffers from dcache aliasing a user program may observe
      stale VDSO data from an aliased cache line. Notably this can break the
      expectation that clock_gettime(CLOCK_MONOTONIC, ...) is, as its name
      suggests, monotonic.
      
      In order to ensure that users observe updates to the VDSO data page as
      intended, align the user mappings of the VDSO data page such that their
      cache colouring matches that of the virtual address range which the
      kernel will use to update the data page - typically its unmapped address
      within kseg0.
      
      This ensures that we don't introduce aliasing cache lines for the VDSO
      data page, and therefore that userland will observe updates without
      requiring cache invalidation.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Reported-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
      Reported-by: default avatarRene Nielsen <rene.nielsen@microsemi.com>
      Reported-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Fixes: ebb5e78c ("MIPS: Initial implementation of a VDSO")
      Patchwork: https://patchwork.linux-mips.org/patch/20344/Tested-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Tested-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: stable@vger.kernel.org # v4.4+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9efcaa7c
    • Minchan Kim's avatar
      android: binder: fix the race mmap and alloc_new_buf_locked · 49251910
      Minchan Kim authored
      commit da1b9564 upstream.
      
      There is RaceFuzzer report like below because we have no lock to close
      below the race between binder_mmap and binder_alloc_new_buf_locked.
      To close the race, let's use memory barrier so that if someone see
      alloc->vma is not NULL, alloc->vma_vm_mm should be never NULL.
      
      (I didn't add stable mark intentionallybecause standard android
      userspace libraries that interact with binder (libbinder & libhwbinder)
      prevent the mmap/ioctl race. - from Todd)
      
      "
      Thread interleaving:
      CPU0 (binder_alloc_mmap_handler)              CPU1 (binder_alloc_new_buf_locked)
      =====                                         =====
      // drivers/android/binder_alloc.c
      // #L718 (v4.18-rc3)
      alloc->vma = vma;
                                                    // drivers/android/binder_alloc.c
                                                    // #L346 (v4.18-rc3)
                                                    if (alloc->vma == NULL) {
                                                        ...
                                                        // alloc->vma is not NULL at this point
                                                        return ERR_PTR(-ESRCH);
                                                    }
                                                    ...
                                                    // #L438
                                                    binder_update_page_range(alloc, 0,
                                                            (void *)PAGE_ALIGN((uintptr_t)buffer->data),
                                                            end_page_addr);
      
                                                    // In binder_update_page_range() #L218
                                                    // But still alloc->vma_vm_mm is NULL here
                                                    if (need_mm && mmget_not_zero(alloc->vma_vm_mm))
      alloc->vma_vm_mm = vma->vm_mm;
      
      Crash Log:
      ==================================================================
      BUG: KASAN: null-ptr-deref in __atomic_add_unless include/asm-generic/atomic-instrumented.h:89 [inline]
      BUG: KASAN: null-ptr-deref in atomic_add_unless include/linux/atomic.h:533 [inline]
      BUG: KASAN: null-ptr-deref in mmget_not_zero include/linux/sched/mm.h:75 [inline]
      BUG: KASAN: null-ptr-deref in binder_update_page_range+0xece/0x18e0 drivers/android/binder_alloc.c:218
      Write of size 4 at addr 0000000000000058 by task syz-executor0/11184
      
      CPU: 1 PID: 11184 Comm: syz-executor0 Not tainted 4.18.0-rc3 #1
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x16e/0x22c lib/dump_stack.c:113
       kasan_report_error mm/kasan/report.c:352 [inline]
       kasan_report+0x163/0x380 mm/kasan/report.c:412
       check_memory_region_inline mm/kasan/kasan.c:260 [inline]
       check_memory_region+0x140/0x1a0 mm/kasan/kasan.c:267
       kasan_check_write+0x14/0x20 mm/kasan/kasan.c:278
       __atomic_add_unless include/asm-generic/atomic-instrumented.h:89 [inline]
       atomic_add_unless include/linux/atomic.h:533 [inline]
       mmget_not_zero include/linux/sched/mm.h:75 [inline]
       binder_update_page_range+0xece/0x18e0 drivers/android/binder_alloc.c:218
       binder_alloc_new_buf_locked drivers/android/binder_alloc.c:443 [inline]
       binder_alloc_new_buf+0x467/0xc30 drivers/android/binder_alloc.c:513
       binder_transaction+0x125b/0x4fb0 drivers/android/binder.c:2957
       binder_thread_write+0xc08/0x2770 drivers/android/binder.c:3528
       binder_ioctl_write_read.isra.39+0x24f/0x8e0 drivers/android/binder.c:4456
       binder_ioctl+0xa86/0xf34 drivers/android/binder.c:4596
       vfs_ioctl fs/ioctl.c:46 [inline]
       do_vfs_ioctl+0x154/0xd40 fs/ioctl.c:686
       ksys_ioctl+0x94/0xb0 fs/ioctl.c:701
       __do_sys_ioctl fs/ioctl.c:708 [inline]
       __se_sys_ioctl fs/ioctl.c:706 [inline]
       __x64_sys_ioctl+0x43/0x50 fs/ioctl.c:706
       do_syscall_64+0x167/0x4b0 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      "
      Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
      Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Reviewed-by: default avatarMartijn Coenen <maco@android.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49251910
    • Konstantin Khlebnikov's avatar
      block: bfq: swap puts in bfqg_and_blkg_put · 381992bc
      Konstantin Khlebnikov authored
      commit d5274b3c upstream.
      
      Fix trivial use-after-free. This could be last reference to bfqg.
      
      Fixes: 8f9bebc3 ("block, bfq: access and cache blkg data only when safe")
      Acked-by: default avatarPaolo Valente <paolo.valente@linaro.org>
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      381992bc
    • Jens Axboe's avatar
      nbd: don't allow invalid blocksize settings · 23ecbbad
      Jens Axboe authored
      commit bc811f05 upstream.
      
      syzbot reports a divide-by-zero off the NBD_SET_BLKSIZE ioctl.
      We need proper validation of the input here. Not just if it's
      zero, but also if the value is a power-of-2 and in a valid
      range. Add that.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarsyzbot <syzbot+25dbecbec1e62c6b0dd4@syzkaller.appspotmail.com>
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23ecbbad
    • James Smart's avatar
      scsi: lpfc: Correct MDS diag and nvmet configuration · 42573915
      James Smart authored
      commit 53e13ee0 upstream.
      
      A recent change added some MDS processing in the lpfc_drain_txq routine
      that relies on the fcp_wq being allocated. For nvmet operation the fcp_wq
      is not allocated because it can only be an nvme-target.  When the original
      MDS support was added LS_MDS_LOOPBACK was defined wrong, (0x16) it should
      have been 0x10 (decimal value used for hex setting). This incorrect value
      allowed MDS_LOOPBACK to be set simultaneously with LS_NPIV_FAB_SUPPORTED,
      causing the driver to crash when it accesses the non-existent fcp_wq.
      
      Correct the bad value setting for LS_MDS_LOOPBACK.
      
      Fixes: 	ae9e28f3  ("lpfc: Add MDS Diagnostic support.")
      Cc: <stable@vger.kernel.org> # v4.12+
      Signed-off-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
      Signed-off-by: default avatarJames Smart <james.smart@broadcom.com>
      Tested-by: default avatarEwan D. Milne <emilne@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      42573915
    • Felipe Balbi's avatar
      i2c: i801: fix DNV's SMBCTRL register offset · d98b6708
      Felipe Balbi authored
      commit 851a1511 upstream.
      
      DNV's iTCO is slightly different with SMBCTRL sitting at a different
      offset when compared to all other devices. Let's fix so that we can
      properly use iTCO watchdog.
      
      Fixes: 84d7f2eb ("i2c: i801: Add support for Intel DNV")
      Cc: <stable@vger.kernel.org> # v4.4+
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d98b6708
    • Shubhrajyoti Datta's avatar
      i2c: xiic: Make the start and the byte count write atomic · 831223b2
      Shubhrajyoti Datta authored
      commit ae7304c3 upstream.
      
      Disable interrupts while configuring the transfer and enable them back.
      
      We have below as the programming sequence
      1. start and slave address
      2. byte count and stop
      
      In some customer platform there was a lot of interrupts between 1 and 2
      and after slave address (around 7 clock cyles) if 2 is not executed
      then the transaction is nacked.
      
      To fix this case make the 2 writes atomic.
      Signed-off-by: default avatarShubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
      Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      [wsa: added a newline for better readability]
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      831223b2
  2. 15 Sep, 2018 29 commits