17 Jan, 2019

6 commits

  • commit b983f7e92348d7e7d091db1b78b7915e9dd3d63a upstream.

    Currently for MTU requests we allocate maximum possible credits
    in advance and then adjust them according to the request size.
    While we were adjusting the number of credits belonging to the
    server, we were skipping adjustment of credits belonging to the
    request. This patch fixes it by setting request credits to
    CreditCharge field value of SMB2 packet header.

    Also ask 1 credit more for async read and write operations to
    increase parallelism and match the behavior of other operations.

    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Steve French
    CC: Stable
    Signed-off-by: Greg Kroah-Hartman

    Pavel Shilovsky
     
  • commit d1dd42110d2727e81b9265841a62bc84c454c3a2 upstream.

    Disable Headset Mic VREF for headset mode of ALC225.
    This will be controlled by coef bits of headset mode functions.

    [ Fixed a compile warning and code simplification -- tiwai ]

    Signed-off-by: Kailang Yang
    Cc:
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Kailang Yang
     
  • commit 4d4b0c52bde470c379f5d168d5c139ad866cb808 upstream.

    Forgot to add unplug function to unplug state of headset mode
    for ALC225.

    Signed-off-by: Kailang Yang
    Cc:
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Kailang Yang
     
  • commit c2a7c55a04065c3b0c32d23b099db7ea1dbf6250 upstream.

    Dell has new platform for ALC274.
    This will support to enable headset mode.

    Signed-off-by: Kailang Yang
    Cc:
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Kailang Yang
     
  • commit e4f358916d528d479c3c12bd2fd03f2d5a576380 upstream.

    Commit

    4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")

    replaced the RETPOLINE define with CONFIG_RETPOLINE checks. Remove the
    remaining pieces.

    [ bp: Massage commit message. ]

    Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
    Signed-off-by: WANG Chao
    Signed-off-by: Borislav Petkov
    Reviewed-by: Zhenzhong Duan
    Reviewed-by: Masahiro Yamada
    Cc: "H. Peter Anvin"
    Cc: Andi Kleen
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnd Bergmann
    Cc: Daniel Borkmann
    Cc: David Woodhouse
    Cc: Geert Uytterhoeven
    Cc: Jessica Yu
    Cc: Jiri Kosina
    Cc: Kees Cook
    Cc: Konrad Rzeszutek Wilk
    Cc: Luc Van Oostenryck
    Cc: Michal Marek
    Cc: Miguel Ojeda
    Cc: Peter Zijlstra
    Cc: Tim Chen
    Cc: Vasily Gorbik
    Cc: linux-kbuild@vger.kernel.org
    Cc: srinivas.eeda@oracle.com
    Cc: stable
    Cc: x86-ml
    Link: https://lkml.kernel.org/r/20181210163725.95977-1-chao.wang@ucloud.cn
    Signed-off-by: Greg Kroah-Hartman

    WANG Chao
     
  • commit f775b13eedee2f7f3c6fdd4e90fb79090ce5d339 upstream.

    Currently, every time a VCPU is scheduled out, the host kernel will
    first save the guest FPU/xstate context, then load the qemu userspace
    FPU context, only to then immediately save the qemu userspace FPU
    context back to memory. When scheduling in a VCPU, the same extraneous
    FPU loads and saves are done.

    This could be avoided by moving from a model where the guest FPU is
    loaded and stored with preemption disabled, to a model where the
    qemu userspace FPU is swapped out for the guest FPU context for
    the duration of the KVM_RUN ioctl.

    This is done under the VCPU mutex, which is also taken when other
    tasks inspect the VCPU FPU context, so the code should already be
    safe for this change. That should come as no surprise, given that
    s390 already has this optimization.

    This can fix a bug where KVM calls get_user_pages while owning the
    FPU, and the file system ends up requesting the FPU again:

    [258270.527947] __warn+0xcb/0xf0
    [258270.527948] warn_slowpath_null+0x1d/0x20
    [258270.527951] kernel_fpu_disable+0x3f/0x50
    [258270.527953] __kernel_fpu_begin+0x49/0x100
    [258270.527955] kernel_fpu_begin+0xe/0x10
    [258270.527958] crc32c_pcl_intel_update+0x84/0xb0
    [258270.527961] crypto_shash_update+0x3f/0x110
    [258270.527968] crc32c+0x63/0x8a [libcrc32c]
    [258270.527975] dm_bm_checksum+0x1b/0x20 [dm_persistent_data]
    [258270.527978] node_prepare_for_write+0x44/0x70 [dm_persistent_data]
    [258270.527985] dm_block_manager_write_callback+0x41/0x50 [dm_persistent_data]
    [258270.527988] submit_io+0x170/0x1b0 [dm_bufio]
    [258270.527992] __write_dirty_buffer+0x89/0x90 [dm_bufio]
    [258270.527994] __make_buffer_clean+0x4f/0x80 [dm_bufio]
    [258270.527996] __try_evict_buffer+0x42/0x60 [dm_bufio]
    [258270.527998] dm_bufio_shrink_scan+0xc0/0x130 [dm_bufio]
    [258270.528002] shrink_slab.part.40+0x1f5/0x420
    [258270.528004] shrink_node+0x22c/0x320
    [258270.528006] do_try_to_free_pages+0xf5/0x330
    [258270.528008] try_to_free_pages+0xe9/0x190
    [258270.528009] __alloc_pages_slowpath+0x40f/0xba0
    [258270.528011] __alloc_pages_nodemask+0x209/0x260
    [258270.528014] alloc_pages_vma+0x1f1/0x250
    [258270.528017] do_huge_pmd_anonymous_page+0x123/0x660
    [258270.528021] handle_mm_fault+0xfd3/0x1330
    [258270.528025] __get_user_pages+0x113/0x640
    [258270.528027] get_user_pages+0x4f/0x60
    [258270.528063] __gfn_to_pfn_memslot+0x120/0x3f0 [kvm]
    [258270.528108] try_async_pf+0x66/0x230 [kvm]
    [258270.528135] tdp_page_fault+0x130/0x280 [kvm]
    [258270.528149] kvm_mmu_page_fault+0x60/0x120 [kvm]
    [258270.528158] handle_ept_violation+0x91/0x170 [kvm_intel]
    [258270.528162] vmx_handle_exit+0x1ca/0x1400 [kvm_intel]

    No performance changes were detected in quick ping-pong tests on
    my 4 socket system, which is expected since an FPU+xstate load is
    on the order of 0.1us, while ping-ponging between CPUs is on the
    order of 20us, and somewhat noisy.

    Cc: stable@vger.kernel.org
    Signed-off-by: Rik van Riel
    Suggested-by: Christian Borntraeger
    Signed-off-by: Paolo Bonzini
    [Fixed a bug where reset_vcpu called put_fpu without preceding load_fpu,
    which happened inside from KVM_CREATE_VCPU ioctl. - Radim]
    Signed-off-by: Radim Krčmář
    Signed-off-by: Greg Kroah-Hartman

    Rik van Riel
     

