From: Greg Kroah-Hartman Date: Mon, 6 Jun 2022 07:28:15 +0000 (+0200) Subject: 5.18-stable patches X-Git-Tag: v5.10.121~162 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c31a689a5324e5e79809d99a2c3de6998e56e828;p=thirdparty%2Fkernel%2Fstable-queue.git 5.18-stable patches added patches: alsa-hda-realtek-add-new-type-for-alc245.patch alsa-hda-realtek-enable-4-speaker-output-for-dell-xps-15-9520-laptop.patch alsa-hda-realtek-fix-microphone-noise-on-asus-tuf-b550m-plus.patch alsa-usb-audio-cancel-pending-work-at-closing-a-midi-substream.patch fs-ntfs3-check-new-size-for-limits.patch fs-ntfs3-fix-fiemap-fix-shrink-file-size-to-remove-preallocated-space.patch fs-ntfs3-fix-some-memory-leaks-in-an-error-handling-path-of-log_replay.patch fs-ntfs3-in-function-ntfs_set_acl_ex-do-not-change-inode-i_mode-if-called-from-function-ntfs_init_acl.patch fs-ntfs3-keep-preallocated-only-if-option-prealloc-enabled.patch fs-ntfs3-provide-block_invalidate_folio-to-fix-memory-leak.patch fs-ntfs3-restore-ntfs_xattr_get_acl-and-ntfs_xattr_set_acl-functions.patch fs-ntfs3-update-i_ctime-when-xattr-is-added.patch fs-ntfs3-update-valid-size-if-eiocbqueued.patch risc-v-mark-ioresource_exclusive-for-reserved-mem-instead-of-ioresource_busy.patch riscv-fix-irq_work-when-smp-is-disabled.patch riscv-initialize-thread-pointer-before-calling-c-functions.patch riscv-move-alternative-length-validation-into-subsection.patch riscv-wire-up-memfd_secret-in-uapi-header.patch usb-core-hcd-add-support-for-deferring-roothub-registration.patch usb-dwc3-gadget-move-null-pinter-check-to-proper-place.patch usb-isp1760-fix-out-of-bounds-array-access.patch usb-new-quirk-for-dell-gen-2-devices.patch usb-serial-option-add-quectel-bg95-modem.patch usb-serial-pl2303-fix-type-detection-for-odd-device.patch --- diff --git a/queue-5.18/alsa-hda-realtek-add-new-type-for-alc245.patch b/queue-5.18/alsa-hda-realtek-add-new-type-for-alc245.patch new file mode 100644 index 00000000000..25392248cda --- /dev/null +++ b/queue-5.18/alsa-hda-realtek-add-new-type-for-alc245.patch @@ -0,0 +1,60 @@ +From 60571929d06b028800f27b51a7c81de1144944cf Mon Sep 17 00:00:00 2001 +From: Kailang Yang +Date: Tue, 24 May 2022 16:14:04 +0800 +Subject: ALSA: hda/realtek - Add new type for ALC245 + +From: Kailang Yang + +commit 60571929d06b028800f27b51a7c81de1144944cf upstream. + +Add new type for ALC245. + +Signed-off-by: Kailang Yang +Cc: +Link: https://lore.kernel.org/r/cef26a7cd3d146eb96a3994ce79e34d2@realtek.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/hda/patch_realtek.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -3131,6 +3131,7 @@ enum { + ALC269_TYPE_ALC257, + ALC269_TYPE_ALC215, + ALC269_TYPE_ALC225, ++ ALC269_TYPE_ALC245, + ALC269_TYPE_ALC287, + ALC269_TYPE_ALC294, + ALC269_TYPE_ALC300, +@@ -3168,6 +3169,7 @@ static int alc269_parse_auto_config(stru + case ALC269_TYPE_ALC257: + case ALC269_TYPE_ALC215: + case ALC269_TYPE_ALC225: ++ case ALC269_TYPE_ALC245: + case ALC269_TYPE_ALC287: + case ALC269_TYPE_ALC294: + case ALC269_TYPE_ALC300: +@@ -3695,7 +3697,8 @@ static void alc225_init(struct hda_codec + hda_nid_t hp_pin = alc_get_hp_pin(spec); + bool hp1_pin_sense, hp2_pin_sense; + +- if (spec->codec_variant != ALC269_TYPE_ALC287) ++ if (spec->codec_variant != ALC269_TYPE_ALC287 && ++ spec->codec_variant != ALC269_TYPE_ALC245) + /* required only at boot or S3 and S4 resume time */ + if (!spec->done_hp_init || + is_s3_resume(codec) || +@@ -10148,7 +10151,10 @@ static int patch_alc269(struct hda_codec + case 0x10ec0245: + case 0x10ec0285: + case 0x10ec0289: +- spec->codec_variant = ALC269_TYPE_ALC215; ++ if (alc_get_coef0(codec) & 0x0010) ++ spec->codec_variant = ALC269_TYPE_ALC245; ++ else ++ spec->codec_variant = ALC269_TYPE_ALC215; + spec->shutup = alc225_shutup; + spec->init_hook = alc225_init; + spec->gen.mixer_nid = 0; diff --git a/queue-5.18/alsa-hda-realtek-enable-4-speaker-output-for-dell-xps-15-9520-laptop.patch b/queue-5.18/alsa-hda-realtek-enable-4-speaker-output-for-dell-xps-15-9520-laptop.patch new file mode 100644 index 00000000000..6e91260d9d4 --- /dev/null +++ b/queue-5.18/alsa-hda-realtek-enable-4-speaker-output-for-dell-xps-15-9520-laptop.patch @@ -0,0 +1,35 @@ +From 15dad62f4bdb5dc0f0efde8181d680db9963544c Mon Sep 17 00:00:00 2001 +From: Rik van der Kemp +Date: Fri, 27 May 2022 14:07:26 +0200 +Subject: ALSA: hda/realtek: Enable 4-speaker output for Dell XPS 15 9520 laptop + +From: Rik van der Kemp + +commit 15dad62f4bdb5dc0f0efde8181d680db9963544c upstream. + +The 2022-model XPS 15 appears to use the same 4-speakers-on-ALC289 +audio setup as the Dell XPS 15 9510, so requires the same quirk to +enable woofer output. Tested on my own 9520. + +[ Move the entry to the right position in the SSID order -- tiwai ] + +BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=216035 +Cc: +Signed-off-by: Rik van der Kemp +Link: https://lore.kernel.org/r/181056a137b.d14baf90133058.8425453735588429828@upto11.nl +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/hda/patch_realtek.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -8957,6 +8957,7 @@ static const struct snd_pci_quirk alc269 + SND_PCI_QUIRK(0x1028, 0x0a62, "Dell Precision 5560", ALC289_FIXUP_DUAL_SPK), + SND_PCI_QUIRK(0x1028, 0x0a9d, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE), + SND_PCI_QUIRK(0x1028, 0x0a9e, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE), ++ SND_PCI_QUIRK(0x1028, 0x0b19, "Dell XPS 15 9520", ALC289_FIXUP_DUAL_SPK), + SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), + SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), + SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), diff --git a/queue-5.18/alsa-hda-realtek-fix-microphone-noise-on-asus-tuf-b550m-plus.patch b/queue-5.18/alsa-hda-realtek-fix-microphone-noise-on-asus-tuf-b550m-plus.patch new file mode 100644 index 00000000000..edb04ef6b8b --- /dev/null +++ b/queue-5.18/alsa-hda-realtek-fix-microphone-noise-on-asus-tuf-b550m-plus.patch @@ -0,0 +1,68 @@ +From 9bfa7b36343c7d84370bc61c9ed774635b05e4eb Mon Sep 17 00:00:00 2001 +From: Marios Levogiannis +Date: Mon, 30 May 2022 10:41:31 +0300 +Subject: ALSA: hda/realtek - Fix microphone noise on ASUS TUF B550M-PLUS + +From: Marios Levogiannis + +commit 9bfa7b36343c7d84370bc61c9ed774635b05e4eb upstream. + +Set microphone pins 0x18 (rear) and 0x19 (front) to VREF_50 to fix the +microphone noise on ASUS TUF B550M-PLUS which uses the ALCS1200A codec. +The initial value was VREF_80. + +The same issue is also present on Windows using both the default Windows +driver and all tested Realtek drivers before version 6.0.9049.1. Comparing +Realtek driver 6.0.9049.1 (the first one without the microphone noise) to +Realtek driver 6.0.9047.1 (the last one with the microphone noise) +revealed that the fix is the result of setting pins 0x18 and 0x19 to +VREF_50. + +This fix may also work for other boards that have been reported to have +the same microphone issue and use the ALC1150 and ALCS1200A codecs, since +these codecs are similar and the fix in the Realtek driver on Windows is +common for both. However, it is currently enabled only for ASUS TUF +B550M-PLUS as this is the only board that could be tested. + +Signed-off-by: Marios Levogiannis +Cc: +Link: https://lore.kernel.org/r/20220530074131.12258-1-marios.levogiannis@gmail.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/hda/patch_realtek.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -1981,6 +1981,7 @@ enum { + ALC1220_FIXUP_CLEVO_PB51ED_PINS, + ALC887_FIXUP_ASUS_AUDIO, + ALC887_FIXUP_ASUS_HMIC, ++ ALCS1200A_FIXUP_MIC_VREF, + }; + + static void alc889_fixup_coef(struct hda_codec *codec, +@@ -2526,6 +2527,14 @@ static const struct hda_fixup alc882_fix + .chained = true, + .chain_id = ALC887_FIXUP_ASUS_AUDIO, + }, ++ [ALCS1200A_FIXUP_MIC_VREF] = { ++ .type = HDA_FIXUP_PINCTLS, ++ .v.pins = (const struct hda_pintbl[]) { ++ { 0x18, PIN_VREF50 }, /* rear mic */ ++ { 0x19, PIN_VREF50 }, /* front mic */ ++ {} ++ } ++ }, + }; + + static const struct snd_pci_quirk alc882_fixup_tbl[] = { +@@ -2563,6 +2572,7 @@ static const struct snd_pci_quirk alc882 + SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), + SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS), + SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3), ++ SND_PCI_QUIRK(0x1043, 0x8797, "ASUS TUF B550M-PLUS", ALCS1200A_FIXUP_MIC_VREF), + SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP), + SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP), + SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), diff --git a/queue-5.18/alsa-usb-audio-cancel-pending-work-at-closing-a-midi-substream.patch b/queue-5.18/alsa-usb-audio-cancel-pending-work-at-closing-a-midi-substream.patch new file mode 100644 index 00000000000..57642b03e7d --- /dev/null +++ b/queue-5.18/alsa-usb-audio-cancel-pending-work-at-closing-a-midi-substream.patch @@ -0,0 +1,36 @@ +From 0125de38122f0f66bf61336158d12a1aabfe6425 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Wed, 25 May 2022 15:12:03 +0200 +Subject: ALSA: usb-audio: Cancel pending work at closing a MIDI substream + +From: Takashi Iwai + +commit 0125de38122f0f66bf61336158d12a1aabfe6425 upstream. + +At closing a USB MIDI output substream, there might be still a pending +work, which would eventually access the rawmidi runtime object that is +being released. For fixing the race, make sure to cancel the pending +work at closing. + +Reported-by: syzbot+6912c9592caca7ca0e7d@syzkaller.appspotmail.com +Cc: +Link: https://lore.kernel.org/r/000000000000e7e75005dfd07cf6@google.com +Link: https://lore.kernel.org/r/20220525131203.11299-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/usb/midi.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/sound/usb/midi.c ++++ b/sound/usb/midi.c +@@ -1145,6 +1145,9 @@ static int snd_usbmidi_output_open(struc + + static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) + { ++ struct usbmidi_out_port *port = substream->runtime->private_data; ++ ++ cancel_work_sync(&port->ep->work); + return substream_open(substream, 0, 0); + } + diff --git a/queue-5.18/fs-ntfs3-check-new-size-for-limits.patch b/queue-5.18/fs-ntfs3-check-new-size-for-limits.patch new file mode 100644 index 00000000000..d3af4f573f3 --- /dev/null +++ b/queue-5.18/fs-ntfs3-check-new-size-for-limits.patch @@ -0,0 +1,38 @@ +From 114346978cf61de02832cc3cc68432a3de70fb38 Mon Sep 17 00:00:00 2001 +From: Konstantin Komarov +Date: Mon, 25 Oct 2021 18:34:06 +0300 +Subject: fs/ntfs3: Check new size for limits + +From: Konstantin Komarov + +commit 114346978cf61de02832cc3cc68432a3de70fb38 upstream. + +We must check size before trying to allocate. +Size can be set for example by "ulimit -f". +Fixes xfstest generic/228 +Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") + +Reviewed-by: Kari Argillander +Signed-off-by: Konstantin Komarov +Signed-off-by: Greg Kroah-Hartman +--- + fs/ntfs3/file.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/fs/ntfs3/file.c ++++ b/fs/ntfs3/file.c +@@ -662,7 +662,13 @@ static long ntfs_fallocate(struct file * + /* + * Normal file: Allocate clusters, do not change 'valid' size. + */ +- err = ntfs_set_size(inode, max(end, i_size)); ++ loff_t new_size = max(end, i_size); ++ ++ err = inode_newsize_ok(inode, new_size); ++ if (err) ++ goto out; ++ ++ err = ntfs_set_size(inode, new_size); + if (err) + goto out; + diff --git a/queue-5.18/fs-ntfs3-fix-fiemap-fix-shrink-file-size-to-remove-preallocated-space.patch b/queue-5.18/fs-ntfs3-fix-fiemap-fix-shrink-file-size-to-remove-preallocated-space.patch new file mode 100644 index 00000000000..73436544885 --- /dev/null +++ b/queue-5.18/fs-ntfs3-fix-fiemap-fix-shrink-file-size-to-remove-preallocated-space.patch @@ -0,0 +1,70 @@ +From 3880f2b816a7e4ca889b7e8a42e6c62c5706ed36 Mon Sep 17 00:00:00 2001 +From: Konstantin Komarov +Date: Mon, 25 Oct 2021 18:31:28 +0300 +Subject: fs/ntfs3: Fix fiemap + fix shrink file size (to remove preallocated space) + +From: Konstantin Komarov + +commit 3880f2b816a7e4ca889b7e8a42e6c62c5706ed36 upstream. + +Two problems: +1. ntfs3_setattr can't truncate preallocated space; +2. if allocated fragment "cross" valid size, then fragment splits into two parts: +- normal part; +- unwritten part (here we must return FIEMAP_EXTENT_LAST). +Before this commit we returned FIEMAP_EXTENT_LAST for whole fragment. +Fixes xfstest generic/092 +Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") + +Signed-off-by: Konstantin Komarov +Signed-off-by: Greg Kroah-Hartman +--- + fs/ntfs3/file.c | 2 +- + fs/ntfs3/frecord.c | 10 +++++++--- + 2 files changed, 8 insertions(+), 4 deletions(-) + +--- a/fs/ntfs3/file.c ++++ b/fs/ntfs3/file.c +@@ -762,7 +762,7 @@ int ntfs3_setattr(struct user_namespace + } + inode_dio_wait(inode); + +- if (attr->ia_size < oldsize) ++ if (attr->ia_size <= oldsize) + err = ntfs_truncate(inode, attr->ia_size); + else if (attr->ia_size > oldsize) + err = ntfs_extend(inode, attr->ia_size, 0, NULL); +--- a/fs/ntfs3/frecord.c ++++ b/fs/ntfs3/frecord.c +@@ -1964,10 +1964,8 @@ int ni_fiemap(struct ntfs_inode *ni, str + + vcn += clen; + +- if (vbo + bytes >= end) { ++ if (vbo + bytes >= end) + bytes = end - vbo; +- flags |= FIEMAP_EXTENT_LAST; +- } + + if (vbo + bytes <= valid) { + ; +@@ -1977,6 +1975,9 @@ int ni_fiemap(struct ntfs_inode *ni, str + /* vbo < valid && valid < vbo + bytes */ + u64 dlen = valid - vbo; + ++ if (vbo + dlen >= end) ++ flags |= FIEMAP_EXTENT_LAST; ++ + err = fiemap_fill_next_extent(fieinfo, vbo, lbo, dlen, + flags); + if (err < 0) +@@ -1995,6 +1996,9 @@ int ni_fiemap(struct ntfs_inode *ni, str + flags |= FIEMAP_EXTENT_UNWRITTEN; + } + ++ if (vbo + bytes >= end) ++ flags |= FIEMAP_EXTENT_LAST; ++ + err = fiemap_fill_next_extent(fieinfo, vbo, lbo, bytes, flags); + if (err < 0) + break; diff --git a/queue-5.18/fs-ntfs3-fix-some-memory-leaks-in-an-error-handling-path-of-log_replay.patch b/queue-5.18/fs-ntfs3-fix-some-memory-leaks-in-an-error-handling-path-of-log_replay.patch new file mode 100644 index 00000000000..afb038e67c5 --- /dev/null +++ b/queue-5.18/fs-ntfs3-fix-some-memory-leaks-in-an-error-handling-path-of-log_replay.patch @@ -0,0 +1,37 @@ +From e589f9b7078e1c0191613cd736f598e81d2390de Mon Sep 17 00:00:00 2001 +From: Christophe JAILLET +Date: Thu, 11 Nov 2021 08:45:44 +0100 +Subject: fs/ntfs3: Fix some memory leaks in an error handling path of 'log_replay()' + +From: Christophe JAILLET + +commit e589f9b7078e1c0191613cd736f598e81d2390de upstream. + +All error handling paths lead to 'out' where many resources are freed. + +Do it as well here instead of a direct return, otherwise 'log', 'ra' and +'log->one_page_buf' (at least) will leak. + +Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal") +Signed-off-by: Christophe JAILLET +Signed-off-by: Konstantin Komarov +Signed-off-by: Greg Kroah-Hartman +--- + fs/ntfs3/fslog.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/fs/ntfs3/fslog.c ++++ b/fs/ntfs3/fslog.c +@@ -4085,8 +4085,10 @@ process_log: + if (client == LFS_NO_CLIENT_LE) { + /* Insert "NTFS" client LogFile. */ + client = ra->client_idx[0]; +- if (client == LFS_NO_CLIENT_LE) +- return -EINVAL; ++ if (client == LFS_NO_CLIENT_LE) { ++ err = -EINVAL; ++ goto out; ++ } + + t16 = le16_to_cpu(client); + cr = ca + t16; diff --git a/queue-5.18/fs-ntfs3-in-function-ntfs_set_acl_ex-do-not-change-inode-i_mode-if-called-from-function-ntfs_init_acl.patch b/queue-5.18/fs-ntfs3-in-function-ntfs_set_acl_ex-do-not-change-inode-i_mode-if-called-from-function-ntfs_init_acl.patch new file mode 100644 index 00000000000..92089f60263 --- /dev/null +++ b/queue-5.18/fs-ntfs3-in-function-ntfs_set_acl_ex-do-not-change-inode-i_mode-if-called-from-function-ntfs_init_acl.patch @@ -0,0 +1,71 @@ +From 9186d472ee780fabf74424756c4c00545166157e Mon Sep 17 00:00:00 2001 +From: Konstantin Komarov +Date: Wed, 24 Nov 2021 15:08:19 +0300 +Subject: fs/ntfs3: In function ntfs_set_acl_ex do not change inode->i_mode if called from function ntfs_init_acl + +From: Konstantin Komarov + +commit 9186d472ee780fabf74424756c4c00545166157e upstream. + +ntfs_init_acl sets mode. ntfs_init_acl calls ntfs_set_acl_ex. +ntfs_set_acl_ex must not change this mode. +Fixes xfstest generic/444 +Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations") + +Reviewed-by: Joe Perches +Signed-off-by: Konstantin Komarov +Signed-off-by: Greg Kroah-Hartman +--- + fs/ntfs3/xattr.c | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +--- a/fs/ntfs3/xattr.c ++++ b/fs/ntfs3/xattr.c +@@ -541,7 +541,7 @@ struct posix_acl *ntfs_get_acl(struct in + + static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns, + struct inode *inode, struct posix_acl *acl, +- int type) ++ int type, bool init_acl) + { + const char *name; + size_t size, name_len; +@@ -554,8 +554,9 @@ static noinline int ntfs_set_acl_ex(stru + + switch (type) { + case ACL_TYPE_ACCESS: +- if (acl) { +- umode_t mode = inode->i_mode; ++ /* Do not change i_mode if we are in init_acl */ ++ if (acl && !init_acl) { ++ umode_t mode; + + err = posix_acl_update_mode(mnt_userns, inode, &mode, + &acl); +@@ -616,7 +617,7 @@ out: + int ntfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode, + struct posix_acl *acl, int type) + { +- return ntfs_set_acl_ex(mnt_userns, inode, acl, type); ++ return ntfs_set_acl_ex(mnt_userns, inode, acl, type, false); + } + + /* +@@ -636,7 +637,7 @@ int ntfs_init_acl(struct user_namespace + + if (default_acl) { + err = ntfs_set_acl_ex(mnt_userns, inode, default_acl, +- ACL_TYPE_DEFAULT); ++ ACL_TYPE_DEFAULT, true); + posix_acl_release(default_acl); + } else { + inode->i_default_acl = NULL; +@@ -647,7 +648,7 @@ int ntfs_init_acl(struct user_namespace + else { + if (!err) + err = ntfs_set_acl_ex(mnt_userns, inode, acl, +- ACL_TYPE_ACCESS); ++ ACL_TYPE_ACCESS, true); + posix_acl_release(acl); + } + diff --git a/queue-5.18/fs-ntfs3-keep-preallocated-only-if-option-prealloc-enabled.patch b/queue-5.18/fs-ntfs3-keep-preallocated-only-if-option-prealloc-enabled.patch new file mode 100644 index 00000000000..9be0ce62254 --- /dev/null +++ b/queue-5.18/fs-ntfs3-keep-preallocated-only-if-option-prealloc-enabled.patch @@ -0,0 +1,34 @@ +From e95113ed4d428219e3395044e29f5713fc446720 Mon Sep 17 00:00:00 2001 +From: Konstantin Komarov +Date: Fri, 22 Oct 2021 17:37:52 +0300 +Subject: fs/ntfs3: Keep preallocated only if option prealloc enabled + +From: Konstantin Komarov + +commit e95113ed4d428219e3395044e29f5713fc446720 upstream. + +If size of file was reduced, we still kept allocated blocks. +This commit makes ntfs3 work as other fs like btrfs. +Link: https://bugzilla.kernel.org/show_bug.cgi?id=214719 +Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") + +Reported-by: Ganapathi Kamath +Tested-by: Ganapathi Kamath +Reviewed-by: Kari Argillander +Signed-off-by: Konstantin Komarov +Signed-off-by: Greg Kroah-Hartman +--- + fs/ntfs3/file.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/ntfs3/file.c ++++ b/fs/ntfs3/file.c +@@ -495,7 +495,7 @@ static int ntfs_truncate(struct inode *i + + down_write(&ni->file.run_lock); + err = attr_set_size(ni, ATTR_DATA, NULL, 0, &ni->file.run, new_size, +- &new_valid, true, NULL); ++ &new_valid, ni->mi.sbi->options->prealloc, NULL); + up_write(&ni->file.run_lock); + + if (new_valid < ni->i_valid) diff --git a/queue-5.18/fs-ntfs3-provide-block_invalidate_folio-to-fix-memory-leak.patch b/queue-5.18/fs-ntfs3-provide-block_invalidate_folio-to-fix-memory-leak.patch new file mode 100644 index 00000000000..c390c5954b2 --- /dev/null +++ b/queue-5.18/fs-ntfs3-provide-block_invalidate_folio-to-fix-memory-leak.patch @@ -0,0 +1,38 @@ +From 724bbe49c5e427cb077357d72d240a649f2e4054 Mon Sep 17 00:00:00 2001 +From: Mikulas Patocka +Date: Mon, 30 May 2022 13:36:45 +0200 +Subject: fs/ntfs3: provide block_invalidate_folio to fix memory leak +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Mikulas Patocka + +commit 724bbe49c5e427cb077357d72d240a649f2e4054 upstream. + +The ntfs3 filesystem lacks the 'invalidate_folio' method and it causes +memory leak. If you write to the filesystem and then unmount it, the +cached written data are not freed and they are permanently leaked. +Fixes: 7ba13abbd31e ("fs: Turn block_invalidatepage into block_invalidate_folio") + +Reported-by: José Luis Lara Carrascal +Signed-off-by: Mikulas Patocka +Acked-by: Matthew Wilcox (Oracle) +Reviewed-by: Namjae Jeon +Signed-off-by: Konstantin Komarov +Cc: stable@vger.kernel.org # v5.18 +Signed-off-by: Greg Kroah-Hartman +--- + fs/ntfs3/inode.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/fs/ntfs3/inode.c ++++ b/fs/ntfs3/inode.c +@@ -1951,6 +1951,7 @@ const struct address_space_operations nt + .direct_IO = ntfs_direct_IO, + .bmap = ntfs_bmap, + .dirty_folio = block_dirty_folio, ++ .invalidate_folio = block_invalidate_folio, + }; + + const struct address_space_operations ntfs_aops_cmpr = { diff --git a/queue-5.18/fs-ntfs3-restore-ntfs_xattr_get_acl-and-ntfs_xattr_set_acl-functions.patch b/queue-5.18/fs-ntfs3-restore-ntfs_xattr_get_acl-and-ntfs_xattr_set_acl-functions.patch new file mode 100644 index 00000000000..7e45c79e5b6 --- /dev/null +++ b/queue-5.18/fs-ntfs3-restore-ntfs_xattr_get_acl-and-ntfs_xattr_set_acl-functions.patch @@ -0,0 +1,147 @@ +From 87e21c99bad763524c953ff4d1a61ee19038ddc2 Mon Sep 17 00:00:00 2001 +From: Konstantin Komarov +Date: Fri, 22 Oct 2021 18:15:36 +0300 +Subject: fs/ntfs3: Restore ntfs_xattr_get_acl and ntfs_xattr_set_acl functions + +From: Konstantin Komarov + +commit 87e21c99bad763524c953ff4d1a61ee19038ddc2 upstream. + +Apparently we need to maintain these functions with +ntfs_get_acl_ex and ntfs_set_acl_ex. +This commit fixes xfstest generic/099 +Fixes: 95dd8b2c1ed0 ("fs/ntfs3: Remove unnecessary functions") + +Reviewed-by: Kari Argillander +Signed-off-by: Konstantin Komarov +Signed-off-by: Greg Kroah-Hartman +--- + fs/ntfs3/xattr.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 95 insertions(+), 1 deletion(-) + +--- a/fs/ntfs3/xattr.c ++++ b/fs/ntfs3/xattr.c +@@ -112,7 +112,7 @@ static int ntfs_read_ea(struct ntfs_inod + return -ENOMEM; + + if (!size) { +- ; ++ /* EA info persists, but xattr is empty. Looks like EA problem. */ + } else if (attr_ea->non_res) { + struct runs_tree run; + +@@ -620,6 +620,67 @@ int ntfs_set_acl(struct user_namespace * + return ntfs_set_acl_ex(mnt_userns, inode, acl, type, false); + } + ++static int ntfs_xattr_get_acl(struct user_namespace *mnt_userns, ++ struct inode *inode, int type, void *buffer, ++ size_t size) ++{ ++ struct posix_acl *acl; ++ int err; ++ ++ if (!(inode->i_sb->s_flags & SB_POSIXACL)) { ++ ntfs_inode_warn(inode, "add mount option \"acl\" to use acl"); ++ return -EOPNOTSUPP; ++ } ++ ++ acl = ntfs_get_acl(inode, type, false); ++ if (IS_ERR(acl)) ++ return PTR_ERR(acl); ++ ++ if (!acl) ++ return -ENODATA; ++ ++ err = posix_acl_to_xattr(mnt_userns, acl, buffer, size); ++ posix_acl_release(acl); ++ ++ return err; ++} ++ ++static int ntfs_xattr_set_acl(struct user_namespace *mnt_userns, ++ struct inode *inode, int type, const void *value, ++ size_t size) ++{ ++ struct posix_acl *acl; ++ int err; ++ ++ if (!(inode->i_sb->s_flags & SB_POSIXACL)) { ++ ntfs_inode_warn(inode, "add mount option \"acl\" to use acl"); ++ return -EOPNOTSUPP; ++ } ++ ++ if (!inode_owner_or_capable(mnt_userns, inode)) ++ return -EPERM; ++ ++ if (!value) { ++ acl = NULL; ++ } else { ++ acl = posix_acl_from_xattr(mnt_userns, value, size); ++ if (IS_ERR(acl)) ++ return PTR_ERR(acl); ++ ++ if (acl) { ++ err = posix_acl_valid(mnt_userns, acl); ++ if (err) ++ goto release_and_out; ++ } ++ } ++ ++ err = ntfs_set_acl(mnt_userns, inode, acl, type); ++ ++release_and_out: ++ posix_acl_release(acl); ++ return err; ++} ++ + /* + * ntfs_init_acl - Initialize the ACLs of a new inode. + * +@@ -786,6 +847,23 @@ static int ntfs_getxattr(const struct xa + goto out; + } + ++#ifdef CONFIG_NTFS3_FS_POSIX_ACL ++ if ((name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 && ++ !memcmp(name, XATTR_NAME_POSIX_ACL_ACCESS, ++ sizeof(XATTR_NAME_POSIX_ACL_ACCESS))) || ++ (name_len == sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1 && ++ !memcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT, ++ sizeof(XATTR_NAME_POSIX_ACL_DEFAULT)))) { ++ /* TODO: init_user_ns? */ ++ err = ntfs_xattr_get_acl( ++ &init_user_ns, inode, ++ name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 ++ ? ACL_TYPE_ACCESS ++ : ACL_TYPE_DEFAULT, ++ buffer, size); ++ goto out; ++ } ++#endif + /* Deal with NTFS extended attribute. */ + err = ntfs_get_ea(inode, name, name_len, buffer, size, NULL); + +@@ -898,6 +976,22 @@ set_new_fa: + goto out; + } + ++#ifdef CONFIG_NTFS3_FS_POSIX_ACL ++ if ((name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 && ++ !memcmp(name, XATTR_NAME_POSIX_ACL_ACCESS, ++ sizeof(XATTR_NAME_POSIX_ACL_ACCESS))) || ++ (name_len == sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1 && ++ !memcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT, ++ sizeof(XATTR_NAME_POSIX_ACL_DEFAULT)))) { ++ err = ntfs_xattr_set_acl( ++ mnt_userns, inode, ++ name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 ++ ? ACL_TYPE_ACCESS ++ : ACL_TYPE_DEFAULT, ++ value, size); ++ goto out; ++ } ++#endif + /* Deal with NTFS extended attribute. */ + err = ntfs_set_ea(inode, name, name_len, value, size, flags); + diff --git a/queue-5.18/fs-ntfs3-update-i_ctime-when-xattr-is-added.patch b/queue-5.18/fs-ntfs3-update-i_ctime-when-xattr-is-added.patch new file mode 100644 index 00000000000..4e67b4a4de7 --- /dev/null +++ b/queue-5.18/fs-ntfs3-update-i_ctime-when-xattr-is-added.patch @@ -0,0 +1,31 @@ +From 2d44667c306e7806848a3478820f87343feb5421 Mon Sep 17 00:00:00 2001 +From: Konstantin Komarov +Date: Fri, 22 Oct 2021 18:35:43 +0300 +Subject: fs/ntfs3: Update i_ctime when xattr is added + +From: Konstantin Komarov + +commit 2d44667c306e7806848a3478820f87343feb5421 upstream. + +Ctime wasn't updated after setfacl command. +This commit fixes xfstest generic/307 +Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations") + +Signed-off-by: Konstantin Komarov +Signed-off-by: Greg Kroah-Hartman +--- + fs/ntfs3/xattr.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/fs/ntfs3/xattr.c ++++ b/fs/ntfs3/xattr.c +@@ -902,6 +902,9 @@ set_new_fa: + err = ntfs_set_ea(inode, name, name_len, value, size, flags); + + out: ++ inode->i_ctime = current_time(inode); ++ mark_inode_dirty(inode); ++ + return err; + } + diff --git a/queue-5.18/fs-ntfs3-update-valid-size-if-eiocbqueued.patch b/queue-5.18/fs-ntfs3-update-valid-size-if-eiocbqueued.patch new file mode 100644 index 00000000000..0c0c7d5e2f6 --- /dev/null +++ b/queue-5.18/fs-ntfs3-update-valid-size-if-eiocbqueued.patch @@ -0,0 +1,45 @@ +From 52e00ea6b26e45fb8159e3b57cdde8d3f9bdd8e9 Mon Sep 17 00:00:00 2001 +From: Konstantin Komarov +Date: Mon, 25 Oct 2021 18:48:38 +0300 +Subject: fs/ntfs3: Update valid size if -EIOCBQUEUED + +From: Konstantin Komarov + +commit 52e00ea6b26e45fb8159e3b57cdde8d3f9bdd8e9 upstream. + +Update valid size if write is still in I/O queue. +Fixes xfstest generic/240 +Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block") + +Signed-off-by: Konstantin Komarov +Signed-off-by: Greg Kroah-Hartman +--- + fs/ntfs3/inode.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/fs/ntfs3/inode.c ++++ b/fs/ntfs3/inode.c +@@ -757,6 +757,7 @@ static ssize_t ntfs_direct_IO(struct kio + loff_t vbo = iocb->ki_pos; + loff_t end; + int wr = iov_iter_rw(iter) & WRITE; ++ size_t iter_count = iov_iter_count(iter); + loff_t valid; + ssize_t ret; + +@@ -770,10 +771,13 @@ static ssize_t ntfs_direct_IO(struct kio + wr ? ntfs_get_block_direct_IO_W + : ntfs_get_block_direct_IO_R); + +- if (ret <= 0) ++ if (ret > 0) ++ end = vbo + ret; ++ else if (wr && ret == -EIOCBQUEUED) ++ end = vbo + iter_count; ++ else + goto out; + +- end = vbo + ret; + valid = ni->i_valid; + if (wr) { + if (end > valid && !S_ISBLK(inode->i_mode)) { diff --git a/queue-5.18/risc-v-mark-ioresource_exclusive-for-reserved-mem-instead-of-ioresource_busy.patch b/queue-5.18/risc-v-mark-ioresource_exclusive-for-reserved-mem-instead-of-ioresource_busy.patch new file mode 100644 index 00000000000..04660aac4e1 --- /dev/null +++ b/queue-5.18/risc-v-mark-ioresource_exclusive-for-reserved-mem-instead-of-ioresource_busy.patch @@ -0,0 +1,68 @@ +From e61bf5c071148c80d091f8e7220b3b9130780ae3 Mon Sep 17 00:00:00 2001 +From: Xianting Tian +Date: Wed, 18 May 2022 09:34:28 +0800 +Subject: RISC-V: Mark IORESOURCE_EXCLUSIVE for reserved mem instead of IORESOURCE_BUSY + +From: Xianting Tian + +commit e61bf5c071148c80d091f8e7220b3b9130780ae3 upstream. + +Commit 00ab027a3b82 ("RISC-V: Add kernel image sections to the resource tree") +marked IORESOURCE_BUSY for reserved memory, which caused resource map +failed in subsequent operations of related driver, so remove the +IORESOURCE_BUSY flag. In order to prohibit userland mapping reserved +memory, mark IORESOURCE_EXCLUSIVE for it. + +The code to reproduce the issue, +dts: + mem0: memory@a0000000 { + reg = <0x0 0xa0000000 0 0x1000000>; + no-map; + }; + + &test { + status = "okay"; + memory-region = <&mem0>; + }; + +code: + np = of_parse_phandle(pdev->dev.of_node, "memory-region", 0); + ret = of_address_to_resource(np, 0, &r); + base = devm_ioremap_resource(&pdev->dev, &r); + // base = -EBUSY + +Fixes: 00ab027a3b82 ("RISC-V: Add kernel image sections to the resource tree") +Reported-by: Huaming Jiang +Reviewed-by: Guo Ren +Reviewed-by: Heiko Stuebner +Tested-by: Heiko Stuebner +Co-developed-by: Nick Kossifidis +Signed-off-by: Xianting Tian +Link: https://lore.kernel.org/r/20220518013428.1338983-1-xianting.tian@linux.alibaba.com +Cc: stable@vger.kernel.org +Signed-off-by: Palmer Dabbelt +Signed-off-by: Greg Kroah-Hartman +--- + arch/riscv/kernel/setup.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/arch/riscv/kernel/setup.c ++++ b/arch/riscv/kernel/setup.c +@@ -189,7 +189,7 @@ static void __init init_resources(void) + res = &mem_res[res_idx--]; + + res->name = "Reserved"; +- res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; ++ res->flags = IORESOURCE_MEM | IORESOURCE_EXCLUSIVE; + res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); + res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; + +@@ -214,7 +214,7 @@ static void __init init_resources(void) + + if (unlikely(memblock_is_nomap(region))) { + res->name = "Reserved"; +- res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; ++ res->flags = IORESOURCE_MEM | IORESOURCE_EXCLUSIVE; + } else { + res->name = "System RAM"; + res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; diff --git a/queue-5.18/riscv-fix-irq_work-when-smp-is-disabled.patch b/queue-5.18/riscv-fix-irq_work-when-smp-is-disabled.patch new file mode 100644 index 00000000000..bbcce784382 --- /dev/null +++ b/queue-5.18/riscv-fix-irq_work-when-smp-is-disabled.patch @@ -0,0 +1,36 @@ +From 2273272823db6f67d57761df8116ae32e7f05bed Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 29 Apr 2022 22:00:23 -0500 +Subject: riscv: Fix irq_work when SMP is disabled + +From: Samuel Holland + +commit 2273272823db6f67d57761df8116ae32e7f05bed upstream. + +irq_work is triggered via an IPI, but the IPI infrastructure is not +included in uniprocessor kernels. As a result, irq_work never runs. +Fall back to the tick-based irq_work implementation on uniprocessor +configurations. + +Fixes: 298447928bb1 ("riscv: Support irq_work via self IPIs") +Signed-off-by: Samuel Holland +Reviewed-by: Heiko Stuebner +Link: https://lore.kernel.org/r/20220430030025.58405-1-samuel@sholland.org +Cc: stable@vger.kernel.org +Signed-off-by: Palmer Dabbelt +Signed-off-by: Greg Kroah-Hartman +--- + arch/riscv/include/asm/irq_work.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/riscv/include/asm/irq_work.h ++++ b/arch/riscv/include/asm/irq_work.h +@@ -4,7 +4,7 @@ + + static inline bool arch_irq_work_has_interrupt(void) + { +- return true; ++ return IS_ENABLED(CONFIG_SMP); + } + extern void arch_irq_work_raise(void); + #endif /* _ASM_RISCV_IRQ_WORK_H */ diff --git a/queue-5.18/riscv-initialize-thread-pointer-before-calling-c-functions.patch b/queue-5.18/riscv-initialize-thread-pointer-before-calling-c-functions.patch new file mode 100644 index 00000000000..c96ba8f3f40 --- /dev/null +++ b/queue-5.18/riscv-initialize-thread-pointer-before-calling-c-functions.patch @@ -0,0 +1,35 @@ +From 35d33c76d68dfacc330a8eb477b51cc647c5a847 Mon Sep 17 00:00:00 2001 +From: Alexandre Ghiti +Date: Mon, 6 Dec 2021 11:46:56 +0100 +Subject: riscv: Initialize thread pointer before calling C functions + +From: Alexandre Ghiti + +commit 35d33c76d68dfacc330a8eb477b51cc647c5a847 upstream. + +Because of the stack canary feature that reads from the current task +structure the stack canary value, the thread pointer register "tp" must +be set before calling any C function from head.S: by chance, setup_vm +and all the functions that it calls does not seem to be part of the +functions where the canary check is done, but in the following commits, +some functions will. + +Fixes: f2c9699f65557a31 ("riscv: Add STACKPROTECTOR supported") +Signed-off-by: Alexandre Ghiti +Cc: stable@vger.kernel.org +Signed-off-by: Palmer Dabbelt +Signed-off-by: Greg Kroah-Hartman +--- + arch/riscv/kernel/head.S | 1 + + 1 file changed, 1 insertion(+) + +--- a/arch/riscv/kernel/head.S ++++ b/arch/riscv/kernel/head.S +@@ -297,6 +297,7 @@ clear_bss_done: + REG_S a0, (a2) + + /* Initialize page tables and relocate to virtual addresses */ ++ la tp, init_task + la sp, init_thread_union + THREAD_SIZE + XIP_FIXUP_OFFSET sp + #ifdef CONFIG_BUILTIN_DTB diff --git a/queue-5.18/riscv-move-alternative-length-validation-into-subsection.patch b/queue-5.18/riscv-move-alternative-length-validation-into-subsection.patch new file mode 100644 index 00000000000..1660f9f783d --- /dev/null +++ b/queue-5.18/riscv-move-alternative-length-validation-into-subsection.patch @@ -0,0 +1,92 @@ +From 61114e734ccb804bc12561ab4020745e02c468c2 Mon Sep 17 00:00:00 2001 +From: Nathan Chancellor +Date: Mon, 16 May 2022 14:45:21 -0700 +Subject: riscv: Move alternative length validation into subsection + +From: Nathan Chancellor + +commit 61114e734ccb804bc12561ab4020745e02c468c2 upstream. + +After commit 49b290e430d3 ("riscv: prevent compressed instructions in +alternatives"), builds with LLVM's integrated assembler fail: + + In file included from arch/riscv/mm/init.c:10: + In file included from ./include/linux/mm.h:29: + In file included from ./include/linux/pgtable.h:6: + In file included from ./arch/riscv/include/asm/pgtable.h:108: + ./arch/riscv/include/asm/tlbflush.h:23:2: error: expected assembly-time absolute expression + ALT_FLUSH_TLB_PAGE(__asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory")); + ^ + ./arch/riscv/include/asm/errata_list.h:33:5: note: expanded from macro 'ALT_FLUSH_TLB_PAGE' + asm(ALTERNATIVE("sfence.vma %0", "sfence.vma", SIFIVE_VENDOR_ID, \ + ^ + ./arch/riscv/include/asm/alternative-macros.h:187:2: note: expanded from macro 'ALTERNATIVE' + _ALTERNATIVE_CFG(old_content, new_content, vendor_id, errata_id, CONFIG_k) + ^ + ./arch/riscv/include/asm/alternative-macros.h:113:2: note: expanded from macro '_ALTERNATIVE_CFG' + __ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)) + ^ + ./arch/riscv/include/asm/alternative-macros.h:110:2: note: expanded from macro '__ALTERNATIVE_CFG' + ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c) + ^ + ./arch/riscv/include/asm/alternative-macros.h:99:3: note: expanded from macro 'ALT_NEW_CONTENT' + ".org . - (889b - 888b) + (887b - 886b)\n" \ + ^ + :26:6: note: instantiated into assembly here + .org . - (889b - 888b) + (887b - 886b) + ^ + +This error happens because LLVM's integrated assembler has a one-pass +design, which means it cannot figure out the instruction lengths when +the .org directive is outside of the subsection that contains the +instructions, which was changed by the .option directives added by the +above change. + +Move the .org directives before the .previous directive so that these +directives are always within the same subsection, which resolves the +failures and does not introduce any new issues with GNU as. This was +done for arm64 in commit 966a0acce2fc ("arm64/alternatives: move length +validation inside the subsection") and commit 22315a2296f4 ("arm64: +alternatives: Move length validation in alternative_{insn, endif}"). + +While there is no error from the assembly versions of the macro, they +appear to have the same problem so just make the same change there as +well so that there are no problems in the future. + +Link: https://github.com/ClangBuiltLinux/linux/issues/1640 +Reported-by: kernel test robot +Signed-off-by: Nathan Chancellor +Reviewed-by: Heiko Stuebner +Tested-by: Heiko Stuebner +Link: https://lore.kernel.org/r/20220516214520.3252074-1-nathan@kernel.org +Cc: stable@vger.kernel.org +Signed-off-by: Palmer Dabbelt +Signed-off-by: Greg Kroah-Hartman +--- + arch/riscv/include/asm/alternative-macros.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/arch/riscv/include/asm/alternative-macros.h ++++ b/arch/riscv/include/asm/alternative-macros.h +@@ -23,9 +23,9 @@ + 888 : + \new_c + 889 : +- .previous + .org . - (889b - 888b) + (887b - 886b) + .org . - (887b - 886b) + (889b - 888b) ++ .previous + .endif + .endm + +@@ -60,9 +60,9 @@ + "888 :\n" \ + new_c "\n" \ + "889 :\n" \ +- ".previous\n" \ + ".org . - (887b - 886b) + (889b - 888b)\n" \ + ".org . - (889b - 888b) + (887b - 886b)\n" \ ++ ".previous\n" \ + ".endif\n" + + #define __ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, enable) \ diff --git a/queue-5.18/riscv-wire-up-memfd_secret-in-uapi-header.patch b/queue-5.18/riscv-wire-up-memfd_secret-in-uapi-header.patch new file mode 100644 index 00000000000..ac410ee822a --- /dev/null +++ b/queue-5.18/riscv-wire-up-memfd_secret-in-uapi-header.patch @@ -0,0 +1,47 @@ +From 02d88b40cb2e9614e0117c3385afdce878f0d377 Mon Sep 17 00:00:00 2001 +From: Tobias Klauser +Date: Thu, 5 May 2022 10:18:15 +0200 +Subject: riscv: Wire up memfd_secret in UAPI header + +From: Tobias Klauser + +commit 02d88b40cb2e9614e0117c3385afdce878f0d377 upstream. + +Move the __ARCH_WANT_MEMFD_SECRET define added in commit 7bb7f2ac24a0 +("arch, mm: wire up memfd_secret system call where relevant") to + so __NR_memfd_secret is defined when including + in userspace. + +This allows the memfd_secret selftest to pass on riscv. + +Signed-off-by: Tobias Klauser +Link: https://lore.kernel.org/r/20220505081815.22808-1-tklauser@distanz.ch +Fixes: 7bb7f2ac24a0 ("arch, mm: wire up memfd_secret system call where relevant") +Cc: stable@vger.kernel.org +Signed-off-by: Palmer Dabbelt +Signed-off-by: Greg Kroah-Hartman +--- + arch/riscv/include/asm/unistd.h | 1 - + arch/riscv/include/uapi/asm/unistd.h | 1 + + 2 files changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/riscv/include/asm/unistd.h ++++ b/arch/riscv/include/asm/unistd.h +@@ -9,7 +9,6 @@ + */ + + #define __ARCH_WANT_SYS_CLONE +-#define __ARCH_WANT_MEMFD_SECRET + + #include + +--- a/arch/riscv/include/uapi/asm/unistd.h ++++ b/arch/riscv/include/uapi/asm/unistd.h +@@ -21,6 +21,7 @@ + #endif /* __LP64__ */ + + #define __ARCH_WANT_SYS_CLONE3 ++#define __ARCH_WANT_MEMFD_SECRET + + #include + diff --git a/queue-5.18/series b/queue-5.18/series index 038761f76df..c6930ccb222 100644 --- a/queue-5.18/series +++ b/queue-5.18/series @@ -3,3 +3,27 @@ binfmt_flat-do-not-stop-relocating-got-entries-prematurely-on-riscv.patch parisc-fix-a-crash-with-multicore-scheduler.patch parisc-stifb-implement-fb_is_primary_device.patch parisc-stifb-keep-track-of-hardware-path-of-graphics-card.patch +risc-v-mark-ioresource_exclusive-for-reserved-mem-instead-of-ioresource_busy.patch +riscv-initialize-thread-pointer-before-calling-c-functions.patch +riscv-fix-irq_work-when-smp-is-disabled.patch +riscv-wire-up-memfd_secret-in-uapi-header.patch +riscv-move-alternative-length-validation-into-subsection.patch +alsa-hda-realtek-add-new-type-for-alc245.patch +alsa-hda-realtek-enable-4-speaker-output-for-dell-xps-15-9520-laptop.patch +alsa-hda-realtek-fix-microphone-noise-on-asus-tuf-b550m-plus.patch +alsa-usb-audio-cancel-pending-work-at-closing-a-midi-substream.patch +usb-serial-pl2303-fix-type-detection-for-odd-device.patch +usb-serial-option-add-quectel-bg95-modem.patch +usb-new-quirk-for-dell-gen-2-devices.patch +usb-isp1760-fix-out-of-bounds-array-access.patch +usb-dwc3-gadget-move-null-pinter-check-to-proper-place.patch +usb-core-hcd-add-support-for-deferring-roothub-registration.patch +fs-ntfs3-provide-block_invalidate_folio-to-fix-memory-leak.patch +fs-ntfs3-update-valid-size-if-eiocbqueued.patch +fs-ntfs3-fix-fiemap-fix-shrink-file-size-to-remove-preallocated-space.patch +fs-ntfs3-keep-preallocated-only-if-option-prealloc-enabled.patch +fs-ntfs3-check-new-size-for-limits.patch +fs-ntfs3-in-function-ntfs_set_acl_ex-do-not-change-inode-i_mode-if-called-from-function-ntfs_init_acl.patch +fs-ntfs3-fix-some-memory-leaks-in-an-error-handling-path-of-log_replay.patch +fs-ntfs3-update-i_ctime-when-xattr-is-added.patch +fs-ntfs3-restore-ntfs_xattr_get_acl-and-ntfs_xattr_set_acl-functions.patch diff --git a/queue-5.18/usb-core-hcd-add-support-for-deferring-roothub-registration.patch b/queue-5.18/usb-core-hcd-add-support-for-deferring-roothub-registration.patch new file mode 100644 index 00000000000..44f331a3cbe --- /dev/null +++ b/queue-5.18/usb-core-hcd-add-support-for-deferring-roothub-registration.patch @@ -0,0 +1,122 @@ +From a44623d9279086c89f631201d993aa332f7c9e66 Mon Sep 17 00:00:00 2001 +From: Kishon Vijay Abraham I +Date: Tue, 10 May 2022 14:46:29 +0530 +Subject: usb: core: hcd: Add support for deferring roothub registration + +From: Kishon Vijay Abraham I + +commit a44623d9279086c89f631201d993aa332f7c9e66 upstream. + +It has been observed with certain PCIe USB cards (like Inateck connected +to AM64 EVM or J7200 EVM) that as soon as the primary roothub is +registered, port status change is handled even before xHC is running +leading to cold plug USB devices not detected. For such cases, registering +both the root hubs along with the second HCD is required. Add support for +deferring roothub registration in usb_add_hcd(), so that both primary and +secondary roothubs are registered along with the second HCD. + +This patch has been added and reverted earier as it triggered a race +in usb device enumeration. +That race is now fixed in 5.16-rc3, and in stable back to 5.4 +commit 6cca13de26ee ("usb: hub: Fix locking issues with address0_mutex") +commit 6ae6dc22d2d1 ("usb: hub: Fix usb enumeration issue due to address0 +race") + +CC: stable@vger.kernel.org # 5.4+ +Suggested-by: Mathias Nyman +Tested-by: Chris Chiu +Acked-by: Alan Stern +Signed-off-by: Kishon Vijay Abraham I +Link: https://lore.kernel.org/r/20220510091630.16564-2-kishon@ti.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/core/hcd.c | 29 +++++++++++++++++++++++------ + include/linux/usb/hcd.h | 2 ++ + 2 files changed, 25 insertions(+), 6 deletions(-) + +--- a/drivers/usb/core/hcd.c ++++ b/drivers/usb/core/hcd.c +@@ -2816,6 +2816,7 @@ int usb_add_hcd(struct usb_hcd *hcd, + { + int retval; + struct usb_device *rhdev; ++ struct usb_hcd *shared_hcd; + + if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) { + hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev); +@@ -2976,13 +2977,26 @@ int usb_add_hcd(struct usb_hcd *hcd, + goto err_hcd_driver_start; + } + ++ /* starting here, usbcore will pay attention to the shared HCD roothub */ ++ shared_hcd = hcd->shared_hcd; ++ if (!usb_hcd_is_primary_hcd(hcd) && shared_hcd && HCD_DEFER_RH_REGISTER(shared_hcd)) { ++ retval = register_root_hub(shared_hcd); ++ if (retval != 0) ++ goto err_register_root_hub; ++ ++ if (shared_hcd->uses_new_polling && HCD_POLL_RH(shared_hcd)) ++ usb_hcd_poll_rh_status(shared_hcd); ++ } ++ + /* starting here, usbcore will pay attention to this root hub */ +- retval = register_root_hub(hcd); +- if (retval != 0) +- goto err_register_root_hub; ++ if (!HCD_DEFER_RH_REGISTER(hcd)) { ++ retval = register_root_hub(hcd); ++ if (retval != 0) ++ goto err_register_root_hub; + +- if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) +- usb_hcd_poll_rh_status(hcd); ++ if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) ++ usb_hcd_poll_rh_status(hcd); ++ } + + return retval; + +@@ -3020,6 +3034,7 @@ EXPORT_SYMBOL_GPL(usb_add_hcd); + void usb_remove_hcd(struct usb_hcd *hcd) + { + struct usb_device *rhdev = hcd->self.root_hub; ++ bool rh_registered; + + dev_info(hcd->self.controller, "remove, state %x\n", hcd->state); + +@@ -3030,6 +3045,7 @@ void usb_remove_hcd(struct usb_hcd *hcd) + + dev_dbg(hcd->self.controller, "roothub graceful disconnect\n"); + spin_lock_irq (&hcd_root_hub_lock); ++ rh_registered = hcd->rh_registered; + hcd->rh_registered = 0; + spin_unlock_irq (&hcd_root_hub_lock); + +@@ -3039,7 +3055,8 @@ void usb_remove_hcd(struct usb_hcd *hcd) + cancel_work_sync(&hcd->died_work); + + mutex_lock(&usb_bus_idr_lock); +- usb_disconnect(&rhdev); /* Sets rhdev to NULL */ ++ if (rh_registered) ++ usb_disconnect(&rhdev); /* Sets rhdev to NULL */ + mutex_unlock(&usb_bus_idr_lock); + + /* +--- a/include/linux/usb/hcd.h ++++ b/include/linux/usb/hcd.h +@@ -124,6 +124,7 @@ struct usb_hcd { + #define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */ + #define HCD_FLAG_DEAD 6 /* controller has died? */ + #define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */ ++#define HCD_FLAG_DEFER_RH_REGISTER 8 /* Defer roothub registration */ + + /* The flags can be tested using these macros; they are likely to + * be slightly faster than test_bit(). +@@ -134,6 +135,7 @@ struct usb_hcd { + #define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING)) + #define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING)) + #define HCD_DEAD(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEAD)) ++#define HCD_DEFER_RH_REGISTER(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEFER_RH_REGISTER)) + + /* + * Specifies if interfaces are authorized by default diff --git a/queue-5.18/usb-dwc3-gadget-move-null-pinter-check-to-proper-place.patch b/queue-5.18/usb-dwc3-gadget-move-null-pinter-check-to-proper-place.patch new file mode 100644 index 00000000000..dfe80fee0cf --- /dev/null +++ b/queue-5.18/usb-dwc3-gadget-move-null-pinter-check-to-proper-place.patch @@ -0,0 +1,71 @@ +From 3c5880745b4439ac64eccdb040e37fc1cc4c5406 Mon Sep 17 00:00:00 2001 +From: Albert Wang +Date: Wed, 18 May 2022 14:13:15 +0800 +Subject: usb: dwc3: gadget: Move null pinter check to proper place + +From: Albert Wang + +commit 3c5880745b4439ac64eccdb040e37fc1cc4c5406 upstream. + +When dwc3_gadget_ep_cleanup_completed_requests() called to +dwc3_gadget_giveback() where the dwc3 lock is released, other thread is +able to execute. In this situation, usb_ep_disable() gets the chance to +clear endpoint descriptor pointer which leds to the null pointer +dereference problem. So needs to move the null pointer check to a proper +place. + +Example call stack: + +Thread#1: +dwc3_thread_interrupt() + spin_lock + -> dwc3_process_event_buf() + -> dwc3_process_event_entry() + -> dwc3_endpoint_interrupt() + -> dwc3_gadget_endpoint_trbs_complete() + -> dwc3_gadget_ep_cleanup_completed_requests() + ... + -> dwc3_giveback() + spin_unlock + Thread#2 executes + +Thread#2: +configfs_composite_disconnect() + -> __composite_disconnect() + -> ffs_func_disable() + -> ffs_func_set_alt() + -> ffs_func_eps_disable() + -> usb_ep_disable() + wait for dwc3 spin_lock + Thread#1 released lock + clear endpoint.desc + +Fixes: 26288448120b ("usb: dwc3: gadget: Fix null pointer exception") +Cc: stable +Signed-off-by: Albert Wang +Link: https://lore.kernel.org/r/20220518061315.3359198-1-albertccwang@google.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/dwc3/gadget.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -3380,14 +3380,14 @@ static bool dwc3_gadget_endpoint_trbs_co + struct dwc3 *dwc = dep->dwc; + bool no_started_trb = true; + +- if (!dep->endpoint.desc) +- return no_started_trb; +- + dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); + + if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) + goto out; + ++ if (!dep->endpoint.desc) ++ return no_started_trb; ++ + if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && + list_empty(&dep->started_list) && + (list_empty(&dep->pending_list) || status == -EXDEV)) diff --git a/queue-5.18/usb-isp1760-fix-out-of-bounds-array-access.patch b/queue-5.18/usb-isp1760-fix-out-of-bounds-array-access.patch new file mode 100644 index 00000000000..d0a6a693480 --- /dev/null +++ b/queue-5.18/usb-isp1760-fix-out-of-bounds-array-access.patch @@ -0,0 +1,85 @@ +From 26ae2c942b5702f2e43d36b2a4389cfb7d616b6a Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Mon, 16 May 2022 11:14:24 +0200 +Subject: usb: isp1760: Fix out-of-bounds array access + +From: Linus Walleij + +commit 26ae2c942b5702f2e43d36b2a4389cfb7d616b6a upstream. + +Running the driver through kasan gives an interesting splat: + + BUG: KASAN: global-out-of-bounds in isp1760_register+0x180/0x70c + Read of size 20 at addr f1db2e64 by task swapper/0/1 + (...) + isp1760_register from isp1760_plat_probe+0x1d8/0x220 + (...) + +This happens because the loop reading the regmap fields for the +different ISP1760 variants look like this: + + for (i = 0; i < HC_FIELD_MAX; i++) { ... } + +Meaning it expects the arrays to be at least HC_FIELD_MAX - 1 long. + +However the arrays isp1760_hc_reg_fields[], isp1763_hc_reg_fields[], +isp1763_hc_volatile_ranges[] and isp1763_dc_volatile_ranges[] are +dynamically sized during compilation. + +Fix this by putting an empty assignment to the [HC_FIELD_MAX] +and [DC_FIELD_MAX] array member at the end of each array. +This will make the array one member longer than it needs to be, +but avoids the risk of overwriting whatever is inside +[HC_FIELD_MAX - 1] and is simple and intuitive to read. Also +add comments explaining what is going on. + +Fixes: 1da9e1c06873 ("usb: isp1760: move to regmap for register access") +Cc: stable@vger.kernel.org +Cc: Rui Miguel Silva +Cc: Dietmar Eggemann +Reviewed-by: Rui Miguel Silva +Signed-off-by: Linus Walleij +Link: https://lore.kernel.org/r/20220516091424.391209-1-linus.walleij@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/isp1760/isp1760-core.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/drivers/usb/isp1760/isp1760-core.c ++++ b/drivers/usb/isp1760/isp1760-core.c +@@ -251,6 +251,8 @@ static const struct reg_field isp1760_hc + [HW_DM_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL, 2, 2), + [HW_DP_PULLDOWN] = REG_FIELD(ISP176x_HC_OTG_CTRL, 1, 1), + [HW_DP_PULLUP] = REG_FIELD(ISP176x_HC_OTG_CTRL, 0, 0), ++ /* Make sure the array is sized properly during compilation */ ++ [HC_FIELD_MAX] = {}, + }; + + static const struct reg_field isp1763_hc_reg_fields[] = { +@@ -321,6 +323,8 @@ static const struct reg_field isp1763_hc + [HW_DM_PULLDOWN_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 2, 2), + [HW_DP_PULLDOWN_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 1, 1), + [HW_DP_PULLUP_CLEAR] = REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 0, 0), ++ /* Make sure the array is sized properly during compilation */ ++ [HC_FIELD_MAX] = {}, + }; + + static const struct regmap_range isp1763_hc_volatile_ranges[] = { +@@ -405,6 +409,8 @@ static const struct reg_field isp1761_dc + [DC_CHIP_ID_HIGH] = REG_FIELD(ISP176x_DC_CHIPID, 16, 31), + [DC_CHIP_ID_LOW] = REG_FIELD(ISP176x_DC_CHIPID, 0, 15), + [DC_SCRATCH] = REG_FIELD(ISP176x_DC_SCRATCH, 0, 15), ++ /* Make sure the array is sized properly during compilation */ ++ [DC_FIELD_MAX] = {}, + }; + + static const struct regmap_range isp1763_dc_volatile_ranges[] = { +@@ -458,6 +464,8 @@ static const struct reg_field isp1763_dc + [DC_CHIP_ID_HIGH] = REG_FIELD(ISP1763_DC_CHIPID_HIGH, 0, 15), + [DC_CHIP_ID_LOW] = REG_FIELD(ISP1763_DC_CHIPID_LOW, 0, 15), + [DC_SCRATCH] = REG_FIELD(ISP1763_DC_SCRATCH, 0, 15), ++ /* Make sure the array is sized properly during compilation */ ++ [DC_FIELD_MAX] = {}, + }; + + static const struct regmap_config isp1763_dc_regmap_conf = { diff --git a/queue-5.18/usb-new-quirk-for-dell-gen-2-devices.patch b/queue-5.18/usb-new-quirk-for-dell-gen-2-devices.patch new file mode 100644 index 00000000000..628492a223c --- /dev/null +++ b/queue-5.18/usb-new-quirk-for-dell-gen-2-devices.patch @@ -0,0 +1,34 @@ +From 97fa5887cf283bb75ffff5f6b2c0e71794c02400 Mon Sep 17 00:00:00 2001 +From: Monish Kumar R +Date: Fri, 20 May 2022 18:30:44 +0530 +Subject: USB: new quirk for Dell Gen 2 devices + +From: Monish Kumar R + +commit 97fa5887cf283bb75ffff5f6b2c0e71794c02400 upstream. + +Add USB_QUIRK_NO_LPM and USB_QUIRK_RESET_RESUME quirks for Dell usb gen +2 device to not fail during enumeration. + +Found this bug on own testing + +Signed-off-by: Monish Kumar R +Cc: stable +Link: https://lore.kernel.org/r/20220520130044.17303-1-monish.kumar.r@intel.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/core/quirks.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/usb/core/quirks.c ++++ b/drivers/usb/core/quirks.c +@@ -510,6 +510,9 @@ static const struct usb_device_id usb_qu + /* DJI CineSSD */ + { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, + ++ /* DELL USB GEN2 */ ++ { USB_DEVICE(0x413c, 0xb062), .driver_info = USB_QUIRK_NO_LPM | USB_QUIRK_RESET_RESUME }, ++ + /* VCOM device */ + { USB_DEVICE(0x4296, 0x7570), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS }, + diff --git a/queue-5.18/usb-serial-option-add-quectel-bg95-modem.patch b/queue-5.18/usb-serial-option-add-quectel-bg95-modem.patch new file mode 100644 index 00000000000..5954b1a0f8b --- /dev/null +++ b/queue-5.18/usb-serial-option-add-quectel-bg95-modem.patch @@ -0,0 +1,115 @@ +From 33b7af2f459df453feb0d44628d820c47fefe7a8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Carl=20Yin=28=E6=AE=B7=E5=BC=A0=E6=88=90=29?= + +Date: Thu, 19 May 2022 02:34:43 +0000 +Subject: USB: serial: option: add Quectel BG95 modem + +From: Carl Yin(殷张成) + +commit 33b7af2f459df453feb0d44628d820c47fefe7a8 upstream. + +The BG95 modem has 3 USB configurations that are configurable via the AT +command AT+QCFGEXT="usbnet",["ecm"|"modem"|"rmnet"] which make the modem +enumerate with the following interfaces, respectively: + +"modem": Diag + GNSS + Modem + Modem +"ecm" : Diag + GNSS + Modem + ECM +"rmnet": Diag + GNSS + Modem + QMI + Don't support Full QMI messages (e.g WDS_START_NETWORK_INTERFACE) + +A detailed description of the USB configuration for each mode follows: + ++QCFGEXT: "usbnet","modem" +-------------------------- +T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 3 Spd=480 MxCh= 0 +D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 +P: Vendor=2c7c ProdID=0700 Rev= 0.00 +S: Manufacturer=Quectel, Incorporated +S: Product=Quectel LPWA Module +S: SerialNumber=884328a2 +C:* #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=500mA +I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option +E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option +E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option +E: Ad=83(I) Atr=03(Int.) MxPS= 64 Ivl=2ms +E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=fe Prot=ff Driver=option +E: Ad=85(I) Atr=03(Int.) MxPS= 64 Ivl=2ms +E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms + ++QCFGEXT: "usbnet","ecm" +------------------------ +T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 4 Spd=480 MxCh= 0 +D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 +P: Vendor=2c7c ProdID=0700 Rev= 0.00 +S: Manufacturer=Quectel, Incorporated +S: Product=Quectel LPWA Module +S: SerialNumber=884328a2 +C:* #Ifs= 5 Cfg#= 1 Atr=e0 MxPwr=500mA +A: FirstIf#= 3 IfCount= 2 Cls=02(comm.) Sub=00 Prot=00 +I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option +E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option +E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option +E: Ad=83(I) Atr=03(Int.) MxPS= 64 Ivl=2ms +E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 3 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=cdc_ether +E: Ad=85(I) Atr=03(Int.) MxPS= 64 Ivl=2ms +I: If#= 4 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether +I:* If#= 4 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether +E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms + ++QCFGEXT: "usbnet","rmnet" +-------------------------- +T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 4 Spd=480 MxCh= 0 +D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 +P: Vendor=2c7c ProdID=0700 Rev= 0.00 +S: Manufacturer=Quectel, Incorporated +S: Product=Quectel LPWA Module +S: SerialNumber=884328a2 +C:* #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=500mA +I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option +E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option +E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option +E: Ad=83(I) Atr=03(Int.) MxPS= 64 Ivl=2ms +E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan +E: Ad=85(I) Atr=03(Int.) MxPS= 64 Ivl=2ms +E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms + +Signed-off-by: Carl Yin +Cc: stable@vger.kernel.org +Signed-off-by: Johan Hovold +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/serial/option.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/usb/serial/option.c ++++ b/drivers/usb/serial/option.c +@@ -1137,6 +1137,8 @@ static const struct usb_device_id option + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 0x0620, 0xff, 0xff, 0x30) }, /* EM160R-GL */ + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, 0x0620, 0xff, 0, 0) }, ++ { USB_DEVICE_INTERFACE_CLASS(QUECTEL_VENDOR_ID, 0x0700, 0xff), /* BG95 */ ++ .driver_info = RSVD(3) | ZLP }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0xff, 0x30) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0xff, 0x10), diff --git a/queue-5.18/usb-serial-pl2303-fix-type-detection-for-odd-device.patch b/queue-5.18/usb-serial-pl2303-fix-type-detection-for-odd-device.patch new file mode 100644 index 00000000000..15fbd63aa67 --- /dev/null +++ b/queue-5.18/usb-serial-pl2303-fix-type-detection-for-odd-device.patch @@ -0,0 +1,37 @@ +From e82e7c6dde91acd6748d672a44dc1980ce239f86 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Tue, 17 May 2022 18:17:36 +0200 +Subject: USB: serial: pl2303: fix type detection for odd device + +From: Johan Hovold + +commit e82e7c6dde91acd6748d672a44dc1980ce239f86 upstream. + +At least one pl2303 device has a bcdUSB of 1.0.1 which most likely was +was intended as 1.1. + +Allow bcdDevice 1.0.1 but interpret it as 1.1. + +Fixes: 1e9faef4d26d ("USB: serial: pl2303: fix HX type detection") +Cc: stable@vger.kernel.org # 5.13 +Link: https://lore.kernel.org/linux-usb/CAJixRzqf4a9-ZKZDgWxicc_BpfdZVE9qqGmkiO7xEstOXUbGvQ@mail.gmail.com +Reported-by: Gary van der Merwe +Link: https://lore.kernel.org/r/20220517161736.13313-1-johan@kernel.org +Signed-off-by: Johan Hovold +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/serial/pl2303.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/usb/serial/pl2303.c ++++ b/drivers/usb/serial/pl2303.c +@@ -421,6 +421,9 @@ static int pl2303_detect_type(struct usb + bcdUSB = le16_to_cpu(desc->bcdUSB); + + switch (bcdUSB) { ++ case 0x101: ++ /* USB 1.0.1? Let's assume they meant 1.1... */ ++ fallthrough; + case 0x110: + switch (bcdDevice) { + case 0x300: