From: Greg Kroah-Hartman Date: Sun, 3 Oct 2021 12:26:20 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v4.4.286~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ebef3f99c072396969fe1d5b1cae07ae9a7b8f9;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: acpi-nfit-use-fallback-node-id-when-numa-info-in-nfit-table-is-incorrect.patch alsa-hda-realtek-quirks-to-enable-speaker-output-for-lenovo-legion-7i-15imhg05-yoga-7i-14itl5-15itl5-and-13s-gen2-laptops.patch fs-verity-fix-signed-integer-overflow-with-i_size-near-s64_max.patch gpio-pca953x-do-not-ignore-i2c-errors.patch hwmon-tmp421-handle-i2c-errors.patch hwmon-w83791d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch hwmon-w83792d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch hwmon-w83793-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch mac80211-fix-use-after-free-in-ccmp-gcmp-rx.patch scsi-ufs-fix-illegal-offset-in-upiu-event-trace.patch --- diff --git a/queue-5.10/acpi-nfit-use-fallback-node-id-when-numa-info-in-nfit-table-is-incorrect.patch b/queue-5.10/acpi-nfit-use-fallback-node-id-when-numa-info-in-nfit-table-is-incorrect.patch new file mode 100644 index 00000000000..152493016a4 --- /dev/null +++ b/queue-5.10/acpi-nfit-use-fallback-node-id-when-numa-info-in-nfit-table-is-incorrect.patch @@ -0,0 +1,49 @@ +From f060db99374e80e853ac4916b49f0a903f65e9dc Mon Sep 17 00:00:00 2001 +From: Jia He +Date: Wed, 22 Sep 2021 23:29:19 +0800 +Subject: ACPI: NFIT: Use fallback node id when numa info in NFIT table is incorrect + +From: Jia He + +commit f060db99374e80e853ac4916b49f0a903f65e9dc upstream. + +When ACPI NFIT table is failing to populate correct numa information +on arm64, dax_kmem will get NUMA_NO_NODE from the NFIT driver. + +Without this patch, pmem can't be probed as RAM devices on arm64 guest: + $ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s 1g -a 128M + kmem dax0.0: rejecting DAX region [mem 0x240400000-0x2bfffffff] with invalid node: -1 + kmem: probe of dax0.0 failed with error -22 + +Suggested-by: Dan Williams +Signed-off-by: Jia He +Cc: +Fixes: c221c0b0308f ("device-dax: "Hotplug" persistent memory for use like normal RAM") +Link: https://lore.kernel.org/r/20210922152919.6940-1-justin.he@arm.com +Signed-off-by: Dan Williams +Signed-off-by: Greg Kroah-Hartman +--- + drivers/acpi/nfit/core.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +--- a/drivers/acpi/nfit/core.c ++++ b/drivers/acpi/nfit/core.c +@@ -3018,6 +3018,18 @@ static int acpi_nfit_register_region(str + ndr_desc->target_node = NUMA_NO_NODE; + } + ++ /* Fallback to address based numa information if node lookup failed */ ++ if (ndr_desc->numa_node == NUMA_NO_NODE) { ++ ndr_desc->numa_node = memory_add_physaddr_to_nid(spa->address); ++ dev_info(acpi_desc->dev, "changing numa node from %d to %d for nfit region [%pa-%pa]", ++ NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end); ++ } ++ if (ndr_desc->target_node == NUMA_NO_NODE) { ++ ndr_desc->target_node = phys_to_target_node(spa->address); ++ dev_info(acpi_desc->dev, "changing target node from %d to %d for nfit region [%pa-%pa]", ++ NUMA_NO_NODE, ndr_desc->numa_node, &res.start, &res.end); ++ } ++ + /* + * Persistence domain bits are hierarchical, if + * ACPI_NFIT_CAPABILITY_CACHE_FLUSH is set then diff --git a/queue-5.10/alsa-hda-realtek-quirks-to-enable-speaker-output-for-lenovo-legion-7i-15imhg05-yoga-7i-14itl5-15itl5-and-13s-gen2-laptops.patch b/queue-5.10/alsa-hda-realtek-quirks-to-enable-speaker-output-for-lenovo-legion-7i-15imhg05-yoga-7i-14itl5-15itl5-and-13s-gen2-laptops.patch new file mode 100644 index 00000000000..64077a9b5f6 --- /dev/null +++ b/queue-5.10/alsa-hda-realtek-quirks-to-enable-speaker-output-for-lenovo-legion-7i-15imhg05-yoga-7i-14itl5-15itl5-and-13s-gen2-laptops.patch @@ -0,0 +1,191 @@ +From ad7cc2d41b7a8d0c5c5ecff37c3de7a4e137b3a6 Mon Sep 17 00:00:00 2001 +From: Cameron Berkenpas +Date: Mon, 13 Sep 2021 14:26:29 -0700 +Subject: ALSA: hda/realtek: Quirks to enable speaker output for Lenovo Legion 7i 15IMHG05, Yoga 7i 14ITL5/15ITL5, and 13s Gen2 laptops. + +From: Cameron Berkenpas + +commit ad7cc2d41b7a8d0c5c5ecff37c3de7a4e137b3a6 upstream. + +This patch initializes and enables speaker output on the Lenovo Legion 7i +15IMHG05, Yoga 7i 14ITL5/15ITL5, and 13s Gen2 series of laptops using the +HDA verb sequence specific to each model. + +Speaker automute is suppressed for the Lenovo Legion 7i 15IMHG05 to avoid +breaking speaker output on resume and when devices are unplugged from its +headphone jack. + +Thanks to: Andreas Holzer, Vincent Morel, sycxyc, Max Christian Pohle and +all others that helped. + +[ minor coding style fixes by tiwai ] + +BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=208555 +Signed-off-by: Cameron Berkenpas +Cc: +Link: https://lore.kernel.org/r/20210913212627.339362-1-cam@neo-zeon.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/hda/patch_realtek.c | 129 ++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 129 insertions(+) + +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -6375,6 +6375,20 @@ static void alc_fixup_thinkpad_acpi(stru + hda_fixup_thinkpad_acpi(codec, fix, action); + } + ++/* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */ ++static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec, ++ const struct hda_fixup *fix, ++ int action) ++{ ++ struct alc_spec *spec = codec->spec; ++ ++ switch (action) { ++ case HDA_FIXUP_ACT_PRE_PROBE: ++ spec->gen.suppress_auto_mute = 1; ++ break; ++ } ++} ++ + /* for alc295_fixup_hp_top_speakers */ + #include "hp_x360_helper.c" + +@@ -6591,6 +6605,10 @@ enum { + ALC623_FIXUP_LENOVO_THINKSTATION_P340, + ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, + ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST, ++ ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS, ++ ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE, ++ ALC287_FIXUP_YOGA7_14ITL_SPEAKERS, ++ ALC287_FIXUP_13S_GEN2_SPEAKERS + }; + + static const struct hda_fixup alc269_fixups[] = { +@@ -8175,6 +8193,113 @@ static const struct hda_fixup alc269_fix + .chained = true, + .chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF, + }, ++ [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = { ++ .type = HDA_FIXUP_VERBS, ++ //.v.verbs = legion_15imhg05_coefs, ++ .v.verbs = (const struct hda_verb[]) { ++ // set left speaker Legion 7i. ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x41 }, ++ ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x1a }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ ++ // set right speaker Legion 7i. ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x42 }, ++ ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x2a }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ {} ++ }, ++ .chained = true, ++ .chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE, ++ }, ++ [ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = { ++ .type = HDA_FIXUP_FUNC, ++ .v.func = alc287_fixup_legion_15imhg05_speakers, ++ .chained = true, ++ .chain_id = ALC269_FIXUP_HEADSET_MODE, ++ }, ++ [ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = { ++ .type = HDA_FIXUP_VERBS, ++ .v.verbs = (const struct hda_verb[]) { ++ // set left speaker Yoga 7i. ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x41 }, ++ ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x1a }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ ++ // set right speaker Yoga 7i. ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x46 }, ++ ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x2a }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ {} ++ }, ++ .chained = true, ++ .chain_id = ALC269_FIXUP_HEADSET_MODE, ++ }, ++ [ALC287_FIXUP_13S_GEN2_SPEAKERS] = { ++ .type = HDA_FIXUP_VERBS, ++ .v.verbs = (const struct hda_verb[]) { ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x41 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x42 }, ++ { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, ++ { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, ++ {} ++ }, ++ .chained = true, ++ .chain_id = ALC269_FIXUP_HEADSET_MODE, ++ }, + }; + + static const struct snd_pci_quirk alc269_fixup_tbl[] = { +@@ -8567,6 +8692,10 @@ static const struct snd_pci_quirk alc269 + SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME), + SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF), + SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP), ++ SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS), ++ SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), ++ SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), ++ SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS), + SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), + SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), + SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI), diff --git a/queue-5.10/fs-verity-fix-signed-integer-overflow-with-i_size-near-s64_max.patch b/queue-5.10/fs-verity-fix-signed-integer-overflow-with-i_size-near-s64_max.patch new file mode 100644 index 00000000000..66731a0f771 --- /dev/null +++ b/queue-5.10/fs-verity-fix-signed-integer-overflow-with-i_size-near-s64_max.patch @@ -0,0 +1,60 @@ +From 80f6e3080bfcf865062a926817b3ca6c4a137a57 Mon Sep 17 00:00:00 2001 +From: Eric Biggers +Date: Thu, 16 Sep 2021 13:34:24 -0700 +Subject: fs-verity: fix signed integer overflow with i_size near S64_MAX + +From: Eric Biggers + +commit 80f6e3080bfcf865062a926817b3ca6c4a137a57 upstream. + +If the file size is almost S64_MAX, the calculated number of Merkle tree +levels exceeds FS_VERITY_MAX_LEVELS, causing FS_IOC_ENABLE_VERITY to +fail. This is unintentional, since as the comment above the definition +of FS_VERITY_MAX_LEVELS states, it is enough for over U64_MAX bytes of +data using SHA-256 and 4K blocks. (Specifically, 4096*128**8 >= 2**64.) + +The bug is actually that when the number of blocks in the first level is +calculated from i_size, there is a signed integer overflow due to i_size +being signed. Fix this by treating i_size as unsigned. + +This was found by the new test "generic: test fs-verity EFBIG scenarios" +(https://lkml.kernel.org/r/b1d116cd4d0ea74b9cd86f349c672021e005a75c.1631558495.git.boris@bur.io). + +This didn't affect ext4 or f2fs since those have a smaller maximum file +size, but it did affect btrfs which allows files up to S64_MAX bytes. + +Reported-by: Boris Burkov +Fixes: 3fda4c617e84 ("fs-verity: implement FS_IOC_ENABLE_VERITY ioctl") +Fixes: fd2d1acfcadf ("fs-verity: add the hook for file ->open()") +Cc: # v5.4+ +Reviewed-by: Boris Burkov +Link: https://lore.kernel.org/r/20210916203424.113376-1-ebiggers@kernel.org +Signed-off-by: Eric Biggers +Signed-off-by: Greg Kroah-Hartman +--- + fs/verity/enable.c | 2 +- + fs/verity/open.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +--- a/fs/verity/enable.c ++++ b/fs/verity/enable.c +@@ -177,7 +177,7 @@ static int build_merkle_tree(struct file + * (level 0) and ascending to the root node (level 'num_levels - 1'). + * Then at the end (level 'num_levels'), calculate the root hash. + */ +- blocks = (inode->i_size + params->block_size - 1) >> ++ blocks = ((u64)inode->i_size + params->block_size - 1) >> + params->log_blocksize; + for (level = 0; level <= params->num_levels; level++) { + err = build_merkle_tree_level(filp, level, blocks, params, +--- a/fs/verity/open.c ++++ b/fs/verity/open.c +@@ -89,7 +89,7 @@ int fsverity_init_merkle_tree_params(str + */ + + /* Compute number of levels and the number of blocks in each level */ +- blocks = (inode->i_size + params->block_size - 1) >> log_blocksize; ++ blocks = ((u64)inode->i_size + params->block_size - 1) >> log_blocksize; + pr_debug("Data is %lld bytes (%llu blocks)\n", inode->i_size, blocks); + while (blocks > 1) { + if (params->num_levels >= FS_VERITY_MAX_LEVELS) { diff --git a/queue-5.10/gpio-pca953x-do-not-ignore-i2c-errors.patch b/queue-5.10/gpio-pca953x-do-not-ignore-i2c-errors.patch new file mode 100644 index 00000000000..2f27d4c4c28 --- /dev/null +++ b/queue-5.10/gpio-pca953x-do-not-ignore-i2c-errors.patch @@ -0,0 +1,44 @@ +From 540cffbab8b8e6c52a4121666ca18d6e94586ed2 Mon Sep 17 00:00:00 2001 +From: Andrey Gusakov +Date: Thu, 23 Sep 2021 20:22:16 +0300 +Subject: gpio: pca953x: do not ignore i2c errors + +From: Andrey Gusakov + +commit 540cffbab8b8e6c52a4121666ca18d6e94586ed2 upstream. + +Per gpio_chip interface, error shall be proparated to the caller. + +Attempt to silent diagnostics by returning zero (as written in the +comment) is plain wrong, because the zero return can be interpreted by +the caller as the gpio value. + +Cc: stable@vger.kernel.org +Signed-off-by: Andrey Gusakov +Signed-off-by: Nikita Yushchenko +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpio/gpio-pca953x.c | 11 ++--------- + 1 file changed, 2 insertions(+), 9 deletions(-) + +--- a/drivers/gpio/gpio-pca953x.c ++++ b/drivers/gpio/gpio-pca953x.c +@@ -467,15 +467,8 @@ static int pca953x_gpio_get_value(struct + mutex_lock(&chip->i2c_lock); + ret = regmap_read(chip->regmap, inreg, ®_val); + mutex_unlock(&chip->i2c_lock); +- if (ret < 0) { +- /* +- * NOTE: +- * diagnostic already emitted; that's all we should +- * do unless gpio_*_value_cansleep() calls become different +- * from their nonsleeping siblings (and report faults). +- */ +- return 0; +- } ++ if (ret < 0) ++ return ret; + + return !!(reg_val & bit); + } diff --git a/queue-5.10/hwmon-tmp421-handle-i2c-errors.patch b/queue-5.10/hwmon-tmp421-handle-i2c-errors.patch new file mode 100644 index 00000000000..507ac90bed4 --- /dev/null +++ b/queue-5.10/hwmon-tmp421-handle-i2c-errors.patch @@ -0,0 +1,99 @@ +From 2938b2978a70d4cc10777ee71c9e512ffe4e0f4b Mon Sep 17 00:00:00 2001 +From: Paul Fertser +Date: Fri, 24 Sep 2021 12:30:09 +0300 +Subject: hwmon: (tmp421) handle I2C errors + +From: Paul Fertser + +commit 2938b2978a70d4cc10777ee71c9e512ffe4e0f4b upstream. + +Function i2c_smbus_read_byte_data() can return a negative error number +instead of the data read if I2C transaction failed for whatever reason. + +Lack of error checking can lead to serious issues on production +hardware, e.g. errors treated as temperatures produce spurious critical +temperature-crossed-threshold errors in BMC logs for OCP server +hardware. The patch was tested with Mellanox OCP Mezzanine card +emulating TMP421 protocol for temperature sensing which sometimes leads +to I2C protocol error during early boot up stage. + +Fixes: 9410700b881f ("hwmon: Add driver for Texas Instruments TMP421/422/423 sensor chips") +Cc: stable@vger.kernel.org +Signed-off-by: Paul Fertser +Link: https://lore.kernel.org/r/20210924093011.26083-1-fercerpav@gmail.com +[groeck: dropped unnecessary line breaks] +Signed-off-by: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hwmon/tmp421.c | 38 ++++++++++++++++++++++++++++---------- + 1 file changed, 28 insertions(+), 10 deletions(-) + +--- a/drivers/hwmon/tmp421.c ++++ b/drivers/hwmon/tmp421.c +@@ -119,38 +119,56 @@ static int temp_from_u16(u16 reg) + return (temp * 1000 + 128) / 256; + } + +-static struct tmp421_data *tmp421_update_device(struct device *dev) ++static int tmp421_update_device(struct tmp421_data *data) + { +- struct tmp421_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; ++ int ret = 0; + int i; + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + (HZ / 2)) || + !data->valid) { +- data->config = i2c_smbus_read_byte_data(client, +- TMP421_CONFIG_REG_1); ++ ret = i2c_smbus_read_byte_data(client, TMP421_CONFIG_REG_1); ++ if (ret < 0) ++ goto exit; ++ data->config = ret; + + for (i = 0; i < data->channels; i++) { +- data->temp[i] = i2c_smbus_read_byte_data(client, +- TMP421_TEMP_MSB[i]) << 8; +- data->temp[i] |= i2c_smbus_read_byte_data(client, +- TMP421_TEMP_LSB[i]); ++ ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_MSB[i]); ++ if (ret < 0) ++ goto exit; ++ data->temp[i] = ret << 8; ++ ++ ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_LSB[i]); ++ if (ret < 0) ++ goto exit; ++ data->temp[i] |= ret; + } + data->last_updated = jiffies; + data->valid = 1; + } + ++exit: + mutex_unlock(&data->update_lock); + +- return data; ++ if (ret < 0) { ++ data->valid = 0; ++ return ret; ++ } ++ ++ return 0; + } + + static int tmp421_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) + { +- struct tmp421_data *tmp421 = tmp421_update_device(dev); ++ struct tmp421_data *tmp421 = dev_get_drvdata(dev); ++ int ret = 0; ++ ++ ret = tmp421_update_device(tmp421); ++ if (ret) ++ return ret; + + switch (attr) { + case hwmon_temp_input: diff --git a/queue-5.10/hwmon-w83791d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch b/queue-5.10/hwmon-w83791d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch new file mode 100644 index 00000000000..21f06098a39 --- /dev/null +++ b/queue-5.10/hwmon-w83791d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch @@ -0,0 +1,84 @@ +From 943c15ac1b84d378da26bba41c83c67e16499ac4 Mon Sep 17 00:00:00 2001 +From: Nadezda Lutovinova +Date: Tue, 21 Sep 2021 18:51:51 +0300 +Subject: hwmon: (w83791d) Fix NULL pointer dereference by removing unnecessary structure field + +From: Nadezda Lutovinova + +commit 943c15ac1b84d378da26bba41c83c67e16499ac4 upstream. + +If driver read val value sufficient for +(val & 0x08) && (!(val & 0x80)) && ((val & 0x7) == ((val >> 4) & 0x7)) +from device then Null pointer dereference occurs. +(It is possible if tmp = 0b0xyz1xyz, where same literals mean same numbers) +Also lm75[] does not serve a purpose anymore after switching to +devm_i2c_new_dummy_device() in w83791d_detect_subclients(). + +The patch fixes possible NULL pointer dereference by removing lm75[]. + +Found by Linux Driver Verification project (linuxtesting.org). + +Cc: stable@vger.kernel.org +Signed-off-by: Nadezda Lutovinova +Link: https://lore.kernel.org/r/20210921155153.28098-1-lutovinova@ispras.ru +[groeck: Dropped unnecessary continuation lines, fixed multi-line alignment] +Signed-off-by: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hwmon/w83791d.c | 29 +++++++++++------------------ + 1 file changed, 11 insertions(+), 18 deletions(-) + +--- a/drivers/hwmon/w83791d.c ++++ b/drivers/hwmon/w83791d.c +@@ -273,9 +273,6 @@ struct w83791d_data { + char valid; /* !=0 if following fields are valid */ + unsigned long last_updated; /* In jiffies */ + +- /* array of 2 pointers to subclients */ +- struct i2c_client *lm75[2]; +- + /* volts */ + u8 in[NUMBER_OF_VIN]; /* Register value */ + u8 in_max[NUMBER_OF_VIN]; /* Register value */ +@@ -1257,7 +1254,6 @@ static const struct attribute_group w837 + static int w83791d_detect_subclients(struct i2c_client *client) + { + struct i2c_adapter *adapter = client->adapter; +- struct w83791d_data *data = i2c_get_clientdata(client); + int address = client->addr; + int i, id; + u8 val; +@@ -1280,22 +1276,19 @@ static int w83791d_detect_subclients(str + } + + val = w83791d_read(client, W83791D_REG_I2C_SUBADDR); +- if (!(val & 0x08)) +- data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter, +- 0x48 + (val & 0x7)); +- if (!(val & 0x80)) { +- if (!IS_ERR(data->lm75[0]) && +- ((val & 0x7) == ((val >> 4) & 0x7))) { +- dev_err(&client->dev, +- "duplicate addresses 0x%x, " +- "use force_subclient\n", +- data->lm75[0]->addr); +- return -ENODEV; +- } +- data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter, +- 0x48 + ((val >> 4) & 0x7)); ++ ++ if (!(val & 0x88) && (val & 0x7) == ((val >> 4) & 0x7)) { ++ dev_err(&client->dev, ++ "duplicate addresses 0x%x, use force_subclient\n", 0x48 + (val & 0x7)); ++ return -ENODEV; + } + ++ if (!(val & 0x08)) ++ devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + (val & 0x7)); ++ ++ if (!(val & 0x80)) ++ devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + ((val >> 4) & 0x7)); ++ + return 0; + } + diff --git a/queue-5.10/hwmon-w83792d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch b/queue-5.10/hwmon-w83792d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch new file mode 100644 index 00000000000..779c9996779 --- /dev/null +++ b/queue-5.10/hwmon-w83792d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch @@ -0,0 +1,83 @@ +From 0f36b88173f028e372668ae040ab1a496834d278 Mon Sep 17 00:00:00 2001 +From: Nadezda Lutovinova +Date: Tue, 21 Sep 2021 18:51:52 +0300 +Subject: hwmon: (w83792d) Fix NULL pointer dereference by removing unnecessary structure field + +From: Nadezda Lutovinova + +commit 0f36b88173f028e372668ae040ab1a496834d278 upstream. + +If driver read val value sufficient for +(val & 0x08) && (!(val & 0x80)) && ((val & 0x7) == ((val >> 4) & 0x7)) +from device then Null pointer dereference occurs. +(It is possible if tmp = 0b0xyz1xyz, where same literals mean same numbers) +Also lm75[] does not serve a purpose anymore after switching to +devm_i2c_new_dummy_device() in w83791d_detect_subclients(). + +The patch fixes possible NULL pointer dereference by removing lm75[]. + +Found by Linux Driver Verification project (linuxtesting.org). + +Cc: stable@vger.kernel.org +Signed-off-by: Nadezda Lutovinova +Link: https://lore.kernel.org/r/20210921155153.28098-2-lutovinova@ispras.ru +[groeck: Dropped unnecessary continuation lines, fixed multipline alignment] +Signed-off-by: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hwmon/w83792d.c | 28 +++++++++++----------------- + 1 file changed, 11 insertions(+), 17 deletions(-) + +--- a/drivers/hwmon/w83792d.c ++++ b/drivers/hwmon/w83792d.c +@@ -264,9 +264,6 @@ struct w83792d_data { + char valid; /* !=0 if following fields are valid */ + unsigned long last_updated; /* In jiffies */ + +- /* array of 2 pointers to subclients */ +- struct i2c_client *lm75[2]; +- + u8 in[9]; /* Register value */ + u8 in_max[9]; /* Register value */ + u8 in_min[9]; /* Register value */ +@@ -927,7 +924,6 @@ w83792d_detect_subclients(struct i2c_cli + int address = new_client->addr; + u8 val; + struct i2c_adapter *adapter = new_client->adapter; +- struct w83792d_data *data = i2c_get_clientdata(new_client); + + id = i2c_adapter_id(adapter); + if (force_subclients[0] == id && force_subclients[1] == address) { +@@ -946,21 +942,19 @@ w83792d_detect_subclients(struct i2c_cli + } + + val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR); +- if (!(val & 0x08)) +- data->lm75[0] = devm_i2c_new_dummy_device(&new_client->dev, adapter, +- 0x48 + (val & 0x7)); +- if (!(val & 0x80)) { +- if (!IS_ERR(data->lm75[0]) && +- ((val & 0x7) == ((val >> 4) & 0x7))) { +- dev_err(&new_client->dev, +- "duplicate addresses 0x%x, use force_subclient\n", +- data->lm75[0]->addr); +- return -ENODEV; +- } +- data->lm75[1] = devm_i2c_new_dummy_device(&new_client->dev, adapter, +- 0x48 + ((val >> 4) & 0x7)); ++ ++ if (!(val & 0x88) && (val & 0x7) == ((val >> 4) & 0x7)) { ++ dev_err(&new_client->dev, ++ "duplicate addresses 0x%x, use force_subclient\n", 0x48 + (val & 0x7)); ++ return -ENODEV; + } + ++ if (!(val & 0x08)) ++ devm_i2c_new_dummy_device(&new_client->dev, adapter, 0x48 + (val & 0x7)); ++ ++ if (!(val & 0x80)) ++ devm_i2c_new_dummy_device(&new_client->dev, adapter, 0x48 + ((val >> 4) & 0x7)); ++ + return 0; + } + diff --git a/queue-5.10/hwmon-w83793-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch b/queue-5.10/hwmon-w83793-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch new file mode 100644 index 00000000000..3739782c4ae --- /dev/null +++ b/queue-5.10/hwmon-w83793-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch @@ -0,0 +1,81 @@ +From dd4d747ef05addab887dc8ff0d6ab9860bbcd783 Mon Sep 17 00:00:00 2001 +From: Nadezda Lutovinova +Date: Tue, 21 Sep 2021 18:51:53 +0300 +Subject: hwmon: (w83793) Fix NULL pointer dereference by removing unnecessary structure field + +From: Nadezda Lutovinova + +commit dd4d747ef05addab887dc8ff0d6ab9860bbcd783 upstream. + +If driver read tmp value sufficient for +(tmp & 0x08) && (!(tmp & 0x80)) && ((tmp & 0x7) == ((tmp >> 4) & 0x7)) +from device then Null pointer dereference occurs. +(It is possible if tmp = 0b0xyz1xyz, where same literals mean same numbers) +Also lm75[] does not serve a purpose anymore after switching to +devm_i2c_new_dummy_device() in w83791d_detect_subclients(). + +The patch fixes possible NULL pointer dereference by removing lm75[]. + +Found by Linux Driver Verification project (linuxtesting.org). + +Cc: stable@vger.kernel.org +Signed-off-by: Nadezda Lutovinova +Link: https://lore.kernel.org/r/20210921155153.28098-3-lutovinova@ispras.ru +[groeck: Dropped unnecessary continuation lines, fixed multi-line alignments] +Signed-off-by: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hwmon/w83793.c | 26 +++++++++++--------------- + 1 file changed, 11 insertions(+), 15 deletions(-) + +--- a/drivers/hwmon/w83793.c ++++ b/drivers/hwmon/w83793.c +@@ -202,7 +202,6 @@ static inline s8 TEMP_TO_REG(long val, s + } + + struct w83793_data { +- struct i2c_client *lm75[2]; + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if following fields are valid */ +@@ -1566,7 +1565,6 @@ w83793_detect_subclients(struct i2c_clie + int address = client->addr; + u8 tmp; + struct i2c_adapter *adapter = client->adapter; +- struct w83793_data *data = i2c_get_clientdata(client); + + id = i2c_adapter_id(adapter); + if (force_subclients[0] == id && force_subclients[1] == address) { +@@ -1586,21 +1584,19 @@ w83793_detect_subclients(struct i2c_clie + } + + tmp = w83793_read_value(client, W83793_REG_I2C_SUBADDR); +- if (!(tmp & 0x08)) +- data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter, +- 0x48 + (tmp & 0x7)); +- if (!(tmp & 0x80)) { +- if (!IS_ERR(data->lm75[0]) +- && ((tmp & 0x7) == ((tmp >> 4) & 0x7))) { +- dev_err(&client->dev, +- "duplicate addresses 0x%x, " +- "use force_subclients\n", data->lm75[0]->addr); +- return -ENODEV; +- } +- data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter, +- 0x48 + ((tmp >> 4) & 0x7)); ++ ++ if (!(tmp & 0x88) && (tmp & 0x7) == ((tmp >> 4) & 0x7)) { ++ dev_err(&client->dev, ++ "duplicate addresses 0x%x, use force_subclient\n", 0x48 + (tmp & 0x7)); ++ return -ENODEV; + } + ++ if (!(tmp & 0x08)) ++ devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + (tmp & 0x7)); ++ ++ if (!(tmp & 0x80)) ++ devm_i2c_new_dummy_device(&client->dev, adapter, 0x48 + ((tmp >> 4) & 0x7)); ++ + return 0; + } + diff --git a/queue-5.10/mac80211-fix-use-after-free-in-ccmp-gcmp-rx.patch b/queue-5.10/mac80211-fix-use-after-free-in-ccmp-gcmp-rx.patch new file mode 100644 index 00000000000..cea48ae3e1a --- /dev/null +++ b/queue-5.10/mac80211-fix-use-after-free-in-ccmp-gcmp-rx.patch @@ -0,0 +1,54 @@ +From 94513069eb549737bcfc3d988d6ed4da948a2de8 Mon Sep 17 00:00:00 2001 +From: Johannes Berg +Date: Mon, 27 Sep 2021 11:58:39 +0200 +Subject: mac80211: fix use-after-free in CCMP/GCMP RX + +From: Johannes Berg + +commit 94513069eb549737bcfc3d988d6ed4da948a2de8 upstream. + +When PN checking is done in mac80211, for fragmentation we need +to copy the PN to the RX struct so we can later use it to do a +comparison, since commit bf30ca922a0c ("mac80211: check defrag +PN against current frame"). + +Unfortunately, in that commit I used the 'hdr' variable without +it being necessarily valid, so use-after-free could occur if it +was necessary to reallocate (parts of) the frame. + +Fix this by reloading the variable after the code that results +in the reallocations, if any. + +This fixes https://bugzilla.kernel.org/show_bug.cgi?id=214401. + +Cc: stable@vger.kernel.org +Fixes: bf30ca922a0c ("mac80211: check defrag PN against current frame") +Link: https://lore.kernel.org/r/20210927115838.12b9ac6bb233.I1d066acd5408a662c3b6e828122cd314fcb28cdb@changeid +Signed-off-by: Johannes Berg +Signed-off-by: Greg Kroah-Hartman +--- + net/mac80211/wpa.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/net/mac80211/wpa.c ++++ b/net/mac80211/wpa.c +@@ -520,6 +520,9 @@ ieee80211_crypto_ccmp_decrypt(struct iee + return RX_DROP_UNUSABLE; + } + ++ /* reload hdr - skb might have been reallocated */ ++ hdr = (void *)rx->skb->data; ++ + data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - mic_len; + if (!rx->sta || data_len < 0) + return RX_DROP_UNUSABLE; +@@ -749,6 +752,9 @@ ieee80211_crypto_gcmp_decrypt(struct iee + return RX_DROP_UNUSABLE; + } + ++ /* reload hdr - skb might have been reallocated */ ++ hdr = (void *)rx->skb->data; ++ + data_len = skb->len - hdrlen - IEEE80211_GCMP_HDR_LEN - mic_len; + if (!rx->sta || data_len < 0) + return RX_DROP_UNUSABLE; diff --git a/queue-5.10/scsi-ufs-fix-illegal-offset-in-upiu-event-trace.patch b/queue-5.10/scsi-ufs-fix-illegal-offset-in-upiu-event-trace.patch new file mode 100644 index 00000000000..dd23b47c7a6 --- /dev/null +++ b/queue-5.10/scsi-ufs-fix-illegal-offset-in-upiu-event-trace.patch @@ -0,0 +1,35 @@ +From e8c2da7e329ce004fee748b921e4c765dc2fa338 Mon Sep 17 00:00:00 2001 +From: Jonathan Hsu +Date: Fri, 24 Sep 2021 16:58:48 +0800 +Subject: scsi: ufs: Fix illegal offset in UPIU event trace + +From: Jonathan Hsu + +commit e8c2da7e329ce004fee748b921e4c765dc2fa338 upstream. + +Fix incorrect index for UTMRD reference in ufshcd_add_tm_upiu_trace(). + +Link: https://lore.kernel.org/r/20210924085848.25500-1-jonathan.hsu@mediatek.com +Fixes: 4b42d557a8ad ("scsi: ufs: core: Fix wrong Task Tag used in task management request UPIUs") +Cc: stable@vger.kernel.org +Reviewed-by: Stanley Chu +Reviewed-by: Bart Van Assche +Signed-off-by: Jonathan Hsu +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/ufs/ufshcd.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/scsi/ufs/ufshcd.c ++++ b/drivers/scsi/ufs/ufshcd.c +@@ -318,8 +318,7 @@ static void ufshcd_add_query_upiu_trace( + static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, + const char *str) + { +- int off = (int)tag - hba->nutrs; +- struct utp_task_req_desc *descp = &hba->utmrdl_base_addr[off]; ++ struct utp_task_req_desc *descp = &hba->utmrdl_base_addr[tag]; + + trace_ufshcd_upiu(dev_name(hba->dev), str, &descp->req_header, + &descp->input_param1); diff --git a/queue-5.10/series b/queue-5.10/series index cb0af102ed7..41bb7ba4893 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -3,3 +3,13 @@ cpufreq-schedutil-use-kobject-release-method-to-free.patch scsi-qla2xxx-changes-to-support-kdump-kernel-for-nvm.patch cpufreq-schedutil-destroy-mutex-before-kobject_put-f.patch usb-cdns3-fix-race-condition-before-setting-doorbell.patch +alsa-hda-realtek-quirks-to-enable-speaker-output-for-lenovo-legion-7i-15imhg05-yoga-7i-14itl5-15itl5-and-13s-gen2-laptops.patch +acpi-nfit-use-fallback-node-id-when-numa-info-in-nfit-table-is-incorrect.patch +fs-verity-fix-signed-integer-overflow-with-i_size-near-s64_max.patch +hwmon-tmp421-handle-i2c-errors.patch +hwmon-w83793-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch +hwmon-w83792d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch +hwmon-w83791d-fix-null-pointer-dereference-by-removing-unnecessary-structure-field.patch +gpio-pca953x-do-not-ignore-i2c-errors.patch +scsi-ufs-fix-illegal-offset-in-upiu-event-trace.patch +mac80211-fix-use-after-free-in-ccmp-gcmp-rx.patch