13 Jan, 2019

34 commits

  • Greg Kroah-Hartman
     
  • commit 755396163148b50fe1afb4bdd3365e47f3ff7a42 upstream.

    Commit 7ed1c1901fe5 (tools: fix cross-compile var clobbering) removed
    setting of LD to $(CROSS_COMPILE)gcc. This broke build of acpica
    (acpidump) in power/acpi:
    ld: unrecognized option '-D_LINUX'

    The tools pass CFLAGS to the linker (incl. -D_LINUX), so revert this
    particular change and let LD be $(CC) again. Note that the old behaviour
    was a bit different, it used $(CROSS_COMPILE)gcc which was eliminated by
    the commit 7ed1c1901fe5. We use $(CC) for that reason.

    Fixes: 7ed1c1901fe5 (tools: fix cross-compile var clobbering)
    Signed-off-by: Jiri Slaby
    Cc: 4.16+ # 4.16+
    Signed-off-by: Rafael J. Wysocki
    Cc: Sudip Mukherjee
    Cc: Martin Kelly
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     
  • commit 38355a5f9a22bfa5bd5b1bb79805aca39fa53729 upstream.

    This happened when I tried to boot normal Fedora 29 system with latest
    available kernel (from fedora rawhide, plus some unrelated custom
    patches):

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
    PGD 0 P4D 0
    Oops: 0010 [#1] SMP PTI
    CPU: 6 PID: 1422 Comm: libvirtd Tainted: G I 4.20.0-0.rc7.git3.hpsa2.1.fc29.x86_64 #1
    Hardware name: HP ProLiant BL460c G6, BIOS I24 05/21/2018
    RIP: 0010: (null)
    Code: Bad RIP value.
    RSP: 0018:ffffa47ccdc9fbe0 EFLAGS: 00010246
    RAX: 0000000000000000 RBX: 00000000000003e8 RCX: ffffa47ccdc9fbf8
    RDX: ffffa47ccdc9fc00 RSI: ffff97d9ee7b01f8 RDI: ffff97d9f0150b80
    RBP: ffff97d9f0150b80 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000003
    R13: ffff97d9ef1e53e8 R14: 0000000000000009 R15: ffff97d9f0ac6730
    FS: 00007f4d224ef700(0000) GS:ffff97d9fa200000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: ffffffffffffffd6 CR3: 00000011ece52006 CR4: 00000000000206e0
    Call Trace:
    ? bnx2x_chip_cleanup+0x195/0x610 [bnx2x]
    ? bnx2x_nic_unload+0x1e2/0x8f0 [bnx2x]
    ? bnx2x_reload_if_running+0x24/0x40 [bnx2x]
    ? bnx2x_set_features+0x79/0xa0 [bnx2x]
    ? __netdev_update_features+0x244/0x9e0
    ? netlink_broadcast_filtered+0x136/0x4b0
    ? netdev_update_features+0x22/0x60
    ? dev_disable_lro+0x1c/0xe0
    ? devinet_sysctl_forward+0x1c6/0x211
    ? proc_sys_call_handler+0xab/0x100
    ? __vfs_write+0x36/0x1a0
    ? rcu_read_lock_sched_held+0x79/0x80
    ? rcu_sync_lockdep_assert+0x2e/0x60
    ? __sb_start_write+0x14c/0x1b0
    ? vfs_write+0x159/0x1c0
    ? vfs_write+0xba/0x1c0
    ? ksys_write+0x52/0xc0
    ? do_syscall_64+0x60/0x1f0
    ? entry_SYSCALL_64_after_hwframe+0x49/0xbe

    After some investigation I figured out that recently added cleanup code
    tries to call VLAN filtering de-initialization function which exist only
    for newer hardware. Corresponding function pointer is not
    set (== 0) for older hardware, namely these chips:

    #define CHIP_NUM_57710 0x164e
    #define CHIP_NUM_57711 0x164f
    #define CHIP_NUM_57711E 0x1650

    And I have one of those in my test system:

    Broadcom Inc. and subsidiaries NetXtreme II BCM57711E 10-Gigabit PCIe [14e4:1650]

    Function bnx2x_init_vlan_mac_fp_objs() from
    drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h decides whether to
    initialize relevant pointers in bnx2x_sp_objs.vlan_obj or not.

    This regression was introduced after v4.20-rc7, and still exists in v4.20
    release.

    Fixes: 04f05230c5c13 ("bnx2x: Remove configured vlans as part of unload sequence.")
    Signed-off-by: Ivan Mironov
    Signed-off-by: Ivan Mironov
    Acked-by: Sudarsana Kalluru
    Signed-off-by: David S. Miller
    Cc: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Ivan Mironov
     
  • commit 2b02a05bdc3a62d36e0d0b015351897109e25991 upstream.

    When vc4_plane_state is duplicated ->is_yuv is left assigned to its
    previous value, and we never set it back to false when switching to
    a non-YUV format.

    Fix that by setting ->is_yuv to false in the 'num_planes == 1' branch
    of the vc4_plane_setup_clipping_and_scaling() function.

    Fixes: fc04023fafecf ("drm/vc4: Add support for YUV planes.")
    Cc:
    Signed-off-by: Boris Brezillon
    Reviewed-by: Eric Anholt
    Link: https://patchwork.freedesktop.org/patch/msgid/20181009132446.21960-1-boris.brezillon@bootlin.com
    Signed-off-by: Greg Kroah-Hartman

    Boris Brezillon
     
  • commit 10fdf838e5f540beca466e9d1325999c072e5d3f upstream.

    On several arches, virt_to_phys() is in io.h

    Build fails without it:

    CC lib/test_debug_virtual.o
    lib/test_debug_virtual.c: In function 'test_debug_virtual_init':
    lib/test_debug_virtual.c:26:7: error: implicit declaration of function 'virt_to_phys' [-Werror=implicit-function-declaration]
    pa = virt_to_phys(va);
    ^

    Fixes: e4dace361552 ("lib: add test module for CONFIG_DEBUG_VIRTUAL")
    CC: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy
    Reviewed-by: Kees Cook
    Signed-off-by: Michael Ellerman
    Signed-off-by: Greg Kroah-Hartman

    Christophe Leroy
     
  • commit ed54ffbe554f0902689fd6d1712bbacbacd11376 upstream.

    According to [1] and [2], the temperature values are in tenths of degree
    Celsius. Exposing the Celsius value makes the battery appear on fire:

    $ upower -i /org/freedesktop/UPower/devices/battery_olpc_battery
    ...
    temperature: 236.9 degrees C

    Tested on OLPC XO-1 and OLPC XO-1.75 laptops.

    [1] include/linux/power_supply.h
    [2] Documentation/power/power_supply_class.txt

    Fixes: fb972873a767 ("[BATTERY] One Laptop Per Child power/battery driver")
    Cc: stable@vger.kernel.org
    Signed-off-by: Lubomir Rintel
    Acked-by: Pavel Machek
    Signed-off-by: Sebastian Reichel
    Signed-off-by: Greg Kroah-Hartman

    Lubomir Rintel
     
  • commit ec5b5ad6e272d8d6b92d1007f79574919862a2d2 upstream.

    The 'nr_pages' attribute of the 'msc' subdevices parses a comma-separated
    list of window sizes, passed from userspace. However, there is a bug in
    the string parsing logic wherein it doesn't exclude the comma character
    from the range of characters as it consumes them. This leads to an
    out-of-bounds access given a sufficiently long list. For example:

    > # echo 8,8,8,8 > /sys/bus/intel_th/devices/0-msc0/nr_pages
    > ==================================================================
    > BUG: KASAN: slab-out-of-bounds in memchr+0x1e/0x40
    > Read of size 1 at addr ffff8803ffcebcd1 by task sh/825
    >
    > CPU: 3 PID: 825 Comm: npktest.sh Tainted: G W 4.20.0-rc1+
    > Call Trace:
    > dump_stack+0x7c/0xc0
    > print_address_description+0x6c/0x23c
    > ? memchr+0x1e/0x40
    > kasan_report.cold.5+0x241/0x308
    > memchr+0x1e/0x40
    > nr_pages_store+0x203/0xd00 [intel_th_msu]

    Fix this by accounting for the comma character.

    Signed-off-by: Alexander Shishkin
    Fixes: ba82664c134ef ("intel_th: Add Memory Storage Unit driver")
    Cc: stable@vger.kernel.org # v4.4+
    Signed-off-by: Greg Kroah-Hartman

    Alexander Shishkin
     
  • commit fdd669684655c07dacbdb0d753fd13833de69a33 upstream.

    Calling the test program genwqe_cksum with the default buffer size of
    2MB triggers the following kernel warning on s390:

    WARNING: CPU: 30 PID: 9311 at mm/page_alloc.c:3189 __alloc_pages_nodemask+0x45c/0xbe0
    CPU: 30 PID: 9311 Comm: genwqe_cksum Kdump: loaded Not tainted 3.10.0-957.el7.s390x #1
    task: 00000005e5d13980 ti: 00000005e7c6c000 task.ti: 00000005e7c6c000
    Krnl PSW : 0704c00180000000 00000000002780ac (__alloc_pages_nodemask+0x45c/0xbe0)
    R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 EA:3
    Krnl GPRS: 00000000002932b8 0000000000b73d7c 0000000000000010 0000000000000009
    0000000000000041 00000005e7c6f9b8 0000000000000001 00000000000080d0
    0000000000000000 0000000000b70500 0000000000000001 0000000000000000
    0000000000b70528 00000000007682c0 0000000000277df2 00000005e7c6f9a0
    Krnl Code: 000000000027809e: de7195001000 ed 1280(114,%r9),0(%r1)
    00000000002780a4: a774fead brc 7,277dfe
    #00000000002780a8: a7f40001 brc 15,2780aa
    >00000000002780ac: 92011000 mvi 0(%r1),1
    00000000002780b0: a7f4fea7 brc 15,277dfe
    00000000002780b4: 9101c6b6 tm 1718(%r12),1
    00000000002780b8: a784ff3a brc 8,277f2c
    00000000002780bc: a7f4fe2e brc 15,277d18
    Call Trace:
    ([] __alloc_pages_nodemask+0x1a2/0xbe0)
    [] s390_dma_alloc+0xfe/0x310
    [] __genwqe_alloc_consistent+0xfa/0x148 [genwqe_card]
    [] genwqe_mmap+0xca/0x248 [genwqe_card]
    [] mmap_region+0x4e2/0x778
    [] do_mmap+0x2ac/0x3e0
    [] vm_mmap_pgoff+0xd6/0x118
    [] SyS_mmap_pgoff+0xdc/0x268
    [] SyS_old_mmap+0x8c/0xb0
    [] sysc_tracego+0x14/0x1e
    [] 0x3ffacf87dc6

    turns out the check in __genwqe_alloc_consistent uses "> MAX_ORDER"
    while the mm code uses ">= MAX_ORDER". Fix genwqe.

    Cc: stable@vger.kernel.org
    Signed-off-by: Christian Borntraeger
    Signed-off-by: Frank Haverkamp
    Signed-off-by: Greg Kroah-Hartman

    Christian Borntraeger
     
  • commit 3c1392d4c49962a31874af14ae9ff289cb2b3851 upstream.

    Updating mseq makes client think importer mds has accepted all prior
    cap messages and importer mds knows what caps client wants. Actually
    some cap messages may have been dropped because of mseq mismatch.

    If mseq is left untouched, importing cap's mds_wanted later will get
    reset by cap import message.

    Cc: stable@vger.kernel.org
    Signed-off-by: "Yan, Zheng"
    Signed-off-by: Ilya Dryomov
    Signed-off-by: Greg Kroah-Hartman

    Yan, Zheng
     
  • commit c40f7d74c741a907cfaeb73a7697081881c497d0 upstream.

    Zhipeng Xie, Xie XiuQi and Sargun Dhillon reported lockups in the
    scheduler under high loads, starting at around the v4.18 time frame,
    and Zhipeng Xie tracked it down to bugs in the rq->leaf_cfs_rq_list
    manipulation.

    Do a (manual) revert of:

    a9e7f6544b9c ("sched/fair: Fix O(nr_cgroups) in load balance path")

    It turns out that the list_del_leaf_cfs_rq() introduced by this commit
    is a surprising property that was not considered in followup commits
    such as:

    9c2791f936ef ("sched/fair: Fix hierarchical order in rq->leaf_cfs_rq_list")

    As Vincent Guittot explains:

    "I think that there is a bigger problem with commit a9e7f6544b9c and
    cfs_rq throttling:

    Let take the example of the following topology TG2 --> TG1 --> root:

    1) The 1st time a task is enqueued, we will add TG2 cfs_rq then TG1
    cfs_rq to leaf_cfs_rq_list and we are sure to do the whole branch in
    one path because it has never been used and can't be throttled so
    tmp_alone_branch will point to leaf_cfs_rq_list at the end.

    2) Then TG1 is throttled

    3) and we add TG3 as a new child of TG1.

    4) The 1st enqueue of a task on TG3 will add TG3 cfs_rq just before TG1
    cfs_rq and tmp_alone_branch will stay on rq->leaf_cfs_rq_list.

    With commit a9e7f6544b9c, we can del a cfs_rq from rq->leaf_cfs_rq_list.
    So if the load of TG1 cfs_rq becomes NULL before step 2) above, TG1
    cfs_rq is removed from the list.
    Then at step 4), TG3 cfs_rq is added at the beginning of rq->leaf_cfs_rq_list
    but tmp_alone_branch still points to TG3 cfs_rq because its throttled
    parent can't be enqueued when the lock is released.
    tmp_alone_branch doesn't point to rq->leaf_cfs_rq_list whereas it should.

    So if TG3 cfs_rq is removed or destroyed before tmp_alone_branch
    points on another TG cfs_rq, the next TG cfs_rq that will be added,
    will be linked outside rq->leaf_cfs_rq_list - which is bad.

    In addition, we can break the ordering of the cfs_rq in
    rq->leaf_cfs_rq_list but this ordering is used to update and
    propagate the update from leaf down to root."

    Instead of trying to work through all these cases and trying to reproduce
    the very high loads that produced the lockup to begin with, simplify
    the code temporarily by reverting a9e7f6544b9c - which change was clearly
    not thought through completely.

    This (hopefully) gives us a kernel that doesn't lock up so people
    can continue to enjoy their holidays without worrying about regressions. ;-)

    [ mingo: Wrote changelog, fixed weird spelling in code comment while at it. ]

    Analyzed-by: Xie XiuQi
    Analyzed-by: Vincent Guittot
    Reported-by: Zhipeng Xie
    Reported-by: Sargun Dhillon
    Reported-by: Xie XiuQi
    Tested-by: Zhipeng Xie
    Tested-by: Sargun Dhillon
    Signed-off-by: Linus Torvalds
    Acked-by: Vincent Guittot
    Cc: # v4.13+
    Cc: Bin Li
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Tejun Heo
    Cc: Thomas Gleixner
    Fixes: a9e7f6544b9c ("sched/fair: Fix O(nr_cgroups) in load balance path")
    Link: http://lkml.kernel.org/r/1545879866-27809-1-git-send-email-xiexiuqi@huawei.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Linus Torvalds
     
  • commit 3569dd07aaad71920c5ea4da2d5cc9a167c1ffd4 upstream.

    The Intel IOMMU driver opportunistically skips a few top level page
    tables from the domain paging directory while programming the IOMMU
    context entry. However there is an implicit assumption in the code that
    domain's adjusted guest address width (agaw) would always be greater
    than IOMMU's agaw.

    The IOMMU capabilities in an upcoming platform cause the domain's agaw
    to be lower than IOMMU's agaw. The issue is seen when the IOMMU supports
    both 4-level and 5-level paging. The domain builds a 4-level page table
    based on agaw of 2. However the IOMMU's agaw is set as 3 (5-level). In
    this case the code incorrectly tries to skip page page table levels.
    This causes the IOMMU driver to avoid programming the context entry. The
    fix handles this case and programs the context entry accordingly.

    Fixes: de24e55395698 ("iommu/vt-d: Simplify domain_context_mapping_one")
    Cc:
    Cc: Ashok Raj
    Cc: Jacob Pan
    Cc: Lu Baolu
    Reviewed-by: Lu Baolu
    Reported-by: Ramos Falcon, Ernesto R
    Tested-by: Ricardo Neri
    Signed-off-by: Sohil Mehta
    Signed-off-by: Joerg Roedel
    Signed-off-by: Greg Kroah-Hartman

    Sohil Mehta
     
  • commit e48d8ed9c6193502d849b35767fd18e20bbd7ba2 upstream.

    Error completions must still contain a valid wr_id and
    qp_num such that the consumer can rely on. Correctly
    fill these fields in receive error completions.

    Reported-by: Walker Benjamin
    Cc: stable@vger.kernel.org
    Signed-off-by: Sagi Grimberg
    Reviewed-by: Zhu Yanjun
    Tested-by: Zhu Yanjun
    Signed-off-by: Doug Ledford
    Signed-off-by: Greg Kroah-Hartman

    Sagi Grimberg
     
  • commit 574d356b7a02c7e1b01a1d9cba8a26b3c2888f45 upstream.

    If the requested msize is too small (either from command line argument
    or from the server version reply), we won't get any work done.
    If it's *really* too small, nothing will work, and this got caught by
    syzbot recently (on a new kmem_cache_create_usercopy() call)

    Just set a minimum msize to 4k in both code paths, until someone
    complains they have a use-case for a smaller msize.

    We need to check in both mount option and server reply individually
    because the msize for the first version request would be unchecked
    with just a global check on clnt->msize.

    Link: http://lkml.kernel.org/r/1541407968-31350-1-git-send-email-asmadeus@codewreck.org
    Reported-by: syzbot+0c1d61e4db7db94102ca@syzkaller.appspotmail.com
    Signed-off-by: Dominique Martinet
    Cc: Eric Van Hensbergen
    Cc: Latchesar Ionkov
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Dominique Martinet
     
  • commit e1c3743e1a20647c53b719dbf28b48f45d23f2cd upstream.

    On a signal handler return, the user could set a context with MSR[TS] bits
    set, and these bits would be copied to task regs->msr.

    At restore_tm_sigcontexts(), after current task regs->msr[TS] bits are set,
    several __get_user() are called and then a recheckpoint is executed.

    This is a problem since a page fault (in kernel space) could happen when
    calling __get_user(). If it happens, the process MSR[TS] bits were
    already set, but recheckpoint was not executed, and SPRs are still invalid.

    The page fault can cause the current process to be de-scheduled, with
    MSR[TS] active and without tm_recheckpoint() being called. More
    importantly, without TEXASR[FS] bit set also.

    Since TEXASR might not have the FS bit set, and when the process is
    scheduled back, it will try to reclaim, which will be aborted because of
    the CPU is not in the suspended state, and, then, recheckpoint. This
    recheckpoint will restore thread->texasr into TEXASR SPR, which might be
    zero, hitting a BUG_ON().

    kernel BUG at /build/linux-sf3Co9/linux-4.9.30/arch/powerpc/kernel/tm.S:434!
    cpu 0xb: Vector: 700 (Program Check) at [c00000041f1576d0]
    pc: c000000000054550: restore_gprs+0xb0/0x180
    lr: 0000000000000000
    sp: c00000041f157950
    msr: 8000000100021033
    current = 0xc00000041f143000
    paca = 0xc00000000fb86300 softe: 0 irq_happened: 0x01
    pid = 1021, comm = kworker/11:1
    kernel BUG at /build/linux-sf3Co9/linux-4.9.30/arch/powerpc/kernel/tm.S:434!
    Linux version 4.9.0-3-powerpc64le (debian-kernel@lists.debian.org) (gcc version 6.3.0 20170516 (Debian 6.3.0-18) ) #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26)
    enter ? for help
    [c00000041f157b30] c00000000001bc3c tm_recheckpoint.part.11+0x6c/0xa0
    [c00000041f157b70] c00000000001d184 __switch_to+0x1e4/0x4c0
    [c00000041f157bd0] c00000000082eeb8 __schedule+0x2f8/0x990
    [c00000041f157cb0] c00000000082f598 schedule+0x48/0xc0
    [c00000041f157ce0] c0000000000f0d28 worker_thread+0x148/0x610
    [c00000041f157d80] c0000000000f96b0 kthread+0x120/0x140
    [c00000041f157e30] c00000000000c0e0 ret_from_kernel_thread+0x5c/0x7c

    This patch simply delays the MSR[TS] set, so, if there is any page fault in
    the __get_user() section, it does not have regs->msr[TS] set, since the TM
    structures are still invalid, thus avoiding doing TM operations for
    in-kernel exceptions and possible process reschedule.

    With this patch, the MSR[TS] will only be set just before recheckpointing
    and setting TEXASR[FS] = 1, thus avoiding an interrupt with TM registers in
    invalid state.

    Other than that, if CONFIG_PREEMPT is set, there might be a preemption just
    after setting MSR[TS] and before tm_recheckpoint(), thus, this block must
    be atomic from a preemption perspective, thus, calling
    preempt_disable/enable() on this code.

    It is not possible to move tm_recheckpoint to happen earlier, because it is
    required to get the checkpointed registers from userspace, with
    __get_user(), thus, the only way to avoid this undesired behavior is
    delaying the MSR[TS] set.

    The 32-bits signal handler seems to be safe this current issue, but, it
    might be exposed to the preemption issue, thus, disabling preemption in
    this chunk of code.

    Changes from v2:
    * Run the critical section with preempt_disable.

    Fixes: 87b4e5393af7 ("powerpc/tm: Fix return of active 64bit signals")
    Cc: stable@vger.kernel.org (v3.9+)
    Signed-off-by: Breno Leitao
    Signed-off-by: Michael Ellerman
    Signed-off-by: Greg Kroah-Hartman

    Breno Leitao
     
  • commit 3bbd3db86470c701091fb1d67f1fab6621debf50 upstream.

    readelf complains about the section layout of vmlinux when building
    with CONFIG_RELOCATABLE=y (for KASLR):

    readelf: Warning: [21]: Link field (0) should index a symtab section.
    readelf: Warning: [21]: Info field (0) should index a relocatable section.

    Also, it seems that our use of '-pie -shared' is contradictory, and
    thus ambiguous. In general, the way KASLR is wired up at the moment
    is highly tailored to how ld.bfd happens to implement (and conflate)
    PIE executables and shared libraries, so given the current effort to
    support other toolchains, let's fix some of these issues as well.

    - Drop the -pie linker argument and just leave -shared. In ld.bfd,
    the differences between them are unclear (except for the ELF type
    of the produced image [0]) but lld chokes on seeing both at the
    same time.

    - Rename the .rela output section to .rela.dyn, as is customary for
    shared libraries and PIE executables, so that it is not misidentified
    by readelf as a static relocation section (producing the warnings
    above).

    - Pass the -z notext and -z norelro options to explicitly instruct the
    linker to permit text relocations, and to omit the RELRO program
    header (which requires a certain section layout that we don't adhere
    to in the kernel). These are the defaults for current versions of
    ld.bfd.

    - Discard .eh_frame and .gnu.hash sections to avoid them from being
    emitted between .head.text and .text, screwing up the section layout.

    These changes only affect the ELF image, and produce the same binary
    image.

    [0] b9dce7f1ba01 ("arm64: kernel: force ET_DYN ELF type for ...")

    Cc: Nick Desaulniers
    Cc: Peter Smith
    Tested-by: Nick Desaulniers
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Will Deacon
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     
  • commit dd6846d774693bfa27d7db4dae5ea67dfe373fa1 upstream.

    Commit 1212f7a16af4 ("scripts/kallsyms: filter arm64's __efistub_
    symbols") updated the kallsyms code to filter out symbols with
    the __efistub_ prefix explicitly, so we no longer require the
    hack in our linker script to emit them as absolute symbols.

    Cc: Nick Desaulniers
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Will Deacon
    [ND: adjusted for context]
    Signed-off-by: Nick Desaulniers
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     
  • commit 1212f7a16af492d59304ba3abccbcc5b5e41423e upstream.

    On arm64, the EFI stub and the kernel proper are essentially the same
    binary, although the EFI stub executes at a different virtual address
    as the kernel. For this reason, the EFI stub is restricted in the
    symbols it can link to, which is ensured by prefixing all EFI stub
    symbols with __efistub_ (and emitting __efistub_ prefixed aliases for
    routines that may be shared between the core kernel and the stub)

    These symbols are leaking into kallsyms, polluting the namespace, so
    let's filter them explicitly.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Will Deacon
    Cc: Nick Desaulniers
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     
  • commit b8eee0e90f9797b747113638bc75e739b192ad38 upstream.

    Commit 9d5b86ac13c5 ("fs/locks: Remove fl_nspid and use fs-specific l_pid
    for remote locks") specified that the l_pid returned for F_GETLK on a local
    file that has a remote lock should be the pid of the lock manager process.
    That commit, while updating other filesystems, failed to update lockd, such
    that locks created by lockd had their fl_pid set to that of the remote
    process holding the lock. Fix that here to be the pid of lockd.

    Also, fix the client case so that the returned lock pid is negative, which
    indicates a remote lock on a remote file.

    Fixes: 9d5b86ac13c5 ("fs/locks: Remove fl_nspid and use fs-specific...")
    Cc: stable@vger.kernel.org

    Signed-off-by: Benjamin Coddington
    Signed-off-by: J. Bruce Fields
    Signed-off-by: Greg Kroah-Hartman

    Benjamin Coddington
     
  • commit 5df275cd4cf51c86d49009f1397132f284ba515e upstream.

    Do the LE conversions before doing the Infiniband-related range checks.
    The incorrect checks are otherwise causing a failure to load any policy
    with an ibendportcon rule on BE systems. This can be reproduced by
    running (on e.g. ppc64):

    cat >my_module.cil <
    Cc: Eli Cohen
    Cc: James Morris
    Cc: Doug Ledford
    Cc: # 4.13+
    Fixes: a806f7a1616f ("selinux: Create policydb version for Infiniband support")
    Signed-off-by: Ondrej Mosnacek
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Ondrej Mosnacek
     
  • commit 8ea3819c0bbef57a51d8abe579e211033e861677 upstream.

    The cordic routine for calculating sines and cosines that was added in
    commit 6f98e62a9f1b ("b43: update cordic code to match current specs")
    contains an error whereby a quantity declared u32 can in fact go negative.

    This problem was detected by Priit Laes who is switching b43 to use the
    routine in the library functions of the kernel.

    Fixes: 986504540306 ("b43: make cordic common (LP-PHY and N-PHY need it)")
    Reported-by: Priit Laes
    Cc: Rafał Miłecki
    Cc: Stable # 2.6.34
    Signed-off-by: Larry Finger
    Signed-off-by: Priit Laes
    Signed-off-by: Kalle Valo
    Signed-off-by: Greg Kroah-Hartman

    Larry Finger
     
  • commit 2d29f6b96d8f80322ed2dd895bca590491c38d34 upstream.

    Fix the resource group wrap-around logic in gfs2_rbm_find that commit
    e579ed4f44 broke. The bug can lead to unnecessary repeated scanning of the
    same bitmaps; there is a risk that future changes will turn this into an
    endless loop.

    Fixes: e579ed4f44 ("GFS2: Introduce rbm field bii")
    Cc: stable@vger.kernel.org # v3.13+
    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Bob Peterson
    Signed-off-by: Greg Kroah-Hartman

    Andreas Gruenbacher
     
  • commit 6ff9b09e00a441599f3aacdf577254455a048bc9 upstream.

    In gfs2_create_inode, after setting and releasing the acl / default_acl, the
    acl / default_acl pointers are not set to NULL as they should be. In that
    state, when the function reaches label fail_free_acls, gfs2_create_inode will
    try to release the same acls again.

    Fix that by setting the pointers to NULL after releasing the acls. Slightly
    simplify the logic. Also, posix_acl_release checks for NULL already, so
    there is no need to duplicate those checks here.

    Fixes: e01580bf9e4d ("gfs2: use generic posix ACL infrastructure")
    Reported-by: Pan Bian
    Cc: Christoph Hellwig
    Cc: stable@vger.kernel.org # v4.9+
    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Bob Peterson
    Signed-off-by: Greg Kroah-Hartman

    Andreas Gruenbacher
     
  • commit d47b41aceeadc6b58abc9c7c6485bef7cfb75636 upstream.

    According to comment in dlm_user_request() ua should be freed
    in dlm_free_lkb() after successful attach to lkb.

    However ua is attached to lkb not in set_lock_args() but later,
    inside request_lock().

    Fixes 597d0cae0f99 ("[DLM] dlm: user locks")
    Cc: stable@kernel.org # 2.6.19

    Signed-off-by: Vasily Averin
    Signed-off-by: David Teigland
    Signed-off-by: Greg Kroah-Hartman

    Vasily Averin
     
  • commit c0174726c3976e67da8649ac62cae43220ae173a upstream.

    Fixes 6d40c4a708e0 ("dlm: improve error and debug messages")
    Cc: stable@kernel.org # 3.5

    Signed-off-by: Vasily Averin
    Signed-off-by: David Teigland
    Signed-off-by: Greg Kroah-Hartman

    Vasily Averin
     
  • commit 23851e978f31eda8b2d01bd410d3026659ca06c7 upstream.

    Fixes 3d6aa675fff9 ("dlm: keep lkbs in idr")
    Cc: stable@kernel.org # 3.1

    Signed-off-by: Vasily Averin
    Signed-off-by: David Teigland
    Signed-off-by: Greg Kroah-Hartman

    Vasily Averin
     
  • commit b982896cdb6e6a6b89d86dfb39df489d9df51e14 upstream.

    If allocation fails on last elements of array need to free already
    allocated elements.

    v2: just move existing out_rsbtbl label to right place

    Fixes 789924ba635f ("dlm: fix race between remove and lookup")
    Cc: stable@kernel.org # 3.6

    Signed-off-by: Vasily Averin
    Signed-off-by: David Teigland
    Signed-off-by: Greg Kroah-Hartman

    Vasily Averin
     
  • commit cbb2ebf70daf7f7d97d3811a2ff8e39655b8c184 upstream.

    In `create_composite_quirk`, the terminating condition of for loops is
    `quirk->ifnum < 0`. So any composite quirks should end with `struct
    snd_usb_audio_quirk` object with ifnum < 0.

    for (quirk = quirk_comp->data; quirk->ifnum >= 0; ++quirk) {

    .....
    }

    the data field of Bower's & Wilkins PX headphones usb device device quirks
    do not end with {.ifnum = -1}, wihch may result in out-of-bound read.

    This Patch fix the bug by adding an ending quirk object.

    Fixes: 240a8af929c7 ("ALSA: usb-audio: Add a quirck for B&W PX headphones")
    Signed-off-by: Hui Peng
    Cc:
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Hui Peng
     
  • commit f4351a199cc120ff9d59e06d02e8657d08e6cc46 upstream.

    The parser for the processing unit reads bNrInPins field before the
    bLength sanity check, which may lead to an out-of-bound access when a
    malformed descriptor is given. Fix it by assignment after the bLength
    check.

    Cc:
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Takashi Iwai
     
  • commit 1524f4e47f90b27a3ac84efbdd94c63172246a6f upstream.

    The "chip->dsp_spos_instance" can be NULL on some of the ealier error
    paths in snd_cs46xx_create().

    Reported-by: "Yavuz, Tuba"
    Signed-off-by: Dan Carpenter
    Cc:
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • commit d57f9da890696af1484f4a47f7f123560197865a upstream.

    struct bioctx includes the ref refcount_t to track the number of I/O
    fragments used to process a target BIO as well as ensure that the zone
    of the BIO is kept in the active state throughout the lifetime of the
    BIO. However, since decrementing of this reference count is done in the
    target .end_io method, the function bio_endio() must be called multiple
    times for read and write target BIOs, which causes problems with the
    value of the __bi_remaining struct bio field for chained BIOs (e.g. the
    clone BIO passed by dm core is large and splits into fragments by the
    block layer), resulting in incorrect values and inconsistencies with the
    BIO_CHAIN flag setting. This is turn triggers the BUG_ON() call:

    BUG_ON(atomic_read(&bio->__bi_remaining)
    Signed-off-by: Mike Snitzer
    Signed-off-by: Greg Kroah-Hartman

    Damien Le Moal
     
  • commit e4b069e0945fa14c71cf8b5b89f8b1b2aa68dbc2 upstream.

    Since commit d1ac3ff008fb ("dm verity: switch to using asynchronous hash
    crypto API") dm-verity uses asynchronous crypto calls for verification,
    so that it can use hardware with asynchronous processing of crypto
    operations.

    These asynchronous calls don't support vmalloc memory, but the buffer data
    can be allocated with vmalloc if dm-bufio is short of memory and uses a
    reserved buffer that was preallocated in dm_bufio_client_create().

    Fix verity_hash_update() so that it deals with vmalloc'd memory
    correctly.

    Reported-by: "Xiao, Jin"
    Signed-off-by: Mikulas Patocka
    Fixes: d1ac3ff008fb ("dm verity: switch to using asynchronous hash crypto API")
    Cc: stable@vger.kernel.org # 4.12+
    Signed-off-by: Mike Snitzer
    Signed-off-by: Sudip Mukherjee
    Acked-by: Mikulas Patocka
    Signed-off-by: Greg Kroah-Hartman

    Mikulas Patocka
     
  • commit a72b69dc083a931422cc8a5e33841aff7d5312f2 upstream.

    The vhost_vsock->guest_cid field is uninitialized when /dev/vhost-vsock
    is opened until the VHOST_VSOCK_SET_GUEST_CID ioctl is called.

    kvmalloc(..., GFP_KERNEL | __GFP_RETRY_MAYFAIL) does not zero memory.
    All other vhost_vsock fields are initialized explicitly so just
    initialize this field too.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: Michael S. Tsirkin
    Cc: Daniel Verkamp
    Signed-off-by: Greg Kroah-Hartman

    Stefan Hajnoczi
     
  • commit e213574a449f7a57d4202c1869bbc7680b6b5521 upstream.

    We cannot build these files with clang as it does not allow altivec
    instructions in assembly when -msoft-float is passed.

    Jinsong Ji wrote:
    > We currently disable Altivec/VSX support when enabling soft-float. So
    > any usage of vector builtins will break.
    >
    > Enable Altivec/VSX with soft-float may need quite some clean up work, so
    > I guess this is currently a limitation.
    >
    > Removing -msoft-float will make it work (and we are lucky that no
    > floating point instructions will be generated as well).

    This is a workaround until the issue is resolved in clang.

    Link: https://bugs.llvm.org/show_bug.cgi?id=31177
    Link: https://github.com/ClangBuiltLinux/linux/issues/239
    Signed-off-by: Joel Stanley
    Reviewed-by: Nick Desaulniers
    Signed-off-by: Michael Ellerman
    [nc: Use 'ifeq ($(cc-name),clang)' instead of 'ifdef CONFIG_CC_IS_CLANG'
    because that config does not exist in 4.14; the Kconfig rewrite
    that added that config happened in 4.18]
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Greg Kroah-Hartman

    Joel Stanley
     
  • commit 813af51f5d30a2da6a2523c08465f9726e51772e upstream.

    Clang needs to be told which target it is building for when cross
    compiling.

    Link: https://github.com/ClangBuiltLinux/linux/issues/259
    Signed-off-by: Joel Stanley
    Tested-by: Daniel Axtens # powerpc 64-bit BE
    Acked-by: Michael Ellerman
    Reviewed-by: Nick Desaulniers
    Signed-off-by: Masahiro Yamada
    [nc: Use 'ifeq ($(cc-name),clang)' instead of 'ifdef CONFIG_CC_IS_CLANG'
    because that config does not exist in 4.14; the Kconfig rewrite
    that added that config happened in 4.18]
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Greg Kroah-Hartman

    Joel Stanley