]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 10 May 2021 08:28:08 +0000 (10:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 10 May 2021 08:28:08 +0000 (10:28 +0200)
added patches:
arm64-vdso-remove-commas-between-macro-name-and-arguments.patch
ext4-do-not-set-sb_active-in-ext4_orphan_cleanup.patch
ext4-fix-check-to-prevent-false-positive-report-of-incorrect-used-inodes.patch
ext4-fix-error-code-in-ext4_commit_super.patch
media-dvbdev-fix-memory-leak-in-dvb_media_device_free.patch
rsi-use-resume_noirq-for-sdio.patch
tty-fix-memory-leak-in-vc_deallocate.patch
usb-dwc2-fix-session-request-interrupt-handler.patch
usb-dwc3-gadget-fix-start_transfer-link-state-check.patch
usb-gadget-dummy_hcd-fix-gpf-in-gadget_setup.patch
usb-gadget-fix-double-free-of-device-descriptor-pointers.patch
usb-gadget-function-f_fs-string-table-fix-for-multiple-languages.patch

13 files changed:
queue-4.19/arm64-vdso-remove-commas-between-macro-name-and-arguments.patch [new file with mode: 0644]
queue-4.19/ext4-do-not-set-sb_active-in-ext4_orphan_cleanup.patch [new file with mode: 0644]
queue-4.19/ext4-fix-check-to-prevent-false-positive-report-of-incorrect-used-inodes.patch [new file with mode: 0644]
queue-4.19/ext4-fix-error-code-in-ext4_commit_super.patch [new file with mode: 0644]
queue-4.19/media-dvbdev-fix-memory-leak-in-dvb_media_device_free.patch [new file with mode: 0644]
queue-4.19/rsi-use-resume_noirq-for-sdio.patch [new file with mode: 0644]
queue-4.19/series
queue-4.19/tty-fix-memory-leak-in-vc_deallocate.patch [new file with mode: 0644]
queue-4.19/usb-dwc2-fix-session-request-interrupt-handler.patch [new file with mode: 0644]
queue-4.19/usb-dwc3-gadget-fix-start_transfer-link-state-check.patch [new file with mode: 0644]
queue-4.19/usb-gadget-dummy_hcd-fix-gpf-in-gadget_setup.patch [new file with mode: 0644]
queue-4.19/usb-gadget-fix-double-free-of-device-descriptor-pointers.patch [new file with mode: 0644]
queue-4.19/usb-gadget-function-f_fs-string-table-fix-for-multiple-languages.patch [new file with mode: 0644]

diff --git a/queue-4.19/arm64-vdso-remove-commas-between-macro-name-and-arguments.patch b/queue-4.19/arm64-vdso-remove-commas-between-macro-name-and-arguments.patch
new file mode 100644 (file)
index 0000000..fe8a051
--- /dev/null
@@ -0,0 +1,119 @@
+From jiancai@google.com  Mon May 10 10:02:08 2021
+From: Jian Cai <jiancai@google.com>
+Date: Wed,  5 May 2021 18:25:08 -0700
+Subject: arm64: vdso: remove commas between macro name and arguments
+To: gregkh@linuxfoundation.org, sashal@kernel.org, will@kernel.org, catalin.marinas@arm.com, nathan@kernel.org
+Cc: stable@vger.kernel.org, ndesaulniers@google.com, manojgupta@google.com, llozano@google.com, clang-built-linux@googlegroups.com, Jian Cai <jiancai@google.com>, Will Deacon <will.deacon@arm.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
+Message-ID: <20210506012508.3822221-1-jiancai@google.com>
+
+From: Jian Cai <jiancai@google.com>
+
+LLVM's integrated assembler appears to assume an argument with default
+value is passed whenever it sees a comma right after the macro name.
+It will be fine if the number of following arguments is one less than
+the number of parameters specified in the macro definition. Otherwise,
+it fails. For example, the following code works:
+
+$ cat foo.s
+.macro  foo arg1=2, arg2=4
+        ldr r0, [r1, #\arg1]
+        ldr r0, [r1, #\arg2]
+.endm
+
+foo, arg2=8
+
+$ llvm-mc -triple=armv7a -filetype=obj foo.s -o ias.o
+arm-linux-gnueabihf-objdump -dr ias.o
+
+ias.o:     file format elf32-littlearm
+
+Disassembly of section .text:
+
+00000000 <.text>:
+   0: e5910001 ldr r0, [r1, #2]
+   4: e5910003 ldr r0, [r1, #8]
+
+While the the following code would fail:
+
+$ cat foo.s
+.macro  foo arg1=2, arg2=4
+        ldr r0, [r1, #\arg1]
+        ldr r0, [r1, #\arg2]
+.endm
+
+foo, arg1=2, arg2=8
+
+$ llvm-mc -triple=armv7a -filetype=obj foo.s -o ias.o
+foo.s:6:14: error: too many positional arguments
+foo, arg1=2, arg2=8
+
+This causes build failures as follows:
+
+arch/arm64/kernel/vdso/gettimeofday.S:230:24: error: too many positional
+arguments
+ clock_gettime_return, shift=1
+                       ^
+arch/arm64/kernel/vdso/gettimeofday.S:253:24: error: too many positional
+arguments
+ clock_gettime_return, shift=1
+                       ^
+arch/arm64/kernel/vdso/gettimeofday.S:274:24: error: too many positional
+arguments
+ clock_gettime_return, shift=1
+
+This error is not in mainline because commit 28b1a824a4f4 ("arm64: vdso:
+Substitute gettimeofday() with C implementation") rewrote this assembler
+file in C as part of a 25 patch series that is unsuitable for stable.
+Just remove the comma in the clock_gettime_return invocations in 4.19 so
+that GNU as and LLVM's integrated assembler work the same.
+
+Link:
+https://github.com/ClangBuiltLinux/linux/issues/1349
+
+Suggested-by: Nathan Chancellor <nathan@kernel.org>
+Reviewed-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Jian Cai <jiancai@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+Changes v1 -> v2:
+  Keep the comma in the macro definition to be consistent with other
+  definitions.
+
+Changes v2 -> v3:
+  Edit tags.
+
+Changes v3 -> v4:
+  Update the commit message based on Nathan's comments.
+
+ arch/arm64/kernel/vdso/gettimeofday.S |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/arch/arm64/kernel/vdso/gettimeofday.S
++++ b/arch/arm64/kernel/vdso/gettimeofday.S
+@@ -227,7 +227,7 @@ realtime:
+       seqcnt_check fail=realtime
+       get_ts_realtime res_sec=x10, res_nsec=x11, \
+               clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9
+-      clock_gettime_return, shift=1
++      clock_gettime_return shift=1
+       ALIGN
+ monotonic:
+@@ -250,7 +250,7 @@ monotonic:
+               clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9
+       add_ts sec=x10, nsec=x11, ts_sec=x3, ts_nsec=x4, nsec_to_sec=x9
+-      clock_gettime_return, shift=1
++      clock_gettime_return shift=1
+       ALIGN
+ monotonic_raw:
+@@ -271,7 +271,7 @@ monotonic_raw:
+               clock_nsec=x15, nsec_to_sec=x9
+       add_ts sec=x10, nsec=x11, ts_sec=x13, ts_nsec=x14, nsec_to_sec=x9
+-      clock_gettime_return, shift=1
++      clock_gettime_return shift=1
+       ALIGN
+ realtime_coarse:
diff --git a/queue-4.19/ext4-do-not-set-sb_active-in-ext4_orphan_cleanup.patch b/queue-4.19/ext4-do-not-set-sb_active-in-ext4_orphan_cleanup.patch
new file mode 100644 (file)
index 0000000..b0c0f81
--- /dev/null
@@ -0,0 +1,49 @@
+From 72ffb49a7b623c92a37657eda7cc46a06d3e8398 Mon Sep 17 00:00:00 2001
+From: Zhang Yi <yi.zhang@huawei.com>
+Date: Wed, 31 Mar 2021 11:31:38 +0800
+Subject: ext4: do not set SB_ACTIVE in ext4_orphan_cleanup()
+
+From: Zhang Yi <yi.zhang@huawei.com>
+
+commit 72ffb49a7b623c92a37657eda7cc46a06d3e8398 upstream.
+
+When CONFIG_QUOTA is enabled, if we failed to mount the filesystem due
+to some error happens behind ext4_orphan_cleanup(), it will end up
+triggering a after free issue of super_block. The problem is that
+ext4_orphan_cleanup() will set SB_ACTIVE flag if CONFIG_QUOTA is
+enabled, after we cleanup the truncated inodes, the last iput() will put
+them into the lru list, and these inodes' pages may probably dirty and
+will be write back by the writeback thread, so it could be raced by
+freeing super_block in the error path of mount_bdev().
+
+After check the setting of SB_ACTIVE flag in ext4_orphan_cleanup(), it
+was used to ensure updating the quota file properly, but evict inode and
+trash data immediately in the last iput does not affect the quotafile,
+so setting the SB_ACTIVE flag seems not required[1]. Fix this issue by
+just remove the SB_ACTIVE setting.
+
+[1] https://lore.kernel.org/linux-ext4/99cce8ca-e4a0-7301-840f-2ace67c551f3@huawei.com/T/#m04990cfbc4f44592421736b504afcc346b2a7c00
+
+Cc: stable@kernel.org
+Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
+Tested-by: Jan Kara <jack@suse.cz>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Link: https://lore.kernel.org/r/20210331033138.918975-1-yi.zhang@huawei.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/super.c |    3 ---
+ 1 file changed, 3 deletions(-)
+
+--- a/fs/ext4/super.c
++++ b/fs/ext4/super.c
+@@ -2629,9 +2629,6 @@ static void ext4_orphan_cleanup(struct s
+               sb->s_flags &= ~SB_RDONLY;
+       }
+ #ifdef CONFIG_QUOTA
+-      /* Needed for iput() to work correctly and not trash data */
+-      sb->s_flags |= SB_ACTIVE;
+-
+       /*
+        * Turn on quotas which were not enabled for read-only mounts if
+        * filesystem has quota feature, so that they are updated correctly.
diff --git a/queue-4.19/ext4-fix-check-to-prevent-false-positive-report-of-incorrect-used-inodes.patch b/queue-4.19/ext4-fix-check-to-prevent-false-positive-report-of-incorrect-used-inodes.patch
new file mode 100644 (file)
index 0000000..622e5d8
--- /dev/null
@@ -0,0 +1,96 @@
+From a149d2a5cabbf6507a7832a1c4fd2593c55fd450 Mon Sep 17 00:00:00 2001
+From: Zhang Yi <yi.zhang@huawei.com>
+Date: Wed, 31 Mar 2021 20:15:16 +0800
+Subject: ext4: fix check to prevent false positive report of incorrect used inodes
+
+From: Zhang Yi <yi.zhang@huawei.com>
+
+commit a149d2a5cabbf6507a7832a1c4fd2593c55fd450 upstream.
+
+Commit <50122847007> ("ext4: fix check to prevent initializing reserved
+inodes") check the block group zero and prevent initializing reserved
+inodes. But in some special cases, the reserved inode may not all belong
+to the group zero, it may exist into the second group if we format
+filesystem below.
+
+  mkfs.ext4 -b 4096 -g 8192 -N 1024 -I 4096 /dev/sda
+
+So, it will end up triggering a false positive report of a corrupted
+file system. This patch fix it by avoid check reserved inodes if no free
+inode blocks will be zeroed.
+
+Cc: stable@kernel.org
+Fixes: 50122847007 ("ext4: fix check to prevent initializing reserved inodes")
+Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
+Suggested-by: Jan Kara <jack@suse.cz>
+Link: https://lore.kernel.org/r/20210331121516.2243099-1-yi.zhang@huawei.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/ialloc.c |   48 ++++++++++++++++++++++++++++++++----------------
+ 1 file changed, 32 insertions(+), 16 deletions(-)
+
+--- a/fs/ext4/ialloc.c
++++ b/fs/ext4/ialloc.c
+@@ -1358,6 +1358,7 @@ int ext4_init_inode_table(struct super_b
+       handle_t *handle;
+       ext4_fsblk_t blk;
+       int num, ret = 0, used_blks = 0;
++      unsigned long used_inos = 0;
+       /* This should not happen, but just to be sure check this */
+       if (sb_rdonly(sb)) {
+@@ -1388,22 +1389,37 @@ int ext4_init_inode_table(struct super_b
+        * used inodes so we need to skip blocks with used inodes in
+        * inode table.
+        */
+-      if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)))
+-              used_blks = DIV_ROUND_UP((EXT4_INODES_PER_GROUP(sb) -
+-                          ext4_itable_unused_count(sb, gdp)),
+-                          sbi->s_inodes_per_block);
+-
+-      if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group) ||
+-          ((group == 0) && ((EXT4_INODES_PER_GROUP(sb) -
+-                             ext4_itable_unused_count(sb, gdp)) <
+-                            EXT4_FIRST_INO(sb)))) {
+-              ext4_error(sb, "Something is wrong with group %u: "
+-                         "used itable blocks: %d; "
+-                         "itable unused count: %u",
+-                         group, used_blks,
+-                         ext4_itable_unused_count(sb, gdp));
+-              ret = 1;
+-              goto err_out;
++      if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT))) {
++              used_inos = EXT4_INODES_PER_GROUP(sb) -
++                          ext4_itable_unused_count(sb, gdp);
++              used_blks = DIV_ROUND_UP(used_inos, sbi->s_inodes_per_block);
++
++              /* Bogus inode unused count? */
++              if (used_blks < 0 || used_blks > sbi->s_itb_per_group) {
++                      ext4_error(sb, "Something is wrong with group %u: "
++                                 "used itable blocks: %d; "
++                                 "itable unused count: %u",
++                                 group, used_blks,
++                                 ext4_itable_unused_count(sb, gdp));
++                      ret = 1;
++                      goto err_out;
++              }
++
++              used_inos += group * EXT4_INODES_PER_GROUP(sb);
++              /*
++               * Are there some uninitialized inodes in the inode table
++               * before the first normal inode?
++               */
++              if ((used_blks != sbi->s_itb_per_group) &&
++                   (used_inos < EXT4_FIRST_INO(sb))) {
++                      ext4_error(sb, "Something is wrong with group %u: "
++                                 "itable unused count: %u; "
++                                 "itables initialized count: %ld",
++                                 group, ext4_itable_unused_count(sb, gdp),
++                                 used_inos);
++                      ret = 1;
++                      goto err_out;
++              }
+       }
+       blk = ext4_inode_table(sb, gdp) + used_blks;
diff --git a/queue-4.19/ext4-fix-error-code-in-ext4_commit_super.patch b/queue-4.19/ext4-fix-error-code-in-ext4_commit_super.patch
new file mode 100644 (file)
index 0000000..43fca22
--- /dev/null
@@ -0,0 +1,38 @@
+From f88f1466e2a2e5ca17dfada436d3efa1b03a3972 Mon Sep 17 00:00:00 2001
+From: Fengnan Chang <changfengnan@vivo.com>
+Date: Fri, 2 Apr 2021 18:16:31 +0800
+Subject: ext4: fix error code in ext4_commit_super
+
+From: Fengnan Chang <changfengnan@vivo.com>
+
+commit f88f1466e2a2e5ca17dfada436d3efa1b03a3972 upstream.
+
+We should set the error code when ext4_commit_super check argument failed.
+Found in code review.
+Fixes: c4be0c1dc4cdc ("filesystem freeze: add error handling of write_super_lockfs/unlockfs").
+
+Cc: stable@kernel.org
+Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
+Reviewed-by: Andreas Dilger <adilger@dilger.ca>
+Link: https://lore.kernel.org/r/20210402101631.561-1-changfengnan@vivo.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/super.c |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/fs/ext4/super.c
++++ b/fs/ext4/super.c
+@@ -4959,8 +4959,10 @@ static int ext4_commit_super(struct supe
+       struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
+       int error = 0;
+-      if (!sbh || block_device_ejected(sb))
+-              return error;
++      if (!sbh)
++              return -EINVAL;
++      if (block_device_ejected(sb))
++              return -ENODEV;
+       /*
+        * If the file system is mounted read-only, don't update the
diff --git a/queue-4.19/media-dvbdev-fix-memory-leak-in-dvb_media_device_free.patch b/queue-4.19/media-dvbdev-fix-memory-leak-in-dvb_media_device_free.patch
new file mode 100644 (file)
index 0000000..01dc1dd
--- /dev/null
@@ -0,0 +1,37 @@
+From bf9a40ae8d722f281a2721779595d6df1c33a0bf Mon Sep 17 00:00:00 2001
+From: Peilin Ye <yepeilin.cs@gmail.com>
+Date: Fri, 11 Dec 2020 09:30:39 +0100
+Subject: media: dvbdev: Fix memory leak in dvb_media_device_free()
+
+From: Peilin Ye <yepeilin.cs@gmail.com>
+
+commit bf9a40ae8d722f281a2721779595d6df1c33a0bf upstream.
+
+dvb_media_device_free() is leaking memory. Free `dvbdev->adapter->conn`
+before setting it to NULL, as documented in include/media/media-device.h:
+"The media_entity instance itself must be freed explicitly by the driver
+if required."
+
+Link: https://syzkaller.appspot.com/bug?id=9bbe4b842c98f0ed05c5eed77a226e9de33bf298
+
+Link: https://lore.kernel.org/linux-media/20201211083039.521617-1-yepeilin.cs@gmail.com
+Cc: stable@vger.kernel.org
+Fixes: 0230d60e4661 ("[media] dvbdev: Add RF connector if needed")
+Reported-by: syzbot+7f09440acc069a0d38ac@syzkaller.appspotmail.com
+Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvbdev.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/media/dvb-core/dvbdev.c
++++ b/drivers/media/dvb-core/dvbdev.c
+@@ -241,6 +241,7 @@ static void dvb_media_device_free(struct
+       if (dvbdev->adapter->conn) {
+               media_device_unregister_entity(dvbdev->adapter->conn);
++              kfree(dvbdev->adapter->conn);
+               dvbdev->adapter->conn = NULL;
+               kfree(dvbdev->adapter->conn_pads);
+               dvbdev->adapter->conn_pads = NULL;
diff --git a/queue-4.19/rsi-use-resume_noirq-for-sdio.patch b/queue-4.19/rsi-use-resume_noirq-for-sdio.patch
new file mode 100644 (file)
index 0000000..3d15775
--- /dev/null
@@ -0,0 +1,46 @@
+From c434e5e48dc4e626364491455f97e2db0aa137b1 Mon Sep 17 00:00:00 2001
+From: Marek Vasut <marex@denx.de>
+Date: Sun, 28 Mar 2021 00:59:32 +0100
+Subject: rsi: Use resume_noirq for SDIO
+
+From: Marek Vasut <marex@denx.de>
+
+commit c434e5e48dc4e626364491455f97e2db0aa137b1 upstream.
+
+The rsi_resume() does access the bus to enable interrupts on the RSI
+SDIO WiFi card, however when calling sdio_claim_host() in the resume
+path, it is possible the bus is already claimed and sdio_claim_host()
+spins indefinitelly. Enable the SDIO card interrupts in resume_noirq
+instead to prevent anything else from claiming the SDIO bus first.
+
+Fixes: 20db07332736 ("rsi: sdio suspend and resume support")
+Signed-off-by: Marek Vasut <marex@denx.de>
+Cc: Amitkumar Karwar <amit.karwar@redpinesignals.com>
+Cc: Angus Ainslie <angus@akkea.ca>
+Cc: David S. Miller <davem@davemloft.net>
+Cc: Jakub Kicinski <kuba@kernel.org>
+Cc: Kalle Valo <kvalo@codeaurora.org>
+Cc: Karun Eagalapati <karun256@gmail.com>
+Cc: Martin Kepplinger <martink@posteo.de>
+Cc: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
+Cc: Siva Rebbagondla <siva8118@gmail.com>
+Cc: netdev@vger.kernel.org
+Cc: stable@vger.kernel.org
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+Link: https://lore.kernel.org/r/20210327235932.175896-1-marex@denx.de
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/wireless/rsi/rsi_91x_sdio.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
++++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
+@@ -1400,7 +1400,7 @@ static int rsi_restore(struct device *de
+ }
+ static const struct dev_pm_ops rsi_pm_ops = {
+       .suspend = rsi_suspend,
+-      .resume = rsi_resume,
++      .resume_noirq = rsi_resume,
+       .freeze = rsi_freeze,
+       .thaw = rsi_thaw,
+       .restore = rsi_restore,
index 4d79ffa27e514c7af5ad99a4951e951f7704ecd8..f11e87ea3332b79c1066c777b4218ee52cefd344 100644 (file)
@@ -100,3 +100,15 @@ fix-misc-new-gcc-warnings.patch
 jffs2-check-the-validity-of-dstlen-in-jffs2_zlib_compress.patch
 revert-337f13046ff0-futex-allow-futex_clock_realtime-with-futex_wait-op.patch
 posix-timers-preserve-return-value-in-clock_adjtime32.patch
+arm64-vdso-remove-commas-between-macro-name-and-arguments.patch
+ext4-fix-check-to-prevent-false-positive-report-of-incorrect-used-inodes.patch
+ext4-do-not-set-sb_active-in-ext4_orphan_cleanup.patch
+ext4-fix-error-code-in-ext4_commit_super.patch
+media-dvbdev-fix-memory-leak-in-dvb_media_device_free.patch
+usb-gadget-dummy_hcd-fix-gpf-in-gadget_setup.patch
+usb-gadget-fix-double-free-of-device-descriptor-pointers.patch
+usb-gadget-function-f_fs-string-table-fix-for-multiple-languages.patch
+usb-dwc3-gadget-fix-start_transfer-link-state-check.patch
+usb-dwc2-fix-session-request-interrupt-handler.patch
+tty-fix-memory-leak-in-vc_deallocate.patch
+rsi-use-resume_noirq-for-sdio.patch
diff --git a/queue-4.19/tty-fix-memory-leak-in-vc_deallocate.patch b/queue-4.19/tty-fix-memory-leak-in-vc_deallocate.patch
new file mode 100644 (file)
index 0000000..8c6ef9e
--- /dev/null
@@ -0,0 +1,34 @@
+From 211b4d42b70f1c1660feaa968dac0efc2a96ac4d Mon Sep 17 00:00:00 2001
+From: Pavel Skripkin <paskripkin@gmail.com>
+Date: Sun, 28 Mar 2021 00:44:43 +0300
+Subject: tty: fix memory leak in vc_deallocate
+
+From: Pavel Skripkin <paskripkin@gmail.com>
+
+commit 211b4d42b70f1c1660feaa968dac0efc2a96ac4d upstream.
+
+syzbot reported memory leak in tty/vt.
+The problem was in VT_DISALLOCATE ioctl cmd.
+After allocating unimap with PIO_UNIMAP it wasn't
+freed via VT_DISALLOCATE, but vc_cons[currcons].d was
+zeroed.
+
+Reported-by: syzbot+bcc922b19ccc64240b42@syzkaller.appspotmail.com
+Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
+Cc: stable <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20210327214443.21548-1-paskripkin@gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/tty/vt/vt.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/tty/vt/vt.c
++++ b/drivers/tty/vt/vt.c
+@@ -1380,6 +1380,7 @@ struct vc_data *vc_deallocate(unsigned i
+               atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, &param);
+               vcs_remove_sysfs(currcons);
+               visual_deinit(vc);
++              con_free_unimap(vc);
+               put_pid(vc->vt_pid);
+               vc_uniscr_set(vc, NULL);
+               kfree(vc->vc_screenbuf);
diff --git a/queue-4.19/usb-dwc2-fix-session-request-interrupt-handler.patch b/queue-4.19/usb-dwc2-fix-session-request-interrupt-handler.patch
new file mode 100644 (file)
index 0000000..2d70665
--- /dev/null
@@ -0,0 +1,47 @@
+From 42b32b164acecd850edef010915a02418345a033 Mon Sep 17 00:00:00 2001
+From: Artur Petrosyan <Arthur.Petrosyan@synopsys.com>
+Date: Thu, 8 Apr 2021 13:45:49 +0400
+Subject: usb: dwc2: Fix session request interrupt handler
+
+From: Artur Petrosyan <Arthur.Petrosyan@synopsys.com>
+
+commit 42b32b164acecd850edef010915a02418345a033 upstream.
+
+According to programming guide in host mode, port
+power must be turned on in session request
+interrupt handlers.
+
+Fixes: 21795c826a45 ("usb: dwc2: exit hibernation on session request")
+Cc: <stable@vger.kernel.org>
+Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
+Signed-off-by: Artur Petrosyan <Arthur.Petrosyan@synopsys.com>
+Link: https://lore.kernel.org/r/20210408094550.75484A0094@mailhost.synopsys.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/dwc2/core_intr.c |    8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+--- a/drivers/usb/dwc2/core_intr.c
++++ b/drivers/usb/dwc2/core_intr.c
+@@ -312,6 +312,7 @@ static void dwc2_handle_conn_id_status_c
+ static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg)
+ {
+       int ret;
++      u32 hprt0;
+       /* Clear interrupt */
+       dwc2_writel(hsotg, GINTSTS_SESSREQINT, GINTSTS);
+@@ -332,6 +333,13 @@ static void dwc2_handle_session_req_intr
+                * established
+                */
+               dwc2_hsotg_disconnect(hsotg);
++      } else {
++              /* Turn on the port power bit. */
++              hprt0 = dwc2_read_hprt0(hsotg);
++              hprt0 |= HPRT0_PWR;
++              dwc2_writel(hsotg, hprt0, HPRT0);
++              /* Connect hcd after port power is set. */
++              dwc2_hcd_connect(hsotg);
+       }
+ }
diff --git a/queue-4.19/usb-dwc3-gadget-fix-start_transfer-link-state-check.patch b/queue-4.19/usb-dwc3-gadget-fix-start_transfer-link-state-check.patch
new file mode 100644 (file)
index 0000000..a3331e4
--- /dev/null
@@ -0,0 +1,63 @@
+From c560e76319a94a3b9285bc426c609903408e4826 Mon Sep 17 00:00:00 2001
+From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
+Date: Mon, 19 Apr 2021 19:11:12 -0700
+Subject: usb: dwc3: gadget: Fix START_TRANSFER link state check
+
+From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
+
+commit c560e76319a94a3b9285bc426c609903408e4826 upstream.
+
+The START_TRANSFER command needs to be executed while in ON/U0 link
+state (with an exception during register initialization). Don't use
+dwc->link_state to check this since the driver only tracks the link
+state when the link state change interrupt is enabled. Check the link
+state from DSTS register instead.
+
+Note that often the host already brings the device out of low power
+before it sends/requests the next transfer. So, the user won't see any
+issue when the device starts transfer then. This issue is more
+noticeable in cases when the device delays starting transfer, which can
+happen during delayed control status after the host put the device in
+low power.
+
+Fixes: 799e9dc82968 ("usb: dwc3: gadget: conditionally disable Link State change events")
+Cc: <stable@vger.kernel.org>
+Acked-by: Felipe Balbi <balbi@kernel.org>
+Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
+Link: https://lore.kernel.org/r/bcefaa9ecbc3e1936858c0baa14de6612960e909.1618884221.git.Thinh.Nguyen@synopsys.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/dwc3/gadget.c |   13 +++++++------
+ 1 file changed, 7 insertions(+), 6 deletions(-)
+
+--- a/drivers/usb/dwc3/gadget.c
++++ b/drivers/usb/dwc3/gadget.c
+@@ -304,13 +304,12 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_
+       }
+       if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
+-              int             needs_wakeup;
++              int link_state;
+-              needs_wakeup = (dwc->link_state == DWC3_LINK_STATE_U1 ||
+-                              dwc->link_state == DWC3_LINK_STATE_U2 ||
+-                              dwc->link_state == DWC3_LINK_STATE_U3);
+-
+-              if (unlikely(needs_wakeup)) {
++              link_state = dwc3_gadget_get_link_state(dwc);
++              if (link_state == DWC3_LINK_STATE_U1 ||
++                  link_state == DWC3_LINK_STATE_U2 ||
++                  link_state == DWC3_LINK_STATE_U3) {
+                       ret = __dwc3_gadget_wakeup(dwc);
+                       dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n",
+                                       ret);
+@@ -1674,6 +1673,8 @@ static int __dwc3_gadget_wakeup(struct d
+       case DWC3_LINK_STATE_RESET:
+       case DWC3_LINK_STATE_RX_DET:    /* in HS, means Early Suspend */
+       case DWC3_LINK_STATE_U3:        /* in HS, means SUSPEND */
++      case DWC3_LINK_STATE_U2:        /* in HS, means Sleep (L1) */
++      case DWC3_LINK_STATE_U1:
+       case DWC3_LINK_STATE_RESUME:
+               break;
+       default:
diff --git a/queue-4.19/usb-gadget-dummy_hcd-fix-gpf-in-gadget_setup.patch b/queue-4.19/usb-gadget-dummy_hcd-fix-gpf-in-gadget_setup.patch
new file mode 100644 (file)
index 0000000..cbaffe5
--- /dev/null
@@ -0,0 +1,90 @@
+From 4a5d797a9f9c4f18585544237216d7812686a71f Mon Sep 17 00:00:00 2001
+From: Anirudh Rayabharam <mail@anirudhrb.com>
+Date: Mon, 19 Apr 2021 09:07:08 +0530
+Subject: usb: gadget: dummy_hcd: fix gpf in gadget_setup
+
+From: Anirudh Rayabharam <mail@anirudhrb.com>
+
+commit 4a5d797a9f9c4f18585544237216d7812686a71f upstream.
+
+Fix a general protection fault reported by syzbot due to a race between
+gadget_setup() and gadget_unbind() in raw_gadget.
+
+The gadget core is supposed to guarantee that there won't be any more
+callbacks to the gadget driver once the driver's unbind routine is
+called. That guarantee is enforced in usb_gadget_remove_driver as
+follows:
+
+        usb_gadget_disconnect(udc->gadget);
+        if (udc->gadget->irq)
+                synchronize_irq(udc->gadget->irq);
+        udc->driver->unbind(udc->gadget);
+        usb_gadget_udc_stop(udc);
+
+usb_gadget_disconnect turns off the pullup resistor, telling the host
+that the gadget is no longer connected and preventing the transmission
+of any more USB packets. Any packets that have already been received
+are sure to processed by the UDC driver's interrupt handler by the time
+synchronize_irq returns.
+
+But this doesn't work with dummy_hcd, because dummy_hcd doesn't use
+interrupts; it uses a timer instead. It does have code to emulate the
+effect of synchronize_irq, but that code doesn't get invoked at the
+right time -- it currently runs in usb_gadget_udc_stop, after the unbind
+callback instead of before. Indeed, there's no way for
+usb_gadget_remove_driver to invoke this code before the unbind callback.
+
+To fix this, move the synchronize_irq() emulation code to dummy_pullup
+so that it runs before unbind. Also, add a comment explaining why it is
+necessary to have it there.
+
+Reported-by: syzbot+eb4674092e6cc8d9e0bd@syzkaller.appspotmail.com
+Suggested-by: Alan Stern <stern@rowland.harvard.edu>
+Acked-by: Alan Stern <stern@rowland.harvard.edu>
+Signed-off-by: Anirudh Rayabharam <mail@anirudhrb.com>
+Link: https://lore.kernel.org/r/20210419033713.3021-1-mail@anirudhrb.com
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/gadget/udc/dummy_hcd.c |   23 +++++++++++++++--------
+ 1 file changed, 15 insertions(+), 8 deletions(-)
+
+--- a/drivers/usb/gadget/udc/dummy_hcd.c
++++ b/drivers/usb/gadget/udc/dummy_hcd.c
+@@ -914,6 +914,21 @@ static int dummy_pullup(struct usb_gadge
+       spin_lock_irqsave(&dum->lock, flags);
+       dum->pullup = (value != 0);
+       set_link_state(dum_hcd);
++      if (value == 0) {
++              /*
++               * Emulate synchronize_irq(): wait for callbacks to finish.
++               * This seems to be the best place to emulate the call to
++               * synchronize_irq() that's in usb_gadget_remove_driver().
++               * Doing it in dummy_udc_stop() would be too late since it
++               * is called after the unbind callback and unbind shouldn't
++               * be invoked until all the other callbacks are finished.
++               */
++              while (dum->callback_usage > 0) {
++                      spin_unlock_irqrestore(&dum->lock, flags);
++                      usleep_range(1000, 2000);
++                      spin_lock_irqsave(&dum->lock, flags);
++              }
++      }
+       spin_unlock_irqrestore(&dum->lock, flags);
+       usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd));
+@@ -1015,14 +1030,6 @@ static int dummy_udc_stop(struct usb_gad
+       spin_lock_irq(&dum->lock);
+       dum->ints_enabled = 0;
+       stop_activity(dum);
+-
+-      /* emulate synchronize_irq(): wait for callbacks to finish */
+-      while (dum->callback_usage > 0) {
+-              spin_unlock_irq(&dum->lock);
+-              usleep_range(1000, 2000);
+-              spin_lock_irq(&dum->lock);
+-      }
+-
+       dum->driver = NULL;
+       spin_unlock_irq(&dum->lock);
diff --git a/queue-4.19/usb-gadget-fix-double-free-of-device-descriptor-pointers.patch b/queue-4.19/usb-gadget-fix-double-free-of-device-descriptor-pointers.patch
new file mode 100644 (file)
index 0000000..091cdd2
--- /dev/null
@@ -0,0 +1,44 @@
+From 43c4cab006f55b6ca549dd1214e22f5965a8675f Mon Sep 17 00:00:00 2001
+From: Hemant Kumar <hemantk@codeaurora.org>
+Date: Wed, 21 Apr 2021 12:47:32 -0700
+Subject: usb: gadget: Fix double free of device descriptor pointers
+
+From: Hemant Kumar <hemantk@codeaurora.org>
+
+commit 43c4cab006f55b6ca549dd1214e22f5965a8675f upstream.
+
+Upon driver unbind usb_free_all_descriptors() function frees all
+speed descriptor pointers without setting them to NULL. In case
+gadget speed changes (i.e from super speed plus to super speed)
+after driver unbind only upto super speed descriptor pointers get
+populated. Super speed plus desc still holds the stale (already
+freed) pointer. Fix this issue by setting all descriptor pointers
+to NULL after freeing them in usb_free_all_descriptors().
+
+Fixes: f5c61225cf29 ("usb: gadget: Update function for SuperSpeedPlus")
+cc: stable@vger.kernel.org
+Reviewed-by: Peter Chen <peter.chen@kernel.org>
+Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
+Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
+Link: https://lore.kernel.org/r/1619034452-17334-1-git-send-email-wcheng@codeaurora.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/gadget/config.c |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/usb/gadget/config.c
++++ b/drivers/usb/gadget/config.c
+@@ -194,9 +194,13 @@ EXPORT_SYMBOL_GPL(usb_assign_descriptors
+ void usb_free_all_descriptors(struct usb_function *f)
+ {
+       usb_free_descriptors(f->fs_descriptors);
++      f->fs_descriptors = NULL;
+       usb_free_descriptors(f->hs_descriptors);
++      f->hs_descriptors = NULL;
+       usb_free_descriptors(f->ss_descriptors);
++      f->ss_descriptors = NULL;
+       usb_free_descriptors(f->ssp_descriptors);
++      f->ssp_descriptors = NULL;
+ }
+ EXPORT_SYMBOL_GPL(usb_free_all_descriptors);
diff --git a/queue-4.19/usb-gadget-function-f_fs-string-table-fix-for-multiple-languages.patch b/queue-4.19/usb-gadget-function-f_fs-string-table-fix-for-multiple-languages.patch
new file mode 100644 (file)
index 0000000..6afed56
--- /dev/null
@@ -0,0 +1,44 @@
+From 55b74ce7d2ce0b0058f3e08cab185a0afacfe39e Mon Sep 17 00:00:00 2001
+From: Dean Anderson <dean@sensoray.com>
+Date: Wed, 17 Mar 2021 15:41:09 -0700
+Subject: usb: gadget/function/f_fs string table fix for multiple languages
+
+From: Dean Anderson <dean@sensoray.com>
+
+commit 55b74ce7d2ce0b0058f3e08cab185a0afacfe39e upstream.
+
+Fixes bug with the handling of more than one language in
+the string table in f_fs.c.
+str_count was not reset for subsequent language codes.
+str_count-- "rolls under" and processes u32 max strings on
+the processing of the second language entry.
+The existing bug can be reproduced by adding a second language table
+to the structure "strings" in tools/usb/ffs-test.c.
+
+Signed-off-by: Dean Anderson <dean@sensoray.com>
+Link: https://lore.kernel.org/r/20210317224109.21534-1-dean@sensoray.com
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/gadget/function/f_fs.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/usb/gadget/function/f_fs.c
++++ b/drivers/usb/gadget/function/f_fs.c
+@@ -2553,6 +2553,7 @@ static int __ffs_data_got_strings(struct
+       do { /* lang_count > 0 so we can use do-while */
+               unsigned needed = needed_count;
++              u32 str_per_lang = str_count;
+               if (unlikely(len < 3))
+                       goto error_free;
+@@ -2588,7 +2589,7 @@ static int __ffs_data_got_strings(struct
+                       data += length + 1;
+                       len -= length + 1;
+-              } while (--str_count);
++              } while (--str_per_lang);
+               s->id = 0;   /* terminator */
+               s->s = NULL;