commit a21f3c11b41beb0b3b7d5de28d3d5a0692c5b22b
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Nov 21 09:24:18 2018 +0100

    Linux 4.14.82

commit dabaf70e3ad6ec7d327bfa98916163985a103e4a
Author: Doug Berger <opendmb@gmail.com>
Date:   Tue Oct 24 12:54:47 2017 -0700

    gpio: brcmstb: release the bgpio lock during irq handlers
    
    commit 142c168e0e50164e67c9399c28dedd65a307cfe5 upstream.
    
    The basic memory-mapped GPIO controller lock must be released
    before calling the registered GPIO interrupt handlers to allow
    the interrupt handlers to access the hardware.
    
    Examples of why a GPIO interrupt handler might want to access
    the GPIO hardware include an interrupt that is configured to
    trigger on rising and falling edges that needs to read the
    current level of the input to know how to respond, or an
    interrupt that causes a change in a GPIO output in the same
    bank. If the lock is not released before enterring the handler
    the hardware accesses will deadlock when they attempt to grab
    the lock.
    
    Since the lock is only needed to protect the calculation of
    unmasked pending interrupts create a dedicated function to
    perform this and hide the complexity.
    
    Fixes: 19a7b6940b78 ("gpio: brcmstb: Add interrupt and wakeup source support")
    Signed-off-by: Doug Berger <opendmb@gmail.com>
    Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
    Acked-by: Gregory Fong <gregory.0xf0@gmail.com>
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a8ba76fc043e1a34e98055f6e818c67ddc3c05c2
Author: Ming Lei <ming.lei@redhat.com>
Date:   Thu Apr 12 09:16:04 2018 -0600

    nvme-loop: fix kernel oops in case of unhandled command
    
    commit 11d9ea6f2ca69237d35d6c55755beba3e006b106 upstream.
    
    When nvmet_req_init() fails, __nvmet_req_complete() is called
    to handle the target request via .queue_response(), so
    nvme_loop_queue_response() shouldn't be called again for
    handling the failure.
    
    This patch fixes this case by the following way:
    
    - move blk_mq_start_request() before nvmet_req_init(), so
    nvme_loop_queue_response() may work well to complete this
    host request
    
    - don't call nvme_cleanup_cmd() which is done in nvme_loop_complete_rq()
    
    - don't call nvme_loop_queue_response() which is done via
    .queue_response()
    
    Signed-off-by: Ming Lei <ming.lei@redhat.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    [trimmed changelog]
    Signed-off-by: Keith Busch <keith.busch@intel.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c9b8d580b3fb0ab65d37c372aef19a318fda3199
