From: Sasha Levin Date: Sun, 13 Oct 2024 20:03:32 +0000 (-0400) Subject: Fixes for 5.10 X-Git-Tag: v5.10.227~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=de28400c0e3979b6dd2d83a939b2e053978fd95d;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- diff --git a/queue-5.10/hwmon-adm9240-add-missing-dependency-on-regmap_i2c.patch b/queue-5.10/hwmon-adm9240-add-missing-dependency-on-regmap_i2c.patch new file mode 100644 index 00000000000..0c5417f8802 --- /dev/null +++ b/queue-5.10/hwmon-adm9240-add-missing-dependency-on-regmap_i2c.patch @@ -0,0 +1,36 @@ +From 51d3afbe3c96cb6a53874821a776cb70def76885 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 2 Oct 2024 03:08:08 +0200 +Subject: hwmon: (adm9240) Add missing dependency on REGMAP_I2C + +From: Javier Carrasco + +[ Upstream commit 14849a2ec175bb8a2280ce20efe002bb19f1e274 ] + +This driver requires REGMAP_I2C to be selected in order to get access to +regmap_config and devm_regmap_init_i2c. Add the missing dependency. + +Fixes: df885d912f67 ("hwmon: (adm9240) Convert to regmap") +Signed-off-by: Javier Carrasco +Message-ID: <20241002-hwmon-select-regmap-v1-1-548d03268934@gmail.com> +Signed-off-by: Guenter Roeck +Signed-off-by: Sasha Levin +--- + drivers/hwmon/Kconfig | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig +index a762334084cf5..606cb865195fb 100644 +--- a/drivers/hwmon/Kconfig ++++ b/drivers/hwmon/Kconfig +@@ -178,6 +178,7 @@ config SENSORS_ADM9240 + tristate "Analog Devices ADM9240 and compatibles" + depends on I2C + select HWMON_VID ++ select REGMAP_I2C + help + If you say yes here you get support for Analog Devices ADM9240, + Dallas DS1780, National Semiconductor LM81 sensor chips. +-- +2.43.0 + diff --git a/queue-5.10/hwmon-tmp513-add-missing-dependency-on-regmap_i2c.patch b/queue-5.10/hwmon-tmp513-add-missing-dependency-on-regmap_i2c.patch new file mode 100644 index 00000000000..a9d355abf02 --- /dev/null +++ b/queue-5.10/hwmon-tmp513-add-missing-dependency-on-regmap_i2c.patch @@ -0,0 +1,45 @@ +From 2c2a4950225c7b291cbd5f11c0d7ecd4d76843ae Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Oct 2024 11:37:15 -0700 +Subject: hwmon: (tmp513) Add missing dependency on REGMAP_I2C + +From: Guenter Roeck + +[ Upstream commit 193bc02c664999581a1f38c152f379fce91afc0c ] + +0-day reports: + +drivers/hwmon/tmp513.c:162:21: error: + variable 'tmp51x_regmap_config' has initializer but incomplete type +162 | static const struct regmap_config tmp51x_regmap_config = { + | ^ + +struct regmap_config is only available if REGMAP is enabled. +Add the missing Kconfig dependency to fix the problem. + +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202410020246.2cTDDx0X-lkp@intel.com/ +Fixes: 59dfa75e5d82 ("hwmon: Add driver for Texas Instruments TMP512/513 sensor chips.") +Cc: Eric Tremblay +Reviewed-by: Javier Carrasco +Signed-off-by: Guenter Roeck +Signed-off-by: Sasha Levin +--- + drivers/hwmon/Kconfig | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig +index 8a427467a8427..a762334084cf5 100644 +--- a/drivers/hwmon/Kconfig ++++ b/drivers/hwmon/Kconfig +@@ -1866,6 +1866,7 @@ config SENSORS_TMP421 + config SENSORS_TMP513 + tristate "Texas Instruments TMP513 and compatibles" + depends on I2C ++ select REGMAP_I2C + help + If you say yes here you get support for Texas Instruments TMP512, + and TMP513 temperature and power supply sensor chips. +-- +2.43.0 + diff --git a/queue-5.10/resource-fix-region_intersects-vs-add_memory_driver_.patch b/queue-5.10/resource-fix-region_intersects-vs-add_memory_driver_.patch new file mode 100644 index 00000000000..aaf5e9c12bb --- /dev/null +++ b/queue-5.10/resource-fix-region_intersects-vs-add_memory_driver_.patch @@ -0,0 +1,180 @@ +From ac64ceff13b42ada1c4edcdbfeb34f36b68ef5cd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 10 Oct 2024 13:33:38 +0800 +Subject: resource: fix region_intersects() vs add_memory_driver_managed() + +From: Huang Ying + +commit b4afe4183ec77f230851ea139d91e5cf2644c68b upstream. + +On a system with CXL memory, the resource tree (/proc/iomem) related to +CXL memory may look like something as follows. + +490000000-50fffffff : CXL Window 0 + 490000000-50fffffff : region0 + 490000000-50fffffff : dax0.0 + 490000000-50fffffff : System RAM (kmem) + +Because drivers/dax/kmem.c calls add_memory_driver_managed() during +onlining CXL memory, which makes "System RAM (kmem)" a descendant of "CXL +Window X". This confuses region_intersects(), which expects all "System +RAM" resources to be at the top level of iomem_resource. This can lead to +bugs. + +For example, when the following command line is executed to write some +memory in CXL memory range via /dev/mem, + + $ dd if=data of=/dev/mem bs=$((1 << 10)) seek=$((0x490000000 >> 10)) count=1 + dd: error writing '/dev/mem': Bad address + 1+0 records in + 0+0 records out + 0 bytes copied, 0.0283507 s, 0.0 kB/s + +the command fails as expected. However, the error code is wrong. It +should be "Operation not permitted" instead of "Bad address". More +seriously, the /dev/mem permission checking in devmem_is_allowed() passes +incorrectly. Although the accessing is prevented later because ioremap() +isn't allowed to map system RAM, it is a potential security issue. During +command executing, the following warning is reported in the kernel log for +calling ioremap() on system RAM. + + ioremap on RAM at 0x0000000490000000 - 0x0000000490000fff + WARNING: CPU: 2 PID: 416 at arch/x86/mm/ioremap.c:216 __ioremap_caller.constprop.0+0x131/0x35d + Call Trace: + memremap+0xcb/0x184 + xlate_dev_mem_ptr+0x25/0x2f + write_mem+0x94/0xfb + vfs_write+0x128/0x26d + ksys_write+0xac/0xfe + do_syscall_64+0x9a/0xfd + entry_SYSCALL_64_after_hwframe+0x4b/0x53 + +The details of command execution process are as follows. In the above +resource tree, "System RAM" is a descendant of "CXL Window 0" instead of a +top level resource. So, region_intersects() will report no System RAM +resources in the CXL memory region incorrectly, because it only checks the +top level resources. Consequently, devmem_is_allowed() will return 1 +(allow access via /dev/mem) for CXL memory region incorrectly. +Fortunately, ioremap() doesn't allow to map System RAM and reject the +access. + +So, region_intersects() needs to be fixed to work correctly with the +resource tree with "System RAM" not at top level as above. To fix it, if +we found a unmatched resource in the top level, we will continue to search +matched resources in its descendant resources. So, we will not miss any +matched resources in resource tree anymore. + +In the new implementation, an example resource tree + +|------------- "CXL Window 0" ------------| +|-- "System RAM" --| + +will behave similar as the following fake resource tree for +region_intersects(, IORESOURCE_SYSTEM_RAM, ), + +|-- "System RAM" --||-- "CXL Window 0a" --| + +Where "CXL Window 0a" is part of the original "CXL Window 0" that +isn't covered by "System RAM". + +Link: https://lkml.kernel.org/r/20240906030713.204292-2-ying.huang@intel.com +Fixes: c221c0b0308f ("device-dax: "Hotplug" persistent memory for use like normal RAM") +Signed-off-by: "Huang, Ying" +Cc: Dan Williams +Cc: David Hildenbrand +Cc: Davidlohr Bueso +Cc: Jonathan Cameron +Cc: Dave Jiang +Cc: Alison Schofield +Cc: Vishal Verma +Cc: Ira Weiny +Cc: Alistair Popple +Cc: Andy Shevchenko +Cc: Bjorn Helgaas +Cc: Baoquan He +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Sasha Levin +--- + kernel/resource.c | 58 ++++++++++++++++++++++++++++++++++++++++------- + 1 file changed, 50 insertions(+), 8 deletions(-) + +diff --git a/kernel/resource.c b/kernel/resource.c +index 100253d4909c9..1087f33d70c4d 100644 +--- a/kernel/resource.c ++++ b/kernel/resource.c +@@ -539,21 +539,63 @@ EXPORT_SYMBOL_GPL(page_is_ram); + int region_intersects(resource_size_t start, size_t size, unsigned long flags, + unsigned long desc) + { +- struct resource res; ++ resource_size_t ostart, oend; + int type = 0; int other = 0; +- struct resource *p; ++ struct resource *p, *dp; ++ bool is_type, covered; ++ struct resource res; + + res.start = start; + res.end = start + size - 1; + + read_lock(&resource_lock); + for (p = iomem_resource.child; p ; p = p->sibling) { +- bool is_type = (((p->flags & flags) == flags) && +- ((desc == IORES_DESC_NONE) || +- (desc == p->desc))); +- +- if (resource_overlaps(p, &res)) +- is_type ? type++ : other++; ++ if (!resource_overlaps(p, &res)) ++ continue; ++ is_type = (p->flags & flags) == flags && ++ (desc == IORES_DESC_NONE || desc == p->desc); ++ if (is_type) { ++ type++; ++ continue; ++ } ++ /* ++ * Continue to search in descendant resources as if the ++ * matched descendant resources cover some ranges of 'p'. ++ * ++ * |------------- "CXL Window 0" ------------| ++ * |-- "System RAM" --| ++ * ++ * will behave similar as the following fake resource ++ * tree when searching "System RAM". ++ * ++ * |-- "System RAM" --||-- "CXL Window 0a" --| ++ */ ++ covered = false; ++ ostart = max(res.start, p->start); ++ oend = min(res.end, p->end); ++ for (dp = p->child; dp; dp = next_resource(dp, false)) { ++ if (!resource_overlaps(dp, &res)) ++ continue; ++ is_type = (dp->flags & flags) == flags && ++ (desc == IORES_DESC_NONE || desc == dp->desc); ++ if (is_type) { ++ type++; ++ /* ++ * Range from 'ostart' to 'dp->start' ++ * isn't covered by matched resource. ++ */ ++ if (dp->start > ostart) ++ break; ++ if (dp->end >= oend) { ++ covered = true; ++ break; ++ } ++ /* Remove covered range */ ++ ostart = max(ostart, dp->end + 1); ++ } ++ } ++ if (!covered) ++ other++; + } + read_unlock(&resource_lock); + +-- +2.43.0 + diff --git a/queue-5.10/series b/queue-5.10/series index 47277bea1b5..73a219f447b 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -503,3 +503,6 @@ netfilter-rpfilter-fib-set-flowic_uid-correctly-for-.patch netfilter-fib-check-correct-rtable-in-vrf-setups.patch ppp-fix-ppp_async_encode-illegal-access.patch slip-make-slhc_remember-more-robust-against-maliciou.patch +resource-fix-region_intersects-vs-add_memory_driver_.patch +hwmon-tmp513-add-missing-dependency-on-regmap_i2c.patch +hwmon-adm9240-add-missing-dependency-on-regmap_i2c.patch