From: Greg Kroah-Hartman Date: Mon, 27 Apr 2020 16:14:18 +0000 (+0200) Subject: 4.19-stable patches X-Git-Tag: v4.19.119~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cbf3e32cad75a934b0504d717470917a8e9d6dbc;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: alsa-hda-realtek-add-new-codec-supported-for-alc245.patch alsa-hda-realtek-fix-unexpected-init_amp-override.patch alsa-usb-audio-filter-out-unsupported-sample-rates-on-focusrite-devices.patch alsa-usb-audio-fix-usb-audio-refcnt-leak-when-getting-spdif.patch alsa-usx2y-fix-potential-null-dereference.patch asoc-dapm-fixup-dapm-kcontrol-widget.patch audit-check-the-length-of-userspace-generated-audit-records.patch iwlwifi-mvm-beacon-statistics-shouldn-t-go-backwards.patch iwlwifi-pcie-actually-release-queue-memory-in-tvqm.patch kvm-check-validity-of-resolved-slot-when-searching-memslots.patch kvm-s390-return-last-valid-slot-if-approx-index-is-out-of-bounds.patch kvm-vmx-enable-machine-check-support-for-32bit-targets.patch mm-hugetlb-fix-a-addressing-exception-caused-by-huge_pte_offset.patch mm-ksm-fix-null-pointer-dereference-when-ksm-zero-page-is-enabled.patch tools-vm-fix-cross-compile-build.patch tpm-ibmvtpm-retry-on-h_closed-in-tpm_ibmvtpm_send.patch tpm-tpm_tis-free-irq-if-probing-fails.patch tty-hvc-fix-buffer-overflow-during-hvc_alloc.patch tty-rocket-avoid-oob-access.patch usb-storage-add-unusual_devs-entry-for-jmicron-jms566.patch vmalloc-fix-remap_vmalloc_range-bounds-checks.patch --- diff --git a/queue-4.19/alsa-hda-realtek-add-new-codec-supported-for-alc245.patch b/queue-4.19/alsa-hda-realtek-add-new-codec-supported-for-alc245.patch new file mode 100644 index 00000000000..e3a445f1cc1 --- /dev/null +++ b/queue-4.19/alsa-hda-realtek-add-new-codec-supported-for-alc245.patch @@ -0,0 +1,47 @@ +From 7fbdcd8301a84c09cebfa64f1317a6dafeec9188 Mon Sep 17 00:00:00 2001 +From: Kailang Yang +Date: Thu, 23 Apr 2020 14:18:31 +0800 +Subject: ALSA: hda/realtek - Add new codec supported for ALC245 + +From: Kailang Yang + +commit 7fbdcd8301a84c09cebfa64f1317a6dafeec9188 upstream. + +Enable new codec supported for ALC245. + +Signed-off-by: Kailang Yang +Cc: +Link: https://lore.kernel.org/r/8c0804738b2c42439f59c39c8437817f@realtek.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/pci/hda/patch_realtek.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -380,6 +380,7 @@ static void alc_fill_eapd_coef(struct hd + case 0x10ec0233: + case 0x10ec0235: + case 0x10ec0236: ++ case 0x10ec0245: + case 0x10ec0255: + case 0x10ec0256: + case 0x10ec0257: +@@ -7792,6 +7793,7 @@ static int patch_alc269(struct hda_codec + spec->gen.mixer_nid = 0; + break; + case 0x10ec0215: ++ case 0x10ec0245: + case 0x10ec0285: + case 0x10ec0289: + spec->codec_variant = ALC269_TYPE_ALC215; +@@ -8913,6 +8915,7 @@ static const struct hda_device_id snd_hd + HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269), + HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269), + HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269), ++ HDA_CODEC_ENTRY(0x10ec0245, "ALC245", patch_alc269), + HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269), + HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269), + HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269), diff --git a/queue-4.19/alsa-hda-realtek-fix-unexpected-init_amp-override.patch b/queue-4.19/alsa-hda-realtek-fix-unexpected-init_amp-override.patch new file mode 100644 index 00000000000..a3ed8a5b0d5 --- /dev/null +++ b/queue-4.19/alsa-hda-realtek-fix-unexpected-init_amp-override.patch @@ -0,0 +1,53 @@ +From 67791202c5e069cf2ba51db0718d56c634709e78 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Sat, 18 Apr 2020 21:06:39 +0200 +Subject: ALSA: hda/realtek - Fix unexpected init_amp override + +From: Takashi Iwai + +commit 67791202c5e069cf2ba51db0718d56c634709e78 upstream. + +The commit 1c76aa5fb48d ("ALSA: hda/realtek - Allow skipping +spec->init_amp detection") changed the way to assign spec->init_amp +field that specifies the way to initialize the amp. Along with the +change, the commit also replaced a few fixups that set spec->init_amp +in HDA_FIXUP_ACT_PROBE with HDA_FIXUP_ACT_PRE_PROBE. This was rather +aligning to the other fixups, and not supposed to change the actual +behavior. + +However, this change turned out to cause a regression on FSC S7020, +which hit exactly the above. The reason was that there is still one +place that overrides spec->init_amp after HDA_FIXUP_ACT_PRE_PROBE +call, namely in alc_ssid_check(). + +This patch fixes the regression by adding the proper spec->init_amp +override check, i.e. verifying whether it's still ALC_INIT_UNDEFINED. + +Fixes: 1c76aa5fb48d ("ALSA: hda/realtek - Allow skipping spec->init_amp detection") +Cc: +BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207329 +Link: https://lore.kernel.org/r/20200418190639.10082-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/pci/hda/patch_realtek.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -801,9 +801,11 @@ static void alc_ssid_check(struct hda_co + { + if (!alc_subsystem_id(codec, ports)) { + struct alc_spec *spec = codec->spec; +- codec_dbg(codec, +- "realtek: Enable default setup for auto mode as fallback\n"); +- spec->init_amp = ALC_INIT_DEFAULT; ++ if (spec->init_amp == ALC_INIT_UNDEFINED) { ++ codec_dbg(codec, ++ "realtek: Enable default setup for auto mode as fallback\n"); ++ spec->init_amp = ALC_INIT_DEFAULT; ++ } + } + } + diff --git a/queue-4.19/alsa-usb-audio-filter-out-unsupported-sample-rates-on-focusrite-devices.patch b/queue-4.19/alsa-usb-audio-filter-out-unsupported-sample-rates-on-focusrite-devices.patch new file mode 100644 index 00000000000..43b28748704 --- /dev/null +++ b/queue-4.19/alsa-usb-audio-filter-out-unsupported-sample-rates-on-focusrite-devices.patch @@ -0,0 +1,105 @@ +From 1c826792586f526a5a5cd21d55aad388f5bb0b23 Mon Sep 17 00:00:00 2001 +From: Alexander Tsoy +Date: Sat, 18 Apr 2020 20:58:15 +0300 +Subject: ALSA: usb-audio: Filter out unsupported sample rates on Focusrite devices + +From: Alexander Tsoy + +commit 1c826792586f526a5a5cd21d55aad388f5bb0b23 upstream. + +Many Focusrite devices supports a limited set of sample rates per +altsetting. These includes audio interfaces with ADAT ports: + - Scarlett 18i6, 18i8 1st gen, 18i20 1st gen; + - Scarlett 18i8 2nd gen, 18i20 2nd gen; + - Scarlett 18i8 3rd gen, 18i20 3rd gen; + - Clarett 2Pre USB, 4Pre USB, 8Pre USB. + +Maximum rate is exposed in the last 4 bytes of Format Type descriptor +which has a non-standard bLength = 10. + +Tested-by: Alexey Skobkin +Signed-off-by: Alexander Tsoy +Cc: +Link: https://lore.kernel.org/r/20200418175815.12211-1-alexander@tsoy.me +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/usb/format.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 52 insertions(+) + +--- a/sound/usb/format.c ++++ b/sound/usb/format.c +@@ -238,6 +238,52 @@ static int parse_audio_format_rates_v1(s + } + + /* ++ * Many Focusrite devices supports a limited set of sampling rates per ++ * altsetting. Maximum rate is exposed in the last 4 bytes of Format Type ++ * descriptor which has a non-standard bLength = 10. ++ */ ++static bool focusrite_valid_sample_rate(struct snd_usb_audio *chip, ++ struct audioformat *fp, ++ unsigned int rate) ++{ ++ struct usb_interface *iface; ++ struct usb_host_interface *alts; ++ unsigned char *fmt; ++ unsigned int max_rate; ++ ++ iface = usb_ifnum_to_if(chip->dev, fp->iface); ++ if (!iface) ++ return true; ++ ++ alts = &iface->altsetting[fp->altset_idx]; ++ fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, ++ NULL, UAC_FORMAT_TYPE); ++ if (!fmt) ++ return true; ++ ++ if (fmt[0] == 10) { /* bLength */ ++ max_rate = combine_quad(&fmt[6]); ++ ++ /* Validate max rate */ ++ if (max_rate != 48000 && ++ max_rate != 96000 && ++ max_rate != 192000 && ++ max_rate != 384000) { ++ ++ usb_audio_info(chip, ++ "%u:%d : unexpected max rate: %u\n", ++ fp->iface, fp->altsetting, max_rate); ++ ++ return true; ++ } ++ ++ return rate <= max_rate; ++ } ++ ++ return true; ++} ++ ++/* + * Helper function to walk the array of sample rate triplets reported by + * the device. The problem is that we need to parse whole array first to + * get to know how many sample rates we have to expect. +@@ -273,6 +319,11 @@ static int parse_uac2_sample_rate_range( + } + + for (rate = min; rate <= max; rate += res) { ++ /* Filter out invalid rates on Focusrite devices */ ++ if (USB_ID_VENDOR(chip->usb_id) == 0x1235 && ++ !focusrite_valid_sample_rate(chip, fp, rate)) ++ goto skip_rate; ++ + if (fp->rate_table) + fp->rate_table[nr_rates] = rate; + if (!fp->rate_min || rate < fp->rate_min) +@@ -287,6 +338,7 @@ static int parse_uac2_sample_rate_range( + break; + } + ++skip_rate: + /* avoid endless loop */ + if (res == 0) + break; diff --git a/queue-4.19/alsa-usb-audio-fix-usb-audio-refcnt-leak-when-getting-spdif.patch b/queue-4.19/alsa-usb-audio-fix-usb-audio-refcnt-leak-when-getting-spdif.patch new file mode 100644 index 00000000000..e30fc4fec58 --- /dev/null +++ b/queue-4.19/alsa-usb-audio-fix-usb-audio-refcnt-leak-when-getting-spdif.patch @@ -0,0 +1,58 @@ +From 59e1947ca09ebd1cae147c08c7c41f3141233c84 Mon Sep 17 00:00:00 2001 +From: Xiyu Yang +Date: Thu, 23 Apr 2020 12:54:19 +0800 +Subject: ALSA: usb-audio: Fix usb audio refcnt leak when getting spdif + +From: Xiyu Yang + +commit 59e1947ca09ebd1cae147c08c7c41f3141233c84 upstream. + +snd_microii_spdif_default_get() invokes snd_usb_lock_shutdown(), which +increases the refcount of the snd_usb_audio object "chip". + +When snd_microii_spdif_default_get() returns, local variable "chip" +becomes invalid, so the refcount should be decreased to keep refcount +balanced. + +The reference counting issue happens in several exception handling paths +of snd_microii_spdif_default_get(). When those error scenarios occur +such as usb_ifnum_to_if() returns NULL, the function forgets to decrease +the refcnt increased by snd_usb_lock_shutdown(), causing a refcnt leak. + +Fix this issue by jumping to "end" label when those error scenarios +occur. + +Fixes: 447d6275f0c2 ("ALSA: usb-audio: Add sanity checks for endpoint accesses") +Signed-off-by: Xiyu Yang +Signed-off-by: Xin Tan +Cc: +Link: https://lore.kernel.org/r/1587617711-13200-1-git-send-email-xiyuyang19@fudan.edu.cn +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/usb/mixer_quirks.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +--- a/sound/usb/mixer_quirks.c ++++ b/sound/usb/mixer_quirks.c +@@ -1519,11 +1519,15 @@ static int snd_microii_spdif_default_get + + /* use known values for that card: interface#1 altsetting#1 */ + iface = usb_ifnum_to_if(chip->dev, 1); +- if (!iface || iface->num_altsetting < 2) +- return -EINVAL; ++ if (!iface || iface->num_altsetting < 2) { ++ err = -EINVAL; ++ goto end; ++ } + alts = &iface->altsetting[1]; +- if (get_iface_desc(alts)->bNumEndpoints < 1) +- return -EINVAL; ++ if (get_iface_desc(alts)->bNumEndpoints < 1) { ++ err = -EINVAL; ++ goto end; ++ } + ep = get_endpoint(alts, 0)->bEndpointAddress; + + err = snd_usb_ctl_msg(chip->dev, diff --git a/queue-4.19/alsa-usx2y-fix-potential-null-dereference.patch b/queue-4.19/alsa-usx2y-fix-potential-null-dereference.patch new file mode 100644 index 00000000000..f41e41461ec --- /dev/null +++ b/queue-4.19/alsa-usx2y-fix-potential-null-dereference.patch @@ -0,0 +1,34 @@ +From 7686e3485253635c529cdd5f416fc640abaf076f Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Mon, 20 Apr 2020 09:55:29 +0200 +Subject: ALSA: usx2y: Fix potential NULL dereference + +From: Takashi Iwai + +commit 7686e3485253635c529cdd5f416fc640abaf076f upstream. + +The error handling code in usX2Y_rate_set() may hit a potential NULL +dereference when an error occurs before allocating all us->urb[]. +Add a proper NULL check for fixing the corner case. + +Reported-by: Lin Yi +Cc: +Link: https://lore.kernel.org/r/20200420075529.27203-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/usb/usx2y/usbusx2yaudio.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/sound/usb/usx2y/usbusx2yaudio.c ++++ b/sound/usb/usx2y/usbusx2yaudio.c +@@ -695,6 +695,8 @@ static int usX2Y_rate_set(struct usX2Yde + us->submitted = 2*NOOF_SETRATE_URBS; + for (i = 0; i < NOOF_SETRATE_URBS; ++i) { + struct urb *urb = us->urb[i]; ++ if (!urb) ++ continue; + if (urb->status) { + if (!err) + err = -ENODEV; diff --git a/queue-4.19/asoc-dapm-fixup-dapm-kcontrol-widget.patch b/queue-4.19/asoc-dapm-fixup-dapm-kcontrol-widget.patch new file mode 100644 index 00000000000..b190ab37a53 --- /dev/null +++ b/queue-4.19/asoc-dapm-fixup-dapm-kcontrol-widget.patch @@ -0,0 +1,71 @@ +From ebf1474745b4373fdde0fcf32d9d1f369b50b212 Mon Sep 17 00:00:00 2001 +From: Gyeongtaek Lee +Date: Sat, 18 Apr 2020 13:13:20 +0900 +Subject: ASoC: dapm: fixup dapm kcontrol widget + +From: Gyeongtaek Lee + +commit ebf1474745b4373fdde0fcf32d9d1f369b50b212 upstream. + +snd_soc_dapm_kcontrol widget which is created by autodisable control +should contain correct on_val, mask and shift because it is set when the +widget is powered and changed value is applied on registers by following +code in dapm_seq_run_coalesced(). + + mask |= w->mask << w->shift; + if (w->power) + value |= w->on_val << w->shift; + else + value |= w->off_val << w->shift; + +Shift on the mask in dapm_kcontrol_data_alloc() is removed to prevent +double shift. +And, on_val in dapm_kcontrol_set_value() is modified to get correct +value in the dapm_seq_run_coalesced(). + +Signed-off-by: Gyeongtaek Lee +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/000001d61537$b212f620$1638e260$@samsung.com +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman + +--- + sound/soc/soc-dapm.c | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +--- a/sound/soc/soc-dapm.c ++++ b/sound/soc/soc-dapm.c +@@ -410,7 +410,7 @@ static int dapm_kcontrol_data_alloc(stru + + memset(&template, 0, sizeof(template)); + template.reg = e->reg; +- template.mask = e->mask << e->shift_l; ++ template.mask = e->mask; + template.shift = e->shift_l; + template.off_val = snd_soc_enum_item_to_val(e, 0); + template.on_val = template.off_val; +@@ -536,8 +536,22 @@ static bool dapm_kcontrol_set_value(cons + if (data->value == value) + return false; + +- if (data->widget) +- data->widget->on_val = value; ++ if (data->widget) { ++ switch (dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->id) { ++ case snd_soc_dapm_switch: ++ case snd_soc_dapm_mixer: ++ case snd_soc_dapm_mixer_named_ctl: ++ data->widget->on_val = value & data->widget->mask; ++ break; ++ case snd_soc_dapm_demux: ++ case snd_soc_dapm_mux: ++ data->widget->on_val = value >> data->widget->shift; ++ break; ++ default: ++ data->widget->on_val = value; ++ break; ++ } ++ } + + data->value = value; + diff --git a/queue-4.19/audit-check-the-length-of-userspace-generated-audit-records.patch b/queue-4.19/audit-check-the-length-of-userspace-generated-audit-records.patch new file mode 100644 index 00000000000..600b3ae5ff2 --- /dev/null +++ b/queue-4.19/audit-check-the-length-of-userspace-generated-audit-records.patch @@ -0,0 +1,38 @@ +From 763dafc520add02a1f4639b500c509acc0ea8e5b Mon Sep 17 00:00:00 2001 +From: Paul Moore +Date: Mon, 20 Apr 2020 16:24:34 -0400 +Subject: audit: check the length of userspace generated audit records + +From: Paul Moore + +commit 763dafc520add02a1f4639b500c509acc0ea8e5b upstream. + +Commit 756125289285 ("audit: always check the netlink payload length +in audit_receive_msg()") fixed a number of missing message length +checks, but forgot to check the length of userspace generated audit +records. The good news is that you need CAP_AUDIT_WRITE to submit +userspace audit records, which is generally only given to trusted +processes, so the impact should be limited. + +Cc: stable@vger.kernel.org +Fixes: 756125289285 ("audit: always check the netlink payload length in audit_receive_msg()") +Reported-by: syzbot+49e69b4d71a420ceda3e@syzkaller.appspotmail.com +Signed-off-by: Paul Moore +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/audit.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/kernel/audit.c ++++ b/kernel/audit.c +@@ -1331,6 +1331,9 @@ static int audit_receive_msg(struct sk_b + case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2: + if (!audit_enabled && msg_type != AUDIT_USER_AVC) + return 0; ++ /* exit early if there isn't at least one character to print */ ++ if (data_len < 2) ++ return -EINVAL; + + err = audit_filter(msg_type, AUDIT_FILTER_USER); + if (err == 1) { /* match or error */ diff --git a/queue-4.19/iwlwifi-mvm-beacon-statistics-shouldn-t-go-backwards.patch b/queue-4.19/iwlwifi-mvm-beacon-statistics-shouldn-t-go-backwards.patch new file mode 100644 index 00000000000..6743e5df23f --- /dev/null +++ b/queue-4.19/iwlwifi-mvm-beacon-statistics-shouldn-t-go-backwards.patch @@ -0,0 +1,55 @@ +From 290d5e4951832e39d10f4184610dbf09038f8483 Mon Sep 17 00:00:00 2001 +From: Mordechay Goodstein +Date: Fri, 17 Apr 2020 10:08:10 +0300 +Subject: iwlwifi: mvm: beacon statistics shouldn't go backwards + +From: Mordechay Goodstein + +commit 290d5e4951832e39d10f4184610dbf09038f8483 upstream. + +We reset statistics also in case that we didn't reassoc so in +this cases keep last beacon counter. + +Cc: stable@vger.kernel.org # v4.19+ +Signed-off-by: Mordechay Goodstein +Signed-off-by: Luca Coelho +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/iwlwifi.20200417100405.1f9142751fbc.Ifbfd0f928a0a761110b8f4f2ca5483a61fb21131@changeid +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c +@@ -587,6 +587,7 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm * + + struct iwl_mvm_stat_data { + struct iwl_mvm *mvm; ++ __le32 flags; + __le32 mac_id; + u8 beacon_filter_average_energy; + void *general; +@@ -630,6 +631,13 @@ static void iwl_mvm_stat_iterator(void * + } + } + ++ /* make sure that beacon statistics don't go backwards with TCM ++ * request to clear statistics ++ */ ++ if (le32_to_cpu(data->flags) & IWL_STATISTICS_REPLY_FLG_CLEAR) ++ mvmvif->beacon_stats.accu_num_beacons += ++ mvmvif->beacon_stats.num_beacons; ++ + if (mvmvif->id != id) + return; + +@@ -790,6 +798,7 @@ void iwl_mvm_handle_rx_statistics(struct + + flags = stats->flag; + } ++ data.flags = flags; + + iwl_mvm_rx_stats_check_trigger(mvm, pkt); + diff --git a/queue-4.19/iwlwifi-pcie-actually-release-queue-memory-in-tvqm.patch b/queue-4.19/iwlwifi-pcie-actually-release-queue-memory-in-tvqm.patch new file mode 100644 index 00000000000..5d9760dc556 --- /dev/null +++ b/queue-4.19/iwlwifi-pcie-actually-release-queue-memory-in-tvqm.patch @@ -0,0 +1,47 @@ +From b98b33d5560a2d940f3b80f6768a6177bf3dfbc0 Mon Sep 17 00:00:00 2001 +From: Johannes Berg +Date: Fri, 17 Apr 2020 10:08:09 +0300 +Subject: iwlwifi: pcie: actually release queue memory in TVQM + +From: Johannes Berg + +commit b98b33d5560a2d940f3b80f6768a6177bf3dfbc0 upstream. + +The iwl_trans_pcie_dyn_txq_free() function only releases the frames +that may be left on the queue by calling iwl_pcie_gen2_txq_unmap(), +but doesn't actually free the DMA ring or byte-count tables for the +queue. This leads to pretty large memory leaks (at least before my +queue size improvements), in particular in monitor/sniffer mode on +channel hopping since this happens on every channel change. + +This was also now more evident after the move to a DMA pool for the +byte count tables, showing messages such as + + BUG iwlwifi:bc (...): Objects remaining in iwlwifi:bc on __kmem_cache_shutdown() + +This fixes https://bugzilla.kernel.org/show_bug.cgi?id=206811. + +Signed-off-by: Johannes Berg +Fixes: 6b35ff91572f ("iwlwifi: pcie: introduce a000 TX queues management") +Cc: stable@vger.kernel.org # v4.14+ +Signed-off-by: Luca Coelho +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/iwlwifi.20200417100405.f5f4c4193ec1.Id5feebc9b4318041913a9c89fc1378bb5454292c@changeid +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c ++++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c +@@ -1231,6 +1231,9 @@ void iwl_trans_pcie_dyn_txq_free(struct + + iwl_pcie_gen2_txq_unmap(trans, queue); + ++ iwl_pcie_gen2_txq_free_memory(trans, trans_pcie->txq[queue]); ++ trans_pcie->txq[queue] = NULL; ++ + IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", queue); + } + diff --git a/queue-4.19/kvm-check-validity-of-resolved-slot-when-searching-memslots.patch b/queue-4.19/kvm-check-validity-of-resolved-slot-when-searching-memslots.patch new file mode 100644 index 00000000000..03be4effb84 --- /dev/null +++ b/queue-4.19/kvm-check-validity-of-resolved-slot-when-searching-memslots.patch @@ -0,0 +1,48 @@ +From b6467ab142b708dd076f6186ca274f14af379c72 Mon Sep 17 00:00:00 2001 +From: Sean Christopherson +Date: Tue, 7 Apr 2020 23:40:58 -0700 +Subject: KVM: Check validity of resolved slot when searching memslots + +From: Sean Christopherson + +commit b6467ab142b708dd076f6186ca274f14af379c72 upstream. + +Check that the resolved slot (somewhat confusingly named 'start') is a +valid/allocated slot before doing the final comparison to see if the +specified gfn resides in the associated slot. The resolved slot can be +invalid if the binary search loop terminated because the search index +was incremented beyond the number of used slots. + +This bug has existed since the binary search algorithm was introduced, +but went unnoticed because KVM statically allocated memory for the max +number of slots, i.e. the access would only be truly out-of-bounds if +all possible slots were allocated and the specified gfn was less than +the base of the lowest memslot. Commit 36947254e5f98 ("KVM: Dynamically +size memslot array based on number of used slots") eliminated the "all +possible slots allocated" condition and made the bug embarrasingly easy +to hit. + +Fixes: 9c1a5d38780e6 ("kvm: optimize GFN to memslot lookup with large slots amount") +Reported-by: syzbot+d889b59b2bb87d4047a2@syzkaller.appspotmail.com +Cc: stable@vger.kernel.org +Signed-off-by: Sean Christopherson +Message-Id: <20200408064059.8957-2-sean.j.christopherson@intel.com> +Reviewed-by: Cornelia Huck +Signed-off-by: Paolo Bonzini +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/kvm_host.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/include/linux/kvm_host.h ++++ b/include/linux/kvm_host.h +@@ -999,7 +999,7 @@ search_memslots(struct kvm_memslots *slo + start = slot + 1; + } + +- if (gfn >= memslots[start].base_gfn && ++ if (start < slots->used_slots && gfn >= memslots[start].base_gfn && + gfn < memslots[start].base_gfn + memslots[start].npages) { + atomic_set(&slots->lru_slot, start); + return &memslots[start]; diff --git a/queue-4.19/kvm-s390-return-last-valid-slot-if-approx-index-is-out-of-bounds.patch b/queue-4.19/kvm-s390-return-last-valid-slot-if-approx-index-is-out-of-bounds.patch new file mode 100644 index 00000000000..76a9db6a48c --- /dev/null +++ b/queue-4.19/kvm-s390-return-last-valid-slot-if-approx-index-is-out-of-bounds.patch @@ -0,0 +1,42 @@ +From 97daa028f3f621adff2c4f7b15fe0874e5b5bd6c Mon Sep 17 00:00:00 2001 +From: Sean Christopherson +Date: Tue, 7 Apr 2020 23:40:59 -0700 +Subject: KVM: s390: Return last valid slot if approx index is out-of-bounds + +From: Sean Christopherson + +commit 97daa028f3f621adff2c4f7b15fe0874e5b5bd6c upstream. + +Return the index of the last valid slot from gfn_to_memslot_approx() if +its binary search loop yielded an out-of-bounds index. The index can +be out-of-bounds if the specified gfn is less than the base of the +lowest memslot (which is also the last valid memslot). + +Note, the sole caller, kvm_s390_get_cmma(), ensures used_slots is +non-zero. + +Fixes: afdad61615cc3 ("KVM: s390: Fix storage attributes migration with memory slots") +Cc: stable@vger.kernel.org # 4.19.x: 0774a964ef56: KVM: Fix out of range accesses to memslots +Cc: stable@vger.kernel.org # 4.19.x +Signed-off-by: Sean Christopherson +Message-Id: <20200408064059.8957-3-sean.j.christopherson@intel.com> +Reviewed-by: Cornelia Huck +Signed-off-by: Paolo Bonzini +Signed-off-by: Greg Kroah-Hartman + +--- + arch/s390/kvm/kvm-s390.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/arch/s390/kvm/kvm-s390.c ++++ b/arch/s390/kvm/kvm-s390.c +@@ -1666,6 +1666,9 @@ static int gfn_to_memslot_approx(struct + start = slot + 1; + } + ++ if (start >= slots->used_slots) ++ return slots->used_slots - 1; ++ + if (gfn >= memslots[start].base_gfn && + gfn < memslots[start].base_gfn + memslots[start].npages) { + atomic_set(&slots->lru_slot, start); diff --git a/queue-4.19/kvm-vmx-enable-machine-check-support-for-32bit-targets.patch b/queue-4.19/kvm-vmx-enable-machine-check-support-for-32bit-targets.patch new file mode 100644 index 00000000000..abd90f1ffa2 --- /dev/null +++ b/queue-4.19/kvm-vmx-enable-machine-check-support-for-32bit-targets.patch @@ -0,0 +1,36 @@ +From fb56baae5ea509e63c2a068d66a4d8ea91969fca Mon Sep 17 00:00:00 2001 +From: Uros Bizjak +Date: Tue, 14 Apr 2020 09:14:14 +0200 +Subject: KVM: VMX: Enable machine check support for 32bit targets + +From: Uros Bizjak + +commit fb56baae5ea509e63c2a068d66a4d8ea91969fca upstream. + +There is no reason to limit the use of do_machine_check +to 64bit targets. MCE handling works for both target familes. + +Cc: Paolo Bonzini +Cc: Sean Christopherson +Cc: stable@vger.kernel.org +Fixes: a0861c02a981 ("KVM: Add VT-x machine check support") +Signed-off-by: Uros Bizjak +Message-Id: <20200414071414.45636-1-ubizjak@gmail.com> +Signed-off-by: Paolo Bonzini +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/kvm/vmx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/x86/kvm/vmx.c ++++ b/arch/x86/kvm/vmx.c +@@ -7015,7 +7015,7 @@ static int handle_rmode_exception(struct + */ + static void kvm_machine_check(void) + { +-#if defined(CONFIG_X86_MCE) && defined(CONFIG_X86_64) ++#if defined(CONFIG_X86_MCE) + struct pt_regs regs = { + .cs = 3, /* Fake ring 3 no matter what the guest ran on */ + .flags = X86_EFLAGS_IF, diff --git a/queue-4.19/mm-hugetlb-fix-a-addressing-exception-caused-by-huge_pte_offset.patch b/queue-4.19/mm-hugetlb-fix-a-addressing-exception-caused-by-huge_pte_offset.patch new file mode 100644 index 00000000000..5dfaab9f952 --- /dev/null +++ b/queue-4.19/mm-hugetlb-fix-a-addressing-exception-caused-by-huge_pte_offset.patch @@ -0,0 +1,122 @@ +From 3c1d7e6ccb644d517a12f73a7ff200870926f865 Mon Sep 17 00:00:00 2001 +From: Longpeng +Date: Mon, 20 Apr 2020 18:13:51 -0700 +Subject: mm/hugetlb: fix a addressing exception caused by huge_pte_offset + +From: Longpeng + +commit 3c1d7e6ccb644d517a12f73a7ff200870926f865 upstream. + +Our machine encountered a panic(addressing exception) after run for a +long time and the calltrace is: + + RIP: hugetlb_fault+0x307/0xbe0 + RSP: 0018:ffff9567fc27f808 EFLAGS: 00010286 + RAX: e800c03ff1258d48 RBX: ffffd3bb003b69c0 RCX: e800c03ff1258d48 + RDX: 17ff3fc00eda72b7 RSI: 00003ffffffff000 RDI: e800c03ff1258d48 + RBP: ffff9567fc27f8c8 R08: e800c03ff1258d48 R09: 0000000000000080 + R10: ffffaba0704c22a8 R11: 0000000000000001 R12: ffff95c87b4b60d8 + R13: 00005fff00000000 R14: 0000000000000000 R15: ffff9567face8074 + FS: 00007fe2d9ffb700(0000) GS:ffff956900e40000(0000) knlGS:0000000000000000 + CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 + CR2: ffffd3bb003b69c0 CR3: 000000be67374000 CR4: 00000000003627e0 + DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 + DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 + Call Trace: + follow_hugetlb_page+0x175/0x540 + __get_user_pages+0x2a0/0x7e0 + __get_user_pages_unlocked+0x15d/0x210 + __gfn_to_pfn_memslot+0x3c5/0x460 [kvm] + try_async_pf+0x6e/0x2a0 [kvm] + tdp_page_fault+0x151/0x2d0 [kvm] + ... + kvm_arch_vcpu_ioctl_run+0x330/0x490 [kvm] + kvm_vcpu_ioctl+0x309/0x6d0 [kvm] + do_vfs_ioctl+0x3f0/0x540 + SyS_ioctl+0xa1/0xc0 + system_call_fastpath+0x22/0x27 + +For 1G hugepages, huge_pte_offset() wants to return NULL or pudp, but it +may return a wrong 'pmdp' if there is a race. Please look at the +following code snippet: + + ... + pud = pud_offset(p4d, addr); + if (sz != PUD_SIZE && pud_none(*pud)) + return NULL; + /* hugepage or swap? */ + if (pud_huge(*pud) || !pud_present(*pud)) + return (pte_t *)pud; + + pmd = pmd_offset(pud, addr); + if (sz != PMD_SIZE && pmd_none(*pmd)) + return NULL; + /* hugepage or swap? */ + if (pmd_huge(*pmd) || !pmd_present(*pmd)) + return (pte_t *)pmd; + ... + +The following sequence would trigger this bug: + + - CPU0: sz = PUD_SIZE and *pud = 0 , continue + - CPU0: "pud_huge(*pud)" is false + - CPU1: calling hugetlb_no_page and set *pud to xxxx8e7(PRESENT) + - CPU0: "!pud_present(*pud)" is false, continue + - CPU0: pmd = pmd_offset(pud, addr) and maybe return a wrong pmdp + +However, we want CPU0 to return NULL or pudp in this case. + +We must make sure there is exactly one dereference of pud and pmd. + +Signed-off-by: Longpeng +Signed-off-by: Andrew Morton +Reviewed-by: Mike Kravetz +Reviewed-by: Jason Gunthorpe +Cc: Matthew Wilcox +Cc: Sean Christopherson +Cc: +Link: http://lkml.kernel.org/r/20200413010342.771-1-longpeng2@huawei.com +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + mm/hugetlb.c | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -4820,8 +4820,8 @@ pte_t *huge_pte_offset(struct mm_struct + { + pgd_t *pgd; + p4d_t *p4d; +- pud_t *pud; +- pmd_t *pmd; ++ pud_t *pud, pud_entry; ++ pmd_t *pmd, pmd_entry; + + pgd = pgd_offset(mm, addr); + if (!pgd_present(*pgd)) +@@ -4831,17 +4831,19 @@ pte_t *huge_pte_offset(struct mm_struct + return NULL; + + pud = pud_offset(p4d, addr); +- if (sz != PUD_SIZE && pud_none(*pud)) ++ pud_entry = READ_ONCE(*pud); ++ if (sz != PUD_SIZE && pud_none(pud_entry)) + return NULL; + /* hugepage or swap? */ +- if (pud_huge(*pud) || !pud_present(*pud)) ++ if (pud_huge(pud_entry) || !pud_present(pud_entry)) + return (pte_t *)pud; + + pmd = pmd_offset(pud, addr); +- if (sz != PMD_SIZE && pmd_none(*pmd)) ++ pmd_entry = READ_ONCE(*pmd); ++ if (sz != PMD_SIZE && pmd_none(pmd_entry)) + return NULL; + /* hugepage or swap? */ +- if (pmd_huge(*pmd) || !pmd_present(*pmd)) ++ if (pmd_huge(pmd_entry) || !pmd_present(pmd_entry)) + return (pte_t *)pmd; + + return NULL; diff --git a/queue-4.19/mm-ksm-fix-null-pointer-dereference-when-ksm-zero-page-is-enabled.patch b/queue-4.19/mm-ksm-fix-null-pointer-dereference-when-ksm-zero-page-is-enabled.patch new file mode 100644 index 00000000000..6c3a3ae8f48 --- /dev/null +++ b/queue-4.19/mm-ksm-fix-null-pointer-dereference-when-ksm-zero-page-is-enabled.patch @@ -0,0 +1,87 @@ +From 56df70a63ed5d989c1d36deee94cae14342be6e9 Mon Sep 17 00:00:00 2001 +From: Muchun Song +Date: Mon, 20 Apr 2020 18:14:04 -0700 +Subject: mm/ksm: fix NULL pointer dereference when KSM zero page is enabled + +From: Muchun Song + +commit 56df70a63ed5d989c1d36deee94cae14342be6e9 upstream. + +find_mergeable_vma() can return NULL. In this case, it leads to a crash +when we access vm_mm(its offset is 0x40) later in write_protect_page. +And this case did happen on our server. The following call trace is +captured in kernel 4.19 with the following patch applied and KSM zero +page enabled on our server. + + commit e86c59b1b12d ("mm/ksm: improve deduplication of zero pages with colouring") + +So add a vma check to fix it. + + BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 + Oops: 0000 [#1] SMP NOPTI + CPU: 9 PID: 510 Comm: ksmd Kdump: loaded Tainted: G OE 4.19.36.bsk.9-amd64 #4.19.36.bsk.9 + RIP: try_to_merge_one_page+0xc7/0x760 + Code: 24 58 65 48 33 34 25 28 00 00 00 89 e8 0f 85 a3 06 00 00 48 83 c4 + 60 5b 5d 41 5c 41 5d 41 5e 41 5f c3 48 8b 46 08 a8 01 75 b8 <49> + 8b 44 24 40 4c 8d 7c 24 20 b9 07 00 00 00 4c 89 e6 4c 89 ff 48 + RSP: 0018:ffffadbdd9fffdb0 EFLAGS: 00010246 + RAX: ffffda83ffd4be08 RBX: ffffda83ffd4be40 RCX: 0000002c6e800000 + RDX: 0000000000000000 RSI: ffffda83ffd4be40 RDI: 0000000000000000 + RBP: ffffa11939f02ec0 R08: 0000000094e1a447 R09: 00000000abe76577 + R10: 0000000000000962 R11: 0000000000004e6a R12: 0000000000000000 + R13: ffffda83b1e06380 R14: ffffa18f31f072c0 R15: ffffda83ffd4be40 + FS: 0000000000000000(0000) GS:ffffa0da43b80000(0000) knlGS:0000000000000000 + CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 + CR2: 0000000000000040 CR3: 0000002c77c0a003 CR4: 00000000007626e0 + DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 + DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 + PKRU: 55555554 + Call Trace: + ksm_scan_thread+0x115e/0x1960 + kthread+0xf5/0x130 + ret_from_fork+0x1f/0x30 + +[songmuchun@bytedance.com: if the vma is out of date, just exit] + Link: http://lkml.kernel.org/r/20200416025034.29780-1-songmuchun@bytedance.com +[akpm@linux-foundation.org: add the conventional braces, replace /** with /*] +Fixes: e86c59b1b12d ("mm/ksm: improve deduplication of zero pages with colouring") +Co-developed-by: Xiongchun Duan +Signed-off-by: Muchun Song +Signed-off-by: Andrew Morton +Reviewed-by: David Hildenbrand +Reviewed-by: Kirill Tkhai +Cc: Hugh Dickins +Cc: Yang Shi +Cc: Claudio Imbrenda +Cc: Markus Elfring +Cc: +Link: http://lkml.kernel.org/r/20200416025034.29780-1-songmuchun@bytedance.com +Link: http://lkml.kernel.org/r/20200414132905.83819-1-songmuchun@bytedance.com +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + mm/ksm.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +--- a/mm/ksm.c ++++ b/mm/ksm.c +@@ -2106,8 +2106,16 @@ static void cmp_and_merge_page(struct pa + + down_read(&mm->mmap_sem); + vma = find_mergeable_vma(mm, rmap_item->address); +- err = try_to_merge_one_page(vma, page, +- ZERO_PAGE(rmap_item->address)); ++ if (vma) { ++ err = try_to_merge_one_page(vma, page, ++ ZERO_PAGE(rmap_item->address)); ++ } else { ++ /* ++ * If the vma is out of date, we do not need to ++ * continue. ++ */ ++ err = 0; ++ } + up_read(&mm->mmap_sem); + /* + * In case of failure, the page was not really empty, so we diff --git a/queue-4.19/series b/queue-4.19/series index cdedd1e1de2..a84bc81748e 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -87,3 +87,24 @@ usb-add-usb_quirk_delay_ctrl_msg-and-usb_quirk_delay_init-for-corsair-k70-rgb-ra usb-early-handle-amd-s-spec-compliant-identifiers-too.patch usb-core-fix-free-while-in-use-bug-in-the-usb-s-glibrary.patch usb-hub-fix-handling-of-connect-changes-during-sleep.patch +vmalloc-fix-remap_vmalloc_range-bounds-checks.patch +mm-hugetlb-fix-a-addressing-exception-caused-by-huge_pte_offset.patch +mm-ksm-fix-null-pointer-dereference-when-ksm-zero-page-is-enabled.patch +tools-vm-fix-cross-compile-build.patch +alsa-usx2y-fix-potential-null-dereference.patch +alsa-hda-realtek-fix-unexpected-init_amp-override.patch +alsa-hda-realtek-add-new-codec-supported-for-alc245.patch +alsa-usb-audio-fix-usb-audio-refcnt-leak-when-getting-spdif.patch +alsa-usb-audio-filter-out-unsupported-sample-rates-on-focusrite-devices.patch +tpm-tpm_tis-free-irq-if-probing-fails.patch +tpm-ibmvtpm-retry-on-h_closed-in-tpm_ibmvtpm_send.patch +kvm-s390-return-last-valid-slot-if-approx-index-is-out-of-bounds.patch +kvm-check-validity-of-resolved-slot-when-searching-memslots.patch +kvm-vmx-enable-machine-check-support-for-32bit-targets.patch +tty-hvc-fix-buffer-overflow-during-hvc_alloc.patch +tty-rocket-avoid-oob-access.patch +usb-storage-add-unusual_devs-entry-for-jmicron-jms566.patch +audit-check-the-length-of-userspace-generated-audit-records.patch +asoc-dapm-fixup-dapm-kcontrol-widget.patch +iwlwifi-pcie-actually-release-queue-memory-in-tvqm.patch +iwlwifi-mvm-beacon-statistics-shouldn-t-go-backwards.patch diff --git a/queue-4.19/tools-vm-fix-cross-compile-build.patch b/queue-4.19/tools-vm-fix-cross-compile-build.patch new file mode 100644 index 00000000000..a9dbc83b84f --- /dev/null +++ b/queue-4.19/tools-vm-fix-cross-compile-build.patch @@ -0,0 +1,40 @@ +From cf01699ee220c38099eb3e43ce3d10690c8b7060 Mon Sep 17 00:00:00 2001 +From: Lucas Stach +Date: Mon, 20 Apr 2020 18:14:23 -0700 +Subject: tools/vm: fix cross-compile build + +From: Lucas Stach + +commit cf01699ee220c38099eb3e43ce3d10690c8b7060 upstream. + +Commit 7ed1c1901fe5 ("tools: fix cross-compile var clobbering") moved +the setup of the CC variable to tools/scripts/Makefile.include to make +the behavior consistent across all the tools Makefiles. + +As the vm tools missed the include we end up with the wrong CC in a +cross-compiling evironment. + +Fixes: 7ed1c1901fe5 (tools: fix cross-compile var clobbering) +Signed-off-by: Lucas Stach +Signed-off-by: Andrew Morton +Cc: Martin Kelly +Cc: +Link: http://lkml.kernel.org/r/20200416104748.25243-1-l.stach@pengutronix.de +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + tools/vm/Makefile | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/tools/vm/Makefile ++++ b/tools/vm/Makefile +@@ -1,6 +1,8 @@ + # SPDX-License-Identifier: GPL-2.0 + # Makefile for vm tools + # ++include ../scripts/Makefile.include ++ + TARGETS=page-types slabinfo page_owner_sort + + LIB_DIR = ../lib/api diff --git a/queue-4.19/tpm-ibmvtpm-retry-on-h_closed-in-tpm_ibmvtpm_send.patch b/queue-4.19/tpm-ibmvtpm-retry-on-h_closed-in-tpm_ibmvtpm_send.patch new file mode 100644 index 00000000000..b13bef4e4dd --- /dev/null +++ b/queue-4.19/tpm-ibmvtpm-retry-on-h_closed-in-tpm_ibmvtpm_send.patch @@ -0,0 +1,218 @@ +From eba5cf3dcb844c82f54d4a857e124824e252206d Mon Sep 17 00:00:00 2001 +From: George Wilson +Date: Thu, 19 Mar 2020 23:27:58 -0400 +Subject: tpm: ibmvtpm: retry on H_CLOSED in tpm_ibmvtpm_send() + +From: George Wilson + +commit eba5cf3dcb844c82f54d4a857e124824e252206d upstream. + +tpm_ibmvtpm_send() can fail during PowerVM Live Partition Mobility resume +with an H_CLOSED return from ibmvtpm_send_crq(). The PAPR says, 'The +"partner partition suspended" transport event disables the associated CRQ +such that any H_SEND_CRQ hcall() to the associated CRQ returns H_Closed +until the CRQ has been explicitly enabled using the H_ENABLE_CRQ hcall.' +This patch adds a check in tpm_ibmvtpm_send() for an H_CLOSED return from +ibmvtpm_send_crq() and in that case calls tpm_ibmvtpm_resume() and +retries the ibmvtpm_send_crq() once. + +Cc: stable@vger.kernel.org # 3.7.x +Fixes: 132f76294744 ("drivers/char/tpm: Add new device driver to support IBM vTPM") +Reported-by: Linh Pham +Reviewed-by: Stefan Berger +Signed-off-by: George Wilson +Tested-by: Linh Pham +Reviewed-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/tpm/tpm_ibmvtpm.c | 136 ++++++++++++++++++++++------------------- + 1 file changed, 73 insertions(+), 63 deletions(-) + +--- a/drivers/char/tpm/tpm_ibmvtpm.c ++++ b/drivers/char/tpm/tpm_ibmvtpm.c +@@ -1,5 +1,5 @@ + /* +- * Copyright (C) 2012 IBM Corporation ++ * Copyright (C) 2012-2020 IBM Corporation + * + * Author: Ashley Lai + * +@@ -141,6 +141,64 @@ static int tpm_ibmvtpm_recv(struct tpm_c + } + + /** ++ * ibmvtpm_crq_send_init - Send a CRQ initialize message ++ * @ibmvtpm: vtpm device struct ++ * ++ * Return: ++ * 0 on success. ++ * Non-zero on failure. ++ */ ++static int ibmvtpm_crq_send_init(struct ibmvtpm_dev *ibmvtpm) ++{ ++ int rc; ++ ++ rc = ibmvtpm_send_crq_word(ibmvtpm->vdev, INIT_CRQ_CMD); ++ if (rc != H_SUCCESS) ++ dev_err(ibmvtpm->dev, ++ "%s failed rc=%d\n", __func__, rc); ++ ++ return rc; ++} ++ ++/** ++ * tpm_ibmvtpm_resume - Resume from suspend ++ * ++ * @dev: device struct ++ * ++ * Return: Always 0. ++ */ ++static int tpm_ibmvtpm_resume(struct device *dev) ++{ ++ struct tpm_chip *chip = dev_get_drvdata(dev); ++ struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); ++ int rc = 0; ++ ++ do { ++ if (rc) ++ msleep(100); ++ rc = plpar_hcall_norets(H_ENABLE_CRQ, ++ ibmvtpm->vdev->unit_address); ++ } while (rc == H_IN_PROGRESS || rc == H_BUSY || H_IS_LONG_BUSY(rc)); ++ ++ if (rc) { ++ dev_err(dev, "Error enabling ibmvtpm rc=%d\n", rc); ++ return rc; ++ } ++ ++ rc = vio_enable_interrupts(ibmvtpm->vdev); ++ if (rc) { ++ dev_err(dev, "Error vio_enable_interrupts rc=%d\n", rc); ++ return rc; ++ } ++ ++ rc = ibmvtpm_crq_send_init(ibmvtpm); ++ if (rc) ++ dev_err(dev, "Error send_init rc=%d\n", rc); ++ ++ return rc; ++} ++ ++/** + * tpm_ibmvtpm_send() - Send a TPM command + * @chip: tpm chip struct + * @buf: buffer contains data to send +@@ -153,6 +211,7 @@ static int tpm_ibmvtpm_recv(struct tpm_c + static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) + { + struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); ++ bool retry = true; + int rc, sig; + + if (!ibmvtpm->rtce_buf) { +@@ -186,18 +245,27 @@ static int tpm_ibmvtpm_send(struct tpm_c + */ + ibmvtpm->tpm_processing_cmd = true; + ++again: + rc = ibmvtpm_send_crq(ibmvtpm->vdev, + IBMVTPM_VALID_CMD, VTPM_TPM_COMMAND, + count, ibmvtpm->rtce_dma_handle); + if (rc != H_SUCCESS) { ++ /* ++ * H_CLOSED can be returned after LPM resume. Call ++ * tpm_ibmvtpm_resume() to re-enable the CRQ then retry ++ * ibmvtpm_send_crq() once before failing. ++ */ ++ if (rc == H_CLOSED && retry) { ++ tpm_ibmvtpm_resume(ibmvtpm->dev); ++ retry = false; ++ goto again; ++ } + dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc); +- rc = 0; + ibmvtpm->tpm_processing_cmd = false; +- } else +- rc = 0; ++ } + + spin_unlock(&ibmvtpm->rtce_lock); +- return rc; ++ return 0; + } + + static void tpm_ibmvtpm_cancel(struct tpm_chip *chip) +@@ -276,26 +344,6 @@ static int ibmvtpm_crq_send_init_complet + } + + /** +- * ibmvtpm_crq_send_init - Send a CRQ initialize message +- * @ibmvtpm: vtpm device struct +- * +- * Return: +- * 0 on success. +- * Non-zero on failure. +- */ +-static int ibmvtpm_crq_send_init(struct ibmvtpm_dev *ibmvtpm) +-{ +- int rc; +- +- rc = ibmvtpm_send_crq_word(ibmvtpm->vdev, INIT_CRQ_CMD); +- if (rc != H_SUCCESS) +- dev_err(ibmvtpm->dev, +- "ibmvtpm_crq_send_init failed rc=%d\n", rc); +- +- return rc; +-} +- +-/** + * tpm_ibmvtpm_remove - ibm vtpm remove entry point + * @vdev: vio device struct + * +@@ -407,44 +455,6 @@ static int ibmvtpm_reset_crq(struct ibmv + ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE); + } + +-/** +- * tpm_ibmvtpm_resume - Resume from suspend +- * +- * @dev: device struct +- * +- * Return: Always 0. +- */ +-static int tpm_ibmvtpm_resume(struct device *dev) +-{ +- struct tpm_chip *chip = dev_get_drvdata(dev); +- struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); +- int rc = 0; +- +- do { +- if (rc) +- msleep(100); +- rc = plpar_hcall_norets(H_ENABLE_CRQ, +- ibmvtpm->vdev->unit_address); +- } while (rc == H_IN_PROGRESS || rc == H_BUSY || H_IS_LONG_BUSY(rc)); +- +- if (rc) { +- dev_err(dev, "Error enabling ibmvtpm rc=%d\n", rc); +- return rc; +- } +- +- rc = vio_enable_interrupts(ibmvtpm->vdev); +- if (rc) { +- dev_err(dev, "Error vio_enable_interrupts rc=%d\n", rc); +- return rc; +- } +- +- rc = ibmvtpm_crq_send_init(ibmvtpm); +- if (rc) +- dev_err(dev, "Error send_init rc=%d\n", rc); +- +- return rc; +-} +- + static bool tpm_ibmvtpm_req_canceled(struct tpm_chip *chip, u8 status) + { + return (status == 0); diff --git a/queue-4.19/tpm-tpm_tis-free-irq-if-probing-fails.patch b/queue-4.19/tpm-tpm_tis-free-irq-if-probing-fails.patch new file mode 100644 index 00000000000..9faacb79d71 --- /dev/null +++ b/queue-4.19/tpm-tpm_tis-free-irq-if-probing-fails.patch @@ -0,0 +1,48 @@ +From b160c94be5d2816b62c8ac338605668304242959 Mon Sep 17 00:00:00 2001 +From: Jarkko Sakkinen +Date: Sun, 12 Apr 2020 20:04:12 +0300 +Subject: tpm/tpm_tis: Free IRQ if probing fails + +From: Jarkko Sakkinen + +commit b160c94be5d2816b62c8ac338605668304242959 upstream. + +Call disable_interrupts() if we have to revert to polling in order not to +unnecessarily reserve the IRQ for the life-cycle of the driver. + +Cc: stable@vger.kernel.org # 4.5.x +Reported-by: Hans de Goede +Fixes: e3837e74a06d ("tpm_tis: Refactor the interrupt setup") +Signed-off-by: Jarkko Sakkinen +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/tpm/tpm_tis_core.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/drivers/char/tpm/tpm_tis_core.c ++++ b/drivers/char/tpm/tpm_tis_core.c +@@ -437,6 +437,9 @@ static void disable_interrupts(struct tp + u32 intmask; + int rc; + ++ if (priv->irq == 0) ++ return; ++ + rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); + if (rc < 0) + intmask = 0; +@@ -984,9 +987,12 @@ int tpm_tis_core_init(struct device *dev + if (irq) { + tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, + irq); +- if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) ++ if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) { + dev_err(&chip->dev, FW_BUG + "TPM interrupt not working, polling instead\n"); ++ ++ disable_interrupts(chip); ++ } + } else { + tpm_tis_probe_irq(chip, intmask); + } diff --git a/queue-4.19/tty-hvc-fix-buffer-overflow-during-hvc_alloc.patch b/queue-4.19/tty-hvc-fix-buffer-overflow-during-hvc_alloc.patch new file mode 100644 index 00000000000..4e649c7e99e --- /dev/null +++ b/queue-4.19/tty-hvc-fix-buffer-overflow-during-hvc_alloc.patch @@ -0,0 +1,126 @@ +From 9a9fc42b86c06120744555fea43fdcabe297c656 Mon Sep 17 00:00:00 2001 +From: Andrew Melnychenko +Date: Tue, 14 Apr 2020 22:15:03 +0300 +Subject: tty: hvc: fix buffer overflow during hvc_alloc(). + +From: Andrew Melnychenko + +commit 9a9fc42b86c06120744555fea43fdcabe297c656 upstream. + +If there is a lot(more then 16) of virtio-console devices +or virtio_console module is reloaded +- buffers 'vtermnos' and 'cons_ops' are overflowed. +In older kernels it overruns spinlock which leads to kernel freezing: +https://bugzilla.redhat.com/show_bug.cgi?id=1786239 + +To reproduce the issue, you can try simple script that +loads/unloads module. Something like this: +while [ 1 ] +do + modprobe virtio_console + sleep 2 + modprobe -r virtio_console + sleep 2 +done + +Description of problem: +Guest get 'Call Trace' when loading module "virtio_console" +and unloading it frequently - clearly reproduced on kernel-4.18.0: + +[ 81.498208] ------------[ cut here ]------------ +[ 81.499263] pvqspinlock: lock 0xffffffff92080020 has corrupted value 0xc0774ca0! +[ 81.501000] WARNING: CPU: 0 PID: 785 at kernel/locking/qspinlock_paravirt.h:500 __pv_queued_spin_unlock_slowpath+0xc0/0xd0 +[ 81.503173] Modules linked in: virtio_console fuse xt_CHECKSUM ipt_MASQUERADE xt_conntrack ipt_REJECT nft_counter nf_nat_tftp nft_objref nf_conntrack_tftp tun bridge stp llc nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nf_tables_set nft_chain_nat_ipv6 nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 nft_chain_route_ipv6 nft_chain_nat_ipv4 nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack nft_chain_route_ipv4 ip6_tables nft_compat ip_set nf_tables nfnetlink sunrpc bochs_drm drm_vram_helper ttm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm i2c_piix4 pcspkr crct10dif_pclmul crc32_pclmul joydev ghash_clmulni_intel ip_tables xfs libcrc32c sd_mod sg ata_generic ata_piix virtio_net libata crc32c_intel net_failover failover serio_raw virtio_scsi dm_mirror dm_region_hash dm_log dm_mod [last unloaded: virtio_console] +[ 81.517019] CPU: 0 PID: 785 Comm: kworker/0:2 Kdump: loaded Not tainted 4.18.0-167.el8.x86_64 #1 +[ 81.518639] Hardware name: Red Hat KVM, BIOS 1.12.0-5.scrmod+el8.2.0+5159+d8aa4d83 04/01/2014 +[ 81.520205] Workqueue: events control_work_handler [virtio_console] +[ 81.521354] RIP: 0010:__pv_queued_spin_unlock_slowpath+0xc0/0xd0 +[ 81.522450] Code: 07 00 48 63 7a 10 e8 bf 64 f5 ff 66 90 c3 8b 05 e6 cf d6 01 85 c0 74 01 c3 8b 17 48 89 fe 48 c7 c7 38 4b 29 91 e8 3a 6c fa ff <0f> 0b c3 0f 0b 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 48 +[ 81.525830] RSP: 0018:ffffb51a01ffbd70 EFLAGS: 00010282 +[ 81.526798] RAX: 0000000000000000 RBX: 0000000000000010 RCX: 0000000000000000 +[ 81.528110] RDX: ffff9e66f1826480 RSI: ffff9e66f1816a08 RDI: ffff9e66f1816a08 +[ 81.529437] RBP: ffffffff9153ff10 R08: 000000000000026c R09: 0000000000000053 +[ 81.530732] R10: 0000000000000000 R11: ffffb51a01ffbc18 R12: ffff9e66cd682200 +[ 81.532133] R13: ffffffff9153ff10 R14: ffff9e6685569500 R15: ffff9e66cd682000 +[ 81.533442] FS: 0000000000000000(0000) GS:ffff9e66f1800000(0000) knlGS:0000000000000000 +[ 81.534914] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +[ 81.535971] CR2: 00005624c55b14d0 CR3: 00000003a023c000 CR4: 00000000003406f0 +[ 81.537283] Call Trace: +[ 81.537763] __raw_callee_save___pv_queued_spin_unlock_slowpath+0x11/0x20 +[ 81.539011] .slowpath+0x9/0xe +[ 81.539585] hvc_alloc+0x25e/0x300 +[ 81.540237] init_port_console+0x28/0x100 [virtio_console] +[ 81.541251] handle_control_message.constprop.27+0x1c4/0x310 [virtio_console] +[ 81.542546] control_work_handler+0x70/0x10c [virtio_console] +[ 81.543601] process_one_work+0x1a7/0x3b0 +[ 81.544356] worker_thread+0x30/0x390 +[ 81.545025] ? create_worker+0x1a0/0x1a0 +[ 81.545749] kthread+0x112/0x130 +[ 81.546358] ? kthread_flush_work_fn+0x10/0x10 +[ 81.547183] ret_from_fork+0x22/0x40 +[ 81.547842] ---[ end trace aa97649bd16c8655 ]--- +[ 83.546539] general protection fault: 0000 [#1] SMP NOPTI +[ 83.547422] CPU: 5 PID: 3225 Comm: modprobe Kdump: loaded Tainted: G W --------- - - 4.18.0-167.el8.x86_64 #1 +[ 83.549191] Hardware name: Red Hat KVM, BIOS 1.12.0-5.scrmod+el8.2.0+5159+d8aa4d83 04/01/2014 +[ 83.550544] RIP: 0010:__pv_queued_spin_lock_slowpath+0x19a/0x2a0 +[ 83.551504] Code: c4 c1 ea 12 41 be 01 00 00 00 4c 8d 6d 14 41 83 e4 03 8d 42 ff 49 c1 e4 05 48 98 49 81 c4 40 a5 02 00 4c 03 24 c5 60 48 34 91 <49> 89 2c 24 b8 00 80 00 00 eb 15 84 c0 75 0a 41 0f b6 54 24 14 84 +[ 83.554449] RSP: 0018:ffffb51a0323fdb0 EFLAGS: 00010202 +[ 83.555290] RAX: 000000000000301c RBX: ffffffff92080020 RCX: 0000000000000001 +[ 83.556426] RDX: 000000000000301d RSI: 0000000000000000 RDI: 0000000000000000 +[ 83.557556] RBP: ffff9e66f196a540 R08: 000000000000028a R09: ffff9e66d2757788 +[ 83.558688] R10: 0000000000000000 R11: 0000000000000000 R12: 646e61725f770b07 +[ 83.559821] R13: ffff9e66f196a554 R14: 0000000000000001 R15: 0000000000180000 +[ 83.560958] FS: 00007fd5032e8740(0000) GS:ffff9e66f1940000(0000) knlGS:0000000000000000 +[ 83.562233] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +[ 83.563149] CR2: 00007fd5022b0da0 CR3: 000000038c334000 CR4: 00000000003406e0 + +Signed-off-by: Andrew Melnychenko +Cc: stable +Link: https://lore.kernel.org/r/20200414191503.3471783-1-andrew@daynix.com +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/hvc/hvc_console.c | 23 ++++++++++++++--------- + 1 file changed, 14 insertions(+), 9 deletions(-) + +--- a/drivers/tty/hvc/hvc_console.c ++++ b/drivers/tty/hvc/hvc_console.c +@@ -302,10 +302,6 @@ int hvc_instantiate(uint32_t vtermno, in + vtermnos[index] = vtermno; + cons_ops[index] = ops; + +- /* reserve all indices up to and including this index */ +- if (last_hvc < index) +- last_hvc = index; +- + /* check if we need to re-register the kernel console */ + hvc_check_console(index); + +@@ -960,13 +956,22 @@ struct hvc_struct *hvc_alloc(uint32_t vt + cons_ops[i] == hp->ops) + break; + +- /* no matching slot, just use a counter */ +- if (i >= MAX_NR_HVC_CONSOLES) +- i = ++last_hvc; ++ if (i >= MAX_NR_HVC_CONSOLES) { ++ ++ /* find 'empty' slot for console */ ++ for (i = 0; i < MAX_NR_HVC_CONSOLES && vtermnos[i] != -1; i++) { ++ } ++ ++ /* no matching slot, just use a counter */ ++ if (i == MAX_NR_HVC_CONSOLES) ++ i = ++last_hvc + MAX_NR_HVC_CONSOLES; ++ } + + hp->index = i; +- cons_ops[i] = ops; +- vtermnos[i] = vtermno; ++ if (i < MAX_NR_HVC_CONSOLES) { ++ cons_ops[i] = ops; ++ vtermnos[i] = vtermno; ++ } + + list_add_tail(&(hp->next), &hvc_structs); + mutex_unlock(&hvc_structs_mutex); diff --git a/queue-4.19/tty-rocket-avoid-oob-access.patch b/queue-4.19/tty-rocket-avoid-oob-access.patch new file mode 100644 index 00000000000..a5422dd7f8f --- /dev/null +++ b/queue-4.19/tty-rocket-avoid-oob-access.patch @@ -0,0 +1,72 @@ +From 7127d24372bf23675a36edc64d092dc7fd92ebe8 Mon Sep 17 00:00:00 2001 +From: Jiri Slaby +Date: Fri, 17 Apr 2020 12:59:59 +0200 +Subject: tty: rocket, avoid OOB access + +From: Jiri Slaby + +commit 7127d24372bf23675a36edc64d092dc7fd92ebe8 upstream. + +init_r_port can access pc104 array out of bounds. pc104 is a 2D array +defined to have 4 members. Each member has 8 submembers. +* we can have more than 4 (PCI) boards, i.e. [board] can be OOB +* line is not modulo-ed by anything, so the first line on the second + board can be 4, on the 3rd 12 or alike (depending on previously + registered boards). It's zero only on the first line of the first + board. So even [line] can be OOB, quite soon (with the 2nd registered + board already). + +This code is broken for ages, so just avoid the OOB accesses and don't +try to fix it as we would need to find out the correct line number. Use +the default: RS232, if we are out. + +Generally, if anyone needs to set the interface types, a module parameter +is past the last thing that should be used for this purpose. The +parameters' description says it's for ISA cards anyway. + +Signed-off-by: Jiri Slaby +Cc: stable +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Link: https://lore.kernel.org/r/20200417105959.15201-2-jslaby@suse.cz +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/rocket.c | 25 ++++++++++++++----------- + 1 file changed, 14 insertions(+), 11 deletions(-) + +--- a/drivers/tty/rocket.c ++++ b/drivers/tty/rocket.c +@@ -632,18 +632,21 @@ init_r_port(int board, int aiop, int cha + tty_port_init(&info->port); + info->port.ops = &rocket_port_ops; + info->flags &= ~ROCKET_MODE_MASK; +- switch (pc104[board][line]) { +- case 422: +- info->flags |= ROCKET_MODE_RS422; +- break; +- case 485: +- info->flags |= ROCKET_MODE_RS485; +- break; +- case 232: +- default: ++ if (board < ARRAY_SIZE(pc104) && line < ARRAY_SIZE(pc104_1)) ++ switch (pc104[board][line]) { ++ case 422: ++ info->flags |= ROCKET_MODE_RS422; ++ break; ++ case 485: ++ info->flags |= ROCKET_MODE_RS485; ++ break; ++ case 232: ++ default: ++ info->flags |= ROCKET_MODE_RS232; ++ break; ++ } ++ else + info->flags |= ROCKET_MODE_RS232; +- break; +- } + + info->intmask = RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR; + if (sInitChan(ctlp, &info->channel, aiop, chan) == 0) { diff --git a/queue-4.19/usb-storage-add-unusual_devs-entry-for-jmicron-jms566.patch b/queue-4.19/usb-storage-add-unusual_devs-entry-for-jmicron-jms566.patch new file mode 100644 index 00000000000..25c7f6dfa10 --- /dev/null +++ b/queue-4.19/usb-storage-add-unusual_devs-entry-for-jmicron-jms566.patch @@ -0,0 +1,47 @@ +From 94f9c8c3c404ee1f7aaff81ad4f24aec4e34a78b Mon Sep 17 00:00:00 2001 +From: Alan Stern +Date: Wed, 22 Apr 2020 16:14:57 -0400 +Subject: usb-storage: Add unusual_devs entry for JMicron JMS566 + +From: Alan Stern + +commit 94f9c8c3c404ee1f7aaff81ad4f24aec4e34a78b upstream. + +Cyril Roelandt reports that his JMicron JMS566 USB-SATA bridge fails +to handle WRITE commands with the FUA bit set, even though it claims +to support FUA. (Oddly enough, a later version of the same bridge, +version 2.03 as opposed to 1.14, doesn't claim to support FUA. Also +oddly, the bridge _does_ support FUA when using the UAS transport +instead of the Bulk-Only transport -- but this device was blacklisted +for uas in commit bc3bdb12bbb3 ("usb-storage: Disable UAS on JMicron +SATA enclosure") for apparently unrelated reasons.) + +This patch adds a usb-storage unusual_devs entry with the BROKEN_FUA +flag. This allows the bridge to work properly with usb-storage. + +Reported-and-tested-by: Cyril Roelandt +Signed-off-by: Alan Stern +CC: +Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2004221613110.11262-100000@iolanthe.rowland.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/storage/unusual_devs.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/drivers/usb/storage/unusual_devs.h ++++ b/drivers/usb/storage/unusual_devs.h +@@ -2323,6 +2323,13 @@ UNUSUAL_DEV( 0x3340, 0xffff, 0x0000, 0x + USB_SC_DEVICE,USB_PR_DEVICE,NULL, + US_FL_MAX_SECTORS_64 ), + ++/* Reported by Cyril Roelandt */ ++UNUSUAL_DEV( 0x357d, 0x7788, 0x0114, 0x0114, ++ "JMicron", ++ "USB to ATA/ATAPI Bridge", ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL, ++ US_FL_BROKEN_FUA ), ++ + /* Reported by Andrey Rahmatullin */ + UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100, + "iRiver", diff --git a/queue-4.19/vmalloc-fix-remap_vmalloc_range-bounds-checks.patch b/queue-4.19/vmalloc-fix-remap_vmalloc_range-bounds-checks.patch new file mode 100644 index 00000000000..42b18f25963 --- /dev/null +++ b/queue-4.19/vmalloc-fix-remap_vmalloc_range-bounds-checks.patch @@ -0,0 +1,165 @@ +From bdebd6a2831b6fab69eb85cee74a8ba77f1a1cc2 Mon Sep 17 00:00:00 2001 +From: Jann Horn +Date: Mon, 20 Apr 2020 18:14:11 -0700 +Subject: vmalloc: fix remap_vmalloc_range() bounds checks + +From: Jann Horn + +commit bdebd6a2831b6fab69eb85cee74a8ba77f1a1cc2 upstream. + +remap_vmalloc_range() has had various issues with the bounds checks it +promises to perform ("This function checks that addr is a valid +vmalloc'ed area, and that it is big enough to cover the vma") over time, +e.g.: + + - not detecting pgoff< +Signed-off-by: Andrew Morton +Cc: stable@vger.kernel.org +Cc: Alexei Starovoitov +Cc: Daniel Borkmann +Cc: Martin KaFai Lau +Cc: Song Liu +Cc: Yonghong Song +Cc: Andrii Nakryiko +Cc: John Fastabend +Cc: KP Singh +Link: http://lkml.kernel.org/r/20200415222312.236431-1-jannh@google.com +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + fs/proc/vmcore.c | 5 +++-- + include/linux/vmalloc.h | 2 +- + mm/vmalloc.c | 16 +++++++++++++--- + samples/vfio-mdev/mdpy.c | 2 +- + 4 files changed, 18 insertions(+), 7 deletions(-) + +--- a/fs/proc/vmcore.c ++++ b/fs/proc/vmcore.c +@@ -250,7 +250,8 @@ static int vmcoredd_mmap_dumps(struct vm + if (start < offset + dump->size) { + tsz = min(offset + (u64)dump->size - start, (u64)size); + buf = dump->buf + start - offset; +- if (remap_vmalloc_range_partial(vma, dst, buf, tsz)) { ++ if (remap_vmalloc_range_partial(vma, dst, buf, 0, ++ tsz)) { + ret = -EFAULT; + goto out_unlock; + } +@@ -607,7 +608,7 @@ static int mmap_vmcore(struct file *file + tsz = min(elfcorebuf_sz + elfnotes_sz - (size_t)start, size); + kaddr = elfnotes_buf + start - elfcorebuf_sz - vmcoredd_orig_sz; + if (remap_vmalloc_range_partial(vma, vma->vm_start + len, +- kaddr, tsz)) ++ kaddr, 0, tsz)) + goto fail; + + size -= tsz; +--- a/include/linux/vmalloc.h ++++ b/include/linux/vmalloc.h +@@ -103,7 +103,7 @@ extern void vunmap(const void *addr); + + extern int remap_vmalloc_range_partial(struct vm_area_struct *vma, + unsigned long uaddr, void *kaddr, +- unsigned long size); ++ unsigned long pgoff, unsigned long size); + + extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr, + unsigned long pgoff); +--- a/mm/vmalloc.c ++++ b/mm/vmalloc.c +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -2228,6 +2229,7 @@ finished: + * @vma: vma to cover + * @uaddr: target user address to start at + * @kaddr: virtual address of vmalloc kernel memory ++ * @pgoff: offset from @kaddr to start at + * @size: size of map area + * + * Returns: 0 for success, -Exxx on failure +@@ -2240,9 +2242,15 @@ finished: + * Similar to remap_pfn_range() (see mm/memory.c) + */ + int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr, +- void *kaddr, unsigned long size) ++ void *kaddr, unsigned long pgoff, ++ unsigned long size) + { + struct vm_struct *area; ++ unsigned long off; ++ unsigned long end_index; ++ ++ if (check_shl_overflow(pgoff, PAGE_SHIFT, &off)) ++ return -EINVAL; + + size = PAGE_ALIGN(size); + +@@ -2256,8 +2264,10 @@ int remap_vmalloc_range_partial(struct v + if (!(area->flags & VM_USERMAP)) + return -EINVAL; + +- if (kaddr + size > area->addr + get_vm_area_size(area)) ++ if (check_add_overflow(size, off, &end_index) || ++ end_index > get_vm_area_size(area)) + return -EINVAL; ++ kaddr += off; + + do { + struct page *page = vmalloc_to_page(kaddr); +@@ -2296,7 +2306,7 @@ int remap_vmalloc_range(struct vm_area_s + unsigned long pgoff) + { + return remap_vmalloc_range_partial(vma, vma->vm_start, +- addr + (pgoff << PAGE_SHIFT), ++ addr, pgoff, + vma->vm_end - vma->vm_start); + } + EXPORT_SYMBOL(remap_vmalloc_range); +--- a/samples/vfio-mdev/mdpy.c ++++ b/samples/vfio-mdev/mdpy.c +@@ -418,7 +418,7 @@ static int mdpy_mmap(struct mdev_device + return -EINVAL; + + return remap_vmalloc_range_partial(vma, vma->vm_start, +- mdev_state->memblk, ++ mdev_state->memblk, 0, + vma->vm_end - vma->vm_start); + } +