Author: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date:   Tue Jan 16 13:47:16 2018 +0900

    printk: Never set console_may_schedule in console_trylock()
    
    commit fd5f7cde1b85d4c8e09ca46ce948e008a2377f64 upstream.
    
    This patch, basically, reverts commit 6b97a20d3a79 ("printk:
    set may_schedule for some of console_trylock() callers").
    That commit was a mistake, it introduced a big dependency
    on the scheduler, by enabling preemption under console_sem
    in printk()->console_unlock() path, which is rather too
    critical. The patch did not significantly reduce the
    possibilities of printk() lockups, but made it possible to
    stall printk(), as has been reported by Tetsuo Handa [1].
    
    Another issues is that preemption under console_sem also
    messes up with Steven Rostedt's hand off scheme, by making
    it possible to sleep with console_sem both in console_unlock()
    and in vprintk_emit(), after acquiring the console_sem
    ownership (anywhere between printk_safe_exit_irqrestore() in
    console_trylock_spinning() and printk_safe_enter_irqsave()
    in console_unlock()). This makes hand off less likely and,
    at the same time, may result in a significant amount of
    pending logbuf messages. Preempted console_sem owner makes
    it impossible for other CPUs to emit logbuf messages, but
    does not make it impossible for other CPUs to append new
    messages to the logbuf.
    
    Reinstate the old behavior and make printk() non-preemptible.
    Should any printk() lockup reports arrive they must be handled
    in a different way.
    
    [1] http://lkml.kernel.org/r/201603022101.CAH73907.OVOOMFHFFtQJSL%20()%20I-love%20!%20SAKURA%20!%20ne%20!%20jp
    Fixes: 6b97a20d3a79 ("printk: set may_schedule for some of console_trylock() callers")
    Link: http://lkml.kernel.org/r/20180116044716.GE6607@jagdpanzerIV
    To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: akpm@linux-foundation.org
    Cc: linux-mm@kvack.org
    Cc: Cong Wang <xiyou.wangcong@gmail.com>
    Cc: Dave Hansen <dave.hansen@intel.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Jan Kara <jack@suse.cz>
    Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    Cc: Byungchul Park <byungchul.park@lge.com>
    Cc: Pavel Machek <pavel@ucw.cz>
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Petr Mladek <pmladek@suse.com>
    Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cd09665ab60b6dcfd416999202f0e9f5e6157797
Author: Miklos Szeredi <mszeredi@redhat.com>
Date:   Wed Oct 31 12:15:23 2018 +0100

    ovl: check whiteout in ovl_create_over_whiteout()
    
    commit 5e1275808630ea3b2c97c776f40e475017535f72 upstream.
    
    Kaixuxia repors that it's possible to crash overlayfs by removing the
    whiteout on the upper layer before creating a directory over it.  This is a
    reproducer:
    
     mkdir lower upper work merge
     touch lower/file
     mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merge
     rm merge/file
     ls -al merge/file
     rm upper/file
     ls -al merge/
     mkdir merge/file
    
    Before commencing with a vfs_rename(..., RENAME_EXCHANGE) verify that the
    lookup of "upper" is positive and is a whiteout, and return ESTALE
    otherwise.
    
    Reported by: kaixuxia <xiakaixu1987@gmail.com>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Fixes: e9be9d5e76e3 ("overlay filesystem")
    Cc: <stable@vger.kernel.org> # v3.18
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9891f6816000e7addacb6f88986cc2d4f9004be0
Author: Stefano Stabellini <stefanos@xilinx.com>
Date:   Wed Oct 31 16:11:49 2018 -0700

    CONFIG_XEN_PV breaks xen_create_contiguous_region on ARM
    
    commit f9005571701920551bcf54a500973fb61f2e1eda upstream.
    
    xen_create_contiguous_region has now only an implementation if
    CONFIG_XEN_PV is defined. However, on ARM we never set CONFIG_XEN_PV but
    we do have an implementation of xen_create_contiguous_region which is
    required for swiotlb-xen to work correctly (although it just sets
    *dma_handle).
    
    [backport: remove change to xen_remap_pfn]
    
    Cc: <stable@vger.kernel.org> # 4.12
    Fixes: 16624390816c ("xen: create xen_create/destroy_contiguous_region() stubs for PVHVM only builds")
    Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    CC: Jeff.Kubascik@dornerworks.com
    CC: Jarvis.Roach@dornerworks.com
    CC: Nathan.Studer@dornerworks.com
    CC: vkuznets@redhat.com
    CC: boris.ostrovsky@oracle.com
    CC: jgross@suse.com
    CC: julien.grall@arm.com
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6576364f6496f5a95f8384d57fcb2b5377765a44
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Nov 8 08:17:38 2018 +0000

    drm/i915/execlists: Force write serialisation into context image vs execution
    
    commit 0a823e8fd4fd67726697854578f3584ee3a49b1d upstream.
    
    Ensure that the writes into the context image are completed prior to the
    register mmio to trigger execution. Although previously we were assured
    by the SDM that all writes are flushed before an uncached memory
    transaction (our mmio write to submit the context to HW for execution),
    we have empirical evidence to believe that this is not actually the
    case.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108656
    References: https://bugs.freedesktop.org/show_bug.cgi?id=108315
    References: https://bugs.freedesktop.org/show_bug.cgi?id=106887
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
    Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
    Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20181108081740.25615-1-chris@chris-wilson.co.uk
    Cc: stable@vger.kernel.org
    (cherry picked from commit 987abd5c62f92ee4970b45aa077f47949974e615)
    Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a5d74ffb65754b4fc751289a287f21b26838df40
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Nov 2 16:12:09 2018 +0000

    drm/i915: Mark pin flags as u64
    
    commit 0014868b9c3c1dda1de6711cf58c3486fb422d07 upstream.
    
    Since the flags are being used to operate on a u64 variable, they too
    need to be marked as such so that the inverses are full width (and not
    zero extended on 32b kernels and bdw+).
    
    Reported-by: Sergii Romantsov <sergii.romantsov@globallogic.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
    Cc: stable@vger.kernel.org
    Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
    Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20181102161232.17742-2-chris@chris-wilson.co.uk
    (cherry picked from commit 83b466b1dc5f0b4d33f0a901e8b00197a8f3582d)
    Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 46c397cd043fce2a2248c9025211eb9c5a16f845
Author: Ville Syrjälä <ville.syrjala@linux.intel.com>
Date:   Mon Nov 5 21:46:04 2018 +0200

    drm/i915: Don't oops during modeset shutdown after lpe audio deinit
    
    commit 6a8915d0f8cf323e1beb792a33095cf652db4056 upstream.
    
    We deinit the lpe audio device before we call
    drm_atomic_helper_shutdown(), which means the platform device
    may already be gone when it comes time to shut down the crtc.
    As we don't know when the last reference to the platform
    device gets dropped by the audio driver we can't assume that
    the device and its data are still around when turning off the
    crtc. Mark the platform device as gone as soon as we do the
    audio deinit.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20181105194604.6994-1-ville.syrjala@linux.intel.com
    Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
    (cherry picked from commit f45a7977d1140c11f334e01a9f77177ed68e3bfa)
    Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dfd13ef64df70fe49c7839b1ed3ee460759364de
Author: Clint Taylor <clinton.a.taylor@intel.com>
Date:   Thu Oct 25 11:52:00 2018 -0700

    drm/i915/hdmi: Add HDMI 2.0 audio clock recovery N values
    
    commit 6503493145cba4413ecd3d4d153faeef4a1e9b85 upstream.
    
    HDMI 2.0 594Mhz modes were incorrectly selecting 25.200Mhz Automatic N value
    mode instead of HDMI specification values.
    
    V2: Fix 88.2 Hz N value
    
    Cc: Jani Nikula <jani.nikula@linux.intel.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Clint Taylor <clinton.a.taylor@intel.com>
    Signed-off-by: Jani Nikula <jani.nikula@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/1540493521-1746-2-git-send-email-clinton.a.taylor@intel.com
    (cherry picked from commit 5a400aa3c562c4a726b4da286e63c96db905ade1)
    Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 943f7d5be05c44999145c053b53ce330217d3992
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Oct 12 15:02:28 2018 +0100

    drm/i915: Large page offsets for pread/pwrite
    
    commit ab0d6a141843e0b4b2709dfd37b53468b5452c3a upstream.
    
    Handle integer overflow when computing the sub-page length for shmem
    backed pread/pwrite.
    
    Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
    Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Cc: stable@vger.kernel.org
    Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20181012140228.29783-1-chris@chris-wilson.co.uk
    (cherry picked from commit a5e856a5348f6cd50889d125c40bbeec7328e466)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 99e43c5415276df371aaab9765876cf4f71cdee4
Author: Lyude Paul <lyude@redhat.com>
Date:   Mon Oct 8 19:24:33 2018 -0400

    drm/i915: Skip vcpi allocation for MSTB ports that are gone
    
    commit c02ba4ef16eefe663fdefcccaa57fad32d5481bf upstream.
    
    Since we need to be able to allow DPMS on->off prop changes after an MST
    port has disappeared from the system, we need to be able to make sure we
    can compute a config for the resulting atomic commit. Currently this is
    impossible when the port has disappeared, since the VCPI slot searching
    we try to do in intel_dp_mst_compute_config() will fail with -EINVAL.
    
    Since the only commits we want to allow on no-longer-present MST ports
    are ones that shut off display hardware, we already know that no VCPI
    allocations are needed. So, hardcode the VCPI slot count to 0 when
    intel_dp_mst_compute_config() is called on an MST port that's gone.
    
    Changes since V4:
    - Don't use mst_port_gone at all, just check whether or not the drm
      connector is registered - Daniel Vetter
    
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Cc: stable@vger.kernel.org
    Link: https://patchwork.freedesktop.org/patch/msgid/20181008232437.5571-5-lyude@redhat.com
    (cherry picked from commit f67207d78ceaf98b7531bc22df6f21328559c8d4)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9ab995dba88232317946124055eb89c915bd5f33
Author: Lyude Paul <lyude@redhat.com>
Date:   Mon Oct 8 19:24:32 2018 -0400

    drm/i915: Don't unset intel_connector->mst_port
    
    commit 80c188695a77eddaa6e8885510ff4ef59fd478c3 upstream.
    
    Currently we set intel_connector->mst_port to NULL to signify that the
    MST port has been removed from the system so that we can prevent further
    action on the port such as connector probes, mode probing, etc.
    However, we're going to need access to intel_connector->mst_port in
    order to fixup ->best_encoder() so that it can always return the correct
    encoder for an MST port to prevent legacy DPMS prop changes from
    failing. This should be safe, so instead keep intel_connector->mst_port
    always set and instead just check the status of
    drm_connector->regustered to signify whether or not the connector has
    disappeared from the system.
    
    Changes since v2:
    - Add a comment to mst_port_gone (Jani Nikula)
    - Change mst_port_gone to a u8 instead of a bool, per the kernel bot.
      Apparently bool is discouraged in structs these days
    Changes since v4:
    - Don't use mst_port_gone at all! Just check if the connector is
      registered or not - Daniel Vetter
    
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Cc: stable@vger.kernel.org
    Link: https://patchwork.freedesktop.org/patch/msgid/20181008232437.5571-4-lyude@redhat.com
    (cherry picked from commit 6ed5bb1fbad34382c8cfe9a9bf737e9a43053df5)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b24df93f18880cde76a69532a23d1cb1f568b611
Author: Ville Syrjälä <ville.syrjala@linux.intel.com>
Date:   Wed Oct 3 17:49:51 2018 +0300

    drm/i915: Restore vblank interrupts earlier
    
    commit 7cada4d0b7a0fb813dbc9777fec092e9ed0546e9 upstream.
    
    Plane sanitation needs vblank interrupts (on account of CxSR disable).
    So let's restore vblank interrupts earlier.
    
    v2: Make it actually build
    v3: Add comment to explain why we need this (Daniel)
    
    Cc: stable@vger.kernel.org
    Cc: Dennis <dennis.nezic@utoronto.ca>
    Tested-by: Dennis <dennis.nezic@utoronto.ca>
    Tested-by: Peter Nowee <peter.nowee@gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105637
    Fixes: b1e01595a66d ("drm/i915: Redo plane sanitation during readout")
    Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20181003144951.4397-1-ville.syrjala@linux.intel.com
    (cherry picked from commit 68bc30deac625b8be8d3950b30dc93d09a3645f5)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b1fd8f59962239c7317933a0522dac8ef8c121a1
Author: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Date:   Fri Nov 9 11:00:12 2018 +0200

    drm/dp_mst: Check if primary mstb is null
    
    commit 23d8003907d094f77cf959228e2248d6db819fa7 upstream.
    
    Unfortunately drm_dp_get_mst_branch_device which is called from both
    drm_dp_mst_handle_down_rep and drm_dp_mst_handle_up_rep seem to rely
    on that mgr->mst_primary is not NULL, which seem to be wrong as it can be
    cleared with simultaneous mode set, if probing fails or in other case.
    mgr->lock mutex doesn't protect against that as it might just get
    assigned to NULL right before, not simultaneously.
    
    There are currently bugs 107738, 108616 bugs which crash in
    drm_dp_get_mst_branch_device, caused by this issue.
    
    v2: Refactored the code, as it was nicely noticed.
        Fixed Bugzilla bug numbers(second was 108616, but not 108816)
        and added links.
    
    [changed title and added stable cc]
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
    Cc: stable@vger.kernel.org
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108616
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107738
    Link: https://patchwork.freedesktop.org/patch/msgid/20181109090012.24438-1-stanislav.lisovskiy@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 438f22af0688cb512f800d61f98cb8bd9b54e323
Author: Lyude Paul <lyude@redhat.com>
Date:   Thu Sep 6 17:43:21 2018 -0400

    drm/nouveau: Check backlight IDs are >= 0, not > 0
    
    commit dc854914999d5d52ac1b31740cb0ea8d89d0372e upstream.
    
    Remember, ida IDs start at 0, not 1!
    
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Reviewed-by: Karol Herbst <kherbst@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a02eadf0639bb5e007e7e270385b97e9c0a4a944
Author: Alex Deucher <alexander.deucher@amd.com>
Date:   Tue Aug 28 14:16:23 2018 -0500

    drm/amdgpu: add missing CHIP_HAINAN in amdgpu_ucode_get_load_type
    
    commit d9997b64c52b70bd98c48f443f068253621d1ffc upstream.
    
    This caused a confusing error message, but there is functionally
    no problem since the default method is DIRECT.
    
    Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7fb7a5ab36922bec92072199cb5085ff04882ed2
Author: Marc Zyngier <marc.zyngier@arm.com>
Date:   Sun Aug 5 13:48:07 2018 +0100

    drm/rockchip: Allow driver to be shutdown on reboot/kexec
    
    commit 7f3ef5dedb146e3d5063b6845781ad1bb59b92b5 upstream.
    
    Leaving the DRM driver enabled on reboot or kexec has the annoying
    effect of leaving the display generating transactions whilst the
    IOMMU has been shut down.
    
    In turn, the IOMMU driver (which shares its interrupt line with
    the VOP) starts warning either on shutdown or when entering the
    secondary kernel in the kexec case (nothing is expected on that
    front).
    
    A cheap way of ensuring that things are nicely shut down is to
    register a shutdown callback in the platform driver.
    
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    Tested-by: Vicente Bergas <vicencb@gmail.com>
    Signed-off-by: Heiko Stuebner <heiko@sntech.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/20180805124807.18169-1-marc.zyngier@arm.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 011d0d8b5bba980c56ecbf8ad7482b721cf52f6f
Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Date:   Wed Nov 14 09:55:42 2018 -0800

    efi/arm/libstub: Pack FDT after populating it
    
    commit 72a58a63a164b4e9d2d914e65caeb551846883f1 upstream.
    
    Commit:
    
      24d7c494ce46 ("efi/arm-stub: Round up FDT allocation to mapping size")
    
    increased the allocation size for the FDT image created by the stub to a
    fixed value of 2 MB, to simplify the former code that made several
    attempts with increasing values for the size. This is reasonable
    given that the allocation is of type EFI_LOADER_DATA, which is released
    to the kernel unless it is explicitly memblock_reserve()d by the early
    boot code.
    
    However, this allocation size leaked into the 'size' field of the FDT
    header metadata, and so the entire allocation remains occupied by the
    device tree binary, even if most of it is not used to store device tree
    information.
    
    So call fdt_pack() to shrink the FDT data structure to its minimum size
    after populating all the fields, so that the remaining memory is no
    longer wasted.
    
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Cc: <stable@vger.kernel.org> # v4.12+
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-efi@vger.kernel.org
    Fixes: 24d7c494ce46 ("efi/arm-stub: Round up FDT allocation to mapping size")
    Link: http://lkml.kernel.org/r/20181114175544.12860-4-ard.biesheuvel@linaro.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d85699259bcda421e28f22b72ef2bd9e9907d66b
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Fri Nov 16 15:08:11 2018 -0800

    mm/swapfile.c: use kvzalloc for swap_info_struct allocation
    
    commit 873d7bcfd066663e3e50113dc4a0de19289b6354 upstream.
    
    Commit a2468cc9bfdf ("swap: choose swap device according to numa node")
    changed 'avail_lists' field of 'struct swap_info_struct' to an array.
    In popular linux distros it increased size of swap_info_struct up to 40
    Kbytes and now swap_info_struct allocation requires order-4 page.
    Switch to kvzmalloc allows to avoid unexpected allocation failures.
    
    Link: http://lkml.kernel.org/r/fc23172d-3c75-21e2-d551-8b1808cbe593@virtuozzo.com
    Fixes: a2468cc9bfdf ("swap: choose swap device according to numa node")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Acked-by: Aaron Lu <aaron.lu@intel.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Huang Ying <ying.huang@intel.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 52fcb8dd8cc224740259800eee9d2031c8ffa830
Author: Mike Kravetz <mike.kravetz@oracle.com>
Date:   Fri Nov 16 15:08:04 2018 -0800

    hugetlbfs: fix kernel BUG at fs/hugetlbfs/inode.c:444!
    
    commit 5e41540c8a0f0e98c337dda8b391e5dda0cde7cf upstream.
    
    This bug has been experienced several times by the Oracle DB team.  The
    BUG is in remove_inode_hugepages() as follows:
    
            /*
             * If page is mapped, it was faulted in after being
             * unmapped in caller.  Unmap (again) now after taking
             * the fault mutex.  The mutex will prevent faults
             * until we finish removing the page.
             *
             * This race can only happen in the hole punch case.
             * Getting here in a truncate operation is a bug.
             */
            if (unlikely(page_mapped(page))) {
                    BUG_ON(truncate_op);
    
    In this case, the elevated map count is not the result of a race.
    Rather it was incorrectly incremented as the result of a bug in the huge
    pmd sharing code.  Consider the following:
    
     - Process A maps a hugetlbfs file of sufficient size and alignment
       (PUD_SIZE) that a pmd page could be shared.
    
     - Process B maps the same hugetlbfs file with the same size and
       alignment such that a pmd page is shared.
    
     - Process B then calls mprotect() to change protections for the mapping
       with the shared pmd. As a result, the pmd is 'unshared'.
    
     - Process B then calls mprotect() again to chage protections for the
       mapping back to their original value. pmd remains unshared.
    
     - Process B then forks and process C is created. During the fork
       process, we do dup_mm -> dup_mmap -> copy_page_range to copy page
       tables. Copying page tables for hugetlb mappings is done in the
       routine copy_hugetlb_page_range.
    
    In copy_hugetlb_page_range(), the destination pte is obtained by:
    
            dst_pte = huge_pte_alloc(dst, addr, sz);
    
    If pmd sharing is possible, the returned pointer will be to a pte in an
    existing page table.  In the situation above, process C could share with
    either process A or process B.  Since process A is first in the list,
    the returned pte is a pointer to a pte in process A's page table.
    
    However, the check for pmd sharing in copy_hugetlb_page_range is:
    
            /* If the pagetables are shared don't copy or take references */
            if (dst_pte == src_pte)
                    continue;
    
    Since process C is sharing with process A instead of process B, the
    above test fails.  The code in copy_hugetlb_page_range which follows
    assumes dst_pte points to a huge_pte_none pte.  It copies the pte entry
    from src_pte to dst_pte and increments this map count of the associated
    page.  This is how we end up with an elevated map count.
    
    To solve, check the dst_pte entry for huge_pte_none.  If !none, this
    implies PMD sharing so do not copy.
    
    Link: http://lkml.kernel.org/r/20181105212315.14125-1-mike.kravetz@oracle.com
    Fixes: c5c99429fa57 ("fix hugepages leak due to pagetable page sharing")
    Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
    Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Davidlohr Bueso <dave@stgolabs.net>
    Cc: Prakash Sangappa <prakash.sangappa@oracle.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit efcbe502ddcc9f28d88a7c35b90f121a4e176823
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Fri Nov 16 15:08:35 2018 -0800

    lib/ubsan.c: don't mark __ubsan_handle_builtin_unreachable as noreturn
    
    commit 1c23b4108d716cc848b38532063a8aca4f86add8 upstream.
    
    gcc-8 complains about the prototype for this function:
    
      lib/ubsan.c:432:1: error: ignoring attribute 'noreturn' in declaration of a built-in function '__ubsan_handle_builtin_unreachable' because it conflicts with attribute 'const' [-Werror=attributes]
    
    This is actually a GCC's bug. In GCC internals
    __ubsan_handle_builtin_unreachable() declared with both 'noreturn' and
    'const' attributes instead of only 'noreturn':
    
       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84210
    
    Workaround this by removing the noreturn attribute.
    
    [aryabinin: add information about GCC bug in changelog]
    Link: http://lkml.kernel.org/r/20181107144516.4587-1-aryabinin@virtuozzo.com
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
    Acked-by: Olof Johansson <olof@lixom.net>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fdc427442b374e84077d4214733764efb1a38a0e
Author: Eric Biggers <ebiggers@google.com>
Date:   Sat Nov 3 14:56:00 2018 -0700

    crypto: user - fix leaking uninitialized memory to userspace
    
    commit f43f39958beb206b53292801e216d9b8a660f087 upstream.
    
    All bytes of the NETLINK_CRYPTO report structures must be initialized,
    since they are copied to userspace.  The change from strncpy() to
    strlcpy() broke this.  As a minimal fix, change it back.
    
    Fixes: 4473710df1f8 ("crypto: user - Prepare for CRYPTO_MAX_ALG_NAME expansion")
    Cc: <stable@vger.kernel.org> # v4.12+
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6c75d139608a603642cd731ce75e4222754fff0e
Author: Andreas Gruenbacher <agruenba@redhat.com>
Date:   Mon Nov 5 22:57:24 2018 +0000

    gfs2: Put bitmap buffers in put_super
    
    commit 10283ea525d30f2e99828978fd04d8427876a7ad upstream.
    
    gfs2_put_super calls gfs2_clear_rgrpd to destroy the gfs2_rgrpd objects
    attached to the resource group glocks.  That function should release the
    buffers attached to the gfs2_bitmap objects (bi_bh), but the call to
    gfs2_rgrp_brelse for doing that is missing.
    
    When gfs2_releasepage later runs across these buffers which are still
    referenced, it refuses to free them.  This causes the pages the buffers
    are attached to to remain referenced as well.  With enough mount/unmount
    cycles, the system will eventually run out of memory.
    
    Fix this by adding the missing call to gfs2_rgrp_brelse in
    gfs2_clear_rgrpd.
    
    (Also fix a gfs2_rgrp_relse -> gfs2_rgrp_brelse typo in a comment.)
    
    Fixes: 39b0f1e92908 ("GFS2: Don't brelse rgrp buffer_heads every allocation")
    Cc: stable@vger.kernel.org # v4.2+
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 56d10194be8102077430b683b2bb156d7ffdd84e
Author: Guenter Roeck <linux@roeck-us.net>
Date:   Sun Jul 1 13:56:54 2018 -0700

    configfs: replace strncpy with memcpy
    
    commit 1823342a1f2b47a4e6f5667f67cd28ab6bc4d6cd upstream.
    
    gcc 8.1.0 complains:
    
    fs/configfs/symlink.c:67:3: warning:
            'strncpy' output truncated before terminating nul copying as many
            bytes from a string as its length
    fs/configfs/symlink.c: In function 'configfs_get_link':
    fs/configfs/symlink.c:63:13: note: length computed here
    
    Using strncpy() is indeed less than perfect since the length of data to
    be copied has already been determined with strlen(). Replace strncpy()
    with memcpy() to address the warning and optimize the code a little.
    
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu@cybertrust.co.jp>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6ceec07cc84a26152e5678e121c824f3d1097de6
Author: Miklos Szeredi <mszeredi@redhat.com>
Date:   Fri Nov 9 15:52:16 2018 +0100

    fuse: fix leaked notify reply
    
    commit 7fabaf303458fcabb694999d6fa772cc13d4e217 upstream.
    
    fuse_request_send_notify_reply() may fail if the connection was reset for
    some reason (e.g. fs was unmounted).  Don't leak request reference in this
    case.  Besides leaking memory, this resulted in fc->num_waiting not being
    decremented and hence fuse_wait_aborted() left in a hanging and unkillable
    state.
    
    Fixes: 2d45ba381a74 ("fuse: add retrieve request")
    Fixes: b8f95e5d13f5 ("fuse: umount should wait for all requests")
    Reported-and-tested-by: syzbot+6339eda9cb4ebbc4c37b@syzkaller.appspotmail.com
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Cc: <stable@vger.kernel.org> #v2.6.36
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a42d933dc28180d92c88131e4cc77fe1b747b5e3
Author: Lukas Czerner <lczerner@redhat.com>
Date:   Fri Nov 9 14:51:46 2018 +0100

    fuse: fix use-after-free in fuse_direct_IO()
    
    commit ebacb81273599555a7a19f7754a1451206a5fc4f upstream.
    
    In async IO blocking case the additional reference to the io is taken for
    it to survive fuse_aio_complete(). In non blocking case this additional
    reference is not needed, however we still reference io to figure out
    whether to wait for completion or not. This is wrong and will lead to
    use-after-free. Fix it by storing blocking information in separate
    variable.
    
    This was spotted by KASAN when running generic/208 fstest.
    
    Signed-off-by: Lukas Czerner <lczerner@redhat.com>
    Reported-by: Zorro Lang <zlang@redhat.com>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Fixes: 744742d692e3 ("fuse: Add reference counting for fuse_io_priv")
    Cc: <stable@vger.kernel.org> # v4.6
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 677f423c995d27bfafd34a7b86773830db6ac09f
Author: Maciej W. Rozycki <macro@linux-mips.org>
Date:   Mon Nov 5 03:48:25 2018 +0000

    rtc: hctosys: Add missing range error reporting
    
    commit 7ce9a992ffde8ce93d5ae5767362a5c7389ae895 upstream.
    
    Fix an issue with the 32-bit range error path in `rtc_hctosys' where no
    error code is set and consequently the successful preceding call result
    from `rtc_read_time' is propagated to `rtc_hctosys_ret'.  This in turn
    makes any subsequent call to `hctosys_show' incorrectly report in sysfs
    that the system time has been set from this RTC while it has not.
    
    Set the error to ERANGE then if we can't express the result due to an
    overflow.
    
    Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
    Fixes: b3a5ac42ab18 ("rtc: hctosys: Ensure system time doesn't overflow time_t")
    Cc: stable@vger.kernel.org # 4.17+
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6d1c38aa47d432f425c5829261eaa8e624274a4f
Author: Scott Mayhew <smayhew@redhat.com>
Date:   Thu Nov 8 11:11:36 2018 -0500

    nfsd: COPY and CLONE operations require the saved filehandle to be set
    
    commit 01310bb7c9c98752cc763b36532fab028e0f8f81 upstream.
    
    Make sure we have a saved filehandle, otherwise we'll oops with a null
    pointer dereference in nfs4_preprocess_stateid_op().
    
    Signed-off-by: Scott Mayhew <smayhew@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a56609f725c3cfff71e0878036263477d59755a4
Author: Frank Sorenson <sorenson@redhat.com>
Date:   Tue Oct 30 15:10:40 2018 -0500

    sunrpc: correct the computation for page_ptr when truncating
    
    commit 5d7a5bcb67c70cbc904057ef52d3fcfeb24420bb upstream.
    
    When truncating the encode buffer, the page_ptr is getting
    advanced, causing the next page to be skipped while encoding.
    The page is still included in the response, so the response
    contains a page of bogus data.
    
    We need to adjust the page_ptr backwards to ensure we encode
    the next page into the correct place.
    
    We saw this triggered when concurrent directory modifications caused
    nfsd4_encode_direct_fattr() to return nfserr_noent, and the resulting
    call to xdr_truncate_encode() corrupted the READDIR reply.
    
    Signed-off-by: Frank Sorenson <sorenson@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dedde93bd683730e78da54db42e52cb87cdb8a0c
Author: Christophe Leroy <christophe.leroy@c-s.fr>
Date:   Thu Sep 27 17:17:57 2018 +0000

    kdb: print real address of pointers instead of hashed addresses
    
    commit 568fb6f42ac6851320adaea25f8f1b94de14e40a upstream.
    
    Since commit ad67b74d2469 ("printk: hash addresses printed with %p"),
    all pointers printed with %p are printed with hashed addresses
    instead of real addresses in order to avoid leaking addresses in
    dmesg and syslog. But this applies to kdb too, with is unfortunate:
    
        Entering kdb (current=0x(ptrval), pid 329) due to Keyboard Entry
        kdb> ps
        15 sleeping system daemon (state M) processes suppressed,
        use 'ps A' to see all.
        Task Addr       Pid   Parent [*] cpu State Thread     Command
        0x(ptrval)      329      328  1    0   R  0x(ptrval) *sh
    
        0x(ptrval)        1        0  0    0   S  0x(ptrval)  init
        0x(ptrval)        3        2  0    0   D  0x(ptrval)  rcu_gp
        0x(ptrval)        4        2  0    0   D  0x(ptrval)  rcu_par_gp
        0x(ptrval)        5        2  0    0   D  0x(ptrval)  kworker/0:0
        0x(ptrval)        6        2  0    0   D  0x(ptrval)  kworker/0:0H
        0x(ptrval)        7        2  0    0   D  0x(ptrval)  kworker/u2:0
        0x(ptrval)        8        2  0    0   D  0x(ptrval)  mm_percpu_wq
        0x(ptrval)       10        2  0    0   D  0x(ptrval)  rcu_preempt
    
    The whole purpose of kdb is to debug, and for debugging real addresses
    need to be known. In addition, data displayed by kdb doesn't go into
    dmesg.
    
    This patch replaces all %p by %px in kdb in order to display real
    addresses.
    
    Fixes: ad67b74d2469 ("printk: hash addresses printed with %p")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
    Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ce583650a908b4b4fdfb3ac13edacf17d4c55c2f
Author: Christophe Leroy <christophe.leroy@c-s.fr>
Date:   Thu Sep 27 17:17:49 2018 +0000

    kdb: use correct pointer when 'btc' calls 'btt'
    
    commit dded2e159208a9edc21dd5c5f583afa28d378d39 upstream.
    
    On a powerpc 8xx, 'btc' fails as follows:
    
    Entering kdb (current=0x(ptrval), pid 282) due to Keyboard Entry
    kdb> btc
    btc: cpu status: Currently on cpu 0
    Available cpus: 0
    kdb_getarea: Bad address 0x0
    
    when booting the kernel with 'debug_boot_weak_hash', it fails as well
    
    Entering kdb (current=0xba99ad80, pid 284) due to Keyboard Entry
    kdb> btc
    btc: cpu status: Currently on cpu 0
    Available cpus: 0
    kdb_getarea: Bad address 0xba99ad80
    
    On other platforms, Oopses have been observed too, see
    https://github.com/linuxppc/linux/issues/139
    
    This is due to btc calling 'btt' with %p pointer as an argument.
    
    This patch replaces %p by %px to get the real pointer value as
    expected by 'btt'
    
    Fixes: ad67b74d2469 ("printk: hash addresses printed with %p")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
    Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f3f529741e54be10d162797275fe432cebe51b96
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Thu Oct 25 12:05:11 2018 -0500

    mount: Prevent MNT_DETACH from disconnecting locked mounts
    
    commit 9c8e0a1b683525464a2abe9fb4b54404a50ed2b4 upstream.
    
    Timothy Baldwin <timbaldwin@fastmail.co.uk> wrote:
    > As per mount_namespaces(7) unprivileged users should not be able to look under mount points:
    >
    >   Mounts that come as a single unit from more privileged mount are locked
    >   together and may not be separated in a less privileged mount namespace.
    >
    > However they can:
    >
    > 1. Create a mount namespace.
    > 2. In the mount namespace open a file descriptor to the parent of a mount point.
    > 3. Destroy the mount namespace.
    > 4. Use the file descriptor to look under the mount point.
    >
    > I have reproduced this with Linux 4.16.18 and Linux 4.18-rc8.
    >
    > The setup:
    >
    > $ sudo sysctl kernel.unprivileged_userns_clone=1
    > kernel.unprivileged_userns_clone = 1
    > $ mkdir -p A/B/Secret
    > $ sudo mount -t tmpfs hide A/B
    >
    >
    > "Secret" is indeed hidden as expected:
    >
    > $ ls -lR A
    > A:
    > total 0
    > drwxrwxrwt 2 root root 40 Feb 12 21:08 B
    >
    > A/B:
    > total 0
    >
    >
    > The attack revealing "Secret":
    >
    > $ unshare -Umr sh -c "exec unshare -m ls -lR /proc/self/fd/4/ 4<A"
    > /proc/self/fd/4/:
    > total 0
    > drwxr-xr-x 3 root root 60 Feb 12 21:08 B
    >
    > /proc/self/fd/4/B:
    > total 0
    > drwxr-xr-x 2 root root 40 Feb 12 21:08 Secret
    >
    > /proc/self/fd/4/B/Secret:
    > total 0
    
    I tracked this down to put_mnt_ns running passing UMOUNT_SYNC and
    disconnecting all of the mounts in a mount namespace.  Fix this by
    factoring drop_mounts out of drop_collected_mounts and passing
    0 instead of UMOUNT_SYNC.
    
    There are two possible behavior differences that result from this.
    - No longer setting UMOUNT_SYNC will no longer set MNT_SYNC_UMOUNT on
      the vfsmounts being unmounted.  This effects the lazy rcu walk by
      kicking the walk out of rcu mode and forcing it to be a non-lazy
      walk.
    - No longer disconnecting locked mounts will keep some mounts around
      longer as they stay because the are locked to other mounts.
    
    There are only two users of drop_collected mounts: audit_tree.c and
    put_mnt_ns.
    
    In audit_tree.c the mounts are private and there are no rcu lazy walks
    only calls to iterate_mounts. So the changes should have no effect
    except for a small timing effect as the connected mounts are disconnected.
    
    In put_mnt_ns there may be references from process outside the mount
    namespace to the mounts.  So the mounts remaining connected will
    be the bug fix that is needed.  That rcu walks are allowed to continue
    appears not to be a problem especially as the rcu walk change was about
    an implementation detail not about semantics.
    
    Cc: stable@vger.kernel.org
    Fixes: 5ff9d8a65ce8 ("vfs: Lock in place mounts from more privileged users")
    Reported-by: Timothy Baldwin <timbaldwin@fastmail.co.uk>
    Tested-by: Timothy Baldwin <timbaldwin@fastmail.co.uk>
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c4585861f8f8055e02fd42b81259a0cb81e32f71
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Thu Oct 25 09:04:18 2018 -0500

    mount: Don't allow copying MNT_UNBINDABLE|MNT_LOCKED mounts
    
    commit df7342b240185d58d3d9665c0bbf0a0f5570ec29 upstream.
    
    Jonathan Calmels from NVIDIA reported that he's able to bypass the
    mount visibility security check in place in the Linux kernel by using
    a combination of the unbindable property along with the private mount
    propagation option to allow a unprivileged user to see a path which
    was purposefully hidden by the root user.
    
    Reproducer:
      # Hide a path to all users using a tmpfs
      root@castiana:~# mount -t tmpfs tmpfs /sys/devices/
      root@castiana:~#
    
      # As an unprivileged user, unshare user namespace and mount namespace
      stgraber@castiana:~$ unshare -U -m -r
    
      # Confirm the path is still not accessible
      root@castiana:~# ls /sys/devices/
    
      # Make /sys recursively unbindable and private
      root@castiana:~# mount --make-runbindable /sys
      root@castiana:~# mount --make-private /sys
    
      # Recursively bind-mount the rest of /sys over to /mnnt
      root@castiana:~# mount --rbind /sys/ /mnt
    
      # Access our hidden /sys/device as an unprivileged user
      root@castiana:~# ls /mnt/devices/
      breakpoint cpu cstate_core cstate_pkg i915 intel_pt isa kprobe
      LNXSYSTM:00 msr pci0000:00 platform pnp0 power software system
      tracepoint uncore_arb uncore_cbox_0 uncore_cbox_1 uprobe virtual
    
    Solve this by teaching copy_tree to fail if a mount turns out to be
    both unbindable and locked.
    
    Cc: stable@vger.kernel.org
    Fixes: 5ff9d8a65ce8 ("vfs: Lock in place mounts from more privileged users")
    Reported-by: Jonathan Calmels <jcalmels@nvidia.com>
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5e64ee8788f585d3e7c144fc232efa45eb61a202
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Mon Oct 22 10:21:38 2018 -0500

    mount: Retest MNT_LOCKED in do_umount
    
    commit 25d202ed820ee347edec0bf3bf553544556bf64b upstream.
    
    It was recently pointed out that the one instance of testing MNT_LOCKED
    outside of the namespace_sem is in ksys_umount.
    
    Fix that by adding a test inside of do_umount with namespace_sem and
    the mount_lock held.  As it helps to fail fails the existing test is
    maintained with an additional comment pointing out that it may be racy
    because the locks are not held.
    
    Cc: stable@vger.kernel.org
    Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
    Fixes: 5ff9d8a65ce8 ("vfs: Lock in place mounts from more privileged users")
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 68b908750ea4cb285aef4f58ed89056e3b0039db
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Wed Nov 7 22:36:23 2018 -0500

    ext4: fix buffer leak in __ext4_read_dirblock() on error path
    
    commit de59fae0043f07de5d25e02ca360f7d57bfa5866 upstream.
    
    Fixes: dc6982ff4db1 ("ext4: refactor code to read directory blocks ...")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 3.9
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit be7e29ce83f689887c198eeb45b2a81ba6497ea4
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Wed Nov 7 11:14:35 2018 -0500

    ext4: fix buffer leak in ext4_expand_extra_isize_ea() on error path
    
    commit 53692ec074d00589c2cf1d6d17ca76ad0adce6ec upstream.
    
    Fixes: de05ca852679 ("ext4: move call to ext4_error() into ...")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 4.17
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4096fc0912778196f04d66fef5189a897dba0131
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Wed Nov 7 11:10:21 2018 -0500

    ext4: fix buffer leak in ext4_xattr_move_to_block() on error path
    
    commit 6bdc9977fcdedf47118d2caf7270a19f4b6d8a8f upstream.
    
    Fixes: 3f2571c1f91f ("ext4: factor out xattr moving")
    Fixes: 6dd4ee7cab7e ("ext4: Expand extra_inodes space per ...")
    Reviewed-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 2.6.23
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8113972d21440db9d098d363ff00cca96d9ce1ab
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Wed Nov 7 11:07:01 2018 -0500

    ext4: release bs.bh before re-using in ext4_xattr_block_find()
    
    commit 45ae932d246f721e6584430017176cbcadfde610 upstream.
    
    bs.bh was taken in previous ext4_xattr_block_find() call,
    it should be released before re-using
    
    Fixes: 7e01c8e5420b ("ext3/4: fix uninitialized bs in ...")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 2.6.26
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 70ca35b44acea71dff052bb45e9c806a991d8bca
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Wed Nov 7 11:01:33 2018 -0500

    ext4: fix buffer leak in ext4_xattr_get_block() on error path
    
    commit ecaaf408478b6fb4d9986f9b6652f3824e374f4c upstream.
    
    Fixes: dec214d00e0d ("ext4: xattr inode deduplication")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 4.13
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 181224f970c445bc3de2b3b42e30f2e2a294e30f
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Wed Nov 7 10:56:28 2018 -0500

    ext4: fix possible leak of s_journal_flag_rwsem in error path
    
    commit af18e35bfd01e6d65a5e3ef84ffe8b252d1628c5 upstream.
    
    Fixes: c8585c6fcaf2 ("ext4: fix races between changing inode journal ...")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 4.7
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1124e5a89bd285468563df6723ceebab754735f6
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Wed Nov 7 10:32:53 2018 -0500

    ext4: fix possible leak of sbi->s_group_desc_leak in error path
    
    commit 9e463084cdb22e0b56b2dfbc50461020409a5fd3 upstream.
    
    Fixes: bfe0a5f47ada ("ext4: add more mount time checks of the superblock")
    Reported-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 4.18
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bf04dace8318d6ae20a11c9e7692f36d9e387c23
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Tue Nov 6 17:18:17 2018 -0500

    ext4: avoid possible double brelse() in add_new_gdb() on error path
    
    commit 4f32c38b4662312dd3c5f113d8bdd459887fb773 upstream.
    
    Fixes: b40971426a83 ("ext4: add error checking to calls to ...")
    Reported-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 2.6.38
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 65b1ce496c490e74b88f6fafc84a3eed756807a4
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Tue Nov 6 16:16:01 2018 -0500

    ext4: fix missing cleanup if ext4_alloc_flex_bg_array() fails while resizing
    
    commit f348e2241fb73515d65b5d77dd9c174128a7fbf2 upstream.
    
    Fixes: 117fff10d7f1 ("ext4: grow the s_flex_groups array as needed ...")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 3.7
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cffd3297173a7397da8171cd2ef20ae8eec8cee8
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Tue Nov 6 17:01:36 2018 -0500

    ext4: avoid buffer leak in ext4_orphan_add() after prior errors
    
    commit feaf264ce7f8d54582e2f66eb82dd9dd124c94f3 upstream.
    
    Fixes: d745a8c20c1f ("ext4: reduce contention on s_orphan_lock")
    Fixes: 6e3617e579e0 ("ext4: Handle non empty on-disk orphan link")
    Cc: Dmitry Monakhov <dmonakhov@gmail.com>
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 2.6.34
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit da497e7a38bb774a1ed6f6264b52704c9330e1fd
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Tue Nov 6 16:49:50 2018 -0500

    ext4: avoid buffer leak on shutdown in ext4_mark_iloc_dirty()
    
    commit a6758309a005060b8297a538a457c88699cb2520 upstream.
    
    ext4_mark_iloc_dirty() callers expect that it releases iloc->bh
    even if it returns an error.
    
    Fixes: 0db1ff222d40 ("ext4: add shutdown bit and check for it")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 4.11
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3caa7b620c0f9e2047468447ab26684daae1913f
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Tue Nov 6 16:20:40 2018 -0500

    ext4: fix possible inode leak in the retry loop of ext4_resize_fs()
    
    commit db6aee62406d9fbb53315fcddd81f1dc271d49fa upstream.
    
    Fixes: 1c6bd7173d66 ("ext4: convert file system to meta_bg if needed ...")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 3.7
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dd2775337188cc97bcc8ef75f876fdf55a4a6501
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Fri Nov 9 11:34:40 2018 -0500

    ext4: missing !bh check in ext4_xattr_inode_write()
    
    commit eb6984fa4ce2837dcb1f66720a600f31b0bb3739 upstream.
    
    According to Ted Ts'o ext4_getblk() called in ext4_xattr_inode_write()
    should not return bh = NULL
    
    The only time that bh could be NULL, then, would be in the case of
    something really going wrong; a programming error elsewhere (perhaps a
    wild pointer dereference) or I/O error causing on-disk file system
    corruption (although that would be highly unlikely given that we had
    *just* allocated the blocks and so the metadata blocks in question
    probably would still be in the cache).
    
    Fixes: e50e5129f384 ("ext4: xattr-in-inode support")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 4.13
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4e7e558e8bfa8017a04a9735fc2ed65cf3b1ea3c
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Sat Nov 3 16:13:17 2018 -0400

    ext4: avoid potential extra brelse in setup_new_flex_group_blocks()
    
    commit 9e4028935cca3f9ef9b6a90df9da6f1f94853536 upstream.
    
    Currently bh is set to NULL only during first iteration of for cycle,
    then this pointer is not cleared after end of using.
    Therefore rollback after errors can lead to extra brelse(bh) call,
    decrements bh counter and later trigger an unexpected warning in __brelse()
    
    Patch moves brelse() calls in body of cycle to exclude requirement of
    brelse() call in rollback.
    
    Fixes: 33afdcc5402d ("ext4: add a function which sets up group blocks ...")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 3.3+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 64176ffd7ffcd22dd748cf800fd3c1df8d18a137
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Sat Nov 3 16:50:08 2018 -0400

    ext4: add missing brelse() add_new_gdb_meta_bg()'s error path
    
    commit 61a9c11e5e7a0dab5381afa5d9d4dd5ebf18f7a0 upstream.
    
    Fixes: 01f795f9e0d6 ("ext4: add online resizing support for meta_bg ...")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 3.7
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit feddbc0114dfc5f602ac471e400f36d1e9c6a4b6
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Sat Nov 3 16:22:10 2018 -0400

    ext4: add missing brelse() in set_flexbg_block_bitmap()'s error path
    
    commit cea5794122125bf67559906a0762186cf417099c upstream.
    
    Fixes: 33afdcc5402d ("ext4: add a function which sets up group blocks ...")
    Cc: stable@kernel.org # 3.3
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9910b2578039587832804469610f6742c2d06148
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Sat Nov 3 17:11:19 2018 -0400

    ext4: add missing brelse() update_backups()'s error path
    
    commit ea0abbb648452cdb6e1734b702b6330a7448fcf8 upstream.
    
    Fixes: ac27a0ec112a ("ext4: initial copy of files from ext3")
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org # 2.6.19
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 79d80b876396693e5b6d7d345963b83a2f917816
Author: Michael Kelley <mikelley@microsoft.com>
Date:   Sun Nov 4 03:48:54 2018 +0000

    clockevents/drivers/i8253: Add support for PIT shutdown quirk
    
    commit 35b69a420bfb56b7b74cb635ea903db05e357bec upstream.
    
    Add support for platforms where pit_shutdown() doesn't work because of a
    quirk in the PIT emulation. On these platforms setting the counter register
    to zero causes the PIT to start running again, negating the shutdown.
    
    Provide a global variable that controls whether the counter register is
    zero'ed, which platform specific code can override.
    
    Signed-off-by: Michael Kelley <mikelley@microsoft.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
    Cc: "devel@linuxdriverproject.org" <devel@linuxdriverproject.org>
    Cc: "daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>
    Cc: "virtualization@lists.linux-foundation.org" <virtualization@lists.linux-foundation.org>
    Cc: "jgross@suse.com" <jgross@suse.com>
    Cc: "akataria@vmware.com" <akataria@vmware.com>
    Cc: "olaf@aepfle.de" <olaf@aepfle.de>
    Cc: "apw@canonical.com" <apw@canonical.com>
    Cc: vkuznets <vkuznets@redhat.com>
    Cc: "jasowang@redhat.com" <jasowang@redhat.com>
    Cc: "marcelo.cerri@canonical.com" <marcelo.cerri@canonical.com>
    Cc: KY Srinivasan <kys@microsoft.com>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/1541303219-11142-2-git-send-email-mikelley@microsoft.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d62eead029806345c60becda77169d5e01009510
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Nov 5 11:14:17 2018 +0000

    Btrfs: fix data corruption due to cloning of eof block
    
    commit ac765f83f1397646c11092a032d4f62c3d478b81 upstream.
    
    We currently allow cloning a range from a file which includes the last
    block of the file even if the file's size is not aligned to the block
    size. This is fine and useful when the destination file has the same size,
    but when it does not and the range ends somewhere in the middle of the
    destination file, it leads to corruption because the bytes between the EOF
    and the end of the block have undefined data (when there is support for
    discard/trimming they have a value of 0x00).
    
    Example:
    
     $ mkfs.btrfs -f /dev/sdb
     $ mount /dev/sdb /mnt
    
     $ export foo_size=$((256 * 1024 + 100))
     $ xfs_io -f -c "pwrite -S 0x3c 0 $foo_size" /mnt/foo
     $ xfs_io -f -c "pwrite -S 0xb5 0 1M" /mnt/bar
    
     $ xfs_io -c "reflink /mnt/foo 0 512K $foo_size" /mnt/bar
    
     $ od -A d -t x1 /mnt/bar
     0000000 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5
     *
     0524288 3c 3c 3c 3c 3c 3c 3c 3c 3c 3c 3c 3c 3c 3c 3c 3c
     *
     0786528 3c 3c 3c 3c 00 00 00 00 00 00 00 00 00 00 00 00
     0786544 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
     *
     0790528 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5
     *
     1048576
    
    The bytes in the range from 786532 (512Kb + 256Kb + 100 bytes) to 790527
    (512Kb + 256Kb + 4Kb - 1) got corrupted, having now a value of 0x00 instead
    of 0xb5.
    
    This is similar to the problem we had for deduplication that got recently
    fixed by commit de02b9f6bb65 ("Btrfs: fix data corruption when
    deduplicating between different files").
    
    Fix this by not allowing such operations to be performed and return the
    errno -EINVAL to user space. This is what XFS is doing as well at the VFS
    level. This change however now makes us return -EINVAL instead of
    -EOPNOTSUPP for cases where the source range maps to an inline extent and
    the destination range's end is smaller then the destination file's size,
    since the detection of inline extents is done during the actual process of
    dropping file extent items (at __btrfs_drop_extents()). Returning the
    -EINVAL error is done early on and solely based on the input parameters
    (offsets and length) and destination file's size. This makes us consistent
    with XFS and anyone else supporting cloning since this case is now checked
    at a higher level in the VFS and is where the -EINVAL will be returned
    from starting with kernel 4.20 (the VFS changed was introduced in 4.20-rc1
    by commit 07d19dc9fbe9 ("vfs: avoid problematic remapping requests into
    partial EOF block"). So this change is more geared towards stable kernels,
    as it's unlikely the new VFS checks get removed intentionally.
    
    A test case for fstests follows soon, as well as an update to filter
    existing tests that expect -EOPNOTSUPP to accept -EINVAL as well.
    
    CC: <stable@vger.kernel.org> # 4.4+
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c7a082fb631a3282667b60ad36bfbeea45322cdd
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Nov 5 11:14:05 2018 +0000

    Btrfs: fix infinite loop on inode eviction after deduplication of eof block
    
    commit 11023d3f5fdf89bba5e1142127701ca6e6014587 upstream.
    
    If we attempt to deduplicate the last block of a file A into the middle of
    a file B, and file A's size is not a multiple of the block size, we end
    rounding the deduplication length to 0 bytes, to avoid the data corruption
    issue fixed by commit de02b9f6bb65 ("Btrfs: fix data corruption when
    deduplicating between different files"). However a length of zero will
    cause the insertion of an extent state with a start value greater (by 1)
    then the end value, leading to a corrupt extent state that will trigger a
    warning and cause chaos such as an infinite loop during inode eviction.
    Example trace:
    
     [96049.833585] ------------[ cut here ]------------
     [96049.833714] WARNING: CPU: 0 PID: 24448 at fs/btrfs/extent_io.c:436 insert_state+0x101/0x120 [btrfs]
     [96049.833767] CPU: 0 PID: 24448 Comm: xfs_io Not tainted 4.19.0-rc7-btrfs-next-39 #1
     [96049.833768] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.2-0-gf9626ccb91-prebuilt.qemu-project.org 04/01/2014
     [96049.833780] RIP: 0010:insert_state+0x101/0x120 [btrfs]
     [96049.833783] RSP: 0018:ffffafd2c3707af0 EFLAGS: 00010282
     [96049.833785] RAX: 0000000000000000 RBX: 000000000004dfff RCX: 0000000000000006
     [96049.833786] RDX: 0000000000000007 RSI: ffff99045c143230 RDI: ffff99047b2168a0
     [96049.833787] RBP: ffff990457851cd0 R08: 0000000000000001 R09: 0000000000000000
     [96049.833787] R10: ffffafd2c3707ab8 R11: 0000000000000000 R12: ffff9903b93b12c8
     [96049.833788] R13: 000000000004e000 R14: ffffafd2c3707b80 R15: ffffafd2c3707b78
     [96049.833790] FS:  00007f5c14e7d700(0000) GS:ffff99047b200000(0000) knlGS:0000000000000000
     [96049.833791] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
     [96049.833792] CR2: 00007f5c146abff8 CR3: 0000000115f4c004 CR4: 00000000003606f0
     [96049.833795] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
     [96049.833796] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
     [96049.833796] Call Trace:
     [96049.833809]  __set_extent_bit+0x46c/0x6a0 [btrfs]
     [96049.833823]  lock_extent_bits+0x6b/0x210 [btrfs]
     [96049.833831]  ? _raw_spin_unlock+0x24/0x30
     [96049.833841]  ? test_range_bit+0xdf/0x130 [btrfs]
     [96049.833853]  lock_extent_range+0x8e/0x150 [btrfs]
     [96049.833864]  btrfs_double_extent_lock+0x78/0xb0 [btrfs]
     [96049.833875]  btrfs_extent_same_range+0x14e/0x550 [btrfs]
     [96049.833885]  ? rcu_read_lock_sched_held+0x3f/0x70
     [96049.833890]  ? __kmalloc_node+0x2b0/0x2f0
     [96049.833899]  ? btrfs_dedupe_file_range+0x19a/0x280 [btrfs]
     [96049.833909]  btrfs_dedupe_file_range+0x270/0x280 [btrfs]
     [96049.833916]  vfs_dedupe_file_range_one+0xd9/0xe0
     [96049.833919]  vfs_dedupe_file_range+0x131/0x1b0
     [96049.833924]  do_vfs_ioctl+0x272/0x6e0
     [96049.833927]  ? __fget+0x113/0x200
     [96049.833931]  ksys_ioctl+0x70/0x80
     [96049.833933]  __x64_sys_ioctl+0x16/0x20
     [96049.833937]  do_syscall_64+0x60/0x1b0
     [96049.833939]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
     [96049.833941] RIP: 0033:0x7f5c1478ddd7
     [96049.833943] RSP: 002b:00007ffe15b196a8 EFLAGS: 00000202 ORIG_RAX: 0000000000000010
     [96049.833945] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f5c1478ddd7
     [96049.833946] RDX: 00005625ece322d0 RSI: 00000000c0189436 RDI: 0000000000000004
     [96049.833947] RBP: 0000000000000000 R08: 00007f5c14a46f48 R09: 0000000000000040
     [96049.833948] R10: 0000000000000541 R11: 0000000000000202 R12: 0000000000000000
     [96049.833949] R13: 0000000000000000 R14: 0000000000000004 R15: 00005625ece322d0
     [96049.833954] irq event stamp: 6196
     [96049.833956] hardirqs last  enabled at (6195): [<ffffffff91b00663>] console_unlock+0x503/0x640
     [96049.833958] hardirqs last disabled at (6196): [<ffffffff91a037dd>] trace_hardirqs_off_thunk+0x1a/0x1c
     [96049.833959] softirqs last  enabled at (6114): [<ffffffff92600370>] __do_softirq+0x370/0x421
     [96049.833964] softirqs last disabled at (6095): [<ffffffff91a8dd4d>] irq_exit+0xcd/0xe0
     [96049.833965] ---[ end trace db7b05f01b7fa10c ]---
     [96049.935816] R13: 0000000000000000 R14: 00005562e5259240 R15: 00007ffff092b910
     [96049.935822] irq event stamp: 6584
     [96049.935823] hardirqs last  enabled at (6583): [<ffffffff91b00663>] console_unlock+0x503/0x640
     [96049.935825] hardirqs last disabled at (6584): [<ffffffff91a037dd>] trace_hardirqs_off_thunk+0x1a/0x1c
     [96049.935827] softirqs last  enabled at (6328): [<ffffffff92600370>] __do_softirq+0x370/0x421
     [96049.935828] softirqs last disabled at (6313): [<ffffffff91a8dd4d>] irq_exit+0xcd/0xe0
     [96049.935829] ---[ end trace db7b05f01b7fa123 ]---
     [96049.935840] ------------[ cut here ]------------
     [96049.936065] WARNING: CPU: 1 PID: 24463 at fs/btrfs/extent_io.c:436 insert_state+0x101/0x120 [btrfs]
     [96049.936107] CPU: 1 PID: 24463 Comm: umount Tainted: G        W         4.19.0-rc7-btrfs-next-39 #1
     [96049.936108] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.2-0-gf9626ccb91-prebuilt.qemu-project.org 04/01/2014
     [96049.936117] RIP: 0010:insert_state+0x101/0x120 [btrfs]
     [96049.936119] RSP: 0018:ffffafd2c3637bc0 EFLAGS: 00010282
     [96049.936120] RAX: 0000000000000000 RBX: 000000000004dfff RCX: 0000000000000006
     [96049.936121] RDX: 0000000000000007 RSI: ffff990445cf88e0 RDI: ffff99047b2968a0
     [96049.936122] RBP: ffff990457851cd0 R08: 0000000000000001 R09: 0000000000000000
     [96049.936123] R10: ffffafd2c3637b88 R11: 0000000000000000 R12: ffff9904574301e8
     [96049.936124] R13: 000000000004e000 R14: ffffafd2c3637c50 R15: ffffafd2c3637c48
     [96049.936125] FS:  00007fe4b87e72c0(0000) GS:ffff99047b280000(0000) knlGS:0000000000000000
     [96049.936126] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
     [96049.936128] CR2: 00005562e52618d8 CR3: 00000001151c8005 CR4: 00000000003606e0
     [96049.936129] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
     [96049.936131] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
     [96049.936131] Call Trace:
     [96049.936141]  __set_extent_bit+0x46c/0x6a0 [btrfs]
     [96049.936154]  lock_extent_bits+0x6b/0x210 [btrfs]
     [96049.936167]  btrfs_evict_inode+0x1e1/0x5a0 [btrfs]
     [96049.936172]  evict+0xbf/0x1c0
     [96049.936174]  dispose_list+0x51/0x80
     [96049.936176]  evict_inodes+0x193/0x1c0
     [96049.936180]  generic_shutdown_super+0x3f/0x110
     [96049.936182]  kill_anon_super+0xe/0x30
     [96049.936189]  btrfs_kill_super+0x13/0x100 [btrfs]
     [96049.936191]  deactivate_locked_super+0x3a/0x70
     [96049.936193]  cleanup_mnt+0x3b/0x80
     [96049.936195]  task_work_run+0x93/0xc0
     [96049.936198]  exit_to_usermode_loop+0xfa/0x100
     [96049.936201]  do_syscall_64+0x17f/0x1b0
     [96049.936202]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
     [96049.936204] RIP: 0033:0x7fe4b80cfb37
     [96049.936206] RSP: 002b:00007ffff092b688 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
     [96049.936207] RAX: 0000000000000000 RBX: 00005562e5259060 RCX: 00007fe4b80cfb37
     [96049.936208] RDX: 0000000000000001 RSI: 0000000000000000 RDI: 00005562e525faa0
     [96049.936209] RBP: 00005562e525faa0 R08: 00005562e525f770 R09: 0000000000000015
     [96049.936210] R10: 00000000000006b4 R11: 0000000000000246 R12: 00007fe4b85d1e64
     [96049.936211] R13: 0000000000000000 R14: 00005562e5259240 R15: 00007ffff092b910
     [96049.936211] R13: 0000000000000000 R14: 00005562e5259240 R15: 00007ffff092b910
     [96049.936216] irq event stamp: 6616
     [96049.936219] hardirqs last  enabled at (6615): [<ffffffff91b00663>] console_unlock+0x503/0x640
     [96049.936219] hardirqs last disabled at (6616): [<ffffffff91a037dd>] trace_hardirqs_off_thunk+0x1a/0x1c
     [96049.936222] softirqs last  enabled at (6328): [<ffffffff92600370>] __do_softirq+0x370/0x421
     [96049.936222] softirqs last disabled at (6313): [<ffffffff91a8dd4d>] irq_exit+0xcd/0xe0
     [96049.936223] ---[ end trace db7b05f01b7fa124 ]---
    
    The second stack trace, from inode eviction, is repeated forever due to
    the infinite loop during eviction.
    
    This is the same type of problem fixed way back in 2015 by commit
    113e8283869b ("Btrfs: fix inode eviction infinite loop after extent_same
    ioctl") and commit ccccf3d67294 ("Btrfs: fix inode eviction infinite loop
    after cloning into it").
    
    So fix this by returning immediately if the deduplication range length
    gets rounded down to 0 bytes, as there is nothing that needs to be done in
    such case.
    
    Example reproducer:
    
     $ mkfs.btrfs -f /dev/sdb
     $ mount /dev/sdb /mnt
    
     $ xfs_io -f -c "pwrite -S 0xe6 0 100" /mnt/foo
     $ xfs_io -f -c "pwrite -S 0xe6 0 1M" /mnt/bar
    
     # Unmount the filesystem and mount it again so that we start without any
     # extent state records when we ask for the deduplication.
     $ umount /mnt
     $ mount /dev/sdb /mnt
    
     $ xfs_io -c "dedupe /mnt/foo 0 500K 100" /mnt/bar
    
     # This unmount triggers the infinite loop.
     $ umount /mnt
    
    A test case for fstests will follow soon.
    
    Fixes: de02b9f6bb65 ("Btrfs: fix data corruption when deduplicating between different files")
    CC: <stable@vger.kernel.org> # 4.19+
    Reviewed-by: Nikolay Borisov <nborisov@suse.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6dcd34f106ec113db47dddf9a70f0af7d81af468
Author: Robbie Ko <robbieko@synology.com>
Date:   Tue Oct 30 18:04:04 2018 +0800

    Btrfs: fix cur_offset in the error case for nocow
    
    commit 506481b20e818db40b6198815904ecd2d6daee64 upstream.
    
    When the cow_file_range fails, the related resources are unlocked
    according to the range [start..end), so the unlock cannot be repeated in
    run_delalloc_nocow.
    
    In some cases (e.g. cur_offset <= end && cow_start != -1), cur_offset is
    not updated correctly, so move the cur_offset update before
    cow_file_range.
    
      kernel BUG at mm/page-writeback.c:2663!
      Internal error: Oops - BUG: 0 [#1] SMP
      CPU: 3 PID: 31525 Comm: kworker/u8:7 Tainted: P O
      Hardware name: Realtek_RTD1296 (DT)
      Workqueue: writeback wb_workfn (flush-btrfs-1)
      task: ffffffc076db3380 ti: ffffffc02e9ac000 task.ti: ffffffc02e9ac000
      PC is at clear_page_dirty_for_io+0x1bc/0x1e8
      LR is at clear_page_dirty_for_io+0x14/0x1e8
      pc : [<ffffffc00033c91c>] lr : [<ffffffc00033c774>] pstate: 40000145
      sp : ffffffc02e9af4f0
      Process kworker/u8:7 (pid: 31525, stack limit = 0xffffffc02e9ac020)
      Call trace:
      [<ffffffc00033c91c>] clear_page_dirty_for_io+0x1bc/0x1e8
      [<ffffffbffc514674>] extent_clear_unlock_delalloc+0x1e4/0x210 [btrfs]
      [<ffffffbffc4fb168>] run_delalloc_nocow+0x3b8/0x948 [btrfs]
      [<ffffffbffc4fb948>] run_delalloc_range+0x250/0x3a8 [btrfs]
      [<ffffffbffc514c0c>] writepage_delalloc.isra.21+0xbc/0x1d8 [btrfs]
      [<ffffffbffc516048>] __extent_writepage+0xe8/0x248 [btrfs]
      [<ffffffbffc51630c>] extent_write_cache_pages.isra.17+0x164/0x378 [btrfs]
      [<ffffffbffc5185a8>] extent_writepages+0x48/0x68 [btrfs]
      [<ffffffbffc4f5828>] btrfs_writepages+0x20/0x30 [btrfs]
      [<ffffffc00033d758>] do_writepages+0x30/0x88
      [<ffffffc0003ba0f4>] __writeback_single_inode+0x34/0x198
      [<ffffffc0003ba6c4>] writeback_sb_inodes+0x184/0x3c0
      [<ffffffc0003ba96c>] __writeback_inodes_wb+0x6c/0xc0
      [<ffffffc0003bac20>] wb_writeback+0x1b8/0x1c0
      [<ffffffc0003bb0f0>] wb_workfn+0x150/0x250
      [<ffffffc0002b0014>] process_one_work+0x1dc/0x388
      [<ffffffc0002b02f0>] worker_thread+0x130/0x500
      [<ffffffc0002b6344>] kthread+0x10c/0x110
      [<ffffffc000284590>] ret_from_fork+0x10/0x40
      Code: d503201f a9025bb5 a90363b7 f90023b9 (d4210000)
    
    CC: stable@vger.kernel.org # 4.4+
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: Robbie Ko <robbieko@synology.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 84e7fe7bd079dcc81622e56912f002287cda8b32
Author: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Date:   Wed Oct 24 20:24:03 2018 +0800

    btrfs: fix pinned underflow after transaction aborted
    
    commit fcd5e74288f7d36991b1f0fb96b8c57079645e38 upstream.
    
    When running generic/475, we may get the following warning in dmesg:
    
    [ 6902.102154] WARNING: CPU: 3 PID: 18013 at fs/btrfs/extent-tree.c:9776 btrfs_free_block_groups+0x2af/0x3b0 [btrfs]
    [ 6902.109160] CPU: 3 PID: 18013 Comm: umount Tainted: G        W  O      4.19.0-rc8+ #8
    [ 6902.110971] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
    [ 6902.112857] RIP: 0010:btrfs_free_block_groups+0x2af/0x3b0 [btrfs]
    [ 6902.118921] RSP: 0018:ffffc9000459bdb0 EFLAGS: 00010286
    [ 6902.120315] RAX: ffff880175050bb0 RBX: ffff8801124a8000 RCX: 0000000000170007
    [ 6902.121969] RDX: 0000000000000002 RSI: 0000000000170007 RDI: ffffffff8125fb74
    [ 6902.123716] RBP: ffff880175055d10 R08: 0000000000000000 R09: 0000000000000000
    [ 6902.125417] R10: 0000000000000000 R11: 0000000000000000 R12: ffff880175055d88
    [ 6902.127129] R13: ffff880175050bb0 R14: 0000000000000000 R15: dead000000000100
    [ 6902.129060] FS:  00007f4507223780(0000) GS:ffff88017ba00000(0000) knlGS:0000000000000000
    [ 6902.130996] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 6902.132558] CR2: 00005623599cac78 CR3: 000000014b700001 CR4: 00000000003606e0
    [ 6902.134270] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [ 6902.135981] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [ 6902.137836] Call Trace:
    [ 6902.138939]  close_ctree+0x171/0x330 [btrfs]
    [ 6902.140181]  ? kthread_stop+0x146/0x1f0
    [ 6902.141277]  generic_shutdown_super+0x6c/0x100
    [ 6902.142517]  kill_anon_super+0x14/0x30
    [ 6902.143554]  btrfs_kill_super+0x13/0x100 [btrfs]
    [ 6902.144790]  deactivate_locked_super+0x2f/0x70
    [ 6902.146014]  cleanup_mnt+0x3b/0x70
    [ 6902.147020]  task_work_run+0x9e/0xd0
    [ 6902.148036]  do_syscall_64+0x470/0x600
    [ 6902.149142]  ? trace_hardirqs_off_thunk+0x1a/0x1c
    [ 6902.150375]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
    [ 6902.151640] RIP: 0033:0x7f45077a6a7b
    [ 6902.157324] RSP: 002b:00007ffd589f3e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
    [ 6902.159187] RAX: 0000000000000000 RBX: 000055e8eec732b0 RCX: 00007f45077a6a7b
    [ 6902.160834] RDX: 0000000000000001 RSI: 0000000000000000 RDI: 000055e8eec73490
    [ 6902.162526] RBP: 0000000000000000 R08: 000055e8eec734b0 R09: 00007ffd589f26c0
    [ 6902.164141] R10: 0000000000000000 R11: 0000000000000246 R12: 000055e8eec73490
    [ 6902.165815] R13: 00007f4507ac61a4 R14: 0000000000000000 R15: 00007ffd589f40d8
    [ 6902.167553] irq event stamp: 0
    [ 6902.168998] hardirqs last  enabled at (0): [<0000000000000000>]           (null)
    [ 6902.170731] hardirqs last disabled at (0): [<ffffffff810cd810>] copy_process.part.55+0x3b0/0x1f00
    [ 6902.172773] softirqs last  enabled at (0): [<ffffffff810cd810>] copy_process.part.55+0x3b0/0x1f00
    [ 6902.174671] softirqs last disabled at (0): [<0000000000000000>]           (null)
    [ 6902.176407] ---[ end trace 463138c2986b275c ]---
    [ 6902.177636] BTRFS info (device dm-3): space_info 4 has 273465344 free, is not full
    [ 6902.179453] BTRFS info (device dm-3): space_info total=276824064, used=4685824, pinned=18446744073708158976, reserved=0, may_use=0, readonly=65536
    
    In the above line there's "pinned=18446744073708158976" which is an
    unsigned u64 value of -1392640, an obvious underflow.
    
    When transaction_kthread is running cleanup_transaction(), another
    fsstress is running btrfs_commit_transaction(). The
    btrfs_finish_extent_commit() may get the same range as
    btrfs_destroy_pinned_extent() got, which causes the pinned underflow.
    
    Fixes: d4b450cd4b33 ("Btrfs: fix race between transaction commit and empty block group removal")
    CC: stable@vger.kernel.org # 4.4+
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ca35750b5fb7bd3c4233a77b0b2de6f6a9c6cbdc
Author: Mathieu Malaterre <malat@debian.org>
Date:   Wed Jun 6 21:42:32 2018 +0200

    watchdog/core: Add missing prototypes for weak functions
    
    commit 81bd415c91eb966118d773dddf254aebf3022411 upstream.
    
    The split out of the hard lockup detector exposed two new weak functions,
    but no prototypes for them, which triggers the build warning:
    
      kernel/watchdog.c:109:12: warning: no previous prototype for ‘watchdog_nmi_enable’ [-Wmissing-prototypes]
      kernel/watchdog.c:115:13: warning: no previous prototype for ‘watchdog_nmi_disable’ [-Wmissing-prototypes]
    
    Add the prototypes.
    
    Fixes: 73ce0511c436 ("kernel/watchdog.c: move hardlockup detector to separate file")
    Signed-off-by: Mathieu Malaterre <malat@debian.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Babu Moger <babu.moger@oracle.com>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/20180606194232.17653-1-malat@debian.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4fa1a679ed0140e84e8d4a25d0c3edd8b02b9976
Author: H. Peter Anvin (Intel) <hpa@zytor.com>
Date:   Mon Oct 22 09:19:05 2018 -0700

    arch/alpha, termios: implement BOTHER, IBSHIFT and termios2
    
    commit d0ffb805b729322626639336986bc83fc2e60871 upstream.
    
    Alpha has had c_ispeed and c_ospeed, but still set speeds in c_cflags
    using arbitrary flags. Because BOTHER is not defined, the general
    Linux code doesn't allow setting arbitrary baud rates, and because
    CBAUDEX == 0, we can have an array overrun of the baud_rate[] table in
    drivers/tty/tty_baudrate.c if (c_cflags & CBAUD) == 037.
    
    Resolve both problems by #defining BOTHER to 037 on Alpha.
    
    However, userspace still needs to know if setting BOTHER is actually
    safe given legacy kernels (does anyone actually care about that on
    Alpha anymore?), so enable the TCGETS2/TCSETS*2 ioctls on Alpha, even
    though they use the same structure. Define struct termios2 just for
    compatibility; it is the exact same structure as struct termios. In a
    future patchset, this will be cleaned up so the uapi headers are
    usable from libc.
    
    Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
    Cc: Jiri Slaby <jslaby@suse.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Richard Henderson <rth@twiddle.net>
    Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
    Cc: Matt Turner <mattst88@gmail.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Kate Stewart <kstewart@linuxfoundation.org>
    Cc: Philippe Ombredanne <pombredanne@nexb.com>
    Cc: Eugene Syromiatnikov <esyr@redhat.com>
    Cc: <linux-alpha@vger.kernel.org>
    Cc: <linux-serial@vger.kernel.org>
    Cc: Johan Hovold <johan@kernel.org>
    Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d85114a0a131e839070728f2d7bc253a9bfa8eb8
Author: H. Peter Anvin <hpa@zytor.com>
Date:   Mon Oct 22 09:19:04 2018 -0700

    termios, tty/tty_baudrate.c: fix buffer overrun
    
    commit 991a25194097006ec1e0d2e0814ff920e59e3465 upstream.
    
    On architectures with CBAUDEX == 0 (Alpha and PowerPC), the code in tty_baudrate.c does
    not do any limit checking on the tty_baudrate[] array, and in fact a
    buffer overrun is possible on both architectures. Add a limit check to
    prevent that situation.
    
    This will be followed by a much bigger cleanup/simplification patch.
    
    Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
    Requested-by: Cc: Johan Hovold <johan@kernel.org>
    Cc: Jiri Slaby <jslaby@suse.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Richard Henderson <rth@twiddle.net>
    Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
    Cc: Matt Turner <mattst88@gmail.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Kate Stewart <kstewart@linuxfoundation.org>
    Cc: Philippe Ombredanne <pombredanne@nexb.com>
    Cc: Eugene Syromiatnikov <esyr@redhat.com>
    Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit de51aafd80bedac4ce10072510203d67eb6ea3b4
Author: Michael Kelley <mikelley@microsoft.com>
Date:   Sun Nov 4 03:48:57 2018 +0000

    x86/hyper-v: Enable PIT shutdown quirk
    
    commit 1de72c706488b7be664a601cf3843bd01e327e58 upstream.
    
    Hyper-V emulation of the PIT has a quirk such that the normal PIT shutdown
    path doesn't work, because clearing the counter register restarts the
    timer.
    
    Disable the counter clearing on PIT shutdown.
    
    Signed-off-by: Michael Kelley <mikelley@microsoft.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
    Cc: "devel@linuxdriverproject.org" <devel@linuxdriverproject.org>
    Cc: "daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>
    Cc: "virtualization@lists.linux-foundation.org" <virtualization@lists.linux-foundation.org>
    Cc: "jgross@suse.com" <jgross@suse.com>
    Cc: "akataria@vmware.com" <akataria@vmware.com>
    Cc: "olaf@aepfle.de" <olaf@aepfle.de>
    Cc: "apw@canonical.com" <apw@canonical.com>
    Cc: vkuznets <vkuznets@redhat.com>
    Cc: "jasowang@redhat.com" <jasowang@redhat.com>
    Cc: "marcelo.cerri@canonical.com" <marcelo.cerri@canonical.com>
    Cc: KY Srinivasan <kys@microsoft.com>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/1541303219-11142-3-git-send-email-mikelley@microsoft.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c46d34365a1983225abee5fbe283c2852c17ac8e
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Fri Nov 9 15:22:07 2018 -0500

    x86/cpu/vmware: Do not trace vmware_sched_clock()
    
    commit 15035388439f892017d38b05214d3cda6578af64 upstream.
    
    When running function tracing on a Linux guest running on VMware
    Workstation, the guest would crash. This is due to tracing of the
    sched_clock internal call of the VMware vmware_sched_clock(), which
    causes an infinite recursion within the tracing code (clock calls must
    not be traced).
    
    Make vmware_sched_clock() not traced by ftrace.
    
    Fixes: 80e9a4f21fd7c ("x86/vmware: Add paravirt sched clock")
    Reported-by: GwanYeong Kim <gy741.kim@gmail.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    CC: Alok Kataria <akataria@vmware.com>
    CC: GwanYeong Kim <gy741.kim@gmail.com>
    CC: "H. Peter Anvin" <hpa@zytor.com>
    CC: Ingo Molnar <mingo@kernel.org>
    Cc: stable@vger.kernel.org
    CC: Thomas Gleixner <tglx@linutronix.de>
    CC: virtualization@lists.linux-foundation.org
    CC: x86-ml <x86@kernel.org>
    Link: http://lkml.kernel.org/r/20181109152207.4d3e7d70@gandalf.local.home
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9c6f231e8ad5947b757c66bf0a8f5c10ec83ccc2
Author: John Garry <john.garry@huawei.com>
Date:   Thu Nov 8 18:17:03 2018 +0800

    of, numa: Validate some distance map rules
    
    commit 89c38422e072bb453e3045b8f1b962a344c3edea upstream.
    
    Currently the NUMA distance map parsing does not validate the distance
    table for the distance-matrix rules 1-2 in [1].
    
    However the arch NUMA code may enforce some of these rules, but not all.
    Such is the case for the arm64 port, which does not enforce the rule that
    the distance between separates nodes cannot equal LOCAL_DISTANCE.
    
    The patch adds the following rules validation:
    - distance of node to self equals LOCAL_DISTANCE
    - distance of separate nodes > LOCAL_DISTANCE
    
    This change avoids a yet-unresolved crash reported in [2].
    
    A note on dealing with symmetrical distances between nodes:
    
    Validating symmetrical distances between nodes is difficult. If it were
    mandated in the bindings that every distance must be recorded in the
    table, then it would be easy. However, it isn't.
    
    In addition to this, it is also possible to record [b, a] distance only
    (and not [a, b]). So, when processing the table for [b, a], we cannot
    assert that current distance of [a, b] != [b, a] as invalid, as [a, b]
    distance may not be present in the table and current distance would be
    default at REMOTE_DISTANCE.
    
    As such, we maintain the policy that we overwrite distance [a, b] = [b, a]
    for b > a. This policy is different to kernel ACPI SLIT validation, which
    allows non-symmetrical distances (ACPI spec SLIT rules allow it). However,
    the distance debug message is dropped as it may be misleading (for a distance
    which is later overwritten).
    
    Some final notes on semantics:
    
    - It is implied that it is the responsibility of the arch NUMA code to
      reset the NUMA distance map for an error in distance map parsing.
    
    - It is the responsibility of the FW NUMA topology parsing (whether OF or
      ACPI) to enforce NUMA distance rules, and not arch NUMA code.
    
    [1] Documents/devicetree/bindings/numa.txt
    [2] https://www.spinics.net/lists/arm-kernel/msg683304.html
    
    Cc: stable@vger.kernel.org # 4.7
    Signed-off-by: John Garry <john.garry@huawei.com>
    Acked-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Rob Herring <robh@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fbd703540e22c5f8820a0bffbee4801fb4067e6b
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Thu Oct 11 13:06:16 2018 +0200

    mtd: docg3: don't set conflicting BCH_CONST_PARAMS option
    
    commit be2e1c9dcf76886a83fb1c433a316e26d4ca2550 upstream.
    
    I noticed during the creation of another bugfix that the BCH_CONST_PARAMS
    option that is set by DOCG3 breaks setting variable parameters for any
    other users of the BCH library code.
    
    The only other user we have today is the MTD_NAND software BCH
    implementation (most flash controllers use hardware BCH these days
    and are not affected). I considered removing BCH_CONST_PARAMS entirely
    because of the inherent conflict, but according to the description in
    lib/bch.c there is a significant performance benefit in keeping it.
    
    To avoid the immediate problem of the conflict between MTD_NAND_BCH
    and DOCG3, this only sets the constant parameters if MTD_NAND_BCH
    is disabled, which should fix the problem for all cases that
    are affected. This should also work for all stable kernels.
    
    Note that there is only one machine that actually seems to use the
    DOCG3 driver (arch/arm/mach-pxa/mioa701.c), so most users should have
    the driver disabled, but it almost certainly shows up if we wanted
    to test random kernels on machines that use software BCH in MTD.
    
    Fixes: d13d19ece39f ("mtd: docg3: add ECC correction code")
    Cc: stable@vger.kernel.org
    Cc: Robert Jarzmik <robert.jarzmik@free.fr>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2d155427ffb2057fd7ece3e735b204b393fd62cf
Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Date:   Mon Nov 5 14:54:56 2018 +0100

    ARM: 8809/1: proc-v7: fix Thumb annotation of cpu_v7_hvc_switch_mm
    
    commit 6282e916f774e37845c65d1eae9f8c649004f033 upstream.
    
    Due to what appears to be a copy/paste error, the opening ENTRY()
    of cpu_v7_hvc_switch_mm() lacks a matching ENDPROC(), and instead,
    the one for cpu_v7_smc_switch_mm() is duplicated.
    
    Given that it is ENDPROC() that emits the Thumb annotation, the
    cpu_v7_hvc_switch_mm() routine will be called in ARM mode on a
    Thumb2 kernel, resulting in the following splat:
    
      Internal error: Oops - undefined instruction: 0 [#1] SMP THUMB2
      Modules linked in:
      CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.18.0-rc1-00030-g4d28ad89189d-dirty #488
      Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
      PC is at cpu_v7_hvc_switch_mm+0x12/0x18
      LR is at flush_old_exec+0x31b/0x570
      pc : [<c0316efe>]    lr : [<c04117c7>]    psr: 00000013
      sp : ee899e50  ip : 00000000  fp : 00000001
      r10: eda28f34  r9 : eda31800  r8 : c12470e0
      r7 : eda1fc00  r6 : eda53000  r5 : 00000000  r4 : ee88c000
      r3 : c0316eec  r2 : 00000001  r1 : eda53000  r0 : 6da6c000
      Flags: nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
    
    Note the 'ISA ARM' in the last line.
    
    Fix this by using the correct name in ENDPROC().
    
    Cc: <stable@vger.kernel.org>
    Fixes: 10115105cb3a ("ARM: spectre-v2: add firmware based hardening")
    Reviewed-by: Dave Martin <Dave.Martin@arm.com>
    Acked-by: Marc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 54ab59528026cc6140be55fd918eedbdf2ee9677
Author: Vasily Khoruzhick <vasilykh@arista.com>
Date:   Thu Oct 25 12:15:43 2018 -0700

    netfilter: conntrack: fix calculation of next bucket number in early_drop
    
    commit f393808dc64149ccd0e5a8427505ba2974a59854 upstream.
    
    If there's no entry to drop in bucket that corresponds to the hash,
    early_drop() should look for it in other buckets. But since it increments
    hash instead of bucket number, it actually looks in the same bucket 8
    times: hsize is 16k by default (14 bits) and hash is 32-bit value, so
    reciprocal_scale(hash, hsize) returns the same value for hash..hash+7 in
    most cases.
    
    Fix it by increasing bucket number instead of hash and rename _hash
    to bucket to avoid future confusion.
    
    Fixes: 3e86638e9a0b ("netfilter: conntrack: consider ct netns in early_drop logic")
    Cc: <stable@vger.kernel.org> # v4.7+
    Signed-off-by: Vasily Khoruzhick <vasilykh@arista.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e6e4f052a20670e324d7cebd68460228f00086e5
Author: Andrea Arcangeli <aarcange@redhat.com>
Date:   Fri Nov 2 15:47:59 2018 -0700

    mm: thp: relax __GFP_THISNODE for MADV_HUGEPAGE mappings
    
    commit ac5b2c18911ffe95c08d69273917f90212cf5659 upstream.
    
    THP allocation might be really disruptive when allocated on NUMA system
    with the local node full or hard to reclaim.  Stefan has posted an
    allocation stall report on 4.12 based SLES kernel which suggests the
    same issue:
    
      kvm: page allocation stalls for 194572ms, order:9, mode:0x4740ca(__GFP_HIGHMEM|__GFP_IO|__GFP_FS|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_THISNODE|__GFP_MOVABLE|__GFP_DIRECT_RECLAIM), nodemask=(null)
      kvm cpuset=/ mems_allowed=0-1
      CPU: 10 PID: 84752 Comm: kvm Tainted: G        W 4.12.0+98-ph <a href="/view.php?id=1" title="[geschlossen] Integration Ramdisk" class="resolved">0000001</a> SLE15 (unreleased)
      Hardware name: Supermicro SYS-1029P-WTRT/X11DDW-NT, BIOS 2.0 12/05/2017
      Call Trace:
       dump_stack+0x5c/0x84
       warn_alloc+0xe0/0x180
       __alloc_pages_slowpath+0x820/0xc90
       __alloc_pages_nodemask+0x1cc/0x210
       alloc_pages_vma+0x1e5/0x280
       do_huge_pmd_wp_page+0x83f/0xf00
       __handle_mm_fault+0x93d/0x1060
       handle_mm_fault+0xc6/0x1b0
       __do_page_fault+0x230/0x430
       do_page_fault+0x2a/0x70
       page_fault+0x7b/0x80
       [...]
      Mem-Info:
      active_anon:126315487 inactive_anon:1612476 isolated_anon:5
       active_file:60183 inactive_file:245285 isolated_file:0
       unevictable:15657 dirty:286 writeback:1 unstable:0
       slab_reclaimable:75543 slab_unreclaimable:2509111
       mapped:81814 shmem:31764 pagetables:370616 bounce:0
       free:32294031 free_pcp:6233 free_cma:0
      Node 0 active_anon:254680388kB inactive_anon:1112760kB active_file:240648kB inactive_file:981168kB unevictable:13368kB isolated(anon):0kB isolated(file):0kB mapped:280240kB dirty:1144kB writeback:0kB shmem:95832kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 81225728kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no
      Node 1 active_anon:250583072kB inactive_anon:5337144kB active_file:84kB inactive_file:0kB unevictable:49260kB isolated(anon):20kB isolated(file):0kB mapped:47016kB dirty:0kB writeback:4kB shmem:31224kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 31897600kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no
    
    The defrag mode is "madvise" and from the above report it is clear that
    the THP has been allocated for MADV_HUGEPAGA vma.
    
    Andrea has identified that the main source of the problem is
    __GFP_THISNODE usage:
    
    : The problem is that direct compaction combined with the NUMA
    : __GFP_THISNODE logic in mempolicy.c is telling reclaim to swap very
    : hard the local node, instead of failing the allocation if there's no
    : THP available in the local node.
    :
    : Such logic was ok until __GFP_THISNODE was added to the THP allocation
    : path even with MPOL_DEFAULT.
    :
    : The idea behind the __GFP_THISNODE addition, is that it is better to
    : provide local memory in PAGE_SIZE units than to use remote NUMA THP
    : backed memory. That largely depends on the remote latency though, on
    : threadrippers for example the overhead is relatively low in my
    : experience.
    :
    : The combination of __GFP_THISNODE and __GFP_DIRECT_RECLAIM results in
    : extremely slow qemu startup with vfio, if the VM is larger than the
    : size of one host NUMA node. This is because it will try very hard to
    : unsuccessfully swapout get_user_pages pinned pages as result of the
    : __GFP_THISNODE being set, instead of falling back to PAGE_SIZE
    : allocations and instead of trying to allocate THP on other nodes (it
    : would be even worse without vfio type1 GUP pins of course, except it'd
    : be swapping heavily instead).
    
    Fix this by removing __GFP_THISNODE for THP requests which are
    requesting the direct reclaim.  This effectivelly reverts 5265047ac301
    on the grounds that the zone/node reclaim was known to be disruptive due
    to premature reclaim when there was memory free.  While it made sense at
    the time for HPC workloads without NUMA awareness on rare machines, it
    was ultimately harmful in the majority of cases.  The existing behaviour
    is similar, if not as widespare as it applies to a corner case but
    crucially, it cannot be tuned around like zone_reclaim_mode can.  The
    default behaviour should always be to cause the least harm for the
    common case.
    
    If there are specialised use cases out there that want zone_reclaim_mode
    in specific cases, then it can be built on top.  Longterm we should
    consider a memory policy which allows for the node reclaim like behavior
    for the specific memory ranges which would allow a
    
    [1] http://lkml.kernel.org/r/20180820032204.9591-1-aarcange@redhat.com
    
    Mel said:
    
    : Both patches look correct to me but I'm responding to this one because
    : it's the fix.  The change makes sense and moves further away from the
    : severe stalling behaviour we used to see with both THP and zone reclaim
    : mode.
    :
    : I put together a basic experiment with usemem configured to reference a
    : buffer multiple times that is 80% the size of main memory on a 2-socket
    : box with symmetric node sizes and defrag set to "always".  The defrag
    : setting is not the default but it would be functionally similar to
    : accessing a buffer with madvise(MADV_HUGEPAGE).  Usemem is configured to
    : reference the buffer multiple times and while it's not an interesting
    : workload, it would be expected to complete reasonably quickly as it fits
    : within memory.  The results were;
    :
    : usemem
    :                                   vanilla           noreclaim-v1
    : Amean     Elapsd-1       42.78 (   0.00%)       26.87 (  37.18%)
    : Amean     Elapsd-3       27.55 (   0.00%)        7.44 (  73.00%)
    : Amean     Elapsd-4        5.72 (   0.00%)        5.69 (   0.45%)
    :
    : This shows the elapsed time in seconds for 1 thread, 3 threads and 4
    : threads referencing buffers 80% the size of memory.  With the patches
    : applied, it's 37.18% faster for the single thread and 73% faster with two
    : threads.  Note that 4 threads showing little difference does not indicate
    : the problem is related to thread counts.  It's simply the case that 4
    : threads gets spread so their workload mostly fits in one node.
    :
    : The overall view from /proc/vmstats is more startling
    :
    :                          4.19.0-rc1  4.19.0-rc1
    :                             vanillanoreclaim-v1r1
    : Minor Faults               35593425      708164
    : Major Faults                 484088          36
    : Swap Ins                    3772837           0
    : Swap Outs                   3932295           0
    :
    : Massive amounts of swap in/out without the patch
    :
    : Direct pages scanned        6013214           0
    : Kswapd pages scanned              0           0
    : Kswapd pages reclaimed            0           0
    : Direct pages reclaimed      4033009           0
    :
    : Lots of reclaim activity without the patch
    :
    : Kswapd efficiency              100%        100%
    : Kswapd velocity               0.000       0.000
    : Direct efficiency               67%        100%
    : Direct velocity           11191.956       0.000
    :
    : Mostly from direct reclaim context as you'd expect without the patch.
    :
    : Page writes by reclaim  3932314.000       0.000
    : Page writes file                 19           0
    : Page writes anon            3932295           0
    : Page reclaim immediate        42336           0
    :
    : Writes from reclaim context is never good but the patch eliminates it.
    :
    : We should never have default behaviour to thrash the system for such a
    : basic workload.  If zone reclaim mode behaviour is ever desired but on a
    : single task instead of a global basis then the sensible option is to build
    : a mempolicy that enforces that behaviour.
    
    This was a severe regression compared to previous kernels that made
    important workloads unusable and it starts when __GFP_THISNODE was
    added to THP allocations under MADV_HUGEPAGE.  It is not a significant
    risk to go to the previous behavior before __GFP_THISNODE was added, it
    worked like that for years.
    
    This was simply an optimization to some lucky workloads that can fit in
    a single node, but it ended up breaking the VM for others that can't
    possibly fit in a single node, so going back is safe.
    
    [mhocko@suse.com: rewrote the changelog based on the one from Andrea]
    Link: http://lkml.kernel.org/r/20180925120326.24392-2-mhocko@kernel.org
    Fixes: 5265047ac301 ("mm, thp: really limit transparent hugepage allocation to local node")
    Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
    Signed-off-by: Michal Hocko <mhocko@suse.com>
    Reported-by: Stefan Priebe <s.priebe@profihost.ag>
    Debugged-by: Andrea Arcangeli <aarcange@redhat.com>
    Reported-by: Alex Williamson <alex.williamson@redhat.com>
    Reviewed-by: Mel Gorman <mgorman@techsingularity.net>
    Tested-by: Mel Gorman <mgorman@techsingularity.net>
    Cc: Zi Yan <zi.yan@cs.rutgers.edu>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: David Rientjes <rientjes@google.com>
    Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
    Cc: <stable@vger.kernel.org>    [4.1+]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1d0ad8ac6d1c4d8d513700096e1786e23afcfc26
Author: Wengang Wang <wen.gang.wang@oracle.com>
Date:   Fri Nov 16 15:08:25 2018 -0800

    ocfs2: free up write context when direct IO failed
    
    commit 5040f8df56fb90c7919f1c9b0b6e54c843437456 upstream.
    
    The write context should also be freed even when direct IO failed.
    Otherwise a memory leak is introduced and entries remain in
    oi->ip_unwritten_list causing the following BUG later in unlink path:
    
      ERROR: bug expression: !list_empty(&oi->ip_unwritten_list)
      ERROR: Clear inode of 215043, inode has unwritten extents
      ...
      Call Trace:
      ? __set_current_blocked+0x42/0x68
      ocfs2_evict_inode+0x91/0x6a0 [ocfs2]
      ? bit_waitqueue+0x40/0x33
      evict+0xdb/0x1af
      iput+0x1a2/0x1f7
      do_unlinkat+0x194/0x28f
      SyS_unlinkat+0x1b/0x2f
      do_syscall_64+0x79/0x1ae
      entry_SYSCALL_64_after_hwframe+0x151/0x0
    
    This patch also logs, with frequency limit, direct IO failures.
    
    Link: http://lkml.kernel.org/r/20181102170632.25921-1-wen.gang.wang@oracle.com
    Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
    Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
    Reviewed-by: Changwei Ge <ge.changwei@h3c.com>
    Reviewed-by: Joseph Qi <jiangqi903@gmail.com>
    Cc: Mark Fasheh <mark@fasheh.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ce8bf4cfe4afbd95d7d2db4ffcff9fa6f530f993
Author: Changwei Ge <ge.changwei@h3c.com>
Date:   Fri Nov 2 15:48:15 2018 -0700

    ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry
    
    commit 29aa30167a0a2e6045a0d6d2e89d8168132333d5 upstream.
    
    Somehow, file system metadata was corrupted, which causes
    ocfs2_check_dir_entry() to fail in function ocfs2_dir_foreach_blk_el().
    
    According to the original design intention, if above happens we should
    skip the problematic block and continue to retrieve dir entry.  But
    there is obviouse misuse of brelse around related code.
    
    After failure of ocfs2_check_dir_entry(), current code just moves to
    next position and uses the problematic buffer head again and again
    during which the problematic buffer head is released for multiple times.
    I suppose, this a serious issue which is long-lived in ocfs2.  This may
    cause other file systems which is also used in a the same host insane.
    
    So we should also consider about bakcporting this patch into linux
    -stable.
    
    Link: http://lkml.kernel.org/r/HK2PR06MB045211675B43EED794E597B6D56E0@HK2PR06MB0452.apcprd06.prod.outlook.com
    Signed-off-by: Changwei Ge <ge.changwei@h3c.com>
    Suggested-by: Changkuo Shi <shi.changkuo@h3c.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Mark Fasheh <mark@fasheh.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Junxiao Bi <junxiao.bi@oracle.com>
    Cc: Joseph Qi <jiangqi903@gmail.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d172f2527081d0bb28a32f16343fd2ad84008c9f
Author: Marc Zyngier <marc.zyngier@arm.com>
Date:   Wed Oct 31 08:41:34 2018 +0000

    soc: ti: QMSS: Fix usage of irq_set_affinity_hint
    
    commit 832ad0e3da4510fd17f98804abe512ea9a747035 upstream.
    
    The Keystone QMSS driver is pretty damaged, in the sense that it
    does things like this:
    
            irq_set_affinity_hint(irq, to_cpumask(&cpu_map));
    
    where cpu_map is a local variable. As we leave the function, this
    will point to nowhere-land, and things will end-up badly.
    
    Instead, let's use a proper cpumask that gets allocated, giving
    the driver a chance to actually work with things like irqbalance
    as well as have a hypothetical 64bit future.
    
    Cc: stable@vger.kernel.org
    Acked-by: Santosh Shilimkar <ssantosh@kernel.org>
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: Olof Johansson <olof@lixom.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a061395786ef57f96830ae4791778d1916146cd0
Author: Ming Lei <ming.lei@redhat.com>
Date:   Wed Nov 14 16:25:51 2018 +0800

    SCSI: fix queue cleanup race before queue initialization is done
    
    commit 8dc765d438f1e42b3e8227b3b09fad7d73f4ec9a upstream.
    
    c2856ae2f315d ("blk-mq: quiesce queue before freeing queue") has
    already fixed this race, however the implied synchronize_rcu()
    in blk_mq_quiesce_queue() can slow down LUN probe a lot, so caused
    performance regression.
    
    Then 1311326cf4755c7 ("blk-mq: avoid to synchronize rcu inside blk_cleanup_queue()")
    tried to quiesce queue for avoiding unnecessary synchronize_rcu()
    only when queue initialization is done, because it is usual to see
    lots of inexistent LUNs which need to be probed.
    
    However, turns out it isn't safe to quiesce queue only when queue
    initialization is done. Because when one SCSI command is completed,
    the user of sending command can be waken up immediately, then the
    scsi device may be removed, meantime the run queue in scsi_end_request()
    is still in-progress, so kernel panic can be caused.
    
    In Red Hat QE lab, there are several reports about this kind of kernel
    panic triggered during kernel booting.
    
    This patch tries to address the issue by grabing one queue usage
    counter during freeing one request and the following run queue.
    
    Fixes: 1311326cf4755c7 ("blk-mq: avoid to synchronize rcu inside blk_cleanup_queue()")
    Cc: Andrew Jones <drjones@redhat.com>
    Cc: Bart Van Assche <bart.vanassche@wdc.com>
    Cc: linux-scsi@vger.kernel.org
    Cc: Martin K. Petersen <martin.petersen@oracle.com>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: James E.J. Bottomley <jejb@linux.vnet.ibm.com>
    Cc: stable <stable@vger.kernel.org>
    Cc: jianchao.wang <jianchao.w.wang@oracle.com>
    Signed-off-by: Ming Lei <ming.lei@redhat.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2cbff556f2e153af48564b125711417b7e6dc6ad
Author: Quinn Tran <quinn.tran@cavium.com>
Date:   Tue Nov 6 00:51:21 2018 -0800

    scsi: qla2xxx: Initialize port speed to avoid setting lower speed
    
    commit f635e48e866ee1a47d2d42ce012fdcc07bf55853 upstream.
    
    This patch initializes port speed so that firmware does not set lower
    operating speed. Setting lower speed in firmware impacts WRITE perfomance.
    
    Fixes: 726b85487067 ("qla2xxx: Add framework for async fabric discovery")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
    Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
    Tested-by: Laurence Oberman <loberman@redhat.com>
    Reviewed-by: Ewan D. Milne <emilne@redhat.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 56bce0e5d5cca4377879fd983d454418f6a87263
Author: Greg Edwards <gedwards@ddn.com>
Date:   Wed Aug 22 13:21:53 2018 -0600

    vhost/scsi: truncate T10 PI iov_iter to prot_bytes
    
    commit 4542d623c7134bc1738f8a68ccb6dd546f1c264f upstream.
    
    Commands with protection information included were not truncating the
    protection iov_iter to the number of protection bytes in the command.
    This resulted in vhost_scsi mis-calculating the size of the protection
    SGL in vhost_scsi_calc_sgls(), and including both the protection and
    data SG entries in the protection SGL.
    
    Fixes: 09b13fa8c1a1 ("vhost/scsi: Add ANY_LAYOUT support in vhost_scsi_handle_vq")
    Signed-off-by: Greg Edwards <gedwards@ddn.com>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Fixes: 09b13fa8c1a1093e9458549ac8bb203a7c65c62a
    Cc: stable@vger.kernel.org
    Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b3d3180689f1c433354ed01aa405ffee810df5f9
Author: Gustavo A. R. Silva <gustavo@embeddedor.com>
Date:   Wed Jul 25 19:47:19 2018 -0500

    reset: hisilicon: fix potential NULL pointer dereference
    
    commit e9a2310fb689151166df7fd9971093362d34bd79 upstream.
    
    There is a potential execution path in which function
    platform_get_resource() returns NULL. If this happens,
    we will end up having a NULL pointer dereference.
    
    Fix this by replacing devm_ioremap with devm_ioremap_resource,
    which has the NULL check and the memory region request.
    
    This code was detected with the help of Coccinelle.
    
    Cc: stable@vger.kernel.org
    Fixes: 97b7129cd2af ("reset: hisilicon: change the definition of hisi_reset_init")
    Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 859eac9470c8c9493b8254f05e378f8a7ccaf642
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Mon Oct 8 12:57:35 2018 +0200

    mach64: fix image corruption due to reading accelerator registers
    
    commit c09bcc91bb94ed91f1391bffcbe294963d605732 upstream.
    
    Reading the registers without waiting for engine idle returns
    unpredictable values. These unpredictable values result in display
    corruption - if atyfb_imageblit reads the content of DP_PIX_WIDTH with the
    bit DP_HOST_TRIPLE_EN set (from previous invocation), the driver would
    never ever clear the bit, resulting in display corruption.
    
    We don't want to wait for idle because it would degrade performance, so
    this patch modifies the driver so that it never reads accelerator
    registers.
    
    HOST_CNTL doesn't have to be read, we can just write it with
    HOST_BYTE_ALIGN because no other part of the driver cares if
    HOST_BYTE_ALIGN is set.
    
    DP_PIX_WIDTH is written in the functions atyfb_copyarea and atyfb_fillrect
    with the default value and in atyfb_imageblit with the value set according
    to the source image data.
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Reviewed-by: Ville Syrjälä <syrjala@sci.fi>
    Cc: stable@vger.kernel.org
    Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 07ea136219e0bbb653bb15247f1c1838d635f3bb
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Mon Oct 8 12:57:34 2018 +0200

    mach64: fix display corruption on big endian machines
    
    commit 3c6c6a7878d00a3ac997a779c5b9861ff25dfcc8 upstream.
    
    The code for manual bit triple is not endian-clean. It builds the variable
    "hostdword" using byte accesses, therefore we must read the variable with
    "le32_to_cpu".
    
    The patch also enables (hardware or software) bit triple only if the image
    is monochrome (image->depth). If we want to blit full-color image, we
    shouldn't use the triple code.
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Reviewed-by: Ville Syrjälä <syrjala@sci.fi>
    Cc: stable@vger.kernel.org
    Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3b29cbb592bd712428607fee1ab214d42348719f
Author: Allen Wild <allenwild93@gmail.com>
Date:   Tue Sep 26 19:37:44 2017 +0200

    thermal: enable broadcom menu for arm64 bcm2835
    
    commit fec3624f0bcdb6b20ef9ccf9d9d55d0d75d776f8 upstream.
    
    Moving the bcm2835 thermal driver to the broadcom directory prevented it
    from getting enabled for arm64 builds, since the broadcom directory is only
    available when 32-bit specific ARCH_BCM is set.
    
    Fix this by enabling the Broadcom menu for ARCH_BCM or ARCH_BCM2835.
    
    Fixes: 6892cf07e733 ("thermal: bcm2835: move to the broadcom subdirectory")
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Signed-off-by: Allen Wild <allenwild93@gmail.com>
    Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
    Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 32ffde79e88f5a943d89b04ca3821ac8fb1ce7e5
Author: Yan, Zheng <zyan@redhat.com>
Date:   Thu Sep 27 21:16:05 2018 +0800

    Revert "ceph: fix dentry leak in splice_dentry()"
    
    commit efe328230dc01aa0b1269aad0b5fae73eea4677a upstream.
    
    This reverts commit 8b8f53af1ed9df88a4c0fbfdf3db58f62060edf3.
    
    splice_dentry() is used by three places. For two places, req->r_dentry
    is passed to splice_dentry(). In the case of error, req->r_dentry does
    not get updated. So splice_dentry() should not drop reference.
    
    Cc: stable@vger.kernel.org # 4.18+
    Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fc07f543a6d39399ba425c5bc588920fbdf65f39
Author: Ilya Dryomov <idryomov@gmail.com>
Date:   Wed Sep 26 18:03:16 2018 +0200

    libceph: bump CEPH_MSG_MAX_DATA_LEN
    
    commit 94e6992bb560be8bffb47f287194adf070b57695 upstream.
    
    If the read is large enough, we end up spinning in the messenger:
    
      libceph: osd0 192.168.122.1:6801 io error
      libceph: osd0 192.168.122.1:6801 io error
      libceph: osd0 192.168.122.1:6801 io error
    
    This is a receive side limit, so only reads were affected.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 65dd3e59e96f0e196526f0634c1b4a39b42e0911
Author: Lubomir Rintel <lkundrak@v3.sk>
Date:   Thu Oct 4 17:29:03 2018 -0400

    media: ov7670: make "xclk" clock optional
    
    commit 786fa584eda86d6598db3b87c61dc81f68808d11 upstream.
    
    When the "xclk" clock was added, it was made mandatory. This broke the
    driver on an OLPC plaform which doesn't know such clock. Make it
    optional.
    
    Tested on a OLPC XO-1 laptop.
    
    Fixes: 0a024d634cee ("[media] ov7670: get xclk")
    
    Cc: stable@vger.kernel.org # 4.11+
    Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d2aaeb9a8e05442129694d8f206685f01644ba75
Author: Chris Packham <chris.packham@alliedtelesis.co.nz>
Date:   Thu May 24 17:23:41 2018 +1200

    clk: mvebu: use correct bit for 98DX3236 NAND
    
    commit 00c5a926af12a9f0236928dab3dc9faf621406a1 upstream.
    
    The correct fieldbit value for the NAND PLL reload trigger is 27.
    
    Fixes: commit e120c17a70e5 ("clk: mvebu: support for 98DX3236 SoC")
    Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 864aede99f55cfad8be37ae24a02bd92bc5606ad
Author: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Date:   Tue Oct 16 15:41:44 2018 +0200

    clk: rockchip: Fix static checker warning in rockchip_ddrclk_get_parent call
    
    commit 665636b2940d0897c4130253467f5e8c42eea392 upstream.
    
    Fixes the signedness bug returning '(-22)' on the return type by removing the
    sanity checker in rockchip_ddrclk_get_parent(). The function should return
    and unsigned value only and it's safe to remove the sanity checker as the
    core functions that call get_parent like clk_core_get_parent_by_index already
    ensures the validity of the clk index returned (index >= core->num_parents).
    
    Fixes: a4f182bf81f18 ("clk: rockchip: add new clock-type for the ddrclk")
    Cc: stable@vger.kernel.org
    Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
    Reviewed-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Heiko Stuebner <heiko@sntech.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit abe960b761eb6b3b32b099c80535b3d3943db040
Author: Ronald Wahl <rwahl@gmx.de>
Date:   Wed Oct 10 15:54:54 2018 +0200

    clk: at91: Fix division by zero in PLL recalc_rate()
    
    commit 0f5cb0e6225cae2f029944cb8c74617aab6ddd49 upstream.
    
    Commit a982e45dc150 ("clk: at91: PLL recalc_rate() now using cached MUL
    and DIV values") removed a check that prevents a division by zero. This
    now causes a stacktrace when booting the kernel on a at91 platform if
    the PLL DIV register contains zero. This commit reintroduces this check.
    
    Fixes: a982e45dc150 ("clk: at91: PLL recalc_rate() now using cached...")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Ronald Wahl <rwahl@gmx.de>
    Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f074414aff064f7167756713ebdd8622592fe350
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Wed Aug 29 21:20:10 2018 +0200

    clk: s2mps11: Fix matching when built as module and DT node contains compatible
    
    commit 8985167ecf57f97061599a155bb9652c84ea4913 upstream.
    
    When driver is built as module and DT node contains clocks compatible
    (e.g. "samsung,s2mps11-clk"), the module will not be autoloaded because
    module aliases won't match.
    
    The modalias from uevent: of:NclocksT<NULL>Csamsung,s2mps11-clk
    The modalias from driver: platform:s2mps11-clk
    
    The devices are instantiated by parent's MFD.  However both Device Tree
    bindings and parent define the compatible for clocks devices.  In case
    of module matching this DT compatible will be used.
    
    The issue will not happen if this is a built-in (no need for module
    matching) or when clocks DT node does not contain compatible (not
    correct from bindings perspective but working for driver).
    
    Note when backporting to stable kernels: adjust the list of device ID
    entries.
    
    Cc: <stable@vger.kernel.org>
    Fixes: 53c31b3437a6 ("mfd: sec-core: Add of_compatible strings for clock MFD cells")
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Acked-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5d33c77ba0fa216009728da96d33e0199b58e9ad
Author: Richard Weinberger <richard@nod.at>
Date:   Fri Jun 15 16:42:54 2018 +0200

    um: Drop own definition of PTRACE_SYSEMU/_SINGLESTEP
    
    commit 0676b957c24bfb6e495449ba7b7e72c5b5d79233 upstream.
    
    32bit UML used to define PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP
    own its own because many years ago not all libcs had these request codes
    in their UAPI.
    These days PTRACE_SYSEMU/_SINGLESTEP is well known and part of glibc
    and our own define becomes problematic.
    
    With change c48831d0eebf ("linux/x86: sync sys/ptrace.h with Linux 4.14
    [BZ #22433]") glibc turned PTRACE_SYSEMU/_SINGLESTEP into a enum and
    UML failed to build.
    
    Let's drop our define and rely on the fact that every libc has
    PTRACE_SYSEMU/_SINGLESTEP.
    
    Cc: <stable@vger.kernel.org>
    Cc: Ritesh Raj Sarraf <rrs@researchut.com>
    Reported-and-tested-by: Ritesh Raj Sarraf <rrs@researchut.com>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fa68fdf0a20137a416f5a5cce72aed098faa6858
Author: Max Filippov <jcmvbkbc@gmail.com>
Date:   Tue Nov 13 23:46:42 2018 -0800

    xtensa: fix boot parameters address translation
    
    commit 40dc948f234b73497c3278875eb08a01d5854d3f upstream.
    
    The bootloader may pass physical address of the boot parameters structure
    to the MMUv3 kernel in the register a2. Code in the _SetupMMU block in
    the arch/xtensa/kernel/head.S is supposed to map that physical address to
    the virtual address in the configured virtual memory layout.
    
    This code haven't been updated when additional 256+256 and 512+512
    memory layouts were introduced and it may produce wrong addresses when
    used with these layouts.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f221f7b447f34778647bef9db70eed71648d4f28
Author: Max Filippov <jcmvbkbc@gmail.com>
Date:   Sun Nov 4 01:46:00 2018 -0700

    xtensa: make sure bFLT stack is 16 byte aligned
    
    commit 0773495b1f5f1c5e23551843f87b5ff37e7af8f7 upstream.
    
    Xtensa ABI requires stack alignment to be at least 16. In noMMU
    configuration ARCH_SLAB_MINALIGN is used to align stack. Make it at
    least 16.
    
    This fixes the following runtime error in noMMU configuration, caused by
    interaction between insufficiently aligned stack and alloca function,
    that results in corruption of on-stack variable in the libc function
    glob:
    
     Caught unhandled exception in 'sh' (pid = 47, pc = 0x02d05d65)
      - should not happen
      EXCCAUSE is 15
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1592c520d42724546c376d9e1e7aacd2f5de9c64
Author: Max Filippov <jcmvbkbc@gmail.com>
Date:   Mon Oct 29 18:30:13 2018 -0700

    xtensa: add NOTES section to the linker script
    
    commit 4119ba211bc4f1bf638f41e50b7a0f329f58aa16 upstream.
    
    This section collects all source .note.* sections together in the
    vmlinux image. Without it .note.Linux section may be placed at address
    0, while the rest of the kernel is at its normal address, resulting in a
    huge vmlinux.bin image that may not be linked into the xtensa Image.elf.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 14563f42672632609f637c88cfe7411d6a06ee64
Author: Huacai Chen <chenhc@lemote.com>
Date:   Wed Sep 5 17:33:09 2018 +0800

    MIPS: Loongson-3: Fix BRIDGE irq delivery problem
    
    [ Upstream commit 360fe725f8849aaddc53475fef5d4a0c439b05ae ]
    
    After commit e509bd7da149dc349160 ("genirq: Allow migration of chained
    interrupts by installing default action") Loongson-3 fails at here:
    
    setup_irq(LOONGSON_HT1_IRQ, &cascade_irqaction);
    
    This is because both chained_action and cascade_irqaction don't have
    IRQF_SHARED flag. This will cause Loongson-3 resume fails because HPET
    timer interrupt can't be delivered during S3. So we set the irqchip of
    the chained irq to loongson_irq_chip which doesn't disable the chained
    irq in CP0.Status.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Huacai Chen <chenhc@lemote.com>
    Signed-off-by: Paul Burton <paul.burton@mips.com>
    Patchwork: https://patchwork.linux-mips.org/patch/20434/
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: James Hogan <jhogan@kernel.org>
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang <zhangfx@lemote.com>
    Cc: Zhangjin Wu <wuzhangjin@gmail.com>
    Cc: Huacai Chen <chenhuacai@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 639fa868ceeb70c59bec3bc54c828cc5566cca23
Author: Huacai Chen <chenhc@lemote.com>
Date:   Wed Sep 5 17:33:08 2018 +0800

    MIPS: Loongson-3: Fix CPU UART irq delivery problem
    
    [ Upstream commit d06f8a2f1befb5a3d0aa660ab1c05e9b744456ea ]
    
    Masking/unmasking the CPU UART irq in CP0_Status (and redirecting it to
    other CPUs) may cause interrupts be lost, especially in multi-package
    machines (Package-0's UART irq cannot be delivered to others). So make
    mask_loongson_irq() and unmask_loongson_irq() be no-ops.
    
    The original problem (UART IRQ may deliver to any core) is also because
    of masking/unmasking the CPU UART irq in CP0_Status. So it is safe to
    remove all of the stuff.
    
    Signed-off-by: Huacai Chen <chenhc@lemote.com>
    Signed-off-by: Paul Burton <paul.burton@mips.com>
    Patchwork: https://patchwork.linux-mips.org/patch/20433/
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: James Hogan <jhogan@kernel.org>
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang <zhangfx@lemote.com>
    Cc: Zhangjin Wu <wuzhangjin@gmail.com>
    Cc: Huacai Chen <chenhuacai@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3c5cf7980bed91cc0f776eb9902b8b6adbe72edc
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Thu Oct 18 09:45:49 2018 +0300

    ovl: fix recursive oi->lock in ovl_link()
    
    commit 6cd078702f2f33cb6b19a682de3e9184112f1a46 upstream.
    
    linking a non-copied-up file into a non-copied-up parent results in a
    nested call to mutex_lock_interruptible(&oi->lock). Fix this by copying up
    target parent before ovl_nlink_start(), same as done in ovl_rename().
    
    ~/unionmount-testsuite$ ./run --ov -s
    ~/unionmount-testsuite$ ln /mnt/a/foo100 /mnt/a/dir100/
    
     WARNING: possible recursive locking detected
     --------------------------------------------
     ln/1545 is trying to acquire lock:
     00000000bcce7c4c (&ovl_i_lock_key[depth]){+.+.}, at:
         ovl_copy_up_start+0x28/0x7d
     but task is already holding lock:
     0000000026d73d5b (&ovl_i_lock_key[depth]){+.+.}, at:
         ovl_nlink_start+0x3c/0xc1
    
    [SzM: this seems to be a false positive, but doing the copy-up first is
    harmless and removes the lockdep splat]
    
    Reported-by: syzbot+3ef5c0d1a5cb0b21e6be@syzkaller.appspotmail.com
    Fixes: 5f8415d6b87e ("ovl: persistent overlay inode nlink for...")
    Cc: <stable@vger.kernel.org> # v4.13
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    [amir: backport to v4.18]
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 78da72ee42d82cfd001e863510eeb270bdd08143
Author: Miklos Szeredi <mszeredi@redhat.com>
Date:   Fri Sep 28 16:43:22 2018 +0200

    fuse: set FR_SENT while locked
    
    commit 4c316f2f3ff315cb48efb7435621e5bfb81df96d upstream.
    
    Otherwise fuse_dev_do_write() could come in and finish off the request, and
    the set_bit(FR_SENT, ...) could trigger the WARN_ON(test_bit(FR_SENT, ...))
    in request_end().
    
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Reported-by: syzbot+ef054c4d3f64cd7f7cec@syzkaller.appspotmai
    Fixes: 46c34a348b0a ("fuse: no fc->lock for pqueue parts")
    Cc: <stable@vger.kernel.org> # v4.2
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f6f21a2b70c6023c0b6ba103da62e214e02179bd
Author: Miklos Szeredi <mszeredi@redhat.com>
Date:   Fri Sep 28 16:43:22 2018 +0200

    fuse: fix blocked_waitq wakeup
    
    commit 908a572b80f6e9577b45e81b3dfe2e22111286b8 upstream.
    
    Using waitqueue_active() is racy.  Make sure we issue a wake_up()
    unconditionally after storing into fc->blocked.  After that it's okay to
    optimize with waitqueue_active() since the first wake up provides the
    necessary barrier for all waiters, not the just the woken one.
    
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Fixes: 3c18ef8117f0 ("fuse: optimize wake_up")
    Cc: <stable@vger.kernel.org> # v3.10
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ab962e91008a93af5da403c652745883d19a6adf
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Sep 25 12:52:42 2018 +0300

    fuse: Fix use-after-free in fuse_dev_do_write()
    
    commit d2d2d4fb1f54eff0f3faa9762d84f6446a4bc5d0 upstream.
    
    After we found req in request_find() and released the lock,
    everything may happen with the req in parallel:
    
    cpu0                              cpu1
    fuse_dev_do_write()               fuse_dev_do_write()
      req = request_find(fpq, ...)    ...
      spin_unlock(&fpq->lock)         ...
      ...                             req = request_find(fpq, oh.unique)
      ...                             spin_unlock(&fpq->lock)
      queue_interrupt(&fc->iq, req);   ...
      ...                              ...
      ...                              ...
      request_end(fc, req);
        fuse_put_request(fc, req);
      ...                              queue_interrupt(&fc->iq, req);
    
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Fixes: 46c34a348b0a ("fuse: no fc->lock for pqueue parts")
    Cc: <stable@vger.kernel.org> # v4.2
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d94b3a2375cbbd55e6961c7b0dd1f8a75ebc8e10
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Sep 25 12:28:55 2018 +0300

    fuse: Fix use-after-free in fuse_dev_do_read()
    
    commit bc78abbd55dd28e2287ec6d6502b842321a17c87 upstream.
    
    We may pick freed req in this way:
    
    [cpu0]                                  [cpu1]
    fuse_dev_do_read()                      fuse_dev_do_write()
       list_move_tail(&req->list, ...);     ...
       spin_unlock(&fpq->lock);             ...
       ...                                  request_end(fc, req);
       ...                                    fuse_put_request(fc, req);
       if (test_bit(FR_INTERRUPTED, ...))
             queue_interrupt(fiq, req);
    
    Fix that by keeping req alive until we finish all manipulations.
    
    Reported-by: syzbot+4e975615ca01f2277bdd@syzkaller.appspotmail.com
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Fixes: 46c34a348b0a ("fuse: no fc->lock for pqueue parts")
    Cc: <stable@vger.kernel.org> # v4.2
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0a7a9ed0ce1d1e669b50d5763168d4cdddba58b2
Author: Quinn Tran <quinn.tran@cavium.com>
Date:   Wed Sep 26 22:05:14 2018 -0700

    scsi: qla2xxx: Fix re-using LoopID when handle is in use
    
    commit 5c6400536481d9ef44ef94e7bf2c7b8e81534db7 upstream.
    
    This patch fixes issue where driver clears NPort ID map instead of marking
    handle in use. Once driver clears NPort ID from the database, it can reuse
    the same NPort ID resulting in a PLOGI failure.
    
    [mkp: fixed Himanshu's SoB]
    
    Fixes: a084fd68e1d2 ("scsi: qla2xxx: Fix re-login for Nport Handle in use")
    Cc: <stable@vger.kernel.org>
    Signed-of-by: Quinn Tran <quinn.tran@cavium.com>
    Reviewed-by: Ewan D. Milne <emilne@redhat.com>
    Signed-off-by: Himanshu Madhani <hmadhani@cavium.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 21339e8cf0024bf6068a118d985f28417afc1d66
Author: Quinn Tran <quinn.tran@cavium.com>
Date:   Tue Sep 11 10:18:21 2018 -0700

    scsi: qla2xxx: shutdown chip if reset fail
    
    commit 1e4ac5d6fe0a4af17e4b6251b884485832bf75a3 upstream.
    
    If chip unable to fully initialize, use full shutdown sequence to clear out
    any stale FW state.
    
    Fixes: e315cd28b9ef ("[SCSI] qla2xxx: Code changes for qla data structure refactoring")
    Cc: stable@vger.kernel.org  #4.10
    Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
    Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4b6f0ec528d6c56e7394dde2bb72ba2af35305ac
Author: Quinn Tran <quinn.tran@cavium.com>
Date:   Tue Sep 11 10:18:24 2018 -0700

    scsi: qla2xxx: Remove stale debug trace message from tcm_qla2xxx
    
    commit 7c388f91ec1a59b0ed815b07b90536e2d57e1e1f upstream.
    
    Remove stale debug trace.
    
    Fixes: 1eb42f965ced ("qla2xxx: Make trace flags more readable")
    Cc: stable@vger.kernel.org #4.10
    Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
    Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 89fdc7f8646eba683709c3ecd1b7fa2d60e3f06a
Author: Quinn Tran <quinn.tran@cavium.com>
Date:   Fri Aug 31 11:24:26 2018 -0700

    scsi: qla2xxx: Fix process response queue for ISP26XX and above
    
    commit b86ac8fd4b2f6ec2f9ca9194c56eac12d620096f upstream.
    
    This patch improves performance for 16G and above adapter by removing
    additional call to process_response_queue().
    
    [mkp: typo]
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
    Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c60d5af75baaa459aa3619a0487637315de4f83c
Author: Himanshu Madhani <himanshu.madhani@cavium.com>
Date:   Fri Aug 31 11:24:27 2018 -0700

    scsi: qla2xxx: Fix incorrect port speed being set for FC adapters
    
    commit 4c1458df9635c7e3ced155f594d2e7dfd7254e21 upstream.
    
    Fixes: 6246b8a1d26c7c ("[SCSI] qla2xxx: Enhancements to support ISP83xx.")
    Fixes: 1bb395485160d2 ("qla2xxx: Correct iiDMA-update calling conventions.")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0afa17be1a78bf35085bffb7d0e04b96b766f3ba
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Wed Oct 10 19:10:06 2018 +0300

    ovl: fix error handling in ovl_verify_set_fh()
    
    commit babf4770be0adc69e6d2de150f4040f175e24beb upstream.
    
    We hit a BUG on kfree of an ERR_PTR()...
    
    Reported-by: syzbot+ff03fe05c717b82502d0@syzkaller.appspotmail.com
    Fixes: 8b88a2e64036 ("ovl: verify upper root dir matches lower root dir")
    Cc: <stable@vger.kernel.org> # v4.13
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a8c254d8e96032d5bb235cb2e777203d9acda09d
Author: Young_X <YangX92@hotmail.com>
Date:   Wed Oct 3 12:54:29 2018 +0000

    cdrom: fix improper type cast, which can leat to information leak.
    
    commit e4f3aa2e1e67bb48dfbaaf1cad59013d5a5bc276 upstream.
    
    There is another cast from unsigned long to int which causes
    a bounds check to fail with specially crafted input. The value is
    then used as an index in the slot array in cdrom_slot_status().
    
    This issue is similar to CVE-2018-16658 and CVE-2018-10940.
    
    Signed-off-by: Young_X <YangX92@hotmail.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 18280c1260154343e01accb1d52a0dd321cfc828
Author: Dominique Martinet <dominique.martinet@cea.fr>
Date:   Tue Aug 28 07:32:35 2018 +0900

    9p: clear dangling pointers in p9stat_free
    
    [ Upstream commit 62e3941776fea8678bb8120607039410b1b61a65 ]
    
    p9stat_free is more of a cleanup function than a 'free' function as it
    only frees the content of the struct; there are chances of use-after-free
    if it is improperly used (e.g. p9stat_free called twice as it used to be
    possible to)
    
    Clearing dangling pointers makes the function idempotent and safer to use.
    
    Link: http://lkml.kernel.org/r/1535410108-20650-2-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
    Reported-by: syzbot+d4252148d198410b864f@syzkaller.appspotmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 491fc097e3d49f777d2e45ec3ae6341cff986f44
Author: Dominique Martinet <dominique.martinet@cea.fr>
Date:   Sat Sep 8 01:18:43 2018 +0900

    9p locks: fix glock.client_id leak in do_lock
    
    [ Upstream commit b4dc44b3cac9e8327e0655f530ed0c46f2e6214c ]
    
    the 9p client code overwrites our glock.client_id pointing to a static
    buffer by an allocated string holding the network provided value which
    we do not care about; free and reset the value as appropriate.
    
    This is almost identical to the leak in v9fs_file_getlock() fixed by
    Al Viro in commit ce85dd58ad5a6 ("9p: we are leaking glock.client_id
    in v9fs_file_getlock()"), which was returned as an error by a coverity
    false positive -- while we are here attempt to make the code slightly
    more robust to future change of the net/9p/client code and hopefully
    more clear to coverity that there is no problem.
    
    Link: http://lkml.kernel.org/r/1536339057-21974-5-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 442b54290c782f22a848941064625cad3e263f39
Author: Alexandru Ardelean <alexandru.ardelean@analog.com>
Date:   Thu Sep 13 11:44:09 2018 +0300

    staging:iio:ad7606: fix voltage scales
    
    [ Upstream commit 4ee033301c898dd0835d035d0e0eb768a3d35da1 ]
    
    Fixes commit 17be2a2905a6ec9aa27cd59521495e2f490d2af0 ("staging: iio:
    ad7606: replace range/range_available with corresponding scale").
    
    The AD7606 devices don't have a 2.5V voltage range, they have 5V & 10V
    voltage range, which is selectable via the `gpio_range` descriptor.
    
    The scales also seem to have been miscomputed, because when they were
    applied to the raw values, the results differ from the expected values.
    After checking the ADC transfer function in the datasheet, these were
    re-computed.
    
    Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d3835bb8fa6758b4f38da3741e206192a6340f90
Author: Breno Leitao <leitao@debian.org>
Date:   Tue Jul 31 17:55:57 2018 -0300

    powerpc/selftests: Wait all threads to join
    
    [ Upstream commit 693b31b2fc1636f0aa7af53136d3b49f6ad9ff39 ]
    
    Test tm-tmspr might exit before all threads stop executing, because it just
    waits for the very last thread to join before proceeding/exiting.
    
    This patch makes sure that all threads that were created will join before
    proceeding/exiting.
    
    This patch also guarantees that the amount of threads being created is equal
    to thread_num.
    
    Signed-off-by: Breno Leitao <leitao@debian.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3e59ed2e314373c6c91599b027e95b607f5cb584
Author: Marco Felsch <m.felsch@pengutronix.de>
Date:   Thu Jun 28 12:20:33 2018 -0400

    media: tvp5150: fix width alignment during set_selection()
    
    [ Upstream commit bd24db04101f45a9c1d874fe21b0c7eab7bcadec ]
    
    The driver ignored the width alignment which exists due to the UYVY
    colorspace format. Fix the width alignment and make use of the the
    provided v4l2 helper function to set the width, height and all
    alignments in one.
    
    Fixes: 963ddc63e20d ("[media] media: tvp5150: Add cropping support")
    
    Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4d0df50d740ecfd8ca7831c739e5c98c7466a94a
Author: Phil Elwell <phil@raspberrypi.org>
Date:   Wed Sep 12 15:31:55 2018 +0100

    sc16is7xx: Fix for multi-channel stall
    
    [ Upstream commit 8344498721059754e09d30fe255a12dab8fb03ef ]
    
    The SC16IS752 is a dual-channel device. The two channels are largely
    independent, but the IRQ signals are wired together as an open-drain,
    active low signal which will be driven low while either of the
    channels requires attention, which can be for significant periods of
    time until operations complete and the interrupt can be acknowledged.
    In that respect it is should be treated as a true level-sensitive IRQ.
    
    The kernel, however, needs to be able to exit interrupt context in
    order to use I2C or SPI to access the device registers (which may
    involve sleeping).  Therefore the interrupt needs to be masked out or
    paused in some way.
    
    The usual way to manage sleeping from within an interrupt handler
    is to use a threaded interrupt handler - a regular interrupt routine
    does the minimum amount of work needed to triage the interrupt before
    waking the interrupt service thread. If the threaded IRQ is marked as
    IRQF_ONESHOT the kernel will automatically mask out the interrupt
    until the thread runs to completion. The sc16is7xx driver used to
    use a threaded IRQ, but a patch switched to using a kthread_worker
    in order to set realtime priorities on the handler thread and for
    other optimisations. The end result is non-threaded IRQ that
    schedules some work then returns IRQ_HANDLED, making the kernel
    think that all IRQ processing has completed.
    
    The work-around to prevent a constant stream of interrupts is to
    mark the interrupt as edge-sensitive rather than level-sensitive,
    but interpreting an active-low source as a falling-edge source
    requires care to prevent a total cessation of interrupts. Whereas
    an edge-triggering source will generate a new edge for every interrupt
    condition a level-triggering source will keep the signal at the
    interrupting level until it no longer requires attention; in other
    words, the host won't see another edge until all interrupt conditions
    are cleared. It is therefore vital that the interrupt handler does not
    exit with an outstanding interrupt condition, otherwise the kernel
    will not receive another interrupt unless some other operation causes
    the interrupt state on the device to be cleared.
    
    The existing sc16is7xx driver has a very simple interrupt "thread"
    (kthread_work job) that processes interrupts on each channel in turn
    until there are no more. If both channels are active and the first
    channel starts interrupting while the handler for the second channel
    is running then it will not be detected and an IRQ stall ensues. This
    could be handled easily if there was a shared IRQ status register, or
    a convenient way to determine if the IRQ had been deasserted for any
    length of time, but both appear to be lacking.
    
    Avoid this problem (or at least make it much less likely to happen)
    by reducing the granularity of per-channel interrupt processing
    to one condition per iteration, only exiting the overall loop when
    both channels are no longer interrupting.
    
    Signed-off-by: Phil Elwell <phil@raspberrypi.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f9cb913a7959321bf491b824e5f207a2520cd412
Author: Huacai Chen <chenhc@lemote.com>
Date:   Sat Sep 15 14:01:12 2018 +0800

    MIPS/PCI: Call pcie_bus_configure_settings() to set MPS/MRRS
    
    [ Upstream commit 2794f688b2c336e0da85e9f91fed33febbd9f54a ]
    
    Call pcie_bus_configure_settings() on MIPS, like for other platforms.
    The function pcie_bus_configure_settings() makes sure the MPS (Max
    Payload Size) across the bus is uniform and provides the ability to
    tune the MRSS (Max Read Request Size) and MPS (Max Payload Size) to
    higher performance values. Some devices will not operate properly if
    these aren't set correctly because the firmware doesn't always do it.
    
    Signed-off-by: Huacai Chen <chenhc@lemote.com>
    Signed-off-by: Paul Burton <paul.burton@mips.com>
    Patchwork: https://patchwork.linux-mips.org/patch/20649/
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: James Hogan <jhogan@kernel.org>
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang <zhangfx@lemote.com>
    Cc: Zhangjin Wu <wuzhangjin@gmail.com>
    Cc: Huacai Chen <chenhuacai@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 983721397fe0a6b2a5937da74b43d4bc0bbb13fe
Author: Rashmica Gupta <rashmica.g@gmail.com>
Date:   Fri Aug 17 14:25:01 2018 +1000

    powerpc/memtrace: Remove memory in chunks
    
    [ Upstream commit 3f7daf3d7582dc6628ac40a9045dd1bbd80c5f35 ]
    
    When hot-removing memory release_mem_region_adjustable() splits iomem
    resources if they are not the exact size of the memory being
    hot-deleted. Adding this memory back to the kernel adds a new resource.
    
    Eg a node has memory 0x0 - 0xfffffffff. Hot-removing 1GB from
    0xf40000000 results in the single resource 0x0-0xfffffffff being split
    into two resources: 0x0-0xf3fffffff and 0xf80000000-0xfffffffff.
    
    When we hot-add the memory back we now have three resources:
    0x0-0xf3fffffff, 0xf40000000-0xf7fffffff, and 0xf80000000-0xfffffffff.
    
    This is an issue if we try to remove some memory that overlaps
    resources. Eg when trying to remove 2GB at address 0xf40000000,
    release_mem_region_adjustable() fails as it expects the chunk of memory
    to be within the boundaries of a single resource. We then get the
    warning: "Unable to release resource" and attempting to use memtrace
    again gives us this error: "bash: echo: write error: Resource
    temporarily unavailable"
    
    This patch makes memtrace remove memory in chunks that are always the
    same size from an address that is always equal to end_of_memory -
    n*size, for some n. So hotremoving and hotadding memory of different
    sizes will now not attempt to remove memory that spans multiple
    resources.
    
    Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f386e1e50e35ea51c6bd977eb4808c2f429a54df
Author: Joel Stanley <joel@jms.id.au>
Date:   Fri Sep 14 13:36:47 2018 +0930

    powerpc/boot: Ensure _zimage_start is a weak symbol
    
    [ Upstream commit ee9d21b3b3583712029a0db65a4b7c081d08d3b3 ]
    
    When building with clang crt0's _zimage_start is not marked weak, which
    breaks the build when linking the kernel image:
    
     $ objdump -t arch/powerpc/boot/crt0.o |grep _zimage_start$
     0000000000000058 g       .text  0000000000000000 _zimage_start
    
     ld: arch/powerpc/boot/wrapper.a(crt0.o): in function '_zimage_start':
     (.text+0x58): multiple definition of '_zimage_start';
     arch/powerpc/boot/pseries-head.o:(.text+0x0): first defined here
    
    Clang requires the .weak directive to appear after the symbol is
    declared. The binutils manual says:
    
     This directive sets the weak attribute on the comma separated list of
     symbol names. If the symbols do not already exist, they will be
     created.
    
    So it appears this is different with clang. The only reference I could
    see for this was an OpenBSD mailing list post[1].
    
    Changing it to be after the declaration fixes building with Clang, and
    still works with GCC.
    
     $ objdump -t arch/powerpc/boot/crt0.o |grep _zimage_start$
     0000000000000058  w      .text 0000000000000000 _zimage_start
    
    Reported to clang as https://bugs.llvm.org/show_bug.cgi?id=38921
    
    [1] https://groups.google.com/forum/#!topic/fa.openbsd.tech/PAgKKen2YCY
    
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 806be82cd255646c8fa872529447be1289c12c6c
Author: Dengcheng Zhu <dzhu@wavecomp.com>
Date:   Tue Sep 11 14:49:20 2018 -0700

    MIPS: kexec: Mark CPU offline before disabling local IRQ
    
    [ Upstream commit dc57aaf95a516f70e2d527d8287a0332c481a226 ]
    
    After changing CPU online status, it will not be sent any IPIs such as in
    __flush_cache_all() on software coherency systems. Do this before disabling
    local IRQ.
    
    Signed-off-by: Dengcheng Zhu <dzhu@wavecomp.com>
    Signed-off-by: Paul Burton <paul.burton@mips.com>
    Patchwork: https://patchwork.linux-mips.org/patch/20571/
    Cc: pburton@wavecomp.com
    Cc: ralf@linux-mips.org
    Cc: linux-mips@linux-mips.org
    Cc: rachel.mozes@intel.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e56c482e4e7f4d39a851ebceb7652be59d248208
Author: Lucas Stach <l.stach@pengutronix.de>
Date:   Wed Aug 1 10:18:04 2018 -0400

    media: coda: don't overwrite h.264 profile_idc on decoder instance
    
    [ Upstream commit 1f32061e843205f6fe8404d5100d5adcec334e75 ]
    
    On a decoder instance, after the profile has been parsed from the stream
    __v4l2_ctrl_s_ctrl() is called to notify userspace about changes in the
    read-only profile control. This ends up calling back into the CODA driver
    where a missing check on the s_ctrl caused the profile information that has
    just been parsed from the stream to be overwritten with the default
    baseline profile.
    
    Later on the driver fails to enable frame reordering, based on the wrong
    profile information.
    
    Fixes: 347de126d1da (media: coda: add read-only h.264 decoder
                         profile/level controls)
    
    Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
    Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
    Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 27f612940d5cf7b5d4bae316c4dd6dfead6a6ec6
Author: Nicholas Mc Guire <hofrat@osadl.org>
Date:   Sun Sep 9 12:02:32 2018 -0400

    media: pci: cx23885: handle adding to list failure
    
    [ Upstream commit c5d59528e24ad22500347b199d52b9368e686a42 ]
    
    altera_hw_filt_init() which calls append_internal() assumes
    that the node was successfully linked in while in fact it can
    silently fail. So the call-site needs to set return to -ENOMEM
    on append_internal() returning NULL and exit through the err path.
    
    Fixes: 349bcf02e361 ("[media] Altera FPGA based CI driver module")
    
    Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
    Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 18490ea7607c1c136b385075219e65760a656f05
Author: John Garry <john.garry@huawei.com>
Date:   Sat Sep 22 01:25:25 2018 +0800

    drm/hisilicon: hibmc: Do not carry error code in HiBMC framebuffer pointer
    
    [ Upstream commit 331d880b35a76b5de0eec8cbcecbf615d758a5f9 ]
    
    In hibmc_drm_fb_create(), when the call to hibmc_framebuffer_init() fails
    with error, do not store the error code in the HiBMC device frame-buffer
    pointer, as this will be later checked for non-zero value in
    hibmc_fbdev_destroy() when our intention is to check for a valid function
    pointer.
    
    This fixes the following crash:
    [    9.699791] Unable to handle kernel NULL pointer dereference at virtual address 000000000000001a
    [    9.708672] Mem abort info:
    [    9.711489]   ESR = 0x96000004
    [    9.714570]   Exception class = DABT (current EL), IL = 32 bits
    [    9.720551]   SET = 0, FnV = 0
    [    9.723631]   EA = 0, S1PTW = 0
    [    9.726799] Data abort info:
    [    9.729702]   ISV = 0, ISS = 0x00000004
    [    9.733573]   CM = 0, WnR = 0
    [    9.736566] [000000000000001a] user address but active_mm is swapper
    [    9.742987] Internal error: Oops: 96000004 [#1] PREEMPT SMP
    [    9.748614] Modules linked in:
    [    9.751694] CPU: 16 PID: 293 Comm: kworker/16:1 Tainted: G        W         4.19.0-rc4-next-20180920-00001-g9b0012c #322
    [    9.762681] Hardware name: Huawei Taishan 2280 /D05, BIOS Hisilicon D05 IT21 Nemo 2.0 RC0 04/18/2018
    [    9.771915] Workqueue: events work_for_cpu_fn
    [    9.776312] pstate: 60000005 (nZCv daif -PAN -UAO)
    [    9.781150] pc : drm_mode_object_put+0x0/0x20
    [    9.785547] lr : hibmc_fbdev_fini+0x40/0x58
    [    9.789767] sp : ffff00000af1bcf0
    [    9.793108] x29: ffff00000af1bcf0 x28: 0000000000000000
    [    9.798473] x27: 0000000000000000 x26: ffff000008f66630
    [    9.803838] x25: 0000000000000000 x24: ffff0000095abb98
    [    9.809203] x23: ffff8017db92fe00 x22: ffff8017d2b13000
    [    9.814568] x21: ffffffffffffffea x20: ffff8017d2f80018
    [    9.819933] x19: ffff8017d28a0018 x18: ffffffffffffffff
    [    9.825297] x17: 0000000000000000 x16: 0000000000000000
    [    9.830662] x15: ffff0000092296c8 x14: ffff00008939970f
    [    9.836026] x13: ffff00000939971d x12: ffff000009229940
    [    9.841391] x11: ffff0000085f8fc0 x10: ffff00000af1b9a0
    [    9.846756] x9 : 000000000000000d x8 : 6620657a696c6169
    [    9.852121] x7 : ffff8017d3340580 x6 : ffff8017d4168000
    [    9.857486] x5 : 0000000000000000 x4 : ffff8017db92fb20
    [    9.862850] x3 : 0000000000002690 x2 : ffff8017d3340480
    [    9.868214] x1 : 0000000000000028 x0 : 0000000000000002
    [    9.873580] Process kworker/16:1 (pid: 293, stack limit = 0x(____ptrval____))
    [    9.880788] Call trace:
    [    9.883252]  drm_mode_object_put+0x0/0x20
    [    9.887297]  hibmc_unload+0x1c/0x80
    [    9.890815]  hibmc_pci_probe+0x170/0x3c8
    [    9.894773]  local_pci_probe+0x3c/0xb0
    [    9.898555]  work_for_cpu_fn+0x18/0x28
    [    9.902337]  process_one_work+0x1e0/0x318
    [    9.906382]  worker_thread+0x228/0x450
    [    9.910164]  kthread+0x128/0x130
    [    9.913418]  ret_from_fork+0x10/0x18
    [    9.917024] Code: a94153f3 a8c27bfd d65f03c0 d503201f (f9400c01)
    [    9.923180] ---[ end trace 2695ffa0af5be375 ]---
    
    Fixes: d1667b86795a ("drm/hisilicon/hibmc: Add support for frame buffer")
    Signed-off-by: John Garry <john.garry@huawei.com>
    Reviewed-by: Xinliang Liu <z.liuxinliang@hisilicon.com>
    Signed-off-by: Xinliang Liu <z.liuxinliang@hisilicon.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 547d528ea395d104dcb31a18b2d51a285e0973aa
Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
Date:   Wed Sep 26 12:11:27 2018 +0300

    drm/omap: fix memory barrier bug in DMM driver
    
    [ Upstream commit 538f66ba204944470a653a4cccc5f8befdf97c22 ]
    
    A DMM timeout "timed out waiting for done" has been observed on DRA7
    devices. The timeout happens rarely, and only when the system is under
    heavy load.
    
    Debugging showed that the timeout can be made to happen much more
    frequently by optimizing the DMM driver, so that there's almost no code
    between writing the last DMM descriptors to RAM, and writing to DMM
    register which starts the DMM transaction.
    
    The current theory is that a wmb() does not properly ensure that the
    data written to RAM is observable by all the components in the system.
    
    This DMM timeout has caused interesting (and rare) bugs as the error
    handling was not functioning properly (the error handling has been fixed
    in previous commits):
    
     * If a DMM timeout happened when a GEM buffer was being pinned for
       display on the screen, a timeout error would be shown, but the driver
       would continue programming DSS HW with broken buffer, leading to
       SYNCLOST floods and possible crashes.
    
     * If a DMM timeout happened when other user (say, video decoder) was
       pinning a GEM buffer, a timeout would be shown but if the user
       handled the error properly, no other issues followed.
    
     * If a DMM timeout happened when a GEM buffer was being released, the
       driver does not even notice the error, leading to crashes or hang
       later.
    
    This patch adds wmb() and readl() calls after the last bit is written to
    RAM, which should ensure that the execution proceeds only after the data
    is actually in RAM, and thus observable by DMM.
    
    The read-back should not be needed. Further study is required to understand
    if DMM is somehow special case and read-back is ok, or if DRA7's memory
    barriers do not work correctly.
    
    Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
    Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4cb592436db9ff3ff394e6d8d951545a15fc66e8
Author: Christophe Leroy <christophe.leroy@c-s.fr>
Date:   Mon Aug 13 13:19:52 2018 +0000

    powerpc/mm: Don't report hugepage tables as memory leaks when using kmemleak
    
    [ Upstream commit 803d690e68f0c5230183f1a42c7d50a41d16e380 ]
    
    When a process allocates a hugepage, the following leak is
    reported by kmemleak. This is a false positive which is
    due to the pointer to the table being stored in the PGD
    as physical memory address and not virtual memory pointer.
    
    unreferenced object 0xc30f8200 (size 512):
      comm "mmap", pid 374, jiffies 4872494 (age 627.630s)
      hex dump (first 32 bytes):
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      backtrace:
        [<e32b68da>] huge_pte_alloc+0xdc/0x1f8
        [<9e0df1e1>] hugetlb_fault+0x560/0x8f8
        [<7938ec6c>] follow_hugetlb_page+0x14c/0x44c
        [<afbdb405>] __get_user_pages+0x1c4/0x3dc
        [<b8fd7cd9>] __mm_populate+0xac/0x140
        [<3215421e>] vm_mmap_pgoff+0xb4/0xb8
        [<c148db69>] ksys_mmap_pgoff+0xcc/0x1fc
        [<4fcd760f>] ret_from_syscall+0x0/0x38
    
    See commit a984506c542e2 ("powerpc/mm: Don't report PUDs as
    memory leaks when using kmemleak") for detailed explanation.
    
    To fix that, this patch tells kmemleak to ignore the allocated
    hugepage table.
    
    Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3374b0b15ec7c25aa98274aa95dbdea6d6d2af88
Author: Daniel Axtens <dja@axtens.net>
Date:   Mon Oct 1 16:21:51 2018 +1000

    powerpc/nohash: fix undefined behaviour when testing page size support
    
    [ Upstream commit f5e284803a7206d43e26f9ffcae5de9626d95e37 ]
    
    When enumerating page size definitions to check hardware support,
    we construct a constant which is (1U << (def->shift - 10)).
    
    However, the array of page size definitions is only initalised for
    various MMU_PAGE_* constants, so it contains a number of 0-initialised
    elements with def->shift == 0. This means we end up shifting by a
    very large number, which gives the following UBSan splat:
    
    ================================================================================
    UBSAN: Undefined behaviour in /home/dja/dev/linux/linux/arch/powerpc/mm/tlb_nohash.c:506:21
    shift exponent 4294967286 is too large for 32-bit type 'unsigned int'
    CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc3-00045-ga604f927b012-dirty #6
    Call Trace:
    [c00000000101bc20] [c000000000a13d54] .dump_stack+0xa8/0xec (unreliable)
    [c00000000101bcb0] [c0000000004f20a8] .ubsan_epilogue+0x18/0x64
    [c00000000101bd30] [c0000000004f2b10] .__ubsan_handle_shift_out_of_bounds+0x110/0x1a4
    [c00000000101be20] [c000000000d21760] .early_init_mmu+0x1b4/0x5a0
    [c00000000101bf10] [c000000000d1ba28] .early_setup+0x100/0x130
    [c00000000101bf90] [c000000000000528] start_here_multiplatform+0x68/0x80
    ================================================================================
    
    Fix this by first checking if the element exists (shift != 0) before
    constructing the constant.
    
    Signed-off-by: Daniel Axtens <dja@axtens.net>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6c2449a04c43faf8b6ca52cb11617c77fd3ee4dc
Author: Fabio Estevam <fabio.estevam@nxp.com>
Date:   Mon Sep 10 14:45:23 2018 -0300

    ARM: imx_v6_v7_defconfig: Select CONFIG_TMPFS_POSIX_ACL
    
    [ Upstream commit 35d3cbe84544da74e39e1cec01374092467e3119 ]
    
    Andreas Müller reports:
    
    "Fixes:
    
    | Sep 04 09:05:10 imx6qdl-variscite-som systemd-udevd[220]: Failed to apply ACL on /dev/v4l-subdev0: Operation not supported
    | Sep 04 09:05:10 imx6qdl-variscite-som systemd-udevd[224]: Failed to apply ACL on /dev/v4l-subdev1: Operation not supported
    | Sep 04 09:05:10 imx6qdl-variscite-som systemd-udevd[215]: Failed to apply ACL on /dev/v4l-subdev10: Operation not supported
    | Sep 04 09:05:10 imx6qdl-variscite-som systemd-udevd[228]: Failed to apply ACL on /dev/v4l-subdev2: Operation not supported
    | Sep 04 09:05:10 imx6qdl-variscite-som systemd-udevd[232]: Failed to apply ACL on /dev/v4l-subdev5: Operation not supported
    | Sep 04 09:05:10 imx6qdl-variscite-som systemd-udevd[217]: Failed to apply ACL on /dev/v4l-subdev11: Operation not supported
    | Sep 04 09:05:10 imx6qdl-variscite-som systemd-udevd[214]: Failed to apply ACL on /dev/dri/card1: Operation not supported
    | Sep 04 09:05:10 imx6qdl-variscite-som systemd-udevd[216]: Failed to apply ACL on /dev/v4l-subdev8: Operation not supported
    | Sep 04 09:05:10 imx6qdl-variscite-som systemd-udevd[226]: Failed to apply ACL on /dev/v4l-subdev9: Operation not supported
    
    and nasty follow-ups: Starting weston from sddm as unpriviledged user fails
    with some hints on missing access rights."
    
    Select the CONFIG_TMPFS_POSIX_ACL option to fix these issues.
    
    Reported-by: Andreas Müller <schnitzeltony@gmail.com>
    Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
    Acked-by: Otavio Salvador <otavio@ossystems.com.br>
    Signed-off-by: Shawn Guo <shawnguo@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8c5800cdb75c354ec0224f0fbab9e4c604b065c0
Author: Miles Chen <miles.chen@mediatek.com>
Date:   Mon Oct 8 10:39:17 2018 +0800

    tty: check name length in tty_find_polling_driver()
    
    [ Upstream commit 33a1a7be198657c8ca26ad406c4d2a89b7162bcc ]
    
    The issue is found by a fuzzing test.
    If tty_find_polling_driver() recevies an incorrect input such as
    ',,' or '0b', the len becomes 0 and strncmp() always return 0.
    In this case, a null p->ops->poll_init() is called and it causes a kernel
    panic.
    
    Fix this by checking name length against zero in tty_find_polling_driver().
    
    $echo ,, > /sys/module/kgdboc/parameters/kgdboc
    [   20.804451] WARNING: CPU: 1 PID: 104 at drivers/tty/serial/serial_core.c:457
    uart_get_baud_rate+0xe8/0x190
    [   20.804917] Modules linked in:
    [   20.805317] CPU: 1 PID: 104 Comm: sh Not tainted 4.19.0-rc7ajb #8
    [   20.805469] Hardware name: linux,dummy-virt (DT)
    [   20.805732] pstate: 20000005 (nzCv daif -PAN -UAO)
    [   20.805895] pc : uart_get_baud_rate+0xe8/0x190
    [   20.806042] lr : uart_get_baud_rate+0xc0/0x190
    [   20.806476] sp : ffffffc06acff940
    [   20.806676] x29: ffffffc06acff940 x28: 0000000000002580
    [   20.806977] x27: 0000000000009600 x26: 0000000000009600
    [   20.807231] x25: ffffffc06acffad0 x24: 00000000ffffeff0
    [   20.807576] x23: 0000000000000001 x22: 0000000000000000
    [   20.807807] x21: 0000000000000001 x20: 0000000000000000
    [   20.808049] x19: ffffffc06acffac8 x18: 0000000000000000
    [   20.808277] x17: 0000000000000000 x16: 0000000000000000
    [   20.808520] x15: ffffffffffffffff x14: ffffffff00000000
    [   20.808757] x13: ffffffffffffffff x12: 0000000000000001
    [   20.809011] x11: 0101010101010101 x10: ffffff880d59ff5f
    [   20.809292] x9 : ffffff880d59ff5e x8 : ffffffc06acffaf3
    [   20.809549] x7 : 0000000000000000 x6 : ffffff880d59ff5f
    [   20.809803] x5 : 0000000080008001 x4 : 0000000000000003
    [   20.810056] x3 : ffffff900853e6b4 x2 : dfffff9000000000
    [   20.810693] x1 : ffffffc06acffad0 x0 : 0000000000000cb0
    [   20.811005] Call trace:
    [   20.811214]  uart_get_baud_rate+0xe8/0x190
    [   20.811479]  serial8250_do_set_termios+0xe0/0x6f4
    [   20.811719]  serial8250_set_termios+0x48/0x54
    [   20.811928]  uart_set_options+0x138/0x1bc
    [   20.812129]  uart_poll_init+0x114/0x16c
    [   20.812330]  tty_find_polling_driver+0x158/0x200
    [   20.812545]  configure_kgdboc+0xbc/0x1bc
    [   20.812745]  param_set_kgdboc_var+0xb8/0x150
    [   20.812960]  param_attr_store+0xbc/0x150
    [   20.813160]  module_attr_store+0x40/0x58
    [   20.813364]  sysfs_kf_write+0x8c/0xa8
    [   20.813563]  kernfs_fop_write+0x154/0x290
    [   20.813764]  vfs_write+0xf0/0x278
    [   20.813951]  __arm64_sys_write+0x84/0xf4
    [   20.814400]  el0_svc_common+0xf4/0x1dc
    [   20.814616]  el0_svc_handler+0x98/0xbc
    [   20.814804]  el0_svc+0x8/0xc
    [   20.822005] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
    [   20.826913] Mem abort info:
    [   20.827103]   ESR = 0x84000006
    [   20.827352]   Exception class = IABT (current EL), IL = 16 bits
    [   20.827655]   SET = 0, FnV = 0
    [   20.827855]   EA = 0, S1PTW = 0
    [   20.828135] user pgtable: 4k pages, 39-bit VAs, pgdp = (____ptrval____)
    [   20.828484] [0000000000000000] pgd=00000000aadee003, pud=00000000aadee003, pmd=0000000000000000
    [   20.829195] Internal error: Oops: 84000006 [#1] SMP
    [   20.829564] Modules linked in:
    [   20.829890] CPU: 1 PID: 104 Comm: sh Tainted: G        W         4.19.0-rc7ajb #8
    [   20.830545] Hardware name: linux,dummy-virt (DT)
    [   20.830829] pstate: 60000085 (nZCv daIf -PAN -UAO)
    [   20.831174] pc :           (null)
    [   20.831457] lr : serial8250_do_set_termios+0x358/0x6f4
    [   20.831727] sp : ffffffc06acff9b0
    [   20.831936] x29: ffffffc06acff9b0 x28: ffffff9008d7c000
    [   20.832267] x27: ffffff900969e16f x26: 0000000000000000
    [   20.832589] x25: ffffff900969dfb0 x24: 0000000000000000
    [   20.832906] x23: ffffffc06acffad0 x22: ffffff900969e160
    [   20.833232] x21: 0000000000000000 x20: ffffffc06acffac8
    [   20.833559] x19: ffffff900969df90 x18: 0000000000000000
    [   20.833878] x17: 0000000000000000 x16: 0000000000000000
    [   20.834491] x15: ffffffffffffffff x14: ffffffff00000000
    [   20.834821] x13: ffffffffffffffff x12: 0000000000000001
    [   20.835143] x11: 0101010101010101 x10: ffffff880d59ff5f
    [   20.835467] x9 : ffffff880d59ff5e x8 : ffffffc06acffaf3
    [   20.835790] x7 : 0000000000000000 x6 : ffffff880d59ff5f
    [   20.836111] x5 : c06419717c314100 x4 : 0000000000000007
    [   20.836419] x3 : 0000000000000000 x2 : 0000000000000000
    [   20.836732] x1 : 0000000000000001 x0 : ffffff900969df90
    [   20.837100] Process sh (pid: 104, stack limit = 0x(____ptrval____))
    [   20.837396] Call trace:
    [   20.837566]            (null)
    [   20.837816]  serial8250_set_termios+0x48/0x54
    [   20.838089]  uart_set_options+0x138/0x1bc
    [   20.838570]  uart_poll_init+0x114/0x16c
    [   20.838834]  tty_find_polling_driver+0x158/0x200
    [   20.839119]  configure_kgdboc+0xbc/0x1bc
    [   20.839380]  param_set_kgdboc_var+0xb8/0x150
    [   20.839658]  param_attr_store+0xbc/0x150
    [   20.839920]  module_attr_store+0x40/0x58
    [   20.840183]  sysfs_kf_write+0x8c/0xa8
    [   20.840183]  sysfs_kf_write+0x8c/0xa8
    [   20.840440]  kernfs_fop_write+0x154/0x290
    [   20.840702]  vfs_write+0xf0/0x278
    [   20.840942]  __arm64_sys_write+0x84/0xf4
    [   20.841209]  el0_svc_common+0xf4/0x1dc
    [   20.841471]  el0_svc_handler+0x98/0xbc
    [   20.841713]  el0_svc+0x8/0xc
    [   20.842057] Code: bad PC value
    [   20.842764] ---[ end trace a8835d7de79aaadf ]---
    [   20.843134] Kernel panic - not syncing: Fatal exception
    [   20.843515] SMP: stopping secondary CPUs
    [   20.844289] Kernel Offset: disabled
    [   20.844634] CPU features: 0x0,21806002
    [   20.844857] Memory Limit: none
    [   20.845172] ---[ end Kernel panic - not syncing: Fatal exception ]---
    
    Signed-off-by: Miles Chen <miles.chen@mediatek.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 211981e7e186dd3d9119a4f9f90633a677a2d58b
Author: Sam Bobroff <sbobroff@linux.ibm.com>
Date:   Wed Sep 12 11:23:20 2018 +1000

    powerpc/eeh: Fix possible null deref in eeh_dump_dev_log()
    
    [ Upstream commit f9bc28aedfb5bbd572d2d365f3095c1becd7209b ]
    
    If an error occurs during an unplug operation, it's possible for
    eeh_dump_dev_log() to be called when edev->pdn is null, which
    currently leads to dereferencing a null pointer.
    
    Handle this by skipping the error log for those devices.
    
    Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0b1f1204554e4ade5af9ea8d59ce6b59ef95e894
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Wed Aug 15 21:29:45 2018 +1000

    powerpc/mm: Fix page table dump to work on Radix
    
    [ Upstream commit 0d923962ab69c27cca664a2d535e90ef655110ca ]
    
    When we're running on Book3S with the Radix MMU enabled the page table
    dump currently prints the wrong addresses because it uses the wrong
    start address.
    
    Fix it to use PAGE_OFFSET rather than KERN_VIRT_START.
    
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2b9aed7cb2e2dd48092ce1950a0c4bdd792a19d3
Author: Nicholas Piggin <npiggin@gmail.com>
Date:   Wed Aug 29 21:56:56 2018 +1000

    powerpc/64/module: REL32 relocation range check
    
    [ Upstream commit b851ba02a6f3075f0f99c60c4bc30a4af80cf428 ]
    
    The recent module relocation overflow crash demonstrated that we
    have no range checking on REL32 relative relocations. This patch
    implements a basic check, the same kernel that previously oopsed
    and rebooted now continues with some of these errors when loading
    the module:
    
      module_64: x_tables: REL32 527703503449812 out of range!
    
    Possibly other relocations (ADDR32, REL16, TOC16, etc.) should also have
    overflow checks.
    
    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 90c68f716d57886f4e6f3ff7c7c07014b4254745
Author: Christophe Leroy <christophe.leroy@c-s.fr>
Date:   Sat Oct 13 09:16:22 2018 +0000

    powerpc/traps: restore recoverability of machine_check interrupts
    
    [ Upstream commit daf00ae71dad8aa05965713c62558aeebf2df48e ]
    
    commit b96672dd840f ("powerpc: Machine check interrupt is a non-
    maskable interrupt") added a call to nmi_enter() at the beginning of
    machine check restart exception handler. Due to that, in_interrupt()
    always returns true regardless of the state before entering the
    exception, and die() panics even when the system was not already in
    interrupt.
    
    This patch calls nmi_exit() before calling die() in order to restore
    the interrupt state we had before calling nmi_enter()
    
    Fixes: b96672dd840f ("powerpc: Machine check interrupt is a non-maskable interrupt")
    Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
    Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>