From faedab2a36b3e014e37272adf8679f055f8cb4e6 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Sun, 7 Apr 2024 16:11:08 -0400 Subject: [PATCH] Fixes for 5.10 Signed-off-by: Sasha Levin --- ...paround-for-mask-in-snd_soc_get_vols.patch | 42 ++++ ...pci-device-id-table-declaration-comp.patch | 124 ++++++++++++ ...fix-pdc20621_get_from_dimm-on-64-bit.patch | 71 +++++++ .../scsi-mylex-fix-sysfs-buffer-lengths.patch | 189 ++++++++++++++++++ queue-5.10/series | 4 + 5 files changed, 430 insertions(+) create mode 100644 queue-5.10/asoc-ops-fix-wraparound-for-mask-in-snd_soc_get_vols.patch create mode 100644 queue-5.10/ata-sata_mv-fix-pci-device-id-table-declaration-comp.patch create mode 100644 queue-5.10/ata-sata_sx4-fix-pdc20621_get_from_dimm-on-64-bit.patch create mode 100644 queue-5.10/scsi-mylex-fix-sysfs-buffer-lengths.patch diff --git a/queue-5.10/asoc-ops-fix-wraparound-for-mask-in-snd_soc_get_vols.patch b/queue-5.10/asoc-ops-fix-wraparound-for-mask-in-snd_soc_get_vols.patch new file mode 100644 index 0000000000..79dde27b56 --- /dev/null +++ b/queue-5.10/asoc-ops-fix-wraparound-for-mask-in-snd_soc_get_vols.patch @@ -0,0 +1,42 @@ +From af1437f043430f55c3922ecf80749092041e7dcc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 25 Mar 2024 18:01:31 -0700 +Subject: ASoC: ops: Fix wraparound for mask in snd_soc_get_volsw + +From: Stephen Lee + +[ Upstream commit fc563aa900659a850e2ada4af26b9d7a3de6c591 ] + +In snd_soc_info_volsw(), mask is generated by figuring out the index of +the most significant bit set in max and converting the index to a +bitmask through bit shift 1. Unintended wraparound occurs when max is an +integer value with msb bit set. Since the bit shift value 1 is treated +as an integer type, the left shift operation will wraparound and set +mask to 0 instead of all 1's. In order to fix this, we type cast 1 as +`1ULL` to prevent the wraparound. + +Fixes: 7077148fb50a ("ASoC: core: Split ops out of soc-core.c") +Signed-off-by: Stephen Lee +Link: https://msgid.link/r/20240326010131.6211-1-slee08177@gmail.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/soc-ops.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c +index daecd386d5ec8..a83cd8d8a9633 100644 +--- a/sound/soc/soc-ops.c ++++ b/sound/soc/soc-ops.c +@@ -246,7 +246,7 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, + int max = mc->max; + int min = mc->min; + int sign_bit = mc->sign_bit; +- unsigned int mask = (1 << fls(max)) - 1; ++ unsigned int mask = (1ULL << fls(max)) - 1; + unsigned int invert = mc->invert; + int val; + int ret; +-- +2.43.0 + diff --git a/queue-5.10/ata-sata_mv-fix-pci-device-id-table-declaration-comp.patch b/queue-5.10/ata-sata_mv-fix-pci-device-id-table-declaration-comp.patch new file mode 100644 index 0000000000..50e7239efd --- /dev/null +++ b/queue-5.10/ata-sata_mv-fix-pci-device-id-table-declaration-comp.patch @@ -0,0 +1,124 @@ +From 45e65a1dbabda6538c8a43f5fadebbc65620a5ae Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 3 Apr 2024 10:06:48 +0200 +Subject: ata: sata_mv: Fix PCI device ID table declaration compilation warning + +From: Arnd Bergmann + +[ Upstream commit 3137b83a90646917c90951d66489db466b4ae106 ] + +Building with W=1 shows a warning for an unused variable when CONFIG_PCI +is diabled: + +drivers/ata/sata_mv.c:790:35: error: unused variable 'mv_pci_tbl' [-Werror,-Wunused-const-variable] +static const struct pci_device_id mv_pci_tbl[] = { + +Move the table into the same block that containsn the pci_driver +definition. + +Fixes: 7bb3c5290ca0 ("sata_mv: Remove PCI dependency") +Signed-off-by: Arnd Bergmann +Signed-off-by: Damien Le Moal +Signed-off-by: Sasha Levin +--- + drivers/ata/sata_mv.c | 63 +++++++++++++++++++++---------------------- + 1 file changed, 31 insertions(+), 32 deletions(-) + +diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c +index 11be88f70690e..cede4b517646f 100644 +--- a/drivers/ata/sata_mv.c ++++ b/drivers/ata/sata_mv.c +@@ -783,37 +783,6 @@ static const struct ata_port_info mv_port_info[] = { + }, + }; + +-static const struct pci_device_id mv_pci_tbl[] = { +- { PCI_VDEVICE(MARVELL, 0x5040), chip_504x }, +- { PCI_VDEVICE(MARVELL, 0x5041), chip_504x }, +- { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 }, +- { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, +- /* RocketRAID 1720/174x have different identifiers */ +- { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, +- { PCI_VDEVICE(TTI, 0x1740), chip_6042 }, +- { PCI_VDEVICE(TTI, 0x1742), chip_6042 }, +- +- { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, +- { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, +- { PCI_VDEVICE(MARVELL, 0x6042), chip_6042 }, +- { PCI_VDEVICE(MARVELL, 0x6080), chip_608x }, +- { PCI_VDEVICE(MARVELL, 0x6081), chip_608x }, +- +- { PCI_VDEVICE(ADAPTEC2, 0x0241), chip_604x }, +- +- /* Adaptec 1430SA */ +- { PCI_VDEVICE(ADAPTEC2, 0x0243), chip_7042 }, +- +- /* Marvell 7042 support */ +- { PCI_VDEVICE(MARVELL, 0x7042), chip_7042 }, +- +- /* Highpoint RocketRAID PCIe series */ +- { PCI_VDEVICE(TTI, 0x2300), chip_7042 }, +- { PCI_VDEVICE(TTI, 0x2310), chip_7042 }, +- +- { } /* terminate list */ +-}; +- + static const struct mv_hw_ops mv5xxx_ops = { + .phy_errata = mv5_phy_errata, + .enable_leds = mv5_enable_leds, +@@ -4307,6 +4276,36 @@ static int mv_pci_init_one(struct pci_dev *pdev, + static int mv_pci_device_resume(struct pci_dev *pdev); + #endif + ++static const struct pci_device_id mv_pci_tbl[] = { ++ { PCI_VDEVICE(MARVELL, 0x5040), chip_504x }, ++ { PCI_VDEVICE(MARVELL, 0x5041), chip_504x }, ++ { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 }, ++ { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, ++ /* RocketRAID 1720/174x have different identifiers */ ++ { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, ++ { PCI_VDEVICE(TTI, 0x1740), chip_6042 }, ++ { PCI_VDEVICE(TTI, 0x1742), chip_6042 }, ++ ++ { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, ++ { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, ++ { PCI_VDEVICE(MARVELL, 0x6042), chip_6042 }, ++ { PCI_VDEVICE(MARVELL, 0x6080), chip_608x }, ++ { PCI_VDEVICE(MARVELL, 0x6081), chip_608x }, ++ ++ { PCI_VDEVICE(ADAPTEC2, 0x0241), chip_604x }, ++ ++ /* Adaptec 1430SA */ ++ { PCI_VDEVICE(ADAPTEC2, 0x0243), chip_7042 }, ++ ++ /* Marvell 7042 support */ ++ { PCI_VDEVICE(MARVELL, 0x7042), chip_7042 }, ++ ++ /* Highpoint RocketRAID PCIe series */ ++ { PCI_VDEVICE(TTI, 0x2300), chip_7042 }, ++ { PCI_VDEVICE(TTI, 0x2310), chip_7042 }, ++ ++ { } /* terminate list */ ++}; + + static struct pci_driver mv_pci_driver = { + .name = DRV_NAME, +@@ -4319,6 +4318,7 @@ static struct pci_driver mv_pci_driver = { + #endif + + }; ++MODULE_DEVICE_TABLE(pci, mv_pci_tbl); + + /** + * mv_print_info - Dump key info to kernel log for perusal. +@@ -4491,7 +4491,6 @@ static void __exit mv_exit(void) + MODULE_AUTHOR("Brett Russ"); + MODULE_DESCRIPTION("SCSI low-level driver for Marvell SATA controllers"); + MODULE_LICENSE("GPL v2"); +-MODULE_DEVICE_TABLE(pci, mv_pci_tbl); + MODULE_VERSION(DRV_VERSION); + MODULE_ALIAS("platform:" DRV_NAME); + +-- +2.43.0 + diff --git a/queue-5.10/ata-sata_sx4-fix-pdc20621_get_from_dimm-on-64-bit.patch b/queue-5.10/ata-sata_sx4-fix-pdc20621_get_from_dimm-on-64-bit.patch new file mode 100644 index 0000000000..433d67288a --- /dev/null +++ b/queue-5.10/ata-sata_sx4-fix-pdc20621_get_from_dimm-on-64-bit.patch @@ -0,0 +1,71 @@ +From 1fb98dfdf9eafab85dcd2ac75786bc68fb17992e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 26 Mar 2024 15:53:37 +0100 +Subject: ata: sata_sx4: fix pdc20621_get_from_dimm() on 64-bit + +From: Arnd Bergmann + +[ Upstream commit 52f80bb181a9a1530ade30bc18991900bbb9697f ] + +gcc warns about a memcpy() with overlapping pointers because of an +incorrect size calculation: + +In file included from include/linux/string.h:369, + from drivers/ata/sata_sx4.c:66: +In function 'memcpy_fromio', + inlined from 'pdc20621_get_from_dimm.constprop' at drivers/ata/sata_sx4.c:962:2: +include/linux/fortify-string.h:97:33: error: '__builtin_memcpy' accessing 4294934464 bytes at offsets 0 and [16, 16400] overlaps 6442385281 bytes at offset -2147450817 [-Werror=restrict] + 97 | #define __underlying_memcpy __builtin_memcpy + | ^ +include/linux/fortify-string.h:620:9: note: in expansion of macro '__underlying_memcpy' + 620 | __underlying_##op(p, q, __fortify_size); \ + | ^~~~~~~~~~~~~ +include/linux/fortify-string.h:665:26: note: in expansion of macro '__fortify_memcpy_chk' + 665 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ + | ^~~~~~~~~~~~~~~~~~~~ +include/asm-generic/io.h:1184:9: note: in expansion of macro 'memcpy' + 1184 | memcpy(buffer, __io_virt(addr), size); + | ^~~~~~ + +The problem here is the overflow of an unsigned 32-bit number to a +negative that gets converted into a signed 'long', keeping a large +positive number. + +Replace the complex calculation with a more readable min() variant +that avoids the warning. + +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Signed-off-by: Arnd Bergmann +Signed-off-by: Damien Le Moal +Signed-off-by: Sasha Levin +--- + drivers/ata/sata_sx4.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c +index 4c01190a5e370..c95685f693a68 100644 +--- a/drivers/ata/sata_sx4.c ++++ b/drivers/ata/sata_sx4.c +@@ -1004,8 +1004,7 @@ static void pdc20621_get_from_dimm(struct ata_host *host, void *psource, + + offset -= (idx * window_size); + idx++; +- dist = ((long) (window_size - (offset + size))) >= 0 ? size : +- (long) (window_size - offset); ++ dist = min(size, window_size - offset); + memcpy_fromio(psource, dimm_mmio + offset / 4, dist); + + psource += dist; +@@ -1053,8 +1052,7 @@ static void pdc20621_put_to_dimm(struct ata_host *host, void *psource, + readl(mmio + PDC_DIMM_WINDOW_CTLR); + offset -= (idx * window_size); + idx++; +- dist = ((long)(s32)(window_size - (offset + size))) >= 0 ? size : +- (long) (window_size - offset); ++ dist = min(size, window_size - offset); + memcpy_toio(dimm_mmio + offset / 4, psource, dist); + writel(0x01, mmio + PDC_GENERAL_CTLR); + readl(mmio + PDC_GENERAL_CTLR); +-- +2.43.0 + diff --git a/queue-5.10/scsi-mylex-fix-sysfs-buffer-lengths.patch b/queue-5.10/scsi-mylex-fix-sysfs-buffer-lengths.patch new file mode 100644 index 0000000000..3ad05d5220 --- /dev/null +++ b/queue-5.10/scsi-mylex-fix-sysfs-buffer-lengths.patch @@ -0,0 +1,189 @@ +From 68ca5bd11742eb794db51b04a354adc8f283b42b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 26 Mar 2024 23:38:06 +0100 +Subject: scsi: mylex: Fix sysfs buffer lengths + +From: Arnd Bergmann + +[ Upstream commit 1197c5b2099f716b3de327437fb50900a0b936c9 ] + +The myrb and myrs drivers use an odd way of implementing their sysfs files, +calling snprintf() with a fixed length of 32 bytes to print into a page +sized buffer. One of the strings is actually longer than 32 bytes, which +clang can warn about: + +drivers/scsi/myrb.c:1906:10: error: 'snprintf' will always be truncated; specified size is 32, but format string expands to at least 34 [-Werror,-Wformat-truncation] +drivers/scsi/myrs.c:1089:10: error: 'snprintf' will always be truncated; specified size is 32, but format string expands to at least 34 [-Werror,-Wformat-truncation] + +These could all be plain sprintf() without a length as the buffer is always +long enough. On the other hand, sysfs files should not be overly long +either, so just double the length to make sure the longest strings don't +get truncated here. + +Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)") +Fixes: 081ff398c56c ("scsi: myrb: Add Mylex RAID controller (block interface)") +Signed-off-by: Arnd Bergmann +Link: https://lore.kernel.org/r/20240326223825.4084412-8-arnd@kernel.org +Reviewed-by: Hannes Reinecke +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/myrb.c | 20 ++++++++++---------- + drivers/scsi/myrs.c | 24 ++++++++++++------------ + 2 files changed, 22 insertions(+), 22 deletions(-) + +diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c +index ad17c2beaacad..d4c3f00faf1ba 100644 +--- a/drivers/scsi/myrb.c ++++ b/drivers/scsi/myrb.c +@@ -1803,9 +1803,9 @@ static ssize_t raid_state_show(struct device *dev, + + name = myrb_devstate_name(ldev_info->state); + if (name) +- ret = snprintf(buf, 32, "%s\n", name); ++ ret = snprintf(buf, 64, "%s\n", name); + else +- ret = snprintf(buf, 32, "Invalid (%02X)\n", ++ ret = snprintf(buf, 64, "Invalid (%02X)\n", + ldev_info->state); + } else { + struct myrb_pdev_state *pdev_info = sdev->hostdata; +@@ -1824,9 +1824,9 @@ static ssize_t raid_state_show(struct device *dev, + else + name = myrb_devstate_name(pdev_info->state); + if (name) +- ret = snprintf(buf, 32, "%s\n", name); ++ ret = snprintf(buf, 64, "%s\n", name); + else +- ret = snprintf(buf, 32, "Invalid (%02X)\n", ++ ret = snprintf(buf, 64, "Invalid (%02X)\n", + pdev_info->state); + } + return ret; +@@ -1914,11 +1914,11 @@ static ssize_t raid_level_show(struct device *dev, + + name = myrb_raidlevel_name(ldev_info->raid_level); + if (!name) +- return snprintf(buf, 32, "Invalid (%02X)\n", ++ return snprintf(buf, 64, "Invalid (%02X)\n", + ldev_info->state); +- return snprintf(buf, 32, "%s\n", name); ++ return snprintf(buf, 64, "%s\n", name); + } +- return snprintf(buf, 32, "Physical Drive\n"); ++ return snprintf(buf, 64, "Physical Drive\n"); + } + static DEVICE_ATTR_RO(raid_level); + +@@ -1931,15 +1931,15 @@ static ssize_t rebuild_show(struct device *dev, + unsigned char status; + + if (sdev->channel < myrb_logical_channel(sdev->host)) +- return snprintf(buf, 32, "physical device - not rebuilding\n"); ++ return snprintf(buf, 64, "physical device - not rebuilding\n"); + + status = myrb_get_rbld_progress(cb, &rbld_buf); + + if (rbld_buf.ldev_num != sdev->id || + status != MYRB_STATUS_SUCCESS) +- return snprintf(buf, 32, "not rebuilding\n"); ++ return snprintf(buf, 64, "not rebuilding\n"); + +- return snprintf(buf, 32, "rebuilding block %u of %u\n", ++ return snprintf(buf, 64, "rebuilding block %u of %u\n", + rbld_buf.ldev_size - rbld_buf.blocks_left, + rbld_buf.ldev_size); + } +diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c +index e6a6678967e52..857a73e856a14 100644 +--- a/drivers/scsi/myrs.c ++++ b/drivers/scsi/myrs.c +@@ -950,9 +950,9 @@ static ssize_t raid_state_show(struct device *dev, + + name = myrs_devstate_name(ldev_info->dev_state); + if (name) +- ret = snprintf(buf, 32, "%s\n", name); ++ ret = snprintf(buf, 64, "%s\n", name); + else +- ret = snprintf(buf, 32, "Invalid (%02X)\n", ++ ret = snprintf(buf, 64, "Invalid (%02X)\n", + ldev_info->dev_state); + } else { + struct myrs_pdev_info *pdev_info; +@@ -961,9 +961,9 @@ static ssize_t raid_state_show(struct device *dev, + pdev_info = sdev->hostdata; + name = myrs_devstate_name(pdev_info->dev_state); + if (name) +- ret = snprintf(buf, 32, "%s\n", name); ++ ret = snprintf(buf, 64, "%s\n", name); + else +- ret = snprintf(buf, 32, "Invalid (%02X)\n", ++ ret = snprintf(buf, 64, "Invalid (%02X)\n", + pdev_info->dev_state); + } + return ret; +@@ -1069,13 +1069,13 @@ static ssize_t raid_level_show(struct device *dev, + ldev_info = sdev->hostdata; + name = myrs_raid_level_name(ldev_info->raid_level); + if (!name) +- return snprintf(buf, 32, "Invalid (%02X)\n", ++ return snprintf(buf, 64, "Invalid (%02X)\n", + ldev_info->dev_state); + + } else + name = myrs_raid_level_name(MYRS_RAID_PHYSICAL); + +- return snprintf(buf, 32, "%s\n", name); ++ return snprintf(buf, 64, "%s\n", name); + } + static DEVICE_ATTR_RO(raid_level); + +@@ -1089,7 +1089,7 @@ static ssize_t rebuild_show(struct device *dev, + unsigned char status; + + if (sdev->channel < cs->ctlr_info->physchan_present) +- return snprintf(buf, 32, "physical device - not rebuilding\n"); ++ return snprintf(buf, 64, "physical device - not rebuilding\n"); + + ldev_info = sdev->hostdata; + ldev_num = ldev_info->ldev_num; +@@ -1101,11 +1101,11 @@ static ssize_t rebuild_show(struct device *dev, + return -EIO; + } + if (ldev_info->rbld_active) { +- return snprintf(buf, 32, "rebuilding block %zu of %zu\n", ++ return snprintf(buf, 64, "rebuilding block %zu of %zu\n", + (size_t)ldev_info->rbld_lba, + (size_t)ldev_info->cfg_devsize); + } else +- return snprintf(buf, 32, "not rebuilding\n"); ++ return snprintf(buf, 64, "not rebuilding\n"); + } + + static ssize_t rebuild_store(struct device *dev, +@@ -1194,7 +1194,7 @@ static ssize_t consistency_check_show(struct device *dev, + unsigned char status; + + if (sdev->channel < cs->ctlr_info->physchan_present) +- return snprintf(buf, 32, "physical device - not checking\n"); ++ return snprintf(buf, 64, "physical device - not checking\n"); + + ldev_info = sdev->hostdata; + if (!ldev_info) +@@ -1202,11 +1202,11 @@ static ssize_t consistency_check_show(struct device *dev, + ldev_num = ldev_info->ldev_num; + status = myrs_get_ldev_info(cs, ldev_num, ldev_info); + if (ldev_info->cc_active) +- return snprintf(buf, 32, "checking block %zu of %zu\n", ++ return snprintf(buf, 64, "checking block %zu of %zu\n", + (size_t)ldev_info->cc_lba, + (size_t)ldev_info->cfg_devsize); + else +- return snprintf(buf, 32, "not checking\n"); ++ return snprintf(buf, 64, "not checking\n"); + } + + static ssize_t consistency_check_store(struct device *dev, +-- +2.43.0 + diff --git a/queue-5.10/series b/queue-5.10/series index 5fe35ba7d6..f34a1a4453 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -229,3 +229,7 @@ udp-do-not-accept-non-tunnel-gso-skbs-landing-in-a-t.patch net-ravb-always-process-tx-descriptor-ring.patch arm64-dts-qcom-sc7180-remove-clock-for-bluetooth-on-.patch arm64-dts-qcom-sc7180-trogdor-mark-bluetooth-address.patch +asoc-ops-fix-wraparound-for-mask-in-snd_soc_get_vols.patch +ata-sata_sx4-fix-pdc20621_get_from_dimm-on-64-bit.patch +scsi-mylex-fix-sysfs-buffer-lengths.patch +ata-sata_mv-fix-pci-device-id-table-declaration-comp.patch -- 2.39.2