Skip to content
  1. Apr 10, 2021
    • Steven Rostedt (VMware)'s avatar
      tracing: Add a vmalloc_sync_mappings() for safe measure · e22b68fb
      Steven Rostedt (VMware) authored
      commit 11f5efc3 upstream
      
      x86_64 lazily maps in the vmalloc pages, and the way this works with per_cpu
      areas can be complex, to say the least. Mappings may happen at boot up, and
      if nothing synchronizes the page tables, those page mappings may not be
      synced till they are used. This causes issues for anything that might touch
      one of those mappings in the path of the page fault handler. When one of
      those unmapped mappings is touched in the page fault handler, it will cause
      another page fault, which in turn will cause a page fault, and leave us in
      a loop of page faults.
      
      Commit 763802b5 ("x86/mm: split vmalloc_sync_all()") split
      vmalloc_sync_all() into vmalloc_sync_unmappings() and
      vmalloc_sync_mappings(), as on system exit, it did not need to do a full
      sync on x86_64 (although it still needed to be done on x86_32). By chance,
      the vmalloc_sync_all() would synchronize the page mappings done at boot up
      and prevent the per cpu area from being a problem for tracing in the page
      fault handler. But when that synchronization in the exit of a task became a
      nop, it caused the problem to appear.
      
      Link: https://lore.kernel.org/r/20200429054857.66e8e333@oasis.local.home
      
      Cc: stable@vger.kernel.org
      Fixes: 737223fb
      
       ("tracing: Consolidate buffer allocation code")
      Reported-by: default avatar"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
      Suggested-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      [sudip: add header]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e22b68fb
    • Miquel Raynal's avatar
      mtd: rawnand: diskonchip: Fix the probe error path · ff6e7a8f
      Miquel Raynal authored
      commit c5be12e4 upstream
      
      Not sure nand_cleanup() is the right function to call here but in any
      case it is not nand_release(). Indeed, even a comment says that
      calling nand_release() is a bit of a hack as there is no MTD device to
      unregister. So switch to nand_cleanup() for now and drop this
      comment.
      
      There is no Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if it did not intruce
      any bug.
      
      Fixes: d44154f9
      
       ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-13-miquel.raynal@bootlin.com
      [sudip: manual backport to old file]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ff6e7a8f
    • Miquel Raynal's avatar
      mtd: rawnand: orion: Fix the probe error path · 80fd3352
      Miquel Raynal authored
      commit be238fbf upstream
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if this commit is not
      introducing any bug.
      
      Fixes: d44154f9
      
       ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-34-miquel.raynal@bootlin.com
      [sudip: manual backport to old file]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      80fd3352
    • Miquel Raynal's avatar
      mtd: rawnand: pasemi: Fix the probe error path · 544ad9cc
      Miquel Raynal authored
      commit f5146690 upstream
      
      nand_cleanup() is supposed to be called on error after a successful
      call to nand_scan() to free all NAND resources.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible, hence pointing it as the commit to
      fix for backporting purposes, even if this commit is not introducing
      any bug.
      
      Fixes: d44154f9
      
       ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-41-miquel.raynal@bootlin.com
      [sudip: manual backport to old file]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      544ad9cc
    • Miquel Raynal's avatar
      mtd: rawnand: plat_nand: Fix the probe error path · 888a397e
      Miquel Raynal authored
      commit 5284024b upstream
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible, hence pointing it as the commit to
      fix for backporting purposes, even if this commit is not introducing
      any bug.
      
      Fixes: d44154f9
      
       ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-43-miquel.raynal@bootlin.com
      [sudip: manual backport to old file]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      888a397e
    • Miquel Raynal's avatar
      mtd: rawnand: sharpsl: Fix the probe error path · 027e6467
      Miquel Raynal authored
      commit 0f44b327 upstream
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense.
      
      Fixes: d44154f9
      
       ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-49-miquel.raynal@bootlin.com
      [sudip: manual backport to old file]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      027e6467
    • Miquel Raynal's avatar
      mtd: rawnand: socrates: Fix the probe error path · 0e668e00
      Miquel Raynal authored
      commit 9c6c2e5c upstream
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if this commit is not
      introducing any bug.
      
      Fixes: d44154f9
      
       ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-51-miquel.raynal@bootlin.com
      [sudip: manual backport to old file]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e668e00
    • Miquel Raynal's avatar
      mtd: rawnand: tmio: Fix the probe error path · 45b24c91
      Miquel Raynal authored
      commit 75e9a330 upstream
      
      nand_release() is supposed be called after MTD device registration.
      Here, only nand_scan() happened, so use nand_cleanup() instead.
      
      There is no real Fixes tag applying here as the use of nand_release()
      in this driver predates by far the introduction of nand_cleanup() in
      commit d44154f9 ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      which makes this change possible. However, pointing this commit as the
      culprit for backporting purposes makes sense even if this commit is not
      introducing any bug.
      
      Fixes: d44154f9
      
       ("mtd: nand: Provide nand_cleanup() function to free NAND related resources")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-57-miquel.raynal@bootlin.com
      [sudip: manual backport to old file]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45b24c91
    • Shih-Yuan Lee (FourDollars)'s avatar
      ALSA: hda/realtek - Fix pincfg for Dell XPS 13 9370 · 5b6d5741
      Shih-Yuan Lee (FourDollars) authored
      commit 8df4b003 upstream
      
      The initial pin configs for Dell headset mode of ALC3271 has changed.
      
      /sys/class/sound/hwC0D0/init_pin_configs: (BIOS 0.1.4)
      0x12 0xb7a60130
      0x13 0xb8a61140
      0x14 0x40000000
      0x16 0x411111f0
      0x17 0x90170110
      0x18 0x411111f0
      0x19 0x411111f0
      0x1a 0x411111f0
      0x1b 0x411111f0
      0x1d 0x4087992d
      0x1e 0x411111f0
      0x21 0x04211020
      
      has changed to ...
      
      /sys/class/sound/hwC0D0/init_pin_configs: (BIOS 0.2.0)
      0x12 0xb7a60130
      0x13 0x40000000
      0x14 0x411111f0
      0x16 0x411111f0
      0x17 0x90170110
      0x18 0x411111f0
      0x19 0x411111f0
      0x1a 0x411111f0
      0x1b 0x411111f0
      0x1d 0x4067992d
      0x1e 0x411111f0
      0x21 0x04211020
      
      Fixes: b4576de8
      
       ("ALSA: hda/realtek - Fix typo of pincfg for Dell quirk")
      Signed-off-by: default avatarShih-Yuan Lee (FourDollars) <sylee@canonical.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5b6d5741
    • Piotr Krysiuk's avatar
      bpf, x86: Validate computation of branch displacements for x86-64 · ca97582a
      Piotr Krysiuk authored
      commit e4d4d456
      
       upstream.
      
      The branch displacement logic in the BPF JIT compilers for x86 assumes
      that, for any generated branch instruction, the distance cannot
      increase between optimization passes.
      
      But this assumption can be violated due to how the distances are
      computed. Specifically, whenever a backward branch is processed in
      do_jit(), the distance is computed by subtracting the positions in the
      machine code from different optimization passes. This is because part
      of addrs[] is already updated for the current optimization pass, before
      the branch instruction is visited.
      
      And so the optimizer can expand blocks of machine code in some cases.
      
      This can confuse the optimizer logic, where it assumes that a fixed
      point has been reached for all machine code blocks once the total
      program size stops changing. And then the JIT compiler can output
      abnormal machine code containing incorrect branch displacements.
      
      To mitigate this issue, we assert that a fixed point is reached while
      populating the output image. This rejects any problematic programs.
      The issue affects both x86-32 and x86-64. We mitigate separately to
      ease backporting.
      
      Signed-off-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Reviewed-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca97582a
    • Vincent Whitchurch's avatar
      cifs: Silently ignore unknown oplock break handle · d2eb2952
      Vincent Whitchurch authored
      [ Upstream commit 219481a8
      
       ]
      
      Make SMB2 not print out an error when an oplock break is received for an
      unknown handle, similar to SMB1.  The debug message which is printed for
      these unknown handles may also be misleading, so fix that too.
      
      The SMB2 lease break path is not affected by this patch.
      
      Without this, a program which writes to a file from one thread, and
      opens, reads, and writes the same file from another thread triggers the
      below errors several times a minute when run against a Samba server
      configured with "smb2 leases = no".
      
       CIFS: VFS: \\192.168.0.1 No task to wake, unknown frame received! NumMids 2
       00000000: 424d53fe 00000040 00000000 00000012  .SMB@...........
       00000010: 00000001 00000000 ffffffff ffffffff  ................
       00000020: 00000000 00000000 00000000 00000000  ................
       00000030: 00000000 00000000 00000000 00000000  ................
      
      Signed-off-by: default avatarVincent Whitchurch <vincent.whitchurch@axis.com>
      Reviewed-by: default avatarTom Talpey <tom@talpey.com>
      Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d2eb2952
    • Ronnie Sahlberg's avatar
      cifs: revalidate mapping when we open files for SMB1 POSIX · 41466e53
      Ronnie Sahlberg authored
      [ Upstream commit cee8f4f6
      
       ]
      
      RHBZ: 1933527
      
      Under SMB1 + POSIX, if an inode is reused on a server after we have read and
      cached a part of a file, when we then open the new file with the
      re-cycled inode there is a chance that we may serve the old data out of cache
      to the application.
      This only happens for SMB1 (deprecated) and when posix are used.
      The simplest solution to avoid this race is to force a revalidate
      on smb1-posix open.
      
      Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      41466e53
    • Sergei Trofimovich's avatar
      ia64: mca: allocate early mca with GFP_ATOMIC · 0fad0c7f
      Sergei Trofimovich authored
      [ Upstream commit f2a419cf
      
       ]
      
      The sleep warning happens at early boot right at secondary CPU
      activation bootup:
      
          smp: Bringing up secondary CPUs ...
          BUG: sleeping function called from invalid context at mm/page_alloc.c:4942
          in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/1
          CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.12.0-rc2-00007-g79e228d0b611-dirty #99
          ..
          Call Trace:
            show_stack+0x90/0xc0
            dump_stack+0x150/0x1c0
            ___might_sleep+0x1c0/0x2a0
            __might_sleep+0xa0/0x160
            __alloc_pages_nodemask+0x1a0/0x600
            alloc_page_interleave+0x30/0x1c0
            alloc_pages_current+0x2c0/0x340
            __get_free_pages+0x30/0xa0
            ia64_mca_cpu_init+0x2d0/0x3a0
            cpu_init+0x8b0/0x1440
            start_secondary+0x60/0x700
            start_ap+0x750/0x780
          Fixed BSP b0 value from CPU 1
      
      As I understand interrupts are not enabled yet and system has a lot of
      memory.  There is little chance to sleep and switch to GFP_ATOMIC should
      be a no-op.
      
      Link: https://lkml.kernel.org/r/20210315085045.204414-1-slyfox@gentoo.org
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0fad0c7f
    • Arnd Bergmann's avatar
      x86/build: Turn off -fcf-protection for realmode targets · db4394a3
      Arnd Bergmann authored
      [ Upstream commit 9fcb51c1
      
       ]
      
      The new Ubuntu GCC packages turn on -fcf-protection globally,
      which causes a build failure in the x86 realmode code:
      
        cc1: error: ‘-fcf-protection’ is not compatible with this target
      
      Turn it off explicitly on compilers that understand this option.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20210323124846.1584944-1-arnd@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      db4394a3
    • Karthikeyan Kathirvel's avatar
      mac80211: choose first enabled channel for monitor · aa86e244
      Karthikeyan Kathirvel authored
      [ Upstream commit 041c881a
      
       ]
      
      Even if the first channel from sband channel list is invalid
      or disabled mac80211 ends up choosing it as the default channel
      for monitor interfaces, making them not usable.
      
      Fix this by assigning the first available valid or enabled
      channel instead.
      
      Signed-off-by: default avatarKarthikeyan Kathirvel <kathirve@codeaurora.org>
      Link: https://lore.kernel.org/r/1615440547-7661-1-git-send-email-kathirve@codeaurora.org
      [reword commit message, comment, code cleanups]
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aa86e244
    • Tong Zhang's avatar
      mISDN: fix crash in fritzpci · 2ae79538
      Tong Zhang authored
      [ Upstream commit a9f81244
      
       ]
      
      setup_fritz() in avmfritz.c might fail with -EIO and in this case the
      isac.type and isac.write_reg is not initialized and remains 0(NULL).
      A subsequent call to isac_release() will dereference isac->write_reg and
      crash.
      
      [    1.737444] BUG: kernel NULL pointer dereference, address: 0000000000000000
      [    1.737809] #PF: supervisor instruction fetch in kernel mode
      [    1.738106] #PF: error_code(0x0010) - not-present page
      [    1.738378] PGD 0 P4D 0
      [    1.738515] Oops: 0010 [#1] SMP NOPTI
      [    1.738711] CPU: 0 PID: 180 Comm: systemd-udevd Not tainted 5.12.0-rc2+ #78
      [    1.739077] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-48-gd9c812dda519-p
      rebuilt.qemu.org 04/01/2014
      [    1.739664] RIP: 0010:0x0
      [    1.739807] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
      [    1.740200] RSP: 0018:ffffc9000027ba10 EFLAGS: 00010202
      [    1.740478] RAX: 0000000000000000 RBX: ffff888102f41840 RCX: 0000000000000027
      [    1.740853] RDX: 00000000000000ff RSI: 0000000000000020 RDI: ffff888102f41800
      [    1.741226] RBP: ffffc9000027ba20 R08: ffff88817bc18440 R09: ffffc9000027b808
      [    1.741600] R10: 0000000000000001 R11: 0000000000000001 R12: ffff888102f41840
      [    1.741976] R13: 00000000fffffffb R14: ffff888102f41800 R15: ffff8881008b0000
      [    1.742351] FS:  00007fda3a38a8c0(0000) GS:ffff88817bc00000(0000) knlGS:0000000000000000
      [    1.742774] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    1.743076] CR2: ffffffffffffffd6 CR3: 00000001021ec000 CR4: 00000000000006f0
      [    1.743452] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [    1.743828] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [    1.744206] Call Trace:
      [    1.744339]  isac_release+0xcc/0xe0 [mISDNipac]
      [    1.744582]  fritzpci_probe.cold+0x282/0x739 [avmfritz]
      [    1.744861]  local_pci_probe+0x48/0x80
      [    1.745063]  pci_device_probe+0x10f/0x1c0
      [    1.745278]  really_probe+0xfb/0x420
      [    1.745471]  driver_probe_device+0xe9/0x160
      [    1.745693]  device_driver_attach+0x5d/0x70
      [    1.745917]  __driver_attach+0x8f/0x150
      [    1.746123]  ? device_driver_attach+0x70/0x70
      [    1.746354]  bus_for_each_dev+0x7e/0xc0
      [    1.746560]  driver_attach+0x1e/0x20
      [    1.746751]  bus_add_driver+0x152/0x1f0
      [    1.746957]  driver_register+0x74/0xd0
      [    1.747157]  ? 0xffffffffc00d8000
      [    1.747334]  __pci_register_driver+0x54/0x60
      [    1.747562]  AVM_init+0x36/0x1000 [avmfritz]
      [    1.747791]  do_one_initcall+0x48/0x1d0
      [    1.747997]  ? __cond_resched+0x19/0x30
      [    1.748206]  ? kmem_cache_alloc_trace+0x390/0x440
      [    1.748458]  ? do_init_module+0x28/0x250
      [    1.748669]  do_init_module+0x62/0x250
      [    1.748870]  load_module+0x23ee/0x26a0
      [    1.749073]  __do_sys_finit_module+0xc2/0x120
      [    1.749307]  ? __do_sys_finit_module+0xc2/0x120
      [    1.749549]  __x64_sys_finit_module+0x1a/0x20
      [    1.749782]  do_syscall_64+0x38/0x90
      
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2ae79538
    • Pavel Andrianov's avatar
      net: pxa168_eth: Fix a potential data race in pxa168_eth_remove · 48e2623e
      Pavel Andrianov authored
      [ Upstream commit 0571a753
      
       ]
      
      pxa168_eth_remove() firstly calls unregister_netdev(),
      then cancels a timeout work. unregister_netdev() shuts down a device
      interface and removes it from the kernel tables. If the timeout occurs
      in parallel, the timeout work (pxa168_eth_tx_timeout_task) performs stop
      and open of the device. It may lead to an inconsistent state and memory
      leaks.
      
      Found by Linux Driver Verification project (linuxtesting.org).
      
      Signed-off-by: default avatarPavel Andrianov <andrianov@ispras.ru>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      48e2623e
  2. Apr 07, 2021
    • Greg Kroah-Hartman's avatar
      Linux 4.4.265 · a0c64682
      Greg Kroah-Hartman authored
      
      
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarJason Self <jason@bluehome.net>
      Tested-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Link: https://lore.kernel.org/r/20210405085017.012074144@linuxfoundation.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.4.265
      a0c64682
    • Atul Gopinathan's avatar
      staging: rtl8192e: Change state information from u16 to u8 · 42521bf4
      Atul Gopinathan authored
      commit e78836ae upstream.
      
      The "u16 CcxRmState[2];" array field in struct "rtllib_network" has 4
      bytes in total while the operations performed on this array through-out
      the code base are only 2 bytes.
      
      The "CcxRmState" field is fed only 2 bytes of data using memcpy():
      
      (In rtllib_rx.c:1972)
      	memcpy(network->CcxRmState, &info_element->data[4], 2)
      
      With "info_element->data[]" being a u8 array, if 2 bytes are written
      into "CcxRmState" (whose one element is u16 size), then the 2 u8
      elements from "data[]" gets squashed and written into the first element
      ("CcxRmState[0]") while the second element ("CcxRmState[1]") is never
      fed with any data.
      
      Same in file rtllib_rx.c:2522:
      	 memcpy(dst->CcxRmState, src->CcxRmState, 2);
      
      The above line duplicates "src" data to "dst" but only writes 2 bytes
      (and not 4, which is the actual size). Again, only 1st element gets the
      value while the 2nd element remains uninitialized.
      
      This later makes operations done with CcxRmState unpredictable in the
      following lines as the 1st element is having a squashed number while the
      2nd element is having an uninitialized random number.
      
      rtllib_rx.c:1973:    if (network->CcxRmState[0] != 0)
      rtllib_rx.c:1977:    network->MBssidMask = network->CcxRmState[1] & 0x07;
      
      network->MBssidMask is also of type u8 and not u16.
      
      Fix this by changing the type of "CcxRmState" from u16 to u8 so that the
      data written into this array and read from it make sense and are not
      random values.
      
      NOTE: The wrong initialization of "CcxRmState" can be seen in the
      following commit:
      
      commit ecdfa446 ("Staging: add Realtek 8192 PCI wireless driver")
      
      The above commit created a file `rtl8192e/ieee80211.h` which used to
      have the faulty line. The file has been deleted (or possibly renamed)
      with the contents copied in to a new file `rtl8192e/rtllib.h` along with
      additional code in the commit 94a79942 (tagged in Fixes).
      
      Fixes: 94a79942
      
       ("From: wlanfae <wlanfae@realtek.com> [PATCH 1/8] rtl8192e: Import new version of driver from realtek")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAtul Gopinathan <atulgopinathan@gmail.com>
      Link: https://lore.kernel.org/r/20210323113413.29179-2-atulgopinathan@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      42521bf4
    • Atul Gopinathan's avatar
      staging: rtl8192e: Fix incorrect source in memcpy() · 1b404b9a
      Atul Gopinathan authored
      commit 72ad25fb upstream.
      
      The variable "info_element" is of the following type:
      
      	struct rtllib_info_element *info_element
      
      defined in drivers/staging/rtl8192e/rtllib.h:
      
      	struct rtllib_info_element {
      		u8 id;
      		u8 len;
      		u8 data[];
      	} __packed;
      
      The "len" field defines the size of the "data[]" array. The code is
      supposed to check if "info_element->len" is greater than 4 and later
      equal to 6. If this is satisfied then, the last two bytes (the 4th and
      5th element of u8 "data[]" array) are copied into "network->CcxRmState".
      
      Right now the code uses "memcpy()" with the source as "&info_element[4]"
      which would copy in wrong and unintended information. The struct
      "rtllib_info_element" has a size of 2 bytes for "id" and "len",
      therefore indexing will be done in interval of 2 bytes. So,
      "info_element[4]" would point to data which is beyond the memory
      allocated for this pointer (that is, at x+8, while "info_element" has
      been allocated only from x to x+7 (2 + 6 => 8 bytes)).
      
      This patch rectifies this error by using "&info_element->data[4]" which
      correctly copies the last two bytes of "data[]".
      
      NOTE: The faulty line of code came from the following commit:
      
      commit ecdfa446 ("Staging: add Realtek 8192 PCI wireless driver")
      
      The above commit created the file `rtl8192e/ieee80211/ieee80211_rx.c`
      which had the faulty line of code. This file has been deleted (or
      possibly renamed) with the contents copied in to a new file
      `rtl8192e/rtllib_rx.c` along with additional code in the commit
      94a79942 (tagged in Fixes).
      
      Fixes: 94a79942
      
       ("From: wlanfae <wlanfae@realtek.com> [PATCH 1/8] rtl8192e: Import new version of driver from realtek")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAtul Gopinathan <atulgopinathan@gmail.com>
      Link: https://lore.kernel.org/r/20210323113413.29179-1-atulgopinathan@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1b404b9a
    • Johan Hovold's avatar
      USB: cdc-acm: fix use-after-free after probe failure · 1f39a43e
      Johan Hovold authored
      commit 4e49bf37 upstream.
      
      If tty-device registration fails the driver would fail to release the
      data interface. When the device is later disconnected, the disconnect
      callback would still be called for the data interface and would go about
      releasing already freed resources.
      
      Fixes: c93d8195
      
       ("usb: cdc-acm: fix error handling in acm_probe()")
      Cc: stable@vger.kernel.org      # 3.9
      Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>
      Acked-by: default avatarOliver Neukum <oneukum@suse.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20210322155318.9837-3-johan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f39a43e
    • Oliver Neukum's avatar
      USB: cdc-acm: downgrade message to debug · 8e422c16
      Oliver Neukum authored
      commit e4c77070
      
       upstream.
      
      This failure is so common that logging an error here amounts
      to spamming log files.
      
      Reviewed-by: default avatarBruno Thomsen <bruno.thomsen@gmail.com>
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210311130126.15972-2-oneukum@suse.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e422c16
    • Oliver Neukum's avatar
      cdc-acm: fix BREAK rx code path adding necessary calls · 6a51b1e5
      Oliver Neukum authored
      commit 08dff274 upstream.
      
      Counting break events is nice but we should actually report them to
      the tty layer.
      
      Fixes: 5a6a62bd
      
       ("cdc-acm: add TIOCMIWAIT")
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Link: https://lore.kernel.org/r/20210311133714.31881-1-oneukum@suse.com
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a51b1e5
    • Vincent Palatin's avatar
      USB: quirks: ignore remote wake-up on Fibocom L850-GL LTE modem · 7c5ac98e
      Vincent Palatin authored
      commit 0bd86049
      
       upstream.
      
      This LTE modem (M.2 card) has a bug in its power management:
      there is some kind of race condition for U3 wake-up between the host and
      the device. The modem firmware sometimes crashes/locks when both events
      happen at the same time and the modem fully drops off the USB bus (and
      sometimes re-enumerates, sometimes just gets stuck until the next
      reboot).
      
      Tested with the modem wired to the XHCI controller on an AMD 3015Ce
      platform. Without the patch, the modem dropped of the USB bus 5 times in
      3 days. With the quirk, it stayed connected for a week while the
      'runtime_suspended_time' counter incremented as excepted.
      
      Signed-off-by: default avatarVincent Palatin <vpalatin@chromium.org>
      Link: https://lore.kernel.org/r/20210319124802.2315195-1-vpalatin@chromium.org
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c5ac98e
    • Zheyu Ma's avatar
      firewire: nosy: Fix a use-after-free bug in nosy_ioctl() · 63d8737a
      Zheyu Ma authored
      [ Upstream commit 829933ef
      
       ]
      
      For each device, the nosy driver allocates a pcilynx structure.
      A use-after-free might happen in the following scenario:
      
       1. Open nosy device for the first time and call ioctl with command
          NOSY_IOC_START, then a new client A will be malloced and added to
          doubly linked list.
       2. Open nosy device for the second time and call ioctl with command
          NOSY_IOC_START, then a new client B will be malloced and added to
          doubly linked list.
       3. Call ioctl with command NOSY_IOC_START for client A, then client A
          will be readded to the doubly linked list. Now the doubly linked
          list is messed up.
       4. Close the first nosy device and nosy_release will be called. In
          nosy_release, client A will be unlinked and freed.
       5. Close the second nosy device, and client A will be referenced,
          resulting in UAF.
      
      The root cause of this bug is that the element in the doubly linked list
      is reentered into the list.
      
      Fix this bug by adding a check before inserting a client.  If a client
      is already in the linked list, don't insert it.
      
      The following KASAN report reveals it:
      
         BUG: KASAN: use-after-free in nosy_release+0x1ea/0x210
         Write of size 8 at addr ffff888102ad7360 by task poc
         CPU: 3 PID: 337 Comm: poc Not tainted 5.12.0-rc5+ #6
         Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
         Call Trace:
           nosy_release+0x1ea/0x210
           __fput+0x1e2/0x840
           task_work_run+0xe8/0x180
           exit_to_user_mode_prepare+0x114/0x120
           syscall_exit_to_user_mode+0x1d/0x40
           entry_SYSCALL_64_after_hwframe+0x44/0xae
      
         Allocated by task 337:
           nosy_open+0x154/0x4d0
           misc_open+0x2ec/0x410
           chrdev_open+0x20d/0x5a0
           do_dentry_open+0x40f/0xe80
           path_openat+0x1cf9/0x37b0
           do_filp_open+0x16d/0x390
           do_sys_openat2+0x11d/0x360
           __x64_sys_open+0xfd/0x1a0
           do_syscall_64+0x33/0x40
           entry_SYSCALL_64_after_hwframe+0x44/0xae
      
         Freed by task 337:
           kfree+0x8f/0x210
           nosy_release+0x158/0x210
           __fput+0x1e2/0x840
           task_work_run+0xe8/0x180
           exit_to_user_mode_prepare+0x114/0x120
           syscall_exit_to_user_mode+0x1d/0x40
           entry_SYSCALL_64_after_hwframe+0x44/0xae
      
         The buggy address belongs to the object at ffff888102ad7300 which belongs to the cache kmalloc-128 of size 128
         The buggy address is located 96 bytes inside of 128-byte region [ffff888102ad7300, ffff888102ad7380)
      
      [ Modified to use 'list_empty()' inside proper lock  - Linus ]
      
      Link: https://lore.kernel.org/lkml/1617433116-5930-1-git-send-email-zheyuma97@gmail.com/
      Reported-and-tested-by: default avatar马哲宇 (Zheyu Ma) <zheyuma97@gmail.com>
      Signed-off-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      Cc: Greg Kroah-Hartman <greg@kroah.com>
      Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      63d8737a
    • Dinghao Liu's avatar
      extcon: Fix error handling in extcon_dev_register · 7283a33f
      Dinghao Liu authored
      [ Upstream commit d3bdd1c3 ]
      
      When devm_kcalloc() fails, we should execute device_unregister()
      to unregister edev->dev from system.
      
      Fixes: 046050f6
      
       ("extcon: Update the prototype of extcon_register_notifier() with enum extcon")
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7283a33f
    • Wang Panzhenzhuan's avatar
      pinctrl: rockchip: fix restore error in resume · 7e9ed17a
      Wang Panzhenzhuan authored
      commit c971af25 upstream.
      
      The restore in resume should match to suspend which only set for RK3288
      SoCs pinctrl.
      
      Fixes: 8dca9331
      
       ("pinctrl: rockchip: save and restore gpio6_c6 pinmux in suspend/resume")
      Reviewed-by: default avatarJianqun Xu <jay.xu@rock-chips.com>
      Reviewed-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarWang Panzhenzhuan <randy.wang@rock-chips.com>
      Signed-off-by: default avatarJianqun Xu <jay.xu@rock-chips.com>
      Link: https://lore.kernel.org/r/20210223100725.269240-1-jay.xu@rock-chips.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e9ed17a
    • Tetsuo Handa's avatar
      reiserfs: update reiserfs_xattrs_initialized() condition · 9b5869d9
      Tetsuo Handa authored
      commit 5e46d1b7 upstream.
      
      syzbot is reporting NULL pointer dereference at reiserfs_security_init()
      [1], for commit ab17c4f0 ("reiserfs: fixup xattr_root caching")
      is assuming that REISERFS_SB(s)->xattr_root != NULL in
      reiserfs_xattr_jcreate_nblocks() despite that commit made
      REISERFS_SB(sb)->priv_root != NULL && REISERFS_SB(s)->xattr_root == NULL
      case possible.
      
      I guess that commit 6cb4aff0
      
       ("reiserfs: fix oops while creating
      privroot with selinux enabled") wanted to check xattr_root != NULL
      before reiserfs_xattr_jcreate_nblocks(), for the changelog is talking
      about the xattr root.
      
        The issue is that while creating the privroot during mount
        reiserfs_security_init calls reiserfs_xattr_jcreate_nblocks which
        dereferences the xattr root. The xattr root doesn't exist, so we get
        an oops.
      
      Therefore, update reiserfs_xattrs_initialized() to check both the
      privroot and the xattr root.
      
      Link: https://syzkaller.appspot.com/bug?id=8abaedbdeb32c861dc5340544284167dd0e46cde # [1]
      Reported-and-tested-by: default avatarsyzbot <syzbot+690cb1e51970435f9775@syzkaller.appspotmail.com>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Fixes: 6cb4aff0
      
       ("reiserfs: fix oops while creating privroot with selinux enabled")
      Acked-by: default avatarJeff Mahoney <jeffm@suse.com>
      Acked-by: default avatarJan Kara <jack@suse.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9b5869d9
    • Ilya Lipnitskiy's avatar
      mm: fix race by making init_zero_pfn() early_initcall · c7f00219
      Ilya Lipnitskiy authored
      commit e720e7d0
      
       upstream.
      
      There are code paths that rely on zero_pfn to be fully initialized
      before core_initcall.  For example, wq_sysfs_init() is a core_initcall
      function that eventually results in a call to kernel_execve, which
      causes a page fault with a subsequent mmput.  If zero_pfn is not
      initialized by then it may not get cleaned up properly and result in an
      error:
      
        BUG: Bad rss-counter state mm:(ptrval) type:MM_ANONPAGES val:1
      
      Here is an analysis of the race as seen on a MIPS device. On this
      particular MT7621 device (Ubiquiti ER-X), zero_pfn is PFN 0 until
      initialized, at which point it becomes PFN 5120:
      
        1. wq_sysfs_init calls into kobject_uevent_env at core_initcall:
             kobject_uevent_env+0x7e4/0x7ec
             kset_register+0x68/0x88
             bus_register+0xdc/0x34c
             subsys_virtual_register+0x34/0x78
             wq_sysfs_init+0x1c/0x4c
             do_one_initcall+0x50/0x1a8
             kernel_init_freeable+0x230/0x2c8
             kernel_init+0x10/0x100
             ret_from_kernel_thread+0x14/0x1c
      
        2. kobject_uevent_env() calls call_usermodehelper_exec() which executes
           kernel_execve asynchronously.
      
        3. Memory allocations in kernel_execve cause a page fault, bumping the
           MM reference counter:
             add_mm_counter_fast+0xb4/0xc0
             handle_mm_fault+0x6e4/0xea0
             __get_user_pages.part.78+0x190/0x37c
             __get_user_pages_remote+0x128/0x360
             get_arg_page+0x34/0xa0
             copy_string_kernel+0x194/0x2a4
             kernel_execve+0x11c/0x298
             call_usermodehelper_exec_async+0x114/0x194
      
        4. In case zero_pfn has not been initialized yet, zap_pte_range does
           not decrement the MM_ANONPAGES RSS counter and the BUG message is
           triggered shortly afterwards when __mmdrop checks the ref counters:
             __mmdrop+0x98/0x1d0
             free_bprm+0x44/0x118
             kernel_execve+0x160/0x1d8
             call_usermodehelper_exec_async+0x114/0x194
             ret_from_kernel_thread+0x14/0x1c
      
      To avoid races such as described above, initialize init_zero_pfn at
      early_initcall level.  Depending on the architecture, ZERO_PAGE is
      either constant or gets initialized even earlier, at paging_init, so
      there is no issue with initializing zero_pfn earlier.
      
      Link: https://lkml.kernel.org/r/CALCv0x2YqOXEAy2Q=hafjhHCtTHVodChv1qpM=niAXOpqEbt7w@mail.gmail.com
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: stable@vger.kernel.org
      Tested-by: default avatar周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c7f00219
    • Steven Rostedt (VMware)'s avatar
      tracing: Fix stack trace event size · 229371ca
      Steven Rostedt (VMware) authored
      commit 9deb193a upstream.
      
      Commit cbc3b92c fixed an issue to modify the macros of the stack trace
      event so that user space could parse it properly. Originally the stack
      trace format to user space showed that the called stack was a dynamic
      array. But it is not actually a dynamic array, in the way that other
      dynamic event arrays worked, and this broke user space parsing for it. The
      update was to make the array look to have 8 entries in it. Helper
      functions were added to make it parse it correctly, as the stack was
      dynamic, but was determined by the size of the event stored.
      
      Although this fixed user space on how it read the event, it changed the
      internal structure used for the stack trace event. It changed the array
      size from [0] to [8] (added 8 entries). This increased the size of the
      stack trace event by 8 words. The size reserved on the ring buffer was the
      size of the stack trace event plus the number of stack entries found in
      the stack trace. That commit caused the amount to be 8 more than what was
      needed because it did not expect the caller field to have any size. This
      produced 8 entries of garbage (and reading random data) from the stack
      trace event:
      
                <idle>-0       [002] d... 1976396.837549: <stack trace>
       => trace_event_raw_event_sched_switch
       => __traceiter_sched_switch
       => __schedule
       => schedule_idle
       => do_idle
       => cpu_startup_entry
       => secondary_startup_64_no_verify
       => 0xc8c5e150ffff93de
       => 0xffff93de
       => 0
       => 0
       => 0xc8c5e17800000000
       => 0x1f30affff93de
       => 0x00000004
       => 0x200000000
      
      Instead, subtract the size of the caller field from the size of the event
      to make sure that only the amount needed to store the stack trace is
      reserved.
      
      Link: https://lore.kernel.org/lkml/your-ad-here.call-01617191565-ext-9692@work.hours/
      
      Cc: stable@vger.kernel.org
      Fixes: cbc3b92c
      
       ("tracing: Set kernel_stack's caller size properly")
      Reported-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Tested-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Acked-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      229371ca
    • Hui Wang's avatar
      ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook · 1e1aa602
      Hui Wang authored
      commit e54f30be
      
       upstream.
      
      We found the alc_update_headset_mode() is not called on some machines
      when unplugging the headset, as a result, the mode of the
      ALC_HEADSET_MODE_UNPLUGGED can't be set, then the current_headset_type
      is not cleared, if users plug a differnt type of headset next time,
      the determine_headset_type() will not be called and the audio jack is
      set to the headset type of previous time.
      
      On the Dell machines which connect the dmic to the PCH, if we open
      the gnome-sound-setting and unplug the headset, this issue will
      happen. Those machines disable the auto-mute by ucm and has no
      internal mic in the input source, so the update_headset_mode() will
      not be called by cap_sync_hook or automute_hook when unplugging, and
      because the gnome-sound-setting is opened, the codec will not enter
      the runtime_suspend state, so the update_headset_mode() will not be
      called by alc_resume when unplugging. In this case the
      hp_automute_hook is called when unplugging, so add
      update_headset_mode() calling to this function.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarHui Wang <hui.wang@canonical.com>
      Link: https://lore.kernel.org/r/20210320091542.6748-2-hui.wang@canonical.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1e1aa602
    • Ikjoon Jang's avatar
      ALSA: usb-audio: Apply sample rate quirk to Logitech Connect · 37e8402d
      Ikjoon Jang authored
      commit 625bd5a6
      
       upstream.
      
      Logitech ConferenceCam Connect is a compound USB device with UVC and
      UAC. Not 100% reproducible but sometimes it keeps responding STALL to
      every control transfer once it receives get_freq request.
      
      This patch adds 046d:0x084c to a snd_usb_get_sample_rate_quirk list.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203419
      Signed-off-by: default avatarIkjoon Jang <ikjn@chromium.org>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210324105153.2322881-1-ikjn@chromium.org
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      37e8402d
    • Tong Zhang's avatar
      net: wan/lmc: unregister device when no matching device is found · 9fcfaafb
      Tong Zhang authored
      [ Upstream commit 62e69bc4
      
       ]
      
      lmc set sc->lmc_media pointer when there is a matching device.
      However, when no matching device is found, this pointer is NULL
      and the following dereference will result in a null-ptr-deref.
      
      To fix this issue, unregister the hdlc device and return an error.
      
      [    4.569359] BUG: KASAN: null-ptr-deref in lmc_init_one.cold+0x2b6/0x55d [lmc]
      [    4.569748] Read of size 8 at addr 0000000000000008 by task modprobe/95
      [    4.570102]
      [    4.570187] CPU: 0 PID: 95 Comm: modprobe Not tainted 5.11.0-rc7 #94
      [    4.570527] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-48-gd9c812dda519-preb4
      [    4.571125] Call Trace:
      [    4.571261]  dump_stack+0x7d/0xa3
      [    4.571445]  kasan_report.cold+0x10c/0x10e
      [    4.571667]  ? lmc_init_one.cold+0x2b6/0x55d [lmc]
      [    4.571932]  lmc_init_one.cold+0x2b6/0x55d [lmc]
      [    4.572186]  ? lmc_mii_readreg+0xa0/0xa0 [lmc]
      [    4.572432]  local_pci_probe+0x6f/0xb0
      [    4.572639]  pci_device_probe+0x171/0x240
      [    4.572857]  ? pci_device_remove+0xe0/0xe0
      [    4.573080]  ? kernfs_create_link+0xb6/0x110
      [    4.573315]  ? sysfs_do_create_link_sd.isra.0+0x76/0xe0
      [    4.573598]  really_probe+0x161/0x420
      [    4.573799]  driver_probe_device+0x6d/0xd0
      [    4.574022]  device_driver_attach+0x82/0x90
      [    4.574249]  ? device_driver_attach+0x90/0x90
      [    4.574485]  __driver_attach+0x60/0x100
      [    4.574694]  ? device_driver_attach+0x90/0x90
      [    4.574931]  bus_for_each_dev+0xe1/0x140
      [    4.575146]  ? subsys_dev_iter_exit+0x10/0x10
      [    4.575387]  ? klist_node_init+0x61/0x80
      [    4.575602]  bus_add_driver+0x254/0x2a0
      [    4.575812]  driver_register+0xd3/0x150
      [    4.576021]  ? 0xffffffffc0018000
      [    4.576202]  do_one_initcall+0x84/0x250
      [    4.576411]  ? trace_event_raw_event_initcall_finish+0x150/0x150
      [    4.576733]  ? unpoison_range+0xf/0x30
      [    4.576938]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    4.577219]  ? unpoison_range+0xf/0x30
      [    4.577423]  ? unpoison_range+0xf/0x30
      [    4.577628]  do_init_module+0xf8/0x350
      [    4.577833]  load_module+0x3fe6/0x4340
      [    4.578038]  ? vm_unmap_ram+0x1d0/0x1d0
      [    4.578247]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    4.578526]  ? module_frob_arch_sections+0x20/0x20
      [    4.578787]  ? __do_sys_finit_module+0x108/0x170
      [    4.579037]  __do_sys_finit_module+0x108/0x170
      [    4.579278]  ? __ia32_sys_init_module+0x40/0x40
      [    4.579523]  ? file_open_root+0x200/0x200
      [    4.579742]  ? do_sys_open+0x85/0xe0
      [    4.579938]  ? filp_open+0x50/0x50
      [    4.580125]  ? exit_to_user_mode_prepare+0xfc/0x130
      [    4.580390]  do_syscall_64+0x33/0x40
      [    4.580586]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [    4.580859] RIP: 0033:0x7f1a724c3cf7
      [    4.581054] Code: 48 89 57 30 48 8b 04 24 48 89 47 38 e9 1d a0 02 00 48 89 f8 48 89 f7 48 89 d6 48 891
      [    4.582043] RSP: 002b:00007fff44941c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
      [    4.582447] RAX: ffffffffffffffda RBX: 00000000012ada70 RCX: 00007f1a724c3cf7
      [    4.582827] RDX: 0000000000000000 RSI: 00000000012ac9e0 RDI: 0000000000000003
      [    4.583207] RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000001
      [    4.583587] R10: 00007f1a72527300 R11: 0000000000000246 R12: 00000000012ac9e0
      [    4.583968] R13: 0000000000000000 R14: 00000000012acc90 R15: 0000000000000001
      [    4.584349] ==================================================================
      
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9fcfaafb
    • Doug Brown's avatar
      appletalk: Fix skb allocation size in loopback case · 5d44e600
      Doug Brown authored
      [ Upstream commit 39935dcc
      
       ]
      
      If a DDP broadcast packet is sent out to a non-gateway target, it is
      also looped back. There is a potential for the loopback device to have a
      longer hardware header length than the original target route's device,
      which can result in the skb not being created with enough room for the
      loopback device's hardware header. This patch fixes the issue by
      determining that a loopback will be necessary prior to allocating the
      skb, and if so, ensuring the skb has enough room.
      
      This was discovered while testing a new driver that creates a LocalTalk
      network interface (LTALK_HLEN = 1). It caused an skb_under_panic.
      
      Signed-off-by: default avatarDoug Brown <doug@schmorgal.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5d44e600
    • zhangyi (F)'s avatar
      ext4: do not iput inode under running transaction in ext4_rename() · 2fc8ce56
      zhangyi (F) authored
      [ Upstream commit 5dccdc5a ]
      
      In ext4_rename(), when RENAME_WHITEOUT failed to add new entry into
      directory, it ends up dropping new created whiteout inode under the
      running transaction. After commit <9b88f9fb
      
      > ("ext4: Do not iput inode
      under running transaction"), we follow the assumptions that evict() does
      not get called from a transaction context but in ext4_rename() it breaks
      this suggestion. Although it's not a real problem, better to obey it, so
      this patch add inode to orphan list and stop transaction before final
      iput().
      
      Signed-off-by: default avatarzhangyi (F) <yi.zhang@huawei.com>
      Link: https://lore.kernel.org/r/20210303131703.330415-2-yi.zhang@huawei.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2fc8ce56
    • Tong Zhang's avatar
      staging: comedi: cb_pcidas64: fix request_irq() warn · ce3a1192
      Tong Zhang authored
      [ Upstream commit d2d106fe
      
       ]
      
      request_irq() wont accept a name which contains slash so we need to
      repalce it with something else -- otherwise it will trigger a warning
      and the entry in /proc/irq/ will not be created
      since the .name might be used by userspace and we don't want to break
      userspace, so we are changing the parameters passed to request_irq()
      
      [    1.565966] name 'pci-das6402/16'
      [    1.566149] WARNING: CPU: 0 PID: 184 at fs/proc/generic.c:180 __xlate_proc_name+0x93/0xb0
      [    1.568923] RIP: 0010:__xlate_proc_name+0x93/0xb0
      [    1.574200] Call Trace:
      [    1.574722]  proc_mkdir+0x18/0x20
      [    1.576629]  request_threaded_irq+0xfe/0x160
      [    1.576859]  auto_attach+0x60a/0xc40 [cb_pcidas64]
      
      Suggested-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Link: https://lore.kernel.org/r/20210315195814.4692-1-ztong0001@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ce3a1192
    • Tong Zhang's avatar
      staging: comedi: cb_pcidas: fix request_irq() warn · 8cade52f
      Tong Zhang authored
      [ Upstream commit 2e5848a3
      
       ]
      
      request_irq() wont accept a name which contains slash so we need to
      repalce it with something else -- otherwise it will trigger a warning
      and the entry in /proc/irq/ will not be created
      since the .name might be used by userspace and we don't want to break
      userspace, so we are changing the parameters passed to request_irq()
      
      [    1.630764] name 'pci-das1602/16'
      [    1.630950] WARNING: CPU: 0 PID: 181 at fs/proc/generic.c:180 __xlate_proc_name+0x93/0xb0
      [    1.634009] RIP: 0010:__xlate_proc_name+0x93/0xb0
      [    1.639441] Call Trace:
      [    1.639976]  proc_mkdir+0x18/0x20
      [    1.641946]  request_threaded_irq+0xfe/0x160
      [    1.642186]  cb_pcidas_auto_attach+0xf4/0x610 [cb_pcidas]
      
      Suggested-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Link: https://lore.kernel.org/r/20210315195914.4801-1-ztong0001@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8cade52f
    • Alexey Dobriyan's avatar
      scsi: qla2xxx: Fix broken #endif placement · 862caeb2
      Alexey Dobriyan authored
      [ Upstream commit 5999b9e5
      
       ]
      
      Only half of the file is under include guard because terminating #endif
      is placed too early.
      
      Link: https://lore.kernel.org/r/YE4snvoW1SuwcXAn@localhost.localdomain
      Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      862caeb2
    • Lv Yunlong's avatar
      scsi: st: Fix a use after free in st_open() · 9ccfca0f
      Lv Yunlong authored
      [ Upstream commit c8c165de
      
       ]
      
      In st_open(), if STp->in_use is true, STp will be freed by
      scsi_tape_put(). However, STp is still used by DEBC_printk() after. It is
      better to DEBC_printk() before scsi_tape_put().
      
      Link: https://lore.kernel.org/r/20210311064636.10522-1-lyl2019@mail.ustc.edu.cn
      Acked-by: default avatarKai Mäkisara <kai.makisara@kolumbus.fi>
      Signed-off-by: default avatarLv Yunlong <lyl2019@mail.ustc.edu.cn>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9ccfca0f
    • Benjamin Rood's avatar
      ASoC: sgtl5000: set DAP_AVC_CTRL register to correct default value on probe · 97fe6ebe
      Benjamin Rood authored
      [ Upstream commit f86f58e3
      
       ]
      
      According to the SGTL5000 datasheet [1], the DAP_AVC_CTRL register has
      the following bit field definitions:
      
      | BITS  | FIELD       | RW | RESET | DEFINITION                        |
      | 15    | RSVD        | RO | 0x0   | Reserved                          |
      | 14    | RSVD        | RW | 0x1   | Reserved                          |
      | 13:12 | MAX_GAIN    | RW | 0x1   | Max Gain of AVC in expander mode  |
      | 11:10 | RSVD        | RO | 0x0   | Reserved                          |
      | 9:8   | LBI_RESP    | RW | 0x1   | Integrator Response               |
      | 7:6   | RSVD        | RO | 0x0   | Reserved                          |
      | 5     | HARD_LMT_EN | RW | 0x0   | Enable hard limiter mode          |
      | 4:1   | RSVD        | RO | 0x0   | Reserved                          |
      | 0     | EN          | RW | 0x0   | Enable/Disable AVC                |
      
      The original default value written to the DAP_AVC_CTRL register during
      sgtl5000_i2c_probe() was 0x0510.  This would incorrectly write values to
      bits 4 and 10, which are defined as RESERVED.  It would also not set
      bits 12 and 14 to their correct RESET values of 0x1, and instead set
      them to 0x0.  While the DAP_AVC module is effectively disabled because
      the EN bit is 0, this default value is still writing invalid values to
      registers that are marked as read-only and RESERVED as well as not
      setting bits 12 and 14 to their correct default values as defined by the
      datasheet.
      
      The correct value that should be written to the DAP_AVC_CTRL register is
      0x5100, which configures the register bits to the default values defined
      by the datasheet, and prevents any writes to bits defined as
      'read-only'.  Generally speaking, it is best practice to NOT attempt to
      write values to registers/bits defined as RESERVED, as it generally
      produces unwanted/undefined behavior, or errors.
      
      Also, all credit for this patch should go to my colleague Dan MacDonald
      <dmacdonald@curbellmedical.com> for finding this error in the first
      place.
      
      [1] https://www.nxp.com/docs/en/data-sheet/SGTL5000.pdf
      
      Signed-off-by: default avatarBenjamin Rood <benjaminjrood@gmail.com>
      Reviewed-by: default avatarFabio Estevam <festevam@gmail.com>
      Link: https://lore.kernel.org/r/20210219183308.GA2117@ubuntu-dev
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      97fe6ebe