commit 7cc36c3e14ae0af800a3a5d20cb17d0c168fc956
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Fri Nov 12 15:05:52 2021 +0100

    Linux 5.15.2
    
    Link: https://lore.kernel.org/r/20211110182003.700594531@linuxfoundation.org
    Tested-by: Florian Fainelli <f.fainelli@gmail.com>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Fox Chen <foxhlchen@gmail.com>
    Tested-by: Salvatore Bonaccorso <carnil@debian.org>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5dbe126056fb5a1a4de6970ca86e2e567157033a
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Oct 25 14:05:22 2021 +0200

    rsi: fix control-message timeout
    
    commit 541fd20c3ce5b0bc39f0c6a52414b6b92416831c upstream.
    
    USB control-message timeouts are specified in milliseconds and should
    specifically not vary with CONFIG_HZ.
    
    Use the common control-message timeout define for the five-second
    timeout.
    
    Fixes: dad0d04fa7ba ("rsi: Add RS9113 wireless driver")
    Cc: stable@vger.kernel.org      # 3.15
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/20211025120522.6045-5-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7d6f8d3bab7282d01b5efc7ad249d3137532f0b4
Author: Gustavo A. R. Silva <gustavoars@kernel.org>
Date:   Tue Aug 10 19:09:55 2021 +0200

    media: staging/intel-ipu3: css: Fix wrong size comparison imgu_css_fw_init
    
    commit a44f9d6f9dc1fb314a3f1ed2dcd4fbbcc3d9f892 upstream.
    
    There is a wrong comparison of the total size of the loaded firmware
    css->fw->size with the size of a pointer to struct imgu_fw_header.
    
    Turn binary_header into a flexible-array member[1][2], use the
    struct_size() helper and fix the wrong size comparison. Notice
    that the loaded firmware needs to contain at least one 'struct
    imgu_fw_info' item in the binary_header[] array.
    
    It's also worth mentioning that
    
            "css->fw->size < struct_size(css->fwp, binary_header, 1)"
    
    with binary_header declared as a flexible-array member is equivalent
    to
    
            "css->fw->size < sizeof(struct imgu_fw_header)"
    
    with binary_header declared as a one-element array (as in the original
    code).
    
    The replacement of the one-element array with a flexible-array member
    also helps with the ongoing efforts to globally enable -Warray-bounds
    and get us closer to being able to tighten the FORTIFY_SOURCE routines
    on memcpy().
    
    [1] https://en.wikipedia.org/wiki/Flexible_array_member
    [2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays
    
    Link: https://github.com/KSPP/linux/issues/79
    Link: https://github.com/KSPP/linux/issues/109
    
    Fixes: 09d290f0ba21 ("media: staging/intel-ipu3: css: Add support for firmware management")
    Cc: stable@vger.kernel.org
    Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4787caef521c462d3eccc8dc7d2cbefc58522fdb
Author: Martin Kaiser <martin@kaiser.cx>
Date:   Tue Oct 19 22:23:56 2021 +0200

    staging: r8188eu: fix memleak in rtw_wx_set_enc_ext
    
    commit 26f448371820cf733c827c11f0c77ce304a29b51 upstream.
    
    Free the param struct if the caller sets an unsupported algorithm
    and we return an error.
    
    Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver")
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Martin Kaiser <martin@kaiser.cx>
    Link: https://lore.kernel.org/r/20211019202356.12572-1-martin@kaiser.cx
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8f60f9f6ee2498c6abd2d422f9a44f6d12d5cecd
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Oct 25 14:09:09 2021 +0200

    staging: rtl8192u: fix control-message timeouts
    
    commit 4cfa36d312d6789448b59a7aae770ac8425017a3 upstream.
    
    USB control-message timeouts are specified in milliseconds and should
    specifically not vary with CONFIG_HZ.
    
    Fixes: 8fc8598e61f6 ("Staging: Added Realtek rtl8192u driver to staging")
    Cc: stable@vger.kernel.org      # 2.6.33
    Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211025120910.6339-2-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9033490a3fef5b8ddabb325c1ce80aefe4c6b659
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Oct 25 14:09:10 2021 +0200

    staging: r8712u: fix control-message timeout
    
    commit ce4940525f36ffdcf4fa623bcedab9c2a6db893a upstream.
    
    USB control-message timeouts are specified in milliseconds and should
    specifically not vary with CONFIG_HZ.
    
    Fixes: 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline kernel")
    Cc: stable@vger.kernel.org      # 2.6.37
    Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211025120910.6339-3-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3a66e8a661a4b7fd8434669bee7cacda878d38f5
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Oct 25 13:45:32 2021 +0200

    comedi: vmk80xx: fix bulk and interrupt message timeouts
    
    commit a56d3e40bda460edf3f8d6aac00ec0b322b4ab83 upstream.
    
    USB bulk and interrupt message timeouts are specified in milliseconds
    and should specifically not vary with CONFIG_HZ.
    
    Note that the bulk-out transfer timeout was set to the endpoint
    bInterval value, which should be ignored for bulk endpoints and is
    typically set to zero. This meant that a failing bulk-out transfer
    would never time out.
    
    Assume that the 10 second timeout used for all other transfers is more
    than enough also for the bulk-out endpoint.
    
    Fixes: 985cafccbf9b ("Staging: Comedi: vmk80xx: Add k8061 support")
    Fixes: 951348b37738 ("staging: comedi: vmk80xx: wait for URBs to complete")
    Cc: stable@vger.kernel.org      # 2.6.31
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
    Link: https://lore.kernel.org/r/20211025114532.4599-6-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 47b4636ebdbeba2044b3db937c4d2b6a4fe3d0f2
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Oct 25 13:45:31 2021 +0200

    comedi: vmk80xx: fix bulk-buffer overflow
    
    commit 78cdfd62bd54af615fba9e3ca1ba35de39d3871d upstream.
    
    The driver is using endpoint-sized buffers but must not assume that the
    tx and rx buffers are of equal size or a malicious device could overflow
    the slab-allocated receive buffer when doing bulk transfers.
    
    Fixes: 985cafccbf9b ("Staging: Comedi: vmk80xx: Add k8061 support")
    Cc: stable@vger.kernel.org      # 2.6.31
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
    Link: https://lore.kernel.org/r/20211025114532.4599-5-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 06ac746d57e6d32b062e220415c607b7e2e0fa50
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Oct 25 13:45:30 2021 +0200

    comedi: vmk80xx: fix transfer-buffer overflows
    
    commit a23461c47482fc232ffc9b819539d1f837adf2b1 upstream.
    
    The driver uses endpoint-sized USB transfer buffers but up until
    recently had no sanity checks on the sizes.
    
    Commit e1f13c879a7c ("staging: comedi: check validity of wMaxPacketSize
    of usb endpoints found") inadvertently fixed NULL-pointer dereferences
    when accessing the transfer buffers in case a malicious device has a
    zero wMaxPacketSize.
    
    Make sure to allocate buffers large enough to handle also the other
    accesses that are done without a size check (e.g. byte 18 in
    vmk80xx_cnt_insn_read() for the VMK8061_MODEL) to avoid writing beyond
    the buffers, for example, when doing descriptor fuzzing.
    
    The original driver was for a low-speed device with 8-byte buffers.
    Support was later added for a device that uses bulk transfers and is
    presumably a full-speed device with a maximum 64-byte wMaxPacketSize.
    
    Fixes: 985cafccbf9b ("Staging: Comedi: vmk80xx: Add k8061 support")
    Cc: stable@vger.kernel.org      # 2.6.31
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
    Link: https://lore.kernel.org/r/20211025114532.4599-4-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d6a727a681a39ae4f73081a9bedb45d14f95bdd1
Author: Johan Hovold <johan@kernel.org>
Date:   Wed Oct 27 11:35:28 2021 +0200

    comedi: ni_usb6501: fix NULL-deref in command paths
    
    commit 907767da8f3a925b060c740e0b5c92ea7dbec440 upstream.
    
    The driver uses endpoint-sized USB transfer buffers but had no sanity
    checks on the sizes. This can lead to zero-size-pointer dereferences or
    overflowed transfer buffers in ni6501_port_command() and
    ni6501_counter_command() if a (malicious) device has smaller max-packet
    sizes than expected (or when doing descriptor fuzz testing).
    
    Add the missing sanity checks to probe().
    
    Fixes: a03bb00e50ab ("staging: comedi: add NI USB-6501 support")
    Cc: stable@vger.kernel.org      # 3.18
    Cc: Luca Ellero <luca.ellero@brickedbrain.com>
    Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211027093529.30896-2-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 20cebb8b620dc987e55ddc46801de986e081757e
Author: Johan Hovold <johan@kernel.org>
Date:   Wed Oct 27 11:35:29 2021 +0200

    comedi: dt9812: fix DMA buffers on stack
    
    commit 536de747bc48262225889a533db6650731ab25d3 upstream.
    
    USB transfer buffers are typically mapped for DMA and must not be
    allocated on the stack or transfers will fail.
    
    Allocate proper transfer buffers in the various command helpers and
    return an error on short transfers instead of acting on random stack
    data.
    
    Note that this also fixes a stack info leak on systems where DMA is not
    used as 32 bytes are always sent to the device regardless of how short
    the command is.
    
    Fixes: 63274cd7d38a ("Staging: comedi: add usb dt9812 driver")
    Cc: stable@vger.kernel.org      # 2.6.29
    Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211027093529.30896-3-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e7fb722586a2936b37bdff096c095c30ca06404d
Author: Jan Kara <jack@suse.cz>
Date:   Mon Oct 18 12:37:41 2021 +0200

    isofs: Fix out of bound access for corrupted isofs image
    
    commit e96a1866b40570b5950cda8602c2819189c62a48 upstream.
    
    When isofs image is suitably corrupted isofs_read_inode() can read data
    beyond the end of buffer. Sanity-check the directory entry length before
    using it.
    
    Reported-and-tested-by: syzbot+6fc7fb214625d82af7d1@syzkaller.appspotmail.com
    CC: stable@vger.kernel.org
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a65c9afe9f2f55b7a7fb4a25ab654cd4139683a4
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Wed Oct 20 00:17:18 2021 +0300

    staging: rtl8712: fix use-after-free in rtl8712_dl_fw
    
    commit c052cc1a069c3e575619cf64ec427eb41176ca70 upstream.
    
    Syzbot reported use-after-free in rtl8712_dl_fw(). The problem was in
    race condition between r871xu_dev_remove() ->ndo_open() callback.
    
    It's easy to see from crash log, that driver accesses released firmware
    in ->ndo_open() callback. It may happen, since driver was releasing
    firmware _before_ unregistering netdev. Fix it by moving
    unregister_netdev() before cleaning up resources.
    
    Call Trace:
    ...
     rtl871x_open_fw drivers/staging/rtl8712/hal_init.c:83 [inline]
     rtl8712_dl_fw+0xd95/0xe10 drivers/staging/rtl8712/hal_init.c:170
     rtl8712_hal_init drivers/staging/rtl8712/hal_init.c:330 [inline]
     rtl871x_hal_init+0xae/0x180 drivers/staging/rtl8712/hal_init.c:394
     netdev_open+0xe6/0x6c0 drivers/staging/rtl8712/os_intfs.c:380
     __dev_open+0x2bc/0x4d0 net/core/dev.c:1484
    
    Freed by task 1306:
    ...
     release_firmware+0x1b/0x30 drivers/base/firmware_loader/main.c:1053
     r871xu_dev_remove+0xcc/0x2c0 drivers/staging/rtl8712/usb_intf.c:599
     usb_unbind_interface+0x1d8/0x8d0 drivers/usb/core/driver.c:458
    
    Fixes: 8c213fa59199 ("staging: r8712u: Use asynchronous firmware loading")
    Cc: stable <stable@vger.kernel.org>
    Reported-and-tested-by: syzbot+c55162be492189fb4f51@syzkaller.appspotmail.com
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
    Link: https://lore.kernel.org/r/20211019211718.26354-1-paskripkin@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a0041453ff9e17fb52bff32cef1d81d54ac7064a
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Mon Nov 1 12:46:47 2021 -0700

    btrfs: fix lzo_decompress_bio() kmap leakage
    
    commit 2cf3f8133bda2a0945cc4c70e681ecb25b52b913 upstream.
    
    Commit ccaa66c8dd27 reinstated the kmap/kunmap that had been dropped in
    commit 8c945d32e604 ("btrfs: compression: drop kmap/kunmap from lzo").
    
    However, it seems to have done so incorrectly due to the change not
    reverting cleanly, and lzo_decompress_bio() ended up not having a
    matching "kunmap()" to the "kmap()" that was put back.
    
    Also, any assert that the page pointer is not NULL should be before the
    kmap() of said pointer, since otherwise you'd just oops in the kmap()
    before the assert would even trigger.
    
    I noticed this when trying to verify my btrfs merge, and things not
    adding up.  I'm doing this fixup before re-doing my merge, because this
    commit needs to also be backported to 5.15 (after verification from the
    btrfs people).
    
    Fixes: ccaa66c8dd27 ("Revert 'btrfs: compression: drop kmap/kunmap from lzo'")
    Cc: David Sterba <dsterba@suse.com>
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d5dd3b44488b8c9b1bde7005a02b16fe0638db3a
Author: Marco Elver <elver@google.com>
Date:   Fri Nov 5 13:45:49 2021 -0700

    kfence: default to dynamic branch instead of static keys mode
    
    commit 4f612ed3f748962cbef1316ff3d323e2b9055b6e upstream.
    
    We have observed that on very large machines with newer CPUs, the static
    key/branch switching delay is on the order of milliseconds.  This is due
    to the required broadcast IPIs, which simply does not scale well to
    hundreds of CPUs (cores).  If done too frequently, this can adversely
    affect tail latencies of various workloads.
    
    One workaround is to increase the sample interval to several seconds,
    while decreasing sampled allocation coverage, but the problem still
    exists and could still increase tail latencies.
    
    As already noted in the Kconfig help text, there are trade-offs: at
    lower sample intervals the dynamic branch results in better performance;
    however, at very large sample intervals, the static keys mode can result
    in better performance -- careful benchmarking is recommended.
    
    Our initial benchmarking showed that with large enough sample intervals
    and workloads stressing the allocator, the static keys mode was slightly
    better.  Evaluating and observing the possible system-wide side-effects
    of the static-key-switching induced broadcast IPIs, however, was a blind
    spot (in particular on large machines with 100s of cores).
    
    Therefore, a major downside of the static keys mode is, unfortunately,
    that it is hard to predict performance on new system architectures and
    topologies, but also making conclusions about performance of new
    workloads based on a limited set of benchmarks.
    
    Most distributions will simply select the defaults, while targeting a
    large variety of different workloads and system architectures.  As such,
    the better default is CONFIG_KFENCE_STATIC_KEYS=n, and re-enabling it is
    only recommended after careful evaluation.
    
    For reference, on x86-64 the condition in kfence_alloc() generates
    exactly
    2 instructions in the kmem_cache_alloc() fast-path:
    
     | ...
     | cmpl   $0x0,0x1a8021c(%rip)  # ffffffff82d560d0 <kfence_allocation_gate>
     | je     ffffffff812d6003      <kmem_cache_alloc+0x243>
     | ...
    
    which, given kfence_allocation_gate is infrequently modified, should be
    well predicted by most CPUs.
    
    Link: https://lkml.kernel.org/r/20211019102524.2807208-2-elver@google.com
    Signed-off-by: Marco Elver <elver@google.com>
    Cc: Alexander Potapenko <glider@google.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Cc: Jann Horn <jannh@google.com>
    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 93ce7441001f52c283629b9b9bb77c1056de1900
Author: Marco Elver <elver@google.com>
Date:   Fri Nov 5 13:45:46 2021 -0700

    kfence: always use static branches to guard kfence_alloc()
    
    commit 07e8481d3c38f461d7b79c1d5c9afe013b162b0c upstream.
    
    Regardless of KFENCE mode (CONFIG_KFENCE_STATIC_KEYS: either using
    static keys to gate allocations, or using a simple dynamic branch),
    always use a static branch to avoid the dynamic branch in kfence_alloc()
    if KFENCE was disabled at boot.
    
    For CONFIG_KFENCE_STATIC_KEYS=n, this now avoids the dynamic branch if
    KFENCE was disabled at boot.
    
    To simplify, also unifies the location where kfence_allocation_gate is
    read-checked to just be inline in kfence_alloc().
    
    Link: https://lkml.kernel.org/r/20211019102524.2807208-1-elver@google.com
    Signed-off-by: Marco Elver <elver@google.com>
    Cc: Alexander Potapenko <glider@google.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Cc: Jann Horn <jannh@google.com>
    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 5e57d171e2e6398aee9ae57bdb60b87d3925615f
Author: Todd Kjos <tkjos@google.com>
Date:   Fri Oct 15 16:38:11 2021 -0700

    binder: don't detect sender/target during buffer cleanup
    
    commit 32e9f56a96d8d0f23cb2aeb2a3cd18d40393e787 upstream.
    
    When freeing txn buffers, binder_transaction_buffer_release()
    attempts to detect whether the current context is the target by
    comparing current->group_leader to proc->tsk. This is an unreliable
    test. Instead explicitly pass an 'is_failure' boolean.
    
    Detecting the sender was being used as a way to tell if the
    transaction failed to be sent.  When cleaning up after
    failing to send a transaction, there is no need to close
    the fds associated with a BINDER_TYPE_FDA object. Now
    'is_failure' can be used to accurately detect this case.
    
    Fixes: 44d8047f1d87 ("binder: use standard functions to allocate fds")
    Cc: stable <stable@vger.kernel.org>
    Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
    Signed-off-by: Todd Kjos <tkjos@google.com>
    Link: https://lore.kernel.org/r/20211015233811.3532235-1-tkjos@google.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6e8813eadf8bcf0ea26360658b1679971d0a501c
Author: Todd Kjos <tkjos@google.com>
Date:   Tue Oct 12 09:56:14 2021 -0700

    binder: use cred instead of task for getsecid
    
    commit 4d5b5539742d2554591751b4248b0204d20dcc9d upstream.
    
    Use the 'struct cred' saved at binder_open() to lookup
    the security ID via security_cred_getsecid(). This
    ensures that the security context that opened binder
    is the one used to generate the secctx.
    
    Cc: stable@vger.kernel.org # 5.4+
    Fixes: ec74136ded79 ("binder: create node flag to request sender's security context")
    Signed-off-by: Todd Kjos <tkjos@google.com>
    Suggested-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Reported-by: kernel test robot <lkp@intel.com>
    Acked-by: Casey Schaufler <casey@schaufler-ca.com>
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3f3c31dd0f8cfdc4ce301a4a605488fb73602ea5
Author: Todd Kjos <tkjos@google.com>
Date:   Tue Oct 12 09:56:13 2021 -0700

    binder: use cred instead of task for selinux checks
    
    commit 52f88693378a58094c538662ba652aff0253c4fe upstream.
    
    Since binder was integrated with selinux, it has passed
    'struct task_struct' associated with the binder_proc
    to represent the source and target of transactions.
    The conversion of task to SID was then done in the hook
    implementations. It turns out that there are race conditions
    which can result in an incorrect security context being used.
    
    Fix by using the 'struct cred' saved during binder_open and pass
    it to the selinux subsystem.
    
    Cc: stable@vger.kernel.org # 5.14 (need backport for earlier stables)
    Fixes: 79af73079d75 ("Add security hooks to binder and implement the hooks for SELinux.")
    Suggested-by: Jann Horn <jannh@google.com>
    Signed-off-by: Todd Kjos <tkjos@google.com>
    Acked-by: Casey Schaufler <casey@schaufler-ca.com>
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ff1bd01f490ba60d82c765100d95d13cc00c1625
Author: Todd Kjos <tkjos@google.com>
Date:   Tue Oct 12 09:56:12 2021 -0700

    binder: use euid from cred instead of using task
    
    commit 29bc22ac5e5bc63275e850f0c8fc549e3d0e306b upstream.
    
    Save the 'struct cred' associated with a binder process
    at initial open to avoid potential race conditions
    when converting to an euid.
    
    Set a transaction's sender_euid from the 'struct cred'
    saved at binder_open() instead of looking up the euid
    from the binder proc's 'struct task'. This ensures
    the euid is associated with the security context that
    of the task that opened binder.
    
    Cc: stable@vger.kernel.org # 4.4+
    Fixes: 457b9a6f09f0 ("Staging: android: add binder driver")
    Signed-off-by: Todd Kjos <tkjos@google.com>
    Suggested-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Suggested-by: Jann Horn <jannh@google.com>
    Acked-by: Casey Schaufler <casey@schaufler-ca.com>
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ec7c20d417145449e992e549e17a015364a6c47d
Author: Kees Cook <keescook@chromium.org>
Date:   Wed Sep 29 15:02:13 2021 -0700

    Revert "proc/wchan: use printk format instead of lookup_symbol_name()"
    
    commit 54354c6a9f7fd5572d2b9ec108117c4f376d4d23 upstream.
    
    This reverts commit 152c432b128cb043fc107e8f211195fe94b2159c.
    
    When a kernel address couldn't be symbolized for /proc/$pid/wchan, it
    would leak the raw value, a potential information exposure. This is a
    regression compared to the safer pre-v5.12 behavior.
    
    Reported-by: kernel test robot <oliver.sang@intel.com>
    Reported-by: Vito Caputo <vcaputo@pengaru.com>
    Reported-by: Jann Horn <jannh@google.com>
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/20211008111626.090829198@infradead.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2e93afda05203a35531b10955999a485c2233a88
Author: James Buren <braewoods+lkml@braewoods.net>
Date:   Wed Oct 13 20:55:04 2021 -0500

    usb-storage: Add compatibility quirk flags for iODD 2531/2541
    
    commit 05c8f1b67e67dcd786ae3fe44492bbc617b4bd12 upstream.
    
    These drive enclosures have firmware bugs that make it impossible to mount
    a new virtual ISO image after Linux ejects the old one if the device is
    locked by Linux. Windows bypasses this problem by the fact that they do
    not lock the device. Add a quirk to disable device locking for these
    drive enclosures.
    
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: James Buren <braewoods+lkml@braewoods.net>
    Cc: stable <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20211014015504.2695089-1-braewoods+lkml@braewoods.net
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ad5df979295bf9c6b0ce4942b40973508090f89e
Author: Viraj Shah <viraj.shah@linutronix.de>
Date:   Thu Oct 21 11:36:44 2021 +0200

    usb: musb: Balance list entry in musb_gadget_queue
    
    commit 21b5fcdccb32ff09b6b63d4a83c037150665a83f upstream.
    
    musb_gadget_queue() adds the passed request to musb_ep::req_list. If the
    endpoint is idle and it is the first request then it invokes
    musb_queue_resume_work(). If the function returns an error then the
    error is passed to the caller without any clean-up and the request
    remains enqueued on the list. If the caller enqueues the request again
    then the list corrupts.
    
    Remove the request from the list on error.
    
    Fixes: ea2f35c01d5ea ("usb: musb: Fix sleeping function called from invalid context for hdrc glue")
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Viraj Shah <viraj.shah@linutronix.de>
    Link: https://lore.kernel.org/r/20211021093644.4734-1-viraj.shah@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 72a9bf9bb16aa9fab574531b34c31df1c38378ca
Author: Geert Uytterhoeven <geert@linux-m68k.org>
Date:   Wed Oct 27 10:08:49 2021 +0200

    usb: gadget: Mark USB_FSL_QE broken on 64-bit
    
    commit a0548b26901f082684ad1fb3ba397d2de3a1406a upstream.
    
    On 64-bit:
    
        drivers/usb/gadget/udc/fsl_qe_udc.c: In function ‘qe_ep0_rx’:
        drivers/usb/gadget/udc/fsl_qe_udc.c:842:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
          842 |     vaddr = (u32)phys_to_virt(in_be32(&bd->buf));
              |             ^
        In file included from drivers/usb/gadget/udc/fsl_qe_udc.c:41:
        drivers/usb/gadget/udc/fsl_qe_udc.c:843:28: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
          843 |     frame_set_data(pframe, (u8 *)vaddr);
              |                            ^
    
    The driver assumes physical and virtual addresses are 32-bit, hence it
    cannot work on 64-bit platforms.
    
    Acked-by: Li Yang <leoyang.li@nxp.com>
    Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Link: https://lore.kernel.org/r/20211027080849.3276289-1-geert@linux-m68k.org
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit adb1902a12463e334d5e17f91a63220be91cc072
Author: Neal Liu <neal_liu@aspeedtech.com>
Date:   Fri Sep 10 15:36:19 2021 +0800

    usb: ehci: handshake CMD_RUN instead of STS_HALT
    
    commit 7f2d73788d9067fd4f677ac5f60ffd25945af7af upstream.
    
    For Aspeed, HCHalted status depends on not only Run/Stop but also
    ASS/PSS status.
    Handshake CMD_RUN on startup instead.
    
    Tested-by: Tao Ren <rentao.bupt@gmail.com>
    Reviewed-by: Tao Ren <rentao.bupt@gmail.com>
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Neal Liu <neal_liu@aspeedtech.com>
    Link: https://lore.kernel.org/r/20210910073619.26095-1-neal_liu@aspeedtech.com
    Cc: Joel Stanley <joel@jms.id.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aa8a82d6db0bb522e9773aeeb44b47665960ebd9
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 13 15:57:43 2021 +0200

    Revert "x86/kvm: fix vcpu-id indexed array sizes"
    
    commit 1e254d0d86a0f2efd4190a89d5204b37c18c6381 upstream.
    
    This reverts commit 76b4f357d0e7d8f6f0013c733e6cba1773c266d3.
    
    The commit has the wrong reasoning, as KVM_MAX_VCPU_ID is not defining the
    maximum allowed vcpu-id as its name suggests, but the number of vcpu-ids.
    So revert this patch again.
    
    Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20210913135745.13944-2-jgross@suse.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 26ac7dec7ff00704e31e91d35d5ebf4a8a7cc1e9
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Fri Oct 15 04:50:01 2021 -0400

    KVM: x86: avoid warning with -Wbitwise-instead-of-logical
    
    commit 3d5e7a28b1ea2d603dea478e58e37ce75b9597ab upstream.
    
    This is a new warning in clang top-of-tree (will be clang 14):
    
    In file included from arch/x86/kvm/mmu/mmu.c:27:
    arch/x86/kvm/mmu/spte.h:318:9: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
            return __is_bad_mt_xwr(rsvd_check, spte) |
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                     ||
    arch/x86/kvm/mmu/spte.h:318:9: note: cast one or both operands to int to silence this warning
    
    The code is fine, but change it anyway to shut up this clever clogs
    of a compiler.
    
    Reported-by: torvic9@mailbox.org
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>