13 Jan, 2021

40 commits

  • commit 6cb56218ad9e580e519dcd23bfb3db08d8692e5a upstream.

    syzbot reports:
    detected buffer overflow in strlen
    [..]
    Call Trace:
    strlen include/linux/string.h:325 [inline]
    strlcpy include/linux/string.h:348 [inline]
    xt_rateest_tg_checkentry+0x2a5/0x6b0 net/netfilter/xt_RATEEST.c:143

    strlcpy assumes src is a c-string. Check info->name before its used.

    Reported-by: syzbot+e86f7c428c8c50db65b4@syzkaller.appspotmail.com
    Fixes: 5859034d7eb8793 ("[NETFILTER]: x_tables: add RATEEST target")
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • commit 5c8193f568ae16f3242abad6518dc2ca6c8eef86 upstream.

    htable_bits() can call jhash_size(32) and trigger shift-out-of-bounds

    UBSAN: shift-out-of-bounds in net/netfilter/ipset/ip_set_hash_gen.h:151:6
    shift exponent 32 is too large for 32-bit type 'unsigned int'
    CPU: 0 PID: 8498 Comm: syz-executor519
    Not tainted 5.10.0-rc7-next-20201208-syzkaller #0
    Call Trace:
    __dump_stack lib/dump_stack.c:79 [inline]
    dump_stack+0x107/0x163 lib/dump_stack.c:120
    ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
    __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:395
    htable_bits net/netfilter/ipset/ip_set_hash_gen.h:151 [inline]
    hash_mac_create.cold+0x58/0x9b net/netfilter/ipset/ip_set_hash_gen.h:1524
    ip_set_create+0x610/0x1380 net/netfilter/ipset/ip_set_core.c:1115
    nfnetlink_rcv_msg+0xecc/0x1180 net/netfilter/nfnetlink.c:252
    netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
    nfnetlink_rcv+0x1ac/0x420 net/netfilter/nfnetlink.c:600
    netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
    netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1330
    netlink_sendmsg+0x907/0xe40 net/netlink/af_netlink.c:1919
    sock_sendmsg_nosec net/socket.c:652 [inline]
    sock_sendmsg+0xcf/0x120 net/socket.c:672
    ____sys_sendmsg+0x6e8/0x810 net/socket.c:2345
    ___sys_sendmsg+0xf3/0x170 net/socket.c:2399
    __sys_sendmsg+0xe5/0x1b0 net/socket.c:2432
    do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    This patch replaces htable_bits() by simple fls(hashsize - 1) call:
    it alone returns valid nbits both for round and non-round hashsizes.
    It is normal to set any nbits here because it is validated inside
    following htable_size() call which returns 0 for nbits>31.

    Fixes: 1feab10d7e6d("netfilter: ipset: Unified hash type generation")
    Reported-by: syzbot+d66bfadebca46cf61a2b@syzkaller.appspotmail.com
    Signed-off-by: Vasily Averin
    Acked-by: Jozsef Kadlecsik
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Vasily Averin
     
  • commit 443d6e86f821a165fae3fc3fc13086d27ac140b1 upstream.

    This fixes the dereference to fetch the RCU pointer when holding
    the appropriate xtables lock.

    Reported-by: kernel test robot
    Fixes: cc00bcaa5899 ("netfilter: x_tables: Switch synchronization to RCU")
    Signed-off-by: Subash Abhinov Kasiviswanathan
    Reviewed-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Subash Abhinov Kasiviswanathan
     
  • commit f1dc15cd7fc146107cad2a926d9c1d005f69002a upstream.

    AES needs to be disabled on Nokia N950/N9 as well (HS devices), otherwise
    kernel fails to boot.

    Fixes: c312f066314e ("ARM: dts: omap3: Migrate AES from hwmods to sysc-omap2")
    Signed-off-by: Aaro Koskinen
    Signed-off-by: Tony Lindgren
    Signed-off-by: Greg Kroah-Hartman

    Aaro Koskinen
     
  • commit b544011f0e58ce43c40105468d6dc67f980a0c7a upstream.

    In case WQE includes inline header the vlan is inserted by driver even
    if vlan offload is set. On geneve over vlan interface where software
    parser is used the SWP offsets should be updated according to the added
    vlan.

    Fixes: e3cfc7e6b7bd ("net/mlx5e: TX, Add geneve tunnel stateless offload support")
    Signed-off-by: Moshe Shemesh
    Reviewed-by: Tariq Toukan
    Signed-off-by: Saeed Mahameed
    Signed-off-by: Greg Kroah-Hartman

    Moshe Shemesh
     
  • commit b16671e8f493e3df40b1fb0dff4078f391c5099a upstream.

    When large bucket feature was added, BCH_FEATURE_INCOMPAT_LARGE_BUCKET
    was introduced into the incompat feature set. It used bucket_size_hi
    (which was added at the tail of struct cache_sb_disk) to extend current
    16bit bucket size to 32bit with existing bucket_size in struct
    cache_sb_disk.

    This is not a good idea, there are two obvious problems,
    - Bucket size is always value power of 2, if store log2(bucket size) in
    existing bucket_size of struct cache_sb_disk, it is unnecessary to add
    bucket_size_hi.
    - Macro csum_set() assumes d[SB_JOURNAL_BUCKETS] is the last member in
    struct cache_sb_disk, bucket_size_hi was added after d[] which makes
    csum_set calculate an unexpected super block checksum.

    To fix the above problems, this patch introduces a new incompat feature
    bit BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE, when this bit is set, it
    means bucket_size in struct cache_sb_disk stores the order of power-of-2
    bucket size value. When user specifies a bucket size larger than 32768
    sectors, BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE will be set to
    incompat feature set, and bucket_size stores log2(bucket size) more
    than store the real bucket size value.

    The obsoleted BCH_FEATURE_INCOMPAT_LARGE_BUCKET won't be used anymore,
    it is renamed to BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET and still only
    recognized by kernel driver for legacy compatible purpose. The previous
    bucket_size_hi is renmaed to obso_bucket_size_hi in struct cache_sb_disk
    and not used in bcache-tools anymore.

    For cache device created with BCH_FEATURE_INCOMPAT_LARGE_BUCKET feature,
    bcache-tools and kernel driver still recognize the feature string and
    display it as "obso_large_bucket".

    With this change, the unnecessary extra space extend of bcache on-disk
    super block can be avoided, and csum_set() may generate expected check
    sum as well.

    Fixes: ffa470327572 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket")
    Signed-off-by: Coly Li
    Cc: stable@vger.kernel.org # 5.9+
    Signed-off-by: Jens Axboe
    Signed-off-by: Greg Kroah-Hartman

    Coly Li
     
  • commit 1dfc0686c29a9bbd3a446a29f9ccde3dec3bc75a upstream.

    This patch adds the check for features which is incompatible for
    current supported feature sets.

    Now if the bcache device created by bcache-tools has features that
    current kernel doesn't support, read_super() will fail with error
    messoage. E.g. if an unsupported incompatible feature detected,
    bcache register will fail with dmesg "bcache: register_bcache() error :
    Unsupported incompatible feature found".

    Fixes: d721a43ff69c ("bcache: increase super block version for cache device and backing device")
    Fixes: ffa470327572 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket")
    Signed-off-by: Coly Li
    Cc: stable@vger.kernel.org # 5.9+
    Signed-off-by: Jens Axboe
    Signed-off-by: Greg Kroah-Hartman

    Coly Li
     
  • commit f7b4943dea48a572ad751ce1f18a245d43debe7e upstream.

    This patch fixes the following typos,
    from BCH_FEATURE_COMPAT_SUUP to BCH_FEATURE_COMPAT_SUPP
    from BCH_FEATURE_INCOMPAT_SUUP to BCH_FEATURE_INCOMPAT_SUPP
    from BCH_FEATURE_INCOMPAT_SUUP to BCH_FEATURE_RO_COMPAT_SUPP

    Fixes: d721a43ff69c ("bcache: increase super block version for cache device and backing device")
    Fixes: ffa470327572 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket")
    Signed-off-by: Coly Li
    Cc: stable@vger.kernel.org # 5.9+
    Signed-off-by: Jens Axboe
    Signed-off-by: Greg Kroah-Hartman

    Coly Li
     
  • commit 641382e9b44fba81a0778e1914ee35b8471121f9 upstream.

    The reloc batch is short lived but can exist in the user visible ppGTT,
    and since it's backed by an internal object, which lacks page clearing,
    we should take care to clear it upfront.

    Signed-off-by: Matthew Auld
    Reviewed-by: Chris Wilson
    Signed-off-by: Chris Wilson
    Link: https://patchwork.freedesktop.org/patch/msgid/20201224151358.401345-2-matthew.auld@intel.com
    Cc: stable@vger.kernel.org
    (cherry picked from commit 26ebc511e799f621357982ccc37a7987a56a00f4)
    Signed-off-by: Jani Nikula
    Signed-off-by: Greg Kroah-Hartman

    Matthew Auld
     
  • commit 75353bcd2184010f08a3ed2f0da019bd9d604e1e upstream.

    The shadow batch is an internal object, which doesn't have any page
    clearing, and since the batch_len can be smaller than the object, we
    should take care to clear it.

    Testcase: igt/gen9_exec_parse/shadow-peek
    Fixes: 4f7af1948abc ("drm/i915: Support ro ppgtt mapped cmdparser shadow buffers")
    Signed-off-by: Matthew Auld
    Reviewed-by: Chris Wilson
    Signed-off-by: Chris Wilson
    Link: https://patchwork.freedesktop.org/patch/msgid/20201224151358.401345-1-matthew.auld@intel.com
    Cc: stable@vger.kernel.org
    (cherry picked from commit eeb52ee6c4a429ec301faf1dc48988744960786e)
    Signed-off-by: Jani Nikula
    Signed-off-by: Greg Kroah-Hartman

    Matthew Auld
     
  • commit 311bea3cb9ee20ef150ca76fc60a592bf6b159f5 upstream.

    With GNU binutils 2.35+, linking with BFD produces warnings for vmlinux:
    aarch64-linux-gnu-ld: warning: -z norelro ignored

    BFD can produce this warning when the target emulation mode does not
    support RELRO program headers, and -z relro or -z norelro is passed.

    Alan Modra clarifies:
    The default linker emulation for an aarch64-linux ld.bfd is
    -maarch64linux, the default for an aarch64-elf linker is
    -maarch64elf. They are not equivalent. If you choose -maarch64elf
    you get an emulation that doesn't support -z relro.

    The ARCH=arm64 kernel prefers -maarch64elf, but may fall back to
    -maarch64linux based on the toolchain configuration.

    LLD will always create RELRO program header regardless of target
    emulation.

    To avoid the above warning when linking with BFD, pass -z norelro only
    when linking with LLD or with -maarch64linux.

    Fixes: 3b92fa7485eb ("arm64: link with -z norelro regardless of CONFIG_RELOCATABLE")
    Fixes: 3bbd3db86470 ("arm64: relocatable: fix inconsistencies in linker script and options")
    Cc: # 5.0.x-
    Reported-by: kernelci.org bot
    Reported-by: Quentin Perret
    Signed-off-by: Nick Desaulniers
    Reviewed-by: Nathan Chancellor
    Acked-by: Ard Biesheuvel
    Cc: Alan Modra
    Cc: Fāng-ruì Sòng
    Link: https://lore.kernel.org/r/20201218002432.788499-1-ndesaulniers@google.com
    Signed-off-by: Catalin Marinas
    Signed-off-by: Greg Kroah-Hartman

    Nick Desaulniers
     
  • commit 05cd84691eafcd7959a1e120d5e72c0dd98c5d91 upstream.

    It is observed 'use-after-free' on the dmabuf's file->f_inode with the
    race between closing the dmabuf file and reading the dmabuf's debug
    info.

    Consider the below scenario where P1 is closing the dma_buf file
    and P2 is reading the dma_buf's debug info in the system:

    P1 P2
    dma_buf_debug_show()
    dma_buf_put()
    __fput()
    file->f_op->release()
    dput()
    ....
    dentry_unlink_inode()
    iput(dentry->d_inode)
    (where the inode is freed)
    mutex_lock(&db_list.lock)
    read 'dma_buf->file->f_inode'
    (the same inode is freed by P1)
    mutex_unlock(&db_list.lock)
    dentry->d_op->d_release()-->
    dma_buf_release()
    .....
    mutex_lock(&db_list.lock)
    removes the dmabuf from the list
    mutex_unlock(&db_list.lock)

    In the above scenario, when dma_buf_put() is called on a dma_buf, it
    first frees the dma_buf's file->f_inode(=dentry->d_inode) and then
    removes this dma_buf from the system db_list. In between P2 traversing
    the db_list tries to access this dma_buf's file->f_inode that was freed
    by P1 which is a use-after-free case.

    Since, __fput() calls f_op->release first and then later calls the
    d_op->d_release, move the dma_buf's db_list removal from d_release() to
    f_op->release(). This ensures that dma_buf's file->f_inode is not
    accessed after it is released.

    Cc: # 5.4.x-
    Fixes: 4ab59c3c638c ("dma-buf: Move dma_buf_release() from fops to dentry_ops")
    Acked-by: Christian König
    Signed-off-by: Charan Teja Reddy
    Signed-off-by: Sumit Semwal
    Signed-off-by: Thomas Zimmermann
    Link: https://patchwork.freedesktop.org/patch/msgid/1609857399-31549-1-git-send-email-charante@codeaurora.org
    Signed-off-by: Greg Kroah-Hartman

    Charan Teja Reddy
     
  • commit 47f4469970d8861bc06d2d4d45ac8200ff07c693 upstream.

    While commit d5dcce0c414f ("device property: Keep secondary firmware
    node secondary by type") describes everything correct in its commit
    message, the change it made does the opposite and original commit
    c15e1bdda436 ("device property: Fix the secondary firmware node handling
    in set_primary_fwnode()") was fully correct.

    Revert the former one here and improve documentation in the next patch.

    Fixes: d5dcce0c414f ("device property: Keep secondary firmware node secondary by type")
    Signed-off-by: Bard Liao
    Reviewed-by: Andy Shevchenko
    Reviewed-by: Heikki Krogerus
    Cc: 5.10+ # 5.10+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Bard Liao
     
  • commit 0b3f407e6728d990ae1630a02c7b952c21c288d3 upstream.

    When doing an incremental send, if we have a new inode that happens to
    have the same number that an old directory inode had in the base snapshot
    and that old directory has a pending rmdir operation, we end up computing
    a wrong path for the new inode, causing the receiver to fail.

    Example reproducer:

    $ cat test-send-rmdir.sh
    #!/bin/bash

    DEV=/dev/sdi
    MNT=/mnt/sdi

    mkfs.btrfs -f $DEV >/dev/null
    mount $DEV $MNT

    mkdir $MNT/dir
    touch $MNT/dir/file1
    touch $MNT/dir/file2
    touch $MNT/dir/file3

    # Filesystem looks like:
    #
    # . (ino 256)
    # |----- dir/ (ino 257)
    # |----- file1 (ino 258)
    # |----- file2 (ino 259)
    # |----- file3 (ino 260)
    #

    btrfs subvolume snapshot -r $MNT $MNT/snap1
    btrfs send -f /tmp/snap1.send $MNT/snap1

    # Now remove our directory and all its files.
    rm -fr $MNT/dir

    # Unmount the filesystem and mount it again. This is to ensure that
    # the next inode that is created ends up with the same inode number
    # that our directory "dir" had, 257, which is the first free "objectid"
    # available after mounting again the filesystem.
    umount $MNT
    mount $DEV $MNT

    # Now create a new file (it could be a directory as well).
    touch $MNT/newfile

    # Filesystem now looks like:
    #
    # . (ino 256)
    # |----- newfile (ino 257)
    #

    btrfs subvolume snapshot -r $MNT $MNT/snap2
    btrfs send -f /tmp/snap2.send -p $MNT/snap1 $MNT/snap2

    # Now unmount the filesystem, create a new one, mount it and try to apply
    # both send streams to recreate both snapshots.
    umount $DEV

    mkfs.btrfs -f $DEV >/dev/null

    mount $DEV $MNT

    btrfs receive -f /tmp/snap1.send $MNT
    btrfs receive -f /tmp/snap2.send $MNT

    umount $MNT

    When running the test, the receive operation for the incremental stream
    fails:

    $ ./test-send-rmdir.sh
    Create a readonly snapshot of '/mnt/sdi' in '/mnt/sdi/snap1'
    At subvol /mnt/sdi/snap1
    Create a readonly snapshot of '/mnt/sdi' in '/mnt/sdi/snap2'
    At subvol /mnt/sdi/snap2
    At subvol snap1
    At snapshot snap2
    ERROR: chown o257-9-0 failed: No such file or directory

    So fix this by tracking directories that have a pending rmdir by inode
    number and generation number, instead of only inode number.

    A test case for fstests follows soon.

    Reported-by: Massimo B.
    Tested-by: Massimo B.
    Link: https://lore.kernel.org/linux-btrfs/6ae34776e85912960a253a8327068a892998e685.camel@gmx.net/
    CC: stable@vger.kernel.org # 4.19+
    Signed-off-by: Filipe Manana
    Signed-off-by: David Sterba
    Signed-off-by: Greg Kroah-Hartman

    Filipe Manana
     
  • commit ae5e070eaca9dbebde3459dd8f4c2756f8c097d0 upstream.

    There is a chance of racing for qgroup flushing which may lead to
    deadlock:

    Thread A | Thread B
    (not holding trans handle) | (holding a trans handle)
    --------------------------------+--------------------------------
    __btrfs_qgroup_reserve_meta() | __btrfs_qgroup_reserve_meta()
    |- try_flush_qgroup() | |- try_flush_qgroup()
    |- QGROUP_FLUSHING bit set | |
    | | |- test_and_set_bit()
    | | |- wait_event()
    |- btrfs_join_transaction() |
    |- btrfs_commit_transaction()|

    !!! DEAD LOCK !!!

    Since thread A wants to commit transaction, but thread B is holding a
    transaction handle, blocking the commit.
    At the same time, thread B is waiting for thread A to finish its commit.

    This is just a hot fix, and would lead to more EDQUOT when we're near
    the qgroup limit.

    The proper fix would be to make all metadata/data reservations happen
    without holding a transaction handle.

    CC: stable@vger.kernel.org # 5.9+
    Reviewed-by: Filipe Manana
    Signed-off-by: Qu Wenruo
    Signed-off-by: David Sterba
    Signed-off-by: Greg Kroah-Hartman

    Qu Wenruo
     
  • commit 9ad9f45b3b91162b33abfe175ae75ab65718dbf5 upstream.

    'struct intel_svm' is shared by all devices bound to a give process,
    but records only a single pointer to a 'struct intel_iommu'. Consequently,
    cache invalidations may only be applied to a single DMAR unit, and are
    erroneously skipped for the other devices.

    In preparation for fixing this, rework the structures so that the iommu
    pointer resides in 'struct intel_svm_dev', allowing 'struct intel_svm'
    to track them in its device list.

    Fixes: 1c4f88b7f1f9 ("iommu/vt-d: Shared virtual address in scalable mode")
    Cc: Lu Baolu
    Cc: Jacob Pan
    Cc: Raj Ashok
    Cc: David Woodhouse
    Reported-by: Guo Kaijie
    Reported-by: Xin Zeng
    Signed-off-by: Guo Kaijie
    Signed-off-by: Xin Zeng
    Signed-off-by: Liu Yi L
    Tested-by: Guo Kaijie
    Cc: stable@vger.kernel.org # v5.0+
    Acked-by: Lu Baolu
    Link: https://lore.kernel.org/r/1609949037-25291-2-git-send-email-yi.l.liu@intel.com
    Signed-off-by: Will Deacon
    Signed-off-by: Greg Kroah-Hartman

    Liu Yi L
     
  • commit ce2e79b223867b9e586021b55dee7035517a236b upstream.

    Add two "Intel Reference boad" SSID in the alc256.
    Enable "power saving mode" and Enable "headset jack mode".

    Signed-off-by: PeiSen Hou
    Cc:
    Link: https://lore.kernel.org/r/5978d2267f034c28973d117925ec9c63@realtek.com
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    PeiSen Hou
     
  • commit a598098cc9737f612dbab52294433fc26c51cc9b upstream.

    HP EliteBook 850 G7 uses the same GPIO pins as ALC285_FIXUP_HP_GPIO_LED
    to enable mute and micmute LED. So apply the quirk to enable the LEDs.

    Signed-off-by: Kai-Heng Feng
    Cc:
    Link: https://lore.kernel.org/r/20201230125636.45028-1-kai.heng.feng@canonical.com
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Kai-Heng Feng
     
  • commit 484229585a5e91eeb00ee10e05d5204e1ca6c481 upstream.

    HP Pavilion 13-bb0000 (SSID 103c:87c8) needs the same
    quirk as other models with ALC287.

    Signed-off-by: Manuel Jiménez
    Cc:
    Link: https://lore.kernel.org/r/X+s/gKNydVrI6nLj@HP-Pavilion-13
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Manuel Jiménez
     
  • commit f86de9b1c0663b0a3ca2dcddec9aa910ff0fbf2c upstream.

    Cannot adjust speaker's volume on Lenovo C940.
    Applying the alc298_fixup_speaker_volume function can fix the issue.

    [ Additional note: C940 has I2S amp for the speaker and this needs the
    same initialization as Dell machines.
    The patch was slightly modified so that the quirk entry is moved
    next to the corresponding Dell quirk entry. -- tiwai ]

    Signed-off-by: Kailang Yang
    Cc:
    Link: https://lore.kernel.org/r/ea25b4e5c468491aa2e9d6cb1f2fced3@realtek.com
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Kailang Yang
     
  • commit 744a11abc56405c5a106e63da30a941b6d27f737 upstream.

    The current kernel does not support the cx11970 codec chip.
    Add a codec configuration item to kernel.

    [ Minor coding style fix by tiwai ]

    Signed-off-by: bo liu
    Cc:
    Link: https://lore.kernel.org/r/20201229035226.62120-1-bo.liu@senarytech.com
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    bo liu
     
  • commit 4bfd6247fa9164c8e193a55ef9c0ea3ee22f82d8 upstream.

    Clevo W35xSS_370SS with VIA codec has had the runtime PM problem that
    looses the power state of some nodes after the runtime resume. This
    was worked around by disabling the default runtime PM via a denylist
    entry. Since 5.10.x made the runtime PM applied (casually) even
    though it's disabled in the denylist, this problem was revisited. The
    result was that disabling power_save_node feature suffices for the
    runtime PM problem.

    This patch implements the disablement of power_save_node feature in
    VIA codec for the device. It also drops the former denylist entry,
    too, as the runtime PM should work in the codec side properly now.

    Fixes: b529ef2464ad ("ALSA: hda: Add Clevo W35xSS_370SS to the power_save blacklist")
    Reported-by: Christian Labisch
    Cc:
    Link: https://lore.kernel.org/r/20210104153046.19993-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Takashi Iwai
     
  • commit d16baa3f1453c14d680c5fee01cd122a22d0e0ce upstream.

    When initializing iocost for a queue, its rqos should be registered before
    the blkcg policy is activated to allow policy data initiailization to lookup
    the associated ioc. This unfortunately means that the rqos methods can be
    called on bios before iocgs are attached to all existing blkgs.

    While the race is theoretically possible on ioc_rqos_throttle(), it mostly
    happened in ioc_rqos_merge() due to the difference in how they lookup ioc.
    The former determines it from the passed in @rqos and then bails before
    dereferencing iocg if the looked up ioc is disabled, which most likely is
    the case if initialization is still in progress. The latter looked up ioc by
    dereferencing the possibly NULL iocg making it a lot more prone to actually
    triggering the bug.

    * Make ioc_rqos_merge() use the same method as ioc_rqos_throttle() to look
    up ioc for consistency.

    * Make ioc_rqos_throttle() and ioc_rqos_merge() test for NULL iocg before
    dereferencing it.

    * Explain the danger of NULL iocgs in blk_iocost_init().

    Signed-off-by: Tejun Heo
    Reported-by: Jonathan Lemon
    Cc: stable@vger.kernel.org # v5.4+
    Signed-off-by: Jens Axboe
    Signed-off-by: Greg Kroah-Hartman

    Tejun Heo
     
  • commit a0195f314a25582b38993bf30db11c300f4f4611 upstream.

    Shakeel Butt reported in [1] that a user can request a task to be moved
    to a resource group even if the task is already in the group. It just
    wastes time to do the move operation which could be costly to send IPI
    to a different CPU.

    Add a sanity check to ensure that the move operation only happens when
    the task is not already in the resource group.

    [1] https://lore.kernel.org/lkml/CALvZod7E9zzHwenzf7objzGKsdBmVwTgEJ0nPgs0LUFU3SN5Pw@mail.gmail.com/

    Fixes: e02737d5b826 ("x86/intel_rdt: Add tasks files")
    Reported-by: Shakeel Butt
    Signed-off-by: Fenghua Yu
    Signed-off-by: Reinette Chatre
    Signed-off-by: Borislav Petkov
    Reviewed-by: Tony Luck
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/962ede65d8e95be793cb61102cca37f7bb018e66.1608243147.git.reinette.chatre@intel.com
    Signed-off-by: Greg Kroah-Hartman

    Fenghua Yu
     
  • commit ae28d1aae48a1258bd09a6f707ebb4231d79a761 upstream.

    Currently, when moving a task to a resource group the PQR_ASSOC MSR is
    updated with the new closid and rmid in an added task callback. If the
    task is running, the work is run as soon as possible. If the task is not
    running, the work is executed later in the kernel exit path when the
    kernel returns to the task again.

    Updating the PQR_ASSOC MSR as soon as possible on the CPU a moved task
    is running is the right thing to do. Queueing work for a task that is
    not running is unnecessary (the PQR_ASSOC MSR is already updated when
    the task is scheduled in) and causing system resource waste with the way
    in which it is implemented: Work to update the PQR_ASSOC register is
    queued every time the user writes a task id to the "tasks" file, even if
    the task already belongs to the resource group.

    This could result in multiple pending work items associated with a
    single task even if they are all identical and even though only a single
    update with most recent values is needed. Specifically, even if a task
    is moved between different resource groups while it is sleeping then it
    is only the last move that is relevant but yet a work item is queued
    during each move.

    This unnecessary queueing of work items could result in significant
    system resource waste, especially on tasks sleeping for a long time.
    For example, as demonstrated by Shakeel Butt in [1] writing the same
    task id to the "tasks" file can quickly consume significant memory. The
    same problem (wasted system resources) occurs when moving a task between
    different resource groups.

    As pointed out by Valentin Schneider in [2] there is an additional issue
    with the way in which the queueing of work is done in that the task_struct
    update is currently done after the work is queued, resulting in a race with
    the register update possibly done before the data needed by the update is
    available.

    To solve these issues, update the PQR_ASSOC MSR in a synchronous way
    right after the new closid and rmid are ready during the task movement,
    only if the task is running. If a moved task is not running nothing
    is done since the PQR_ASSOC MSR will be updated next time the task is
    scheduled. This is the same way used to update the register when tasks
    are moved as part of resource group removal.

    [1] https://lore.kernel.org/lkml/CALvZod7E9zzHwenzf7objzGKsdBmVwTgEJ0nPgs0LUFU3SN5Pw@mail.gmail.com/
    [2] https://lore.kernel.org/lkml/20201123022433.17905-1-valentin.schneider@arm.com

    [ bp: Massage commit message and drop the two update_task_closid_rmid()
    variants. ]

    Fixes: e02737d5b826 ("x86/intel_rdt: Add tasks files")
    Reported-by: Shakeel Butt
    Reported-by: Valentin Schneider
    Signed-off-by: Fenghua Yu
    Signed-off-by: Reinette Chatre
    Signed-off-by: Borislav Petkov
    Reviewed-by: Tony Luck
    Reviewed-by: James Morse
    Reviewed-by: Valentin Schneider
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/17aa2fb38fc12ce7bb710106b3e7c7b45acb9e94.1608243147.git.reinette.chatre@intel.com
    Signed-off-by: Greg Kroah-Hartman

    Fenghua Yu
     
  • commit a889ea54b3daa63ee1463dc19ed699407d61458b upstream.

    Many TDP MMU functions which need to perform some action on all TDP MMU
    roots hold a reference on that root so that they can safely drop the MMU
    lock in order to yield to other threads. However, when releasing the
    reference on the root, there is a bug: the root will not be freed even
    if its reference count (root_count) is reduced to 0.

    To simplify acquiring and releasing references on TDP MMU root pages, and
    to ensure that these roots are properly freed, move the get/put operations
    into another TDP MMU root iterator macro.

    Moving the get/put operations into an iterator macro also helps
    simplify control flow when a root does need to be freed. Note that using
    the list_for_each_entry_safe macro would not have been appropriate in
    this situation because it could keep a pointer to the next root across
    an MMU lock release + reacquire, during which time that root could be
    freed.

    Reported-by: Maciej S. Szmigiero
    Suggested-by: Paolo Bonzini
    Fixes: faaf05b00aec ("kvm: x86/mmu: Support zapping SPTEs in the TDP MMU")
    Fixes: 063afacd8730 ("kvm: x86/mmu: Support invalidate range MMU notifier for TDP MMU")
    Fixes: a6a0b05da9f3 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
    Fixes: 14881998566d ("kvm: x86/mmu: Support disabling dirty logging for the tdp MMU")
    Signed-off-by: Ben Gardon
    Message-Id:
    Cc: stable@vger.kernel.org
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Ben Gardon
     
  • commit 88bf56d04bc3564542049ec4ec168a8b60d0b48c upstream.

    In kvm_mmu_notifier_invalidate_range_start(), tlbs_dirty is used as:
    need_tlb_flush |= kvm->tlbs_dirty;
    with need_tlb_flush's type being int and tlbs_dirty's type being long.

    It means that tlbs_dirty is always used as int and the higher 32 bits
    is useless. We need to check tlbs_dirty in a correct way and this
    change checks it directly without propagating it to need_tlb_flush.

    Note: it's _extremely_ unlikely this neglecting of higher 32 bits can
    cause problems in practice. It would require encountering tlbs_dirty
    on a 4 billion count boundary, and KVM would need to be using shadow
    paging or be running a nested guest.

    Cc: stable@vger.kernel.org
    Fixes: a4ee1ca4a36e ("KVM: MMU: delay flush all tlbs on sync_page path")
    Signed-off-by: Lai Jiangshan
    Message-Id:
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Lai Jiangshan
     
  • commit 39b4d43e6003cee51cd119596d3c33d0449eb44c upstream.

    Get the so called "root" level from the low level shadow page table
    walkers instead of manually attempting to calculate it higher up the
    stack, e.g. in get_mmio_spte(). When KVM is using PAE shadow paging,
    the starting level of the walk, from the callers perspective, is not
    the CR3 root but rather the PDPTR "root". Checking for reserved bits
    from the CR3 root causes get_mmio_spte() to consume uninitialized stack
    data due to indexing into sptes[] for a level that was not filled by
    get_walk(). This can result in false positives and/or negatives
    depending on what garbage happens to be on the stack.

    Opportunistically nuke a few extra newlines.

    Fixes: 95fb5b0258b7 ("kvm: x86/mmu: Support MMIO in the TDP MMU")
    Reported-by: Richard Herbert
    Cc: Ben Gardon
    Cc: stable@vger.kernel.org
    Signed-off-by: Sean Christopherson
    Message-Id:
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Sean Christopherson
     
  • commit 2aa078932ff6c66bf10cc5b3144440dbfa7d813d upstream.

    Return -1 from the get_walk() helpers if the shadow walk doesn't fill at
    least one spte, which can theoretically happen if the walk hits a
    not-present PDPTR. Returning the root level in such a case will cause
    get_mmio_spte() to return garbage (uninitialized stack data). In
    practice, such a scenario should be impossible as KVM shouldn't get a
    reserved-bit page fault with a not-present PDPTR.

    Note, using mmu->root_level in get_walk() is wrong for other reasons,
    too, but that's now a moot point.

    Fixes: 95fb5b0258b7 ("kvm: x86/mmu: Support MMIO in the TDP MMU")
    Cc: Ben Gardon
    Cc: stable@vger.kernel.org
    Signed-off-by: Sean Christopherson
    Message-Id:
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Sean Christopherson
     
  • commit d1c5246e08eb64991001d97a3bd119c93edbc79a upstream.

    Commit

    28ee90fe6048 ("x86/mm: implement free pmd/pte page interfaces")

    introduced a new location where a pmd was released, but neglected to
    run the pmd page destructor. In fact, this happened previously for a
    different pmd release path and was fixed by commit:

    c283610e44ec ("x86, mm: do not leak page->ptl for pmd page tables").

    This issue was hidden until recently because the failure mode is silent,
    but commit:

    b2b29d6d0119 ("mm: account PMD tables like PTE tables")

    turns the failure mode into this signature:

    BUG: Bad page state in process lt-pmem-ns pfn:15943d
    page:000000007262ed7b refcount:0 mapcount:-1024 mapping:0000000000000000 index:0x0 pfn:0x15943d
    flags: 0xaffff800000000()
    raw: 00affff800000000 dead000000000100 0000000000000000 0000000000000000
    raw: 0000000000000000 ffff913a029bcc08 00000000fffffbff 0000000000000000
    page dumped because: nonzero mapcount
    [..]
    dump_stack+0x8b/0xb0
    bad_page.cold+0x63/0x94
    free_pcp_prepare+0x224/0x270
    free_unref_page+0x18/0xd0
    pud_free_pmd_page+0x146/0x160
    ioremap_pud_range+0xe3/0x350
    ioremap_page_range+0x108/0x160
    __ioremap_caller.constprop.0+0x174/0x2b0
    ? memremap+0x7a/0x110
    memremap+0x7a/0x110
    devm_memremap+0x53/0xa0
    pmem_attach_disk+0x4ed/0x530 [nd_pmem]
    ? __devm_release_region+0x52/0x80
    nvdimm_bus_probe+0x85/0x210 [libnvdimm]

    Given this is a repeat occurrence it seemed prudent to look for other
    places where this destructor might be missing and whether a better
    helper is needed. try_to_free_pmd_page() looks like a candidate, but
    testing with setting up and tearing down pmd mappings via the dax unit
    tests is thus far not triggering the failure.

    As for a better helper pmd_free() is close, but it is a messy fit
    due to requiring an @mm arg. Also, ___pmd_free_tlb() wants to call
    paravirt_tlb_remove_table() instead of free_page(), so open-coded
    pgtable_pmd_page_dtor() seems the best way forward for now.

    Debugged together with Matthew Wilcox .

    Fixes: 28ee90fe6048 ("x86/mm: implement free pmd/pte page interfaces")
    Signed-off-by: Dan Williams
    Signed-off-by: Borislav Petkov
    Tested-by: Yi Zhang
    Acked-by: Peter Zijlstra (Intel)
    Cc:
    Link: https://lkml.kernel.org/r/160697689204.605323.17629854984697045602.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Dan Williams
     
  • commit c2407cf7d22d0c0d94cf20342b3b8f06f1d904e7 upstream.

    Ever since commit 2a9127fcf229 ("mm: rewrite wait_on_page_bit_common()
    logic") we've had some very occasional reports of BUG_ON(PageWriteback)
    in write_cache_pages(), which we thought we already fixed in commit
    073861ed77b6 ("mm: fix VM_BUG_ON(PageTail) and BUG_ON(PageWriteback)").

    But syzbot just reported another one, even with that commit in place.

    And it turns out that there's a simpler way to trigger the BUG_ON() than
    the one Hugh found with page re-use. It all boils down to the fact that
    the page writeback is ostensibly serialized by the page lock, but that
    isn't actually really true.

    Yes, the people _setting_ writeback all do so under the page lock, but
    the actual clearing of the bit - and waking up any waiters - happens
    without any page lock.

    This gives us this fairly simple race condition:

    CPU1 = end previous writeback
    CPU2 = start new writeback under page lock
    CPU3 = write_cache_pages()

    CPU1 CPU2 CPU3
    ---- ---- ----

    end_page_writeback()
    test_clear_page_writeback(page)
    ... delayed...

    lock_page();
    set_page_writeback()
    unlock_page()

    lock_page()
    wait_on_page_writeback();

    wake_up_page(page, PG_writeback);
    .. wakes up CPU3 ..

    BUG_ON(PageWriteback(page));

    where the BUG_ON() happens because we woke up the PG_writeback bit
    becasue of the _previous_ writeback, but a new one had already been
    started because the clearing of the bit wasn't actually atomic wrt the
    actual wakeup or serialized by the page lock.

    The reason this didn't use to happen was that the old logic in waiting
    on a page bit would just loop if it ever saw the bit set again.

    The nice proper fix would probably be to get rid of the whole "wait for
    writeback to clear, and then set it" logic in the writeback path, and
    replace it with an atomic "wait-to-set" (ie the same as we have for page
    locking: we set the page lock bit with a single "lock_page()", not with
    "wait for lock bit to clear and then set it").

    However, out current model for writeback is that the waiting for the
    writeback bit is done by the generic VFS code (ie write_cache_pages()),
    but the actual setting of the writeback bit is done much later by the
    filesystem ".writepages()" function.

    IOW, to make the writeback bit have that same kind of "wait-to-set"
    behavior as we have for page locking, we'd have to change our roughly
    ~50 different writeback functions. Painful.

    Instead, just make "wait_on_page_writeback()" loop on the very unlikely
    situation that the PG_writeback bit is still set, basically re-instating
    the old behavior. This is very non-optimal in case of contention, but
    since we only ever set the bit under the page lock, that situation is
    controlled.

    Reported-by: syzbot+2fc0712f8f8b8b8fa0ef@syzkaller.appspotmail.com
    Fixes: 2a9127fcf229 ("mm: rewrite wait_on_page_bit_common() logic")
    Acked-by: Hugh Dickins
    Cc: Andrew Morton
    Cc: Matthew Wilcox
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Linus Torvalds
     
  • commit 84e261553e6f919bf0b4d65244599ab2b41f1da5 upstream.

    hwmon, specifically hwmon_num_channel_attrs, expects the config
    array in the hwmon_channel_info structure to be terminated by
    a zero entry. amd_energy does not honor this convention. As
    result, a KASAN warning is possible. Fix this by adding an
    additional entry and setting it to zero.

    Fixes: 8abee9566b7e ("hwmon: Add amd_energy driver to report energy counters")

    Signed-off-by: David Arcari
    Cc: Naveen Krishna Chatradhi
    Cc: Jean Delvare
    Cc: Guenter Roeck
    Cc: linux-kernel@vger.kernel.org
    Cc: stable@vger.kernel.org
    Signed-off-by: David Arcari
    Acked-by: Naveen Krishna Chatradhi
    Link: https://lore.kernel.org/r/20210107144707.6927-1-darcari@redhat.com
    Signed-off-by: Guenter Roeck
    Signed-off-by: Greg Kroah-Hartman

    David Arcari
     
  • Remove an unused variable which was mistakingly left by commit
    37faf5061541 ("USB: serial: keyspan_pda: fix write-wakeup
    use-after-free") and only removed by a later change.

    This is needed to suppress a W=1 warning about the unused variable in
    the stable trees that the build bots triggers.

    Reported-by: kernel test robot
    Signed-off-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Johan Hovold
     
  • commit 64e6bbfff52db4bf6785fab9cffab850b2de6870 upstream.

    There is a use-after-free issue, if access udc_name
    in function gadget_dev_desc_UDC_store after another context
    free udc_name in function unregister_gadget.

    Context 1:
    gadget_dev_desc_UDC_store()->unregister_gadget()->
    free udc_name->set udc_name to NULL

    Context 2:
    gadget_dev_desc_UDC_show()-> access udc_name

    Call trace:
    dump_backtrace+0x0/0x340
    show_stack+0x14/0x1c
    dump_stack+0xe4/0x134
    print_address_description+0x78/0x478
    __kasan_report+0x270/0x2ec
    kasan_report+0x10/0x18
    __asan_report_load1_noabort+0x18/0x20
    string+0xf4/0x138
    vsnprintf+0x428/0x14d0
    sprintf+0xe4/0x12c
    gadget_dev_desc_UDC_show+0x54/0x64
    configfs_read_file+0x210/0x3a0
    __vfs_read+0xf0/0x49c
    vfs_read+0x130/0x2b4
    SyS_read+0x114/0x208
    el0_svc_naked+0x34/0x38

    Add mutex_lock to protect this kind of scenario.

    Signed-off-by: Eddie Hung
    Signed-off-by: Macpaul Lin
    Reviewed-by: Peter Chen
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/1609239215-21819-1-git-send-email-macpaul.lin@mediatek.com
    Signed-off-by: Greg Kroah-Hartman

    Eddie Hung
     
  • commit 6cd0fe91387917be48e91385a572a69dfac2f3f7 upstream.

    When binding the ConfigFS gadget to a UDC, the functions in each
    configuration are added in list order. However, if usb_add_function()
    fails, the failed function is put back on its configuration's
    func_list and purge_configs_funcs() is called to further clean up.

    purge_configs_funcs() iterates over the configurations and functions
    in forward order, calling unbind() on each of the previously added
    functions. But after doing so, each function gets moved to the
    tail of the configuration's func_list. This results in reshuffling
    the original order of the functions within a configuration such
    that the failed function now appears first even though it may have
    originally appeared in the middle or even end of the list. At this
    point if the ConfigFS gadget is attempted to re-bind to the UDC,
    the functions will be added in a different order than intended,
    with the only recourse being to remove and relink the functions all
    over again.

    An example of this as follows:

    ln -s functions/mass_storage.0 configs/c.1
    ln -s functions/ncm.0 configs/c.1
    ln -s functions/ffs.adb configs/c.1 # oops, forgot to start adbd
    echo "" > UDC # fails
    start adbd
    echo "" > UDC # now succeeds, but...
    # bind order is
    # "ADB", mass_storage, ncm

    [30133.118289] configfs-gadget gadget: adding 'Mass Storage Function'/ffffff810af87200 to config 'c'/ffffff817d6a2520
    [30133.119875] configfs-gadget gadget: adding 'cdc_network'/ffffff80f48d1a00 to config 'c'/ffffff817d6a2520
    [30133.119974] using random self ethernet address
    [30133.120002] using random host ethernet address
    [30133.139604] usb0: HOST MAC 3e:27:46:ba:3e:26
    [30133.140015] usb0: MAC 6e:28:7e:42:66:6a
    [30133.140062] configfs-gadget gadget: adding 'Function FS Gadget'/ffffff80f3868438 to config 'c'/ffffff817d6a2520
    [30133.140081] configfs-gadget gadget: adding 'Function FS Gadget'/ffffff80f3868438 --> -19
    [30133.140098] configfs-gadget gadget: unbind function 'Mass Storage Function'/ffffff810af87200
    [30133.140119] configfs-gadget gadget: unbind function 'cdc_network'/ffffff80f48d1a00
    [30133.173201] configfs-gadget a600000.dwc3: failed to start g1: -19
    [30136.661933] init: starting service 'adbd'...
    [30136.700126] read descriptors
    [30136.700413] read strings
    [30138.574484] configfs-gadget gadget: adding 'Function FS Gadget'/ffffff80f3868438 to config 'c'/ffffff817d6a2520
    [30138.575497] configfs-gadget gadget: adding 'Mass Storage Function'/ffffff810af87200 to config 'c'/ffffff817d6a2520
    [30138.575554] configfs-gadget gadget: adding 'cdc_network'/ffffff80f48d1a00 to config 'c'/ffffff817d6a2520
    [30138.575631] using random self ethernet address
    [30138.575660] using random host ethernet address
    [30138.595338] usb0: HOST MAC 2e:cf:43:cd:ca:c8
    [30138.597160] usb0: MAC 6a:f0:9f:ee:82:a0
    [30138.791490] configfs-gadget gadget: super-speed config #1: c

    Fix this by reversing the iteration order of the functions in
    purge_config_funcs() when unbinding them, and adding them back to
    the config's func_list at the head instead of the tail. This
    ensures that we unbind and unwind back to the original list order.

    Fixes: 88af8bbe4ef7 ("usb: gadget: the start of the configfs interface")
    Signed-off-by: Chandana Kishori Chiluveru
    Signed-off-by: Jack Pham
    Reviewed-by: Peter Chen
    Link: https://lore.kernel.org/r/20201229224443.31623-1-jackp@codeaurora.org
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Chandana Kishori Chiluveru
     
  • commit 5cc35c224a80aa5a5a539510ef049faf0d6ed181 upstream.

    There is a spinlock lockup as part of composite_disconnect
    when it tries to acquire cdev->lock as part of usb_gadget_deactivate.
    This is because the usb_gadget_deactivate is called from
    usb_function_deactivate with the same spinlock held.

    This would result in the below call stack and leads to stall.

    rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
    rcu: 3-...0: (1 GPs behind) idle=162/1/0x4000000000000000
    softirq=10819/10819 fqs=2356
    (detected by 2, t=5252 jiffies, g=20129, q=3770)
    Task dump for CPU 3:
    task:uvc-gadget_wlhe state:R running task stack: 0 pid: 674 ppid:
    636 flags:0x00000202
    Call trace:
    __switch_to+0xc0/0x170
    _raw_spin_lock_irqsave+0x84/0xb0
    composite_disconnect+0x28/0x78
    configfs_composite_disconnect+0x68/0x70
    usb_gadget_disconnect+0x10c/0x128
    usb_gadget_deactivate+0xd4/0x108
    usb_function_deactivate+0x6c/0x80
    uvc_function_disconnect+0x20/0x58
    uvc_v4l2_release+0x30/0x88
    v4l2_release+0xbc/0xf0
    __fput+0x7c/0x230
    ____fput+0x14/0x20
    task_work_run+0x88/0x140
    do_notify_resume+0x240/0x6f0
    work_pending+0x8/0x200

    Fix this by doing an unlock on cdev->lock before the usb_gadget_deactivate
    call from usb_function_deactivate.

    The same lockup can happen in the usb_gadget_activate path. Fix that path
    as well.

    Reported-by: Peter Chen
    Link: https://lore.kernel.org/linux-usb/20201102094936.GA29581@b29397-desktop/
    Tested-by: Peter Chen
    Signed-off-by: Sriharsha Allenki
    Cc: stable
    Link: https://lore.kernel.org/r/20201202130220.24926-1-sallenki@codeaurora.org
    Signed-off-by: Greg Kroah-Hartman

    Sriharsha Allenki
     
  • commit c91d3a6bcaa031f551ba29a496a8027b31289464 upstream.

    If usb_otg_descriptor_alloc() failed, it need return ENOMEM.

    Fixes: 578aa8a2b12c ("usb: gadget: acm_ms: allocate and init otg descriptor by otg capabilities")
    Reported-by: Hulk Robot
    Signed-off-by: Yang Yingliang
    Cc: stable
    Link: https://lore.kernel.org/r/20201117092955.4102785-1-yangyingliang@huawei.com
    Signed-off-by: Greg Kroah-Hartman

    Yang Yingliang
     
  • commit 0a88fa221ce911c331bf700d2214c5b2f77414d3 upstream.

    Fix the MTU size issue with RX packet size as the host sends the packet
    with extra bytes containing ethernet header. This causes failure when
    user sets the MTU size to the maximum i.e. 15412. In this case the
    ethernet packet received will be of length 15412 plus the ethernet header
    length. This patch fixes the issue where there is a check that RX packet
    length must not be more than max packet length.

    Fixes: bba787a860fa ("usb: gadget: ether: Allow jumbo frames")
    Signed-off-by: Manish Narani
    Cc: stable
    Link: https://lore.kernel.org/r/1605597215-122027-1-git-send-email-manish.narani@xilinx.com
    Signed-off-by: Greg Kroah-Hartman

    Manish Narani
     
  • commit 2cc332e4ee4febcbb685e2962ad323fe4b3b750a upstream.

    When printer driver is loaded, the printer_func_bind function is called, in
    this function, the interface descriptor be allocated memory, if after that,
    the error occurred, the interface descriptor memory need to be free.

    Reviewed-by: Peter Chen
    Cc:
    Signed-off-by: Zqiang
    Link: https://lore.kernel.org/r/20201210020148.6691-1-qiang.zhang@windriver.com
    Signed-off-by: Greg Kroah-Hartman

    Zqiang
     
  • commit 9389044f27081d6ec77730c36d5bf9a1288bcda2 upstream.

    With commit 913e4a90b6f9 ("usb: gadget: f_uac2: finalize wMaxPacketSize according to bandwidth")
    wMaxPacketSize is computed dynamically but the value is never reset.

    Because of this, the actual maximum packet size can only decrease each time
    the audio gadget is instantiated.

    Reset the endpoint maximum packet size and mark wMaxPacketSize as dynamic
    to solve the problem.

    Fixes: 913e4a90b6f9 ("usb: gadget: f_uac2: finalize wMaxPacketSize according to bandwidth")
    Signed-off-by: Jerome Brunet
    Cc: stable
    Link: https://lore.kernel.org/r/20201221173531.215169-2-jbrunet@baylibre.com
    Signed-off-by: Greg Kroah-Hartman

    Jerome Brunet