6.3.2-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 655/694 dmaengine: at_xdmac: restore the content of grws register
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 7c5eb63d16b01c202aaa95f374ae15a807745a73 ]
In case the system suspends to a deep sleep state where power to DMA controller is cut-off we need to restore the content of GRWS register. This is a write only register and writing bit X tells the controller to suspend read and write requests for channel X. Thus set GRWS before restoring the content of GE (Global Enable) regiter.
--- drivers/dma/at_xdmac.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/dma/at_xdmac.c +9 -0
@@ -2211,6 +2211,15 @@ static int __maybe_unused atmel_xdmac_resume(struct device *dev)return ret;at_xdmac_device_resume_internal (atchan); } + +/* +* We may resume from a deep sleep state where power +* to DMA controller is cut-off. Thus, restore the +* suspend state of channels set though dmaengine API. +*/ +else if (at_xdmac_chan_is_paused (atchan)) +at_xdmac_device_pause_set (atxdmac, atchan); +at_xdmac_chan_write (atchan,AT_XDMAC_CNDA , atchan->save_cnda);at_xdmac_chan_write (atchan,AT_XDMAC_CNDC , atchan->save_cndc);at_xdmac_chan_write (atchan,AT_XDMAC_CIE , atchan->save_cim);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 656/694 dmaengine: at_xdmac: do not enable all cyclic channels
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit f8435befd81dd85b7b610598551fadf675849bc1 ]
Do not global enable all the cyclic channels in at_xdmac_resume(). Instead save the global status in at_xdmac_suspend() and re-enable the cyclic channel only if it was active before suspend.
--- drivers/dma/at_xdmac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/at_xdmac.c +4 -1
@@ -246,6 +246,7 @@ struct at_xdmac {int irq;struct clk *clk;u32 save_gim; +u32 save_gs;struct dma_pool *at_xdmac_desc_pool;const struct at_xdmac_layout *layout;struct at_xdmac_chan chan[];
@@ -2162,6 +2163,7 @@ static int __maybe_unused atmel_xdmac_suspend(struct device *dev) } } atxdmac->save_gim =at_xdmac_read (atxdmac,AT_XDMAC_GIM ); + atxdmac->save_gs =at_xdmac_read (atxdmac,AT_XDMAC_GS );at_xdmac_off (atxdmac, false);pm_runtime_mark_last_busy (atxdmac->dev);
@@ -2224,7 +2226,8 @@ static int __maybe_unused atmel_xdmac_resume(struct device *dev)at_xdmac_chan_write (atchan,AT_XDMAC_CNDC , atchan->save_cndc);at_xdmac_chan_write (atchan,AT_XDMAC_CIE , atchan->save_cim);wmb (); -at_xdmac_write (atxdmac,AT_XDMAC_GE , atchan->mask); +if (atxdmac->save_gs & atchan->mask) +at_xdmac_write (atxdmac,AT_XDMAC_GE , atchan->mask); } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 657/694 pinctrl-bcm2835.c: fix race condition when setting gpio dir
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit b7badd752de05312fdb1aeb388480f706d0c087f ]
In the past setting the pin direction called pinctrl_gpio_direction() which uses a mutex to serialize this. That was changed to set the direction directly in the pin controller driver, but that lost the serialization mechanism. Since the direction of multiple pins are in the same register you can have a race condition, something that was in fact observed with the cec-gpio driver.
Add a new spinlock to serialize writing to the FSEL registers.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +15 -4
@@ -90,6 +90,8 @@ struct bcm2835_pinctrl {struct pinctrl_gpio_range gpio_range;raw_spinlock_t irq_lock[BCM2835_NUM_BANKS ]; +/* Protect FSEL registers */ +spinlock_t fsel_lock; };/* pins are just named GPIO0..GPIO53 */
@@ -284,14 +286,19 @@ static inline void bcm2835_pinctrl_fsel_set( struct bcm2835_pinctrl *pc, unsigned pin, enum bcm2835_fsel fsel) { - u32 val = bcm2835_gpio_rd(pc, FSEL_REG(pin)); -enum bcm2835_fsel cur = (val >>FSEL_SHIFT (pin)) &BCM2835_FSEL_MASK ; + u32 val; +enum bcm2835_fsel cur; +unsigned long flags; + +spin_lock_irqsave (&pc->fsel_lock, flags); + val =bcm2835_gpio_rd (pc,FSEL_REG (pin)); + cur = (val >>FSEL_SHIFT (pin)) &BCM2835_FSEL_MASK ;dev_dbg (pc->dev,"read %08x (%u => %s)\n" , val, pin, - bcm2835_functions[cur]); + bcm2835_functions[cur]);if (cur == fsel) -return ; + goto unlock;if (cur !=BCM2835_FSEL_GPIO_IN && fsel !=BCM2835_FSEL_GPIO_IN ) {/* always transition through GPIO_IN */
@@ -309,6 +316,9 @@ static inline void bcm2835_pinctrl_fsel_set(dev_dbg (pc->dev,"write %08x (%u <= %s)\n" , val, pin, bcm2835_functions[fsel]);bcm2835_gpio_wr (pc,FSEL_REG (pin), val); + +unlock: +spin_unlock_irqrestore (&pc->fsel_lock, flags); }static int bcm2835_gpio_direction_input (struct gpio_chip *chip,unsigned offset)
@@ -1248,6 +1258,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) pc->gpio_chip = *pdata->gpio_chip; pc->gpio_chip.parent = dev; +spin_lock_init (&pc->fsel_lock);for (i =0 ; i <BCM2835_NUM_BANKS ; i++) {unsigned long events;unsigned offset;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 658/694 thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe
In reply to Greg Kroah-HartmanFrom: Kang Chen <[email protected]>
[ Upstream commit f05c7b7d9ea9477fcc388476c6f4ade8c66d2d26 ]
Smatch reports:
1. mtk_thermal_probe() warn: 'apmixed_base' from of_iomap() not released.
2. mtk_thermal_probe() warn: 'auxadc_base' from of_iomap() not released.
The original code forgets to release iomap resource when handling errors, fix it by switch to devm_of_iomap.
--- drivers/thermal/mediatek/auxadc_thermal.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/thermal/mediatek/auxadc_thermal.c +12 -2
@@ -1142,7 +1142,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)return -ENODEV ; } - auxadc_base =of_iomap (auxadc,0 ); + auxadc_base =devm_of_iomap (&pdev->dev, auxadc,0 ,NULL ); +if (IS_ERR (auxadc_base)) { +of_node_put (auxadc); +return PTR_ERR (auxadc_base); + } + auxadc_phys_base =of_get_phys_base (auxadc);of_node_put (auxadc);
@@ -1158,7 +1163,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)return -ENODEV ; } - apmixed_base =of_iomap (apmixedsys,0 ); + apmixed_base =devm_of_iomap (&pdev->dev, apmixedsys,0 ,NULL ); +if (IS_ERR (apmixed_base)) { +of_node_put (apmixedsys); +return PTR_ERR (apmixed_base); + } + apmixed_phys_base =of_get_phys_base (apmixedsys);of_node_put (apmixedsys);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 659/694 mfd: tqmx86: Do not access I2C_DETECT register through io_base
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit 1be1b23696b3d4b0231c694f5e0767b4471d33a9 ]
The I2C_DETECT register is at IO port 0x1a7, which is outside the range passed to devm_ioport_map() for io_base, and was only working because there aren't actually any bounds checks for IO port accesses.
Extending the range does not seem like a good solution here, as it would then conflict with the IO resource assigned to the I2C controller. As this is just a one-off access during probe, use a simple inb() instead.
While we're at it, drop the unused define TQMX86_REG_I2C_INT_EN.
--- drivers/mfd/tqmx86.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/mfd/tqmx86.c +7 -3
@@ -49,9 +49,8 @@#define TQMX86_REG_IO_EXT_INT_MASK 0x3#define TQMX86_REG_IO_EXT_INT_GPIO_SHIFT 4 -#define TQMX86_REG_I2C_DETECT 0x47 +#define TQMX86_REG_I2C_DETECT 0x1a7#define TQMX86_REG_I2C_DETECT_SOFT 0xa5 -#define TQMX86_REG_I2C_INT_EN 0x49static uint gpio_irq;module_param (gpio_irq, uint,0 );
@@ -213,7 +212,12 @@ static int tqmx86_probe(struct platform_device *pdev)"Found %s - Board ID %d, PCB Revision %d, PLD Revision %d\n" , board_name, board_id, rev >> 4, rev & 0xf); - i2c_det =ioread8 (io_base +TQMX86_REG_I2C_DETECT ); +/* +* The I2C_DETECT register is in the range assigned to the I2C driver +* later, so we don't extend TQMX86_IOSIZE. Use inb() for this one-off +* access instead of ioport_map + unmap. +*/ + i2c_det =inb (TQMX86_REG_I2C_DETECT );if (gpio_irq_cfg) { io_ext_int_val =
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 660/694 mfd: tqmx86: Specify IO port register range more precisely
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit 051c69ff4f607aa114c7bbdd7c41ed881367aeee ]
Registers 0x160..0x17f are unassigned. Use 0x180 as base register and update offets accordingly.
Also change the size of the range to include 0x19f. While 0x19f is currently reserved for future extensions, so are several of the previous registers up to 0x19e, and it is weird to leave out just the last one.
--- drivers/mfd/tqmx86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mfd/tqmx86.c +5 -5
@@ -16,8 +16,8 @@#include <linux/platform_data/i2c-ocores.h> #include <linux/platform_device.h> -#define TQMX86_IOBASE 0x160 -#define TQMX86_IOSIZE 0x3f +#define TQMX86_IOBASE 0x180 +#define TQMX86_IOSIZE 0x20#define TQMX86_IOBASE_I2C 0x1a0#define TQMX86_IOSIZE_I2C 0xa#define TQMX86_IOBASE_WATCHDOG 0x18b
@@ -25,7 +25,7 @@#define TQMX86_IOBASE_GPIO 0x18d#define TQMX86_IOSIZE_GPIO 0x4 -#define TQMX86_REG_BOARD_ID 0x20 +#define TQMX86_REG_BOARD_ID 0x00#define TQMX86_REG_BOARD_ID_E38M 1#define TQMX86_REG_BOARD_ID_50UC 2#define TQMX86_REG_BOARD_ID_E38C 3
@@ -40,8 +40,8 @@#define TQMX86_REG_BOARD_ID_E40S 13#define TQMX86_REG_BOARD_ID_E40C1 14#define TQMX86_REG_BOARD_ID_E40C2 15 -#define TQMX86_REG_BOARD_REV 0x21 -#define TQMX86_REG_IO_EXT_INT 0x26 +#define TQMX86_REG_BOARD_REV 0x01 +#define TQMX86_REG_IO_EXT_INT 0x06#define TQMX86_REG_IO_EXT_INT_NONE 0#define TQMX86_REG_IO_EXT_INT_7 1#define TQMX86_REG_IO_EXT_INT_9 2
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 661/694 mfd: tqmx86: Correct board names for TQMxE39x
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit f376c479668557bcc2fd9e9fbc0f53e7819a11cd ]
It seems that this driver was developed based on preliminary documentation. Report the correct names for all TQMxE39x variants, as they are used by the released hardware revisions:
- Fix names for TQMxE39C1/C2 board IDs
- Distinguish TQMxE39M and TQMxE39S, which use the same board ID
The TQMxE39M/S are distinguished using the SAUC (Sanctioned Alternate Uses Configuration) register of the GPIO controller. This also prepares for the correct handling of the differences between the GPIO controllers of our COMe and SMARC modules.
--- drivers/mfd/tqmx86.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
drivers/mfd/tqmx86.c +17 -15
@@ -30,9 +30,9 @@#define TQMX86_REG_BOARD_ID_50UC 2#define TQMX86_REG_BOARD_ID_E38C 3#define TQMX86_REG_BOARD_ID_60EB 4 -#define TQMX86_REG_BOARD_ID_E39M 5 -#define TQMX86_REG_BOARD_ID_E39C 6 -#define TQMX86_REG_BOARD_ID_E39x 7 +#define TQMX86_REG_BOARD_ID_E39MS 5 +#define TQMX86_REG_BOARD_ID_E39C1 6 +#define TQMX86_REG_BOARD_ID_E39C2 7#define TQMX86_REG_BOARD_ID_70EB 8#define TQMX86_REG_BOARD_ID_80UC 9#define TQMX86_REG_BOARD_ID_110EB 11
@@ -48,6 +48,7 @@#define TQMX86_REG_IO_EXT_INT_12 3#define TQMX86_REG_IO_EXT_INT_MASK 0x3#define TQMX86_REG_IO_EXT_INT_GPIO_SHIFT 4 +#define TQMX86_REG_SAUC 0x17#define TQMX86_REG_I2C_DETECT 0x1a7#define TQMX86_REG_I2C_DETECT_SOFT 0xa5
@@ -110,7 +111,7 @@ static const struct mfd_cell tqmx86_devs[] = { }, }; -static const char *tqmx86_board_id_to_name (u8 board_id) +static const char *tqmx86_board_id_to_name (u8 board_id,u8 sauc) {switch (board_id) {case TQMX86_REG_BOARD_ID_E38M :
@@ -121,12 +122,12 @@ static const char *tqmx86_board_id_to_name(u8 board_id)return "TQMxE38C" ;case TQMX86_REG_BOARD_ID_60EB :return "TQMx60EB" ; -case TQMX86_REG_BOARD_ID_E39M : -return "TQMxE39M" ; -case TQMX86_REG_BOARD_ID_E39C : -return "TQMxE39C" ; -case TQMX86_REG_BOARD_ID_E39x: -return "TQMxE39x" ; +case TQMX86_REG_BOARD_ID_E39MS : +return (sauc ==0xff ) ?"TQMxE39M" :"TQMxE39S" ; +case TQMX86_REG_BOARD_ID_E39C1 : +return "TQMxE39C1" ; +case TQMX86_REG_BOARD_ID_E39C2 : +return "TQMxE39C2" ;case TQMX86_REG_BOARD_ID_70EB :return "TQMx70EB" ;case TQMX86_REG_BOARD_ID_80UC :
@@ -159,9 +160,9 @@ static int tqmx86_board_id_to_clk_rate(struct device *dev, u8 board_id)case TQMX86_REG_BOARD_ID_E40C1 :case TQMX86_REG_BOARD_ID_E40C2 :return 24000 ; -case TQMX86_REG_BOARD_ID_E39M : -case TQMX86_REG_BOARD_ID_E39C : -case TQMX86_REG_BOARD_ID_E39x: +case TQMX86_REG_BOARD_ID_E39MS : +case TQMX86_REG_BOARD_ID_E39C1 : +case TQMX86_REG_BOARD_ID_E39C2 :return 25000 ;case TQMX86_REG_BOARD_ID_E38M :case TQMX86_REG_BOARD_ID_E38C :
@@ -175,7 +176,7 @@ static int tqmx86_board_id_to_clk_rate(struct device *dev, u8 board_id)static int tqmx86_probe (struct platform_device *pdev) { -u8 board_id, rev, i2c_det, io_ext_int_val; +u8 board_id, sauc, rev, i2c_det, io_ext_int_val;struct device *dev = &pdev->dev;u8 gpio_irq_cfg, readback;const char *board_name;
@@ -205,7 +206,8 @@ static int tqmx86_probe(struct platform_device *pdev)return -ENOMEM ; board_id =ioread8 (io_base +TQMX86_REG_BOARD_ID ); - board_name =tqmx86_board_id_to_name (board_id); + sauc =ioread8 (io_base +TQMX86_REG_SAUC ); + board_name =tqmx86_board_id_to_name (board_id, sauc); rev =ioread8 (io_base +TQMX86_REG_BOARD_REV ); dev_info(dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 662/694 mfd: ocelot-spi: Fix unsupported bulk read
In reply to Greg Kroah-HartmanFrom: Colin Foster <[email protected]>
[ Upstream commit f0484d2f80a72022b7fac72bcb406392900ef1eb ]
Ocelot chips (VSC7511, VSC7512, VSC7513, VSC7514) don't support bulk read operations over SPI.
Many SPI buses have hardware that can optimize consecutive reads. Essentially an address is written to the chip, and if the SPI controller continues to toggle the clock, subsequent register values are reported. This can lead to significant optimizations, because the time between "address is written to the chip" and "chip starts to report data" can often take a fixed amount of time.
When support for Ocelot chips were added in commit f3e893626abe ("mfd:
ocelot: Add support for the vsc7512 chip via spi") it was believed that this optimization was supported. However it is not.
Most register transactions with the Ocelot chips are not done in bulk, so this bug could go unnoticed. The one scenario where bulk register operations _are_ performed is when polling port statistics counters, which was added in commit d87b1c08f38a ("net: mscc: ocelot: use bulk reads for stats").
Things get slightly more complicated here...
A bug was introduced in commit d4c367650704 ("net: mscc: ocelot: keep ocelot_stat_layout by reg address, not offset") that broke the optimization of bulk reads. This means that when Ethernet support for the VSC7512 chip was added in commit 3d7316ac81ac ("net: dsa: ocelot: add external ocelot switch control") things were actually working "as expected".
The bulk read opmtimization was discovered, and fixed in commit 6acc72a43eac ("net: mscc: ocelot: fix stats region batching") and the timing optimizations for SPI were noticed. A bulk read went from ~14ms to ~2ms. But this timing improvement came at the cost of every register reading zero due the fact that bulk reads don't work.
The read timings increase back to 13-14ms, but that's a price worth paying in order to receive valid data. This is verified in a DSA setup (cpsw-new switch tied to port 0 on the VSC7512, after having been running overnight)
Rx Octets: 16222055 # Counters from CPSW switch
Tx Octets: 12034702
Net Octets: 28256757
p00_rx_octets: 12034702 # Counters from Ocelot switch
p00_rx_frames_below_65_octets: 0
p00_rx_frames_65_to_127_octets: 88188
p00_rx_frames_128_to_255_octets: 13
p00_rx_frames_256_to_511_octets: 0
p00_rx_frames_512_to_1023_octets: 0
p00_rx_frames_over_1526_octets: 3306
p00_tx_octets: 16222055--- drivers/mfd/ocelot-spi.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/ocelot-spi.c +1 -0
@@ -130,6 +130,7 @@ static const struct regmap_config ocelot_spi_regmap_config = { .write_flag_mask = 0x80, + .use_single_read = true, .use_single_write = true, .can_multi_write = false,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 663/694 mfd: arizona-spi: Add missing MODULE_DEVICE_TABLE
In reply to Greg Kroah-HartmanFrom: Charles Keepax <[email protected]>
[ Upstream commit 972c91fd7beddc3f19c8c855f6e60e7dbd435cbd ]
This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as a module.
--- drivers/mfd/arizona-spi.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/arizona-spi.c +1 -0
@@ -277,6 +277,7 @@ static const struct of_device_id arizona_spi_of_match[] = { { .compatible = "cirrus,cs47l24", .data = (void *)CS47L24 }, {}, }; +MODULE_DEVICE_TABLE (of, arizona_spi_of_match);#endif static struct spi_driver arizona_spi_driver = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 664/694 hte: tegra: fix struct of_device_id build error
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 6680c835ada1b34e882d0a32612f7294c62e27e0 ]
Without the extra #include, this driver produces a build failure in some configurations.
drivers/hte/hte-tegra194-test.c:96:34: error: array type has incomplete element type 'struct of_device_id'
96 | static const struct of_device_id tegra_hte_test_of_match[] = {
--- drivers/hte/hte-tegra194-test.c | 1 + 1 file changed, 1 insertion(+)
drivers/hte/hte-tegra194-test.c +1 -0
@@ -6,6 +6,7 @@*/ #include <linux/err.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/interrupt.h>
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 665/694 hte: tegra-194: Fix off by one in tegra_hte_map_to_line_id()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e078180d66848a6a890daf0a3ce28dc43cc66790 ]
The "map_sz" is the number of elements in the "m" array so the > comparison needs to be changed to >= to prevent an out of bounds read.
--- drivers/hte/hte-tegra194.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hte/hte-tegra194.c +1 -1
@@ -251,7 +251,7 @@ static int tegra_hte_map_to_line_id(u32 eid, {if (m) { -if (eid > map_sz) +if (eid >= map_sz)return -EINVAL ;if (m[eid].slice ==NV_AON_SLICE_INVALID )return -EINVAL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 666/694 ACPI: PM: Do not turn of unused power resources on the Toshiba Click Mini
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 9b04d99788cf475cbd277f30ec66230ccb7e99f4 ]
The CPR3 power resource on the Toshiba Click Mini toggles a GPIO which is called SISP (for SIS touchscreen power?) on/off.
This CPR3 power resource is not listed in any _PR? lists, let alone in a _PR0 list for the SIS0817 touchscreen ACPI device which needs it.
Before commit a1224f34d72a ("ACPI: PM: Check states of power resources during initialization") this was not an issue because since nothing referenced the CPR3 power resource its state was always ACPI_POWER_RESOURCE_STATE_UNKNOWN and power resources with this state get ignored by acpi_turn_off_unused_power_resources().
This clearly is a bug in the DSDT of this device. Add a DMI quirk to make acpi_turn_off_unused_power_resources() a no-op on this model to fix the touchscreen no longer working since kernel 5.16 .
This quirk also causes 2 other power resources to not get turned off, but the _OFF method on these already was a no-op, so this makes no difference for the other 2 power resources.
--- drivers/acpi/power.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/acpi/power.c +19 -0
@@ -23,6 +23,7 @@#define pr_fmt (fmt) "ACPI: PM: " fmt +#include <linux/dmi.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h>
@@ -1022,6 +1023,21 @@ void acpi_resume_power_resources(void) }#endif +static const struct dmi_system_id dmi_leave_unused_power_resources_on[] = { + { +/* +* The Toshiba Click Mini has a CPR3 power-resource which must +* be on for the touchscreen to work, but which is not in any +* _PR? lists. The other 2 affected power-resources are no-ops. +*/ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"TOSHIBA" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"SATELLITE Click Mini L9W-B" ), + }, + }, + {} +}; +/** * acpi_turn_off_unused_power_resources - Turn off power resources not in use. */
@@ -1029,6 +1045,9 @@ void acpi_turn_off_unused_power_resources(void) {struct acpi_power_resource *resource; +if (dmi_check_system (dmi_leave_unused_power_resources_on)) +return ; +mutex_lock (&power_resource_list_lock);list_for_each_entry_reverse (resource, &acpi_power_resource_list, list_node) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 667/694 PM: hibernate: Turn snapshot_test into global variable
In reply to Greg Kroah-HartmanFrom: Chen Yu <[email protected]>
[ Upstream commit 08169a162f97819d3e5b4a342bb9cf5137787154 ]
There is need to check snapshot_test and open block device in different mode, so as to avoid the race condition.
No functional changes intended.
Stable-dep-of: 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode")
--- kernel/power/hibernate.c | 7 ++++++- kernel/power/power.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
kernel/power/hibernate.c +6 -1
@@ -64,6 +64,7 @@ enum {static int hibernation_mode =HIBERNATION_SHUTDOWN ;bool freezer_test_done; +bool snapshot_test;static const struct platform_hibernation_ops *hibernation_ops;
@@ -716,7 +717,6 @@ static int load_image_and_restore(void)*/ int hibernate (void ) { -bool snapshot_test = false;unsigned int sleep_flags;int error;
@@ -744,6 +744,9 @@ int hibernate(void)if (error) goto Exit; +/* protected by system_transition_mutex */ + snapshot_test = false; +lock_device_hotplug ();/* Allocate memory management structures */ error =create_basic_memory_bitmaps ();
@@ -940,6 +943,8 @@ static int software_resume(void)*/ mutex_lock_nested (&system_transition_mutex,SINGLE_DEPTH_NESTING ); + snapshot_test = false; +if (swsusp_resume_device) goto Check_image;
kernel/power/power.h +1 -0
@@ -59,6 +59,7 @@ asmlinkage int swsusp_save(void);/* kernel/power/hibernate.c */ extern bool freezer_test_done; +extern bool snapshot_test;extern int hibernation_snapshot (int platform_mode);extern int hibernation_restore (int platform_mode);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 668/694 PM: hibernate: Do not get block device exclusively in test_resume mode
In reply to Greg Kroah-HartmanFrom: Chen Yu <[email protected]>
[ Upstream commit 5904de0d735bbb3b4afe9375c5b4f9748f882945 ]
The system refused to do a test_resume because it found that the swap device has already been taken by someone else. Specifically, the swsusp_check()->blkdev_get_by_dev(FMODE_EXCL) is supposed to do this check.
Steps to reproduce:
dd if=/dev/zero of=/swapfile bs=$(cat /proc/meminfo |
awk '/MemTotal/ {print $2}') count=1024 conv=notrunc mkswap /swapfile
swapon /swapfile
swap-offset /swapfile
echo 34816 > /sys/power/resume_offset
echo test_resume > /sys/power/disk
echo disk > /sys/power/state
PM: Using 3 thread(s) for compression
PM: Compressing and saving image data (293150 pages)...
PM: Image saving progress: 0%
PM: Image saving progress: 10%
ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300) ata1.00: configured for UDMA/100
ata2: SATA link down (SStatus 0 SControl 300)
ata5: SATA link down (SStatus 0 SControl 300)
ata6: SATA link down (SStatus 0 SControl 300)
ata3: SATA link down (SStatus 0 SControl 300)
ata4: SATA link down (SStatus 0 SControl 300)
PM: Image saving progress: 20% PM: Image saving progress: 30% PM: Image saving progress: 40% PM: Image saving progress: 50% pcieport 0000:00:02.5: pciehp: Slot(0-5): No device found PM: Image saving progress: 60% PM: Image saving progress: 70% PM: Image saving progress: 80% PM: Image saving progress: 90%
PM: Image saving done
PM: hibernation: Wrote 1172600 kbytes in 2.70 seconds (434.29 MB/s)
PM: S|
PM: hibernation: Basic memory bitmaps freed
PM: Image not found (code -16)
This is because when using the swapfile as the hibernation storage, the block device where the swapfile is located has already been mounted by the OS distribution(usually mounted as the rootfs). This is not an issue for normal hibernation, because software_resume()->swsusp_check() happens before the block device(rootfs) mount. But it is a problem for the test_resume mode. Because when test_resume happens, the block device has been mounted already.
Thus remove the FMODE_EXCL for test_resume mode. This would not be a problem because in test_resume stage, the processes have already been frozen, and the race condition described in
Commit 39fbef4b0f77 ("PM: hibernate: Get block device exclusively in swsusp_check()") is unlikely to happen.
--- kernel/power/hibernate.c | 8 ++++++-- kernel/power/swap.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-)
kernel/power/hibernate.c +6 -2
@@ -688,18 +688,22 @@ static int load_image_and_restore(void) {int error;unsigned int flags; +fmode_t mode =FMODE_READ ; + +if (snapshot_test) + mode |=FMODE_EXCL ;pm_pr_dbg ("Loading hibernation image.\n" );lock_device_hotplug (); error =create_basic_memory_bitmaps ();if (error) { -swsusp_close (FMODE_READ |FMODE_EXCL ); +swsusp_close (mode); goto Unlock; } error =swsusp_read (&flags); -swsusp_close (FMODE_READ |FMODE_EXCL ); +swsusp_close (mode);if (!error) error =hibernation_restore (flags &SF_PLATFORM_MODE );
kernel/power/swap.c +6 -2
@@ -1518,9 +1518,13 @@ int swsusp_check(void) {int error;void *holder; +fmode_t mode =FMODE_READ ; + +if (snapshot_test) + mode |=FMODE_EXCL ; hib_resume_bdev =blkdev_get_by_dev (swsusp_resume_device, -FMODE_READ |FMODE_EXCL , &holder); + mode, &holder);if (!IS_ERR (hib_resume_bdev)) {set_blocksize (hib_resume_bdev,PAGE_SIZE );clear_page (swsusp_header);
@@ -1547,7 +1551,7 @@ int swsusp_check(void) put:if (error) -blkdev_put (hib_resume_bdev,FMODE_READ |FMODE_EXCL ); +blkdev_put (hib_resume_bdev, mode);else pr_debug ("Image signature found, resuming\n" ); }else {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 669/694 afs: Fix updating of i_size with dv jump from server
In reply to Greg Kroah-HartmanFrom: Marc Dionne <[email protected]>
[ Upstream commit d7f74e9a917503ee78f2b603a456d7227cf38919 ]
If the data version returned from the server is larger than expected, the local data is invalidated, but we may still want to note the remote file size.
Since we're setting change_size, we have to also set data_changed for the i_size to get updated.
--- fs/afs/inode.c | 1 + 1 file changed, 1 insertion(+)
fs/afs/inode.c +1 -0
@@ -230,6 +230,7 @@ static void afs_apply_status(struct afs_operation *op,set_bit (AFS_VNODE_ZAP_DATA , &vnode->flags); } change_size = true; + data_changed = true; }else if (vnode->status.type ==AFS_FTYPE_DIR ) {/* Expected directory change is handled elsewhere so * that we can locally edit the directory and save on a
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 670/694 afs: Fix getattr to report server i_size on dirs, not local size
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 45f66fa03ba9943cca5af88d691399332b8bde08 ]
Fix afs_getattr() to report the server's idea of the file size of a directory rather than the local size. The local size may differ as we edit the local copy to avoid having to redownload it and we may end up with a differently structured blob of a different size.
However, if the directory is discarded from the pagecache we then download it again and the user may see the directory file size apparently change.
--- fs/afs/inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/afs/inode.c +8 -1
@@ -450,7 +450,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode) 0 : FSCACHE_ADV_SINGLE_CHUNK, &key,sizeof (key), &aux,sizeof (aux), - vnode->status.size)); + i_size_read(&vnode->netfs.inode)));#endif }
@@ -766,6 +766,13 @@ int afs_getattr(struct mnt_idmap *idmap, const struct path *path,if (test_bit (AFS_VNODE_SILLY_DELETED , &vnode->flags) && stat->nlink >0 ) stat->nlink -=1 ; + +/* Lie about the size of directories. We maintain a locally +* edited copy and may make different allocation decisions on +* it, but we need to give userspace the server's size. +*/ +if (S_ISDIR (inode->i_mode)) + stat->size = vnode->netfs.remote_i_size; }while (need_seqretry (&vnode->cb_lock, seq));done_seqretry (&vnode->cb_lock, seq);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 671/694 afs: Avoid endless loop if file is larger than expected
In reply to Greg Kroah-HartmanFrom: Marc Dionne <[email protected]>
[ Upstream commit 9ea4eff4b6f4f36546d537a74da44fd3f30903ab ]
afs_read_dir fetches an amount of data that's based on what the inode size is thought to be. If the file on the server is larger than what was fetched, the code rechecks i_size and retries. If the local i_size was not properly updated, this can lead to an endless loop of fetching i_size from the server and noticing each time that the size is larger on the server.
If it is known that the remote size is larger than i_size, bump up the fetch size to that size.
--- fs/afs/dir.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/afs/dir.c +4 -0
@@ -275,6 +275,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)loff_t i_size;int nr_pages, i;int ret; +loff_t remote_size =0 ;_enter ("" );
@@ -289,6 +290,8 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key) expand: i_size =i_size_read (&dvnode->netfs.inode); +if (i_size < remote_size) + i_size = remote_size;if (i_size <2048 ) { ret =afs_bad (dvnode, afs_file_error_dir_small); goto error;
@@ -364,6 +367,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)* buffer. */ up_write (&dvnode->validate_lock); + remote_size = req->file_size; goto expand; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 672/694 scripts/gdb: fix lx-timerlist for Python3
In reply to Greg Kroah-HartmanFrom: Peng Liu <[email protected]>
commit 7362042f3556528e9e9b1eb5ce8d7a3a6331476b upstream.
Below incompatibilities between Python2 and Python3 made lx-timerlist fail to run under Python3.
o xrange() is replaced by range() in Python3
o bytes and str are different types in Python3
o the return value of Inferior.read_memory() is memoryview object in Python3
akpm: cc stable so that older kernels are properly debuggable under newer Python.
--- scripts/gdb/linux/timerlist.py | 4 +++- scripts/gdb/linux/utils.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-)
scripts/gdb/linux/timerlist.py +3 -1
@@ -73,7 +73,7 @@ def print_cpu(hrtimer_bases, cpu, max_cl ts = cpus.per_cpu(tick_sched_ptr, cpu) text = "cpu: {}\n".format(cpu) - for i in xrange(max_clock_bases): + for i in range(max_clock_bases): text += " clock {}:\n".format(i) text += print_base(cpu_base['clock_base'][i])
@@ -158,6 +158,8 @@ def pr_cpumask(mask): num_bytes = (nr_cpu_ids + 7) / 8 buf = utils.read_memoryview(inf, bits, num_bytes).tobytes() buf = binascii.b2a_hex(buf) + if type(buf) is not str: + buf=buf.decode() chunks = [] i = num_bytes
scripts/gdb/linux/utils.py +4 -1
@@ -88,7 +88,10 @@ def get_target_endianness(): def read_memoryview(inf, start, length): - return memoryview(inf.read_memory(start, length)) + m = inf.read_memory(start, length) + if type(m) is memoryview: + return m + return memoryview(m) def read_u16(buffer, offset):
Greg Kroah-Hartman
maintainerPATCH 673/694 btrfs: scrub: reject unsupported scrub flags
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit 604e6681e114d05a2e384c4d1e8ef81918037ef5 upstream.
Since the introduction of scrub interface, the only flag that we support is BTRFS_SCRUB_READONLY. Thus there is no sanity checks, if there are some undefined flags passed in, we just ignore them.
This is problematic if we want to introduce new scrub flags, as we have no way to determine if such flags are supported.
Address the problem by introducing a check for the flags, and if unsupported flags are set, return -EOPNOTSUPP to inform the user space.
This check should be backported for all supported kernels before any new scrub flags are introduced.
--- fs/btrfs/ioctl.c | 5 +++++ include/uapi/linux/btrfs.h | 1 + 2 files changed, 6 insertions(+)
fs/btrfs/ioctl.c +5 -0
@@ -3161,6 +3161,11 @@ static long btrfs_ioctl_scrub(struct filif (IS_ERR (sa))return PTR_ERR (sa); +if (sa->flags & ~BTRFS_SCRUB_SUPPORTED_FLAGS ) { + ret = -EOPNOTSUPP ; + goto out; + } +if (!(sa->flags &BTRFS_SCRUB_READONLY )) { ret =mnt_want_write_file (file);if (ret)
include/uapi/linux/btrfs.h +1 -0
@@ -187,6 +187,7 @@ struct btrfs_scrub_progress { };#define BTRFS_SCRUB_READONLY 1 +#define BTRFS_SCRUB_SUPPORTED_FLAGS (BTRFS_SCRUB_READONLY)struct btrfs_ioctl_scrub_args {__u64 devid;/* in */ __u64 start;/* in */
Greg Kroah-Hartman
maintainerPATCH 674/694 s390/dasd: fix hanging blockdevice after request requeue
In reply to Greg Kroah-HartmanFrom: Stefan Haberland <[email protected]>
commit d8898ee50edecacdf0141f26fd90acf43d7e9cd7 upstream.
The DASD driver does not kick the requeue list when requeuing IO requests to the blocklayer. This might lead to hanging blockdevice when there is no other trigger for this.
Fix by automatically kick the requeue list when requeuing DASD requests to the blocklayer.
--- drivers/s390/block/dasd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/block/dasd.c +1 -1
@@ -2941,7 +2941,7 @@ static int _dasd_requeue_request(structreturn 0 ;spin_lock_irq (&cqr->dq->lock); req = (struct request *) cqr->callback_data; -blk_mq_requeue_request (req, false); +blk_mq_requeue_request (req, true);spin_unlock_irq (&cqr->dq->lock);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 675/694 ia64: fix an addr to taddr in huge_pte_offset()
In reply to Greg Kroah-HartmanFrom: Hugh Dickins <[email protected]>
commit 3647ebcfbfca384840231fe13fae665453238a61 upstream.
I know nothing of ia64 htlbpage_to_page(), but guess that the p4d line should be using taddr rather than addr, like everywhere else.
--- arch/ia64/mm/hugetlbpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/mm/hugetlbpage.c +1 -1
@@ -58,7 +58,7 @@ huge_pte_offset (struct mm_struct *mm, u pgd =pgd_offset (mm, taddr);if (pgd_present (*pgd)) { - p4d =p4d_offset (pgd, addr); + p4d =p4d_offset (pgd, taddr);if (p4d_present (*p4d)) { pud =pud_offset (p4d, taddr);if (pud_present (*pud)) {
Greg Kroah-Hartman
maintainerPATCH 676/694 mm/mempolicy: correctly update prev when policy is equal on mbind
In reply to Greg Kroah-HartmanFrom: Lorenzo Stoakes <[email protected]>
commit 00ca0f2e86bf40b016a646e6323a8941a09cf106 upstream.
The refactoring in commit f4e9e0e69468 ("mm/mempolicy: fix use-after-free of VMA iterator") introduces a subtle bug which arises when attempting to apply a new NUMA policy across a range of VMAs in mbind_range().
The refactoring passes a **prev pointer to keep track of the previous VMA in order to reduce duplication, and in all but one case it keeps this correctly updated.
The bug arises when a VMA within the specified range has an equivalent policy as determined by mpol_equal() - which unlike other cases, does not update prev.
This can result in a situation where, later in the iteration, a VMA is found whose policy does need to change. At this point, vma_merge() is invoked with prev pointing to a VMA which is before the previous VMA.
Since vma_merge() discovers the curr VMA by looking for the one immediately after prev, it will now be in a situation where this VMA is incorrect and the merge will not proceed correctly.
This is checked in the VM_WARN_ON() invariant case with end > curr->vm_end, which, if a merge is possible, results in a warning (if CONFIG_DEBUG_VM is specified).
I note that vma_merge() performs these invariant checks only after merge_prev/merge_next are checked, which is debatable as it hides this issue if no merge is possible even though a buggy situation has arisen.
The solution is simply to update the prev pointer even when policies are equal.
This caused a bug to arise in the 6.2.y stable tree, and this patch resolves this bug.
--- mm/mempolicy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/mempolicy.c +3 -1
@@ -808,8 +808,10 @@ static int mbind_range(struct vma_iterat vmstart = vma->vm_start; } -if (mpol_equal (vma_policy (vma), new_pol)) +if (mpol_equal (vma_policy (vma), new_pol)) { + *prev = vma;return 0 ; + } pgoff = vma->vm_pgoff + ((vmstart - vma->vm_start) >>PAGE_SHIFT ); merged = vma_merge(vmi, vma->vm_mm, *prev, vmstart, vmend, vma->vm_flags,
Greg Kroah-Hartman
maintainerPATCH 677/694 mm/hugetlb: fix uffd-wp during fork()
In reply to Greg Kroah-HartmanFrom: Peter Xu <[email protected]>
commit 5a2f8d22ace4c8ac8798fab836dca7350fa710b1 upstream.
Patch series "mm/hugetlb: More fixes around uffd-wp vs fork() / RO pins", v2.
This patch (of 6):
There're a bunch of things that were wrong:
- Reading uffd-wp bit from a swap entry should use pte_swp_uffd_wp() rather than huge_pte_uffd_wp().
- When copying over a pte, we should drop uffd-wp bit when !EVENT_FORK (aka, when !userfaultfd_wp(dst_vma)).
- When doing early CoW for private hugetlb (e.g. when the parent page was pinned), uffd-wp bit should be properly carried over if necessary.
No bug reported probably because most people do not even care about these corner cases, but they are still bugs and can be exposed by the recent unit tests introduced, so fix all of them in one shot.
--- mm/hugetlb.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
mm/hugetlb.c +15 -9
@@ -4949,11 +4949,15 @@ static bool is_hugetlb_entry_hwpoisoned(static void hugetlb_install_folio (struct vm_area_struct *vma,pte_t *ptep,unsigned long addr, -struct folio *new_folio) +struct folio *new_folio,pte_t old) { +pte_t newpte =make_huge_pte (vma, &new_folio->page,1 ); +__folio_mark_uptodate (new_folio);hugepage_add_new_anon_rmap (new_folio, vma, addr); -set_huge_pte_at (vma->vm_mm, addr, ptep,make_huge_pte (vma, &new_folio->page,1 )); +if (userfaultfd_wp (vma) &&huge_pte_uffd_wp (old)) + newpte =huge_pte_mkuffd_wp (newpte); +set_huge_pte_at (vma->vm_mm, addr, ptep, newpte);hugetlb_count_add (pages_per_huge_page (hstate_vma (vma)), vma->vm_mm);folio_set_hugetlb_migratable (new_folio); }
@@ -5028,14 +5032,12 @@ again:*/ ; }else if (unlikely (is_hugetlb_entry_hwpoisoned (entry))) { -bool uffd_wp =huge_pte_uffd_wp (entry); - -if (!userfaultfd_wp (dst_vma) && uffd_wp) +if (!userfaultfd_wp (dst_vma)) entry =huge_pte_clear_uffd_wp (entry);set_huge_pte_at (dst, addr, dst_pte, entry); }else if (unlikely (is_hugetlb_entry_migration (entry))) {swp_entry_t swp_entry =pte_to_swp_entry (entry); -bool uffd_wp =huge_pte_uffd_wp (entry); +bool uffd_wp =pte_swp_uffd_wp (entry);if (!is_readable_migration_entry (swp_entry) && cow) {/*
@@ -5046,10 +5048,10 @@ again: swp_offset(swp_entry)); entry =swp_entry_to_pte (swp_entry);if (userfaultfd_wp (src_vma) && uffd_wp) - entry =huge_pte_mkuffd_wp (entry); + entry =pte_swp_mkuffd_wp (entry);set_huge_pte_at (src, addr, src_pte, entry); } -if (!userfaultfd_wp (dst_vma) && uffd_wp) +if (!userfaultfd_wp (dst_vma)) entry =huge_pte_clear_uffd_wp (entry);set_huge_pte_at (dst, addr, dst_pte, entry); }else if (unlikely (is_pte_marker (entry))) {
@@ -5109,7 +5111,8 @@ again:/* huge_ptep of dst_pte won't change as in child */ goto again; } -hugetlb_install_folio (dst_vma, dst_pte, addr, new_folio); +hugetlb_install_folio (dst_vma, dst_pte, addr, + new_folio, src_pte_old);spin_unlock (src_ptl);spin_unlock (dst_ptl);continue ;
@@ -5127,6 +5130,9 @@ again: entry =huge_pte_wrprotect (entry); } +if (!userfaultfd_wp (dst_vma)) + entry =huge_pte_clear_uffd_wp (entry); +set_huge_pte_at (dst, addr, dst_pte, entry);hugetlb_count_add (npages, dst); }
Greg Kroah-Hartman
maintainerPATCH 678/694 vhost_vdpa: fix unmap process in no-batch mode
In reply to Greg Kroah-HartmanFrom: Cindy Lu <[email protected]>
commit c82729e06644f4e087f5ff0f91b8fb15e03b8890 upstream.
While using the vdpa device with vIOMMU enabled
in the guest VM, when the vdpa device bind to vfio-pci and run testpmd then system will fail to unmap.
The test process is
Load guest VM --> attach to virtio driver--> bind to vfio-pci driver So the mapping process is
1)batched mode map to normal MR
2)batched mode unmapped the normal MR
3)unmapped all the memory
4)mapped to iommu MR
This error happened in step 3). The iotlb was freed in step 2) and the function vhost_vdpa_process_iotlb_msg will return fail Which causes failure.
To fix this, we will not remove the AS while the iotlb->nmaps is 0. This will free in the vhost_vdpa_clean
Message-Id: <[email protected]>
--- drivers/vhost/vdpa.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/vhost/vdpa.c +1 -7
@@ -851,11 +851,7 @@ static void vhost_vdpa_unmap(struct vhosif (!v->in_batch) ops->set_map (vdpa, asid, iotlb); } -/* If we are in the middle of batch processing, delay the free -* of AS until BATCH_END. -*/ -if (!v->in_batch && !iotlb->nmaps) -vhost_vdpa_remove_as (v, asid); + } static int vhost_vdpa_va_map(struct vhost_vdpa *v,
@@ -1112,8 +1108,6 @@ static int vhost_vdpa_process_iotlb_msg(if (v->in_batch && ops->set_map) ops->set_map (vdpa, asid, iotlb); v->in_batch = false; -if (!iotlb->nmaps) -vhost_vdpa_remove_as (v, asid);break ;default : r = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 679/694 dm verity: fix error handling for check_at_most_once on FEC
In reply to Greg Kroah-HartmanFrom: Yeongjin Gil <[email protected]>
commit e8c5d45f82ce0c238a4817739892fe8897a3dcc3 upstream.
In verity_end_io(), if bi_status is not BLK_STS_OK, it can be return directly. But if FEC configured, it is desired to correct the data page through verity_verify_io. And the return value will be converted to blk_status and passed to verity_finish_io().
BTW, when a bit is set in v->validated_blocks, verity_verify_io() skips verification regardless of I/O error for the corresponding bio. In this case, the I/O error could not be returned properly, and as a result, there is a problem that abnormal data could be read for the corresponding block.
To fix this problem, when an I/O error occurs, do not skip verification even if the bit related is set in v->validated_blocks.
--- drivers/md/dm-verity-target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-verity-target.c +1 -1
@@ -523,7 +523,7 @@ static int verity_verify_io(struct dm_vesector_t cur_block = io->block + b;struct ahash_request *req =verity_io_hash_req (v, io); -if (v->validated_blocks && +if (v->validated_blocks && bio->bi_status ==BLK_STS_OK &&likely (test_bit (cur_block, v->validated_blocks))) {verity_bv_skip_block (v, io, iter);continue ;
Greg Kroah-Hartman
maintainerPATCH 680/694 dm clone: call kmem_cache_destroy() in dm_clone_init() error path
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 6827af4a9a9f5bb664c42abf7c11af4978d72201 upstream.
Otherwise the _hydration_cache will leak if dm_register_target() fails.
--- drivers/md/dm-clone-target.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/dm-clone-target.c +1 -0
@@ -2205,6 +2205,7 @@ static int __init dm_clone_init(void) r =dm_register_target (&clone_target);if (r <0 ) {DMERR ("Failed to register clone target" ); +kmem_cache_destroy (_hydration_cache);return r; }
Greg Kroah-Hartman
maintainerPATCH 681/694 dm integrity: call kmem_cache_destroy() in dm_integrity_init() error path
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 6b79a428c02769f2a11f8ae76bf866226d134887 upstream.
Otherwise the journal_io_cache will leak if dm_register_target() fails.
--- drivers/md/dm-integrity.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/md/dm-integrity.c +5 -3
@@ -4703,11 +4703,13 @@ static int __init dm_integrity_init(void } r =dm_register_target (&integrity_target); - -if (r <0 ) +if (r <0 ) {DMERR ("register failed %d" , r); +kmem_cache_destroy (journal_io_cache); +return r; + } -return r; +return 0 ; } static void __exit dm_integrity_exit(void)
Greg Kroah-Hartman
maintainerPATCH 682/694 dm flakey: fix a crash with invalid table line
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 98dba02d9a93eec11bffbb93c7c51624290702d2 upstream.
This command will crash with NULL pointer dereference:
dmsetup create flakey --table \
"0 blockdev --getsize /dev/ram0 flakey /dev/ram0 0 0 1 2 corrupt_bio_byte 512"
Fix the crash by checking if arg_name is non-NULL before comparing it.
--- drivers/md/dm-flakey.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-flakey.c +2 -2
@@ -125,9 +125,9 @@ static int parse_features(struct dm_arg_* Direction r or w? */ arg_name =dm_shift_arg (as); -if (!strcasecmp (arg_name,"w" )) +if (arg_name && !strcasecmp (arg_name,"w" )) fc->corrupt_bio_rw =WRITE ; -else if (!strcasecmp (arg_name,"r" )) +else if (arg_name && !strcasecmp (arg_name,"r" )) fc->corrupt_bio_rw =READ ;else { ti->error ="Invalid corrupt bio direction (r or w)" ;
Greg Kroah-Hartman
maintainerPATCH 683/694 dm ioctl: fix nested locking in table_clear() to remove deadlock concern
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 3d32aaa7e66d5c1479a3c31d6c2c5d45dd0d3b89 upstream.
syzkaller found the following problematic rwsem locking (with write lock already held):
down_read+0x9d/0x450 kernel/locking/rwsem.c:1509 dm_get_inactive_table+0x2b/0xc0 drivers/md/dm-ioctl.c:773 __dev_status+0x4fd/0x7c0 drivers/md/dm-ioctl.c:844 table_clear+0x197/0x280 drivers/md/dm-ioctl.c:1537
In table_clear, it first acquires a write lock
https://elixir.bootlin.com/linux/v6.2/source/drivers/md/dm-ioctl.c#L1520down_write(&_hash_lock);
Then before the lock is released at L1539, there is a path shown above:table_clear -> __dev_status -> dm_get_inactive_table -> down_read
https://elixir.bootlin.com/linux/v6.2/source/drivers/md/dm-ioctl.c#L773down_read(&_hash_lock);
It tries to acquire the same read lock again, resulting in the deadlock problem.
Fix this by moving table_clear()'s __dev_status() call to after its up_write(&_hash_lock);
--- drivers/md/dm-ioctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/md/dm-ioctl.c +4 -3
@@ -1556,11 +1556,12 @@ static int table_clear(struct file *filp has_new_map = true; } - param->flags &= ~DM_INACTIVE_PRESENT_FLAG ; - -__dev_status (hc->md, param); md = hc->md;up_write (&_hash_lock); + + param->flags &= ~DM_INACTIVE_PRESENT_FLAG ; +__dev_status (md, param); +if (old_map) {dm_sync_table (md);dm_table_destroy (old_map);
Greg Kroah-Hartman
maintainerPATCH 684/694 dm: dont lock fs when the map is NULL in process of resume
In reply to Greg Kroah-HartmanFrom: Li Lingfeng <[email protected]>
commit 38d11da522aacaa05898c734a1cec86f1e611129 upstream.
Commit fa247089de99 ("dm: requeue IO if mapping table not yet available") added a detection of whether the mapping table is available in the IO submission process. If the mapping table is unavailable, it returns BLK_STS_RESOURCE and requeues the IO.
This can lead to the following deadlock problem:
dm create mountioctl(DM_DEV_CREATE_CMD)ioctl(DM_TABLE_LOAD_CMD)
do_mount
vfs_get_tree
ext4_get_tree
get_tree_bdev
sget_fc
alloc_super
// got &s->s_umount
down_write_nested(&s->s_umount, ...);
ext4_fill_super
ext4_load_super
ext4_read_bh
submit_bio
// submit and wait io endioctl(DM_DEV_SUSPEND_CMD)dev_suspend
do_resume
dm_suspend
__dm_suspend
lock_fs
freeze_bdev
get_active_super
grab_super
// wait for &s->s_umount
down_write(&s->s_umount);
dm_swap_table
__bind
// set md->map(can't get here)IO will be continuously requeued while holding the lock since mapping table is NULL. At the same time, mapping table won't be set since the lock is not available.
Like request-based DM, bio-based DM also has the same problem.
It's not proper to just abort IO if the mapping table not available. So clear DM_SKIP_LOCKFS_FLAG when the mapping table is NULL, this allows the DM table to be loaded and the IO submitted upon resume.
--- drivers/md/dm-ioctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/dm-ioctl.c +4 -1
@@ -1168,10 +1168,13 @@ static int do_resume(struct dm_ioctl *pa/* Do we need to load a new map ? */ if (new_map) {sector_t old_size, new_size; +int srcu_idx;/* Suspend if it isn't already suspended */ -if (param->flags &DM_SKIP_LOCKFS_FLAG ) + old_map =dm_get_live_table (md, &srcu_idx); +if ((param->flags &DM_SKIP_LOCKFS_FLAG ) || !old_map) suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG ; +dm_put_live_table (md, srcu_idx);if (param->flags &DM_NOFLUSH_FLAG ) suspend_flags |=DM_SUSPEND_NOFLUSH_FLAG ;if (!dm_suspended_md (md))
Greg Kroah-Hartman
maintainerPATCH 685/694 perf auxtrace: Fix address filter entire kernel size
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 1f9f33ccf0320be21703d9195dd2b36a1c9a07cb upstream.
kallsyms is not completely in address order.
In find_entire_kern_cb(), calculate the kernel end from the maximum address not the last symbol.
Example:
Before:
$ sudo cat /proc/kallsyms | grep ' [twTw] ' | tail -1
ffffffffc00b8bd0 t bpf_prog_6deef7357e7b4530 [bpf]
$ sudo cat /proc/kallsyms | grep ' [twTw] ' | sort | tail -1
ffffffffc15e0cc0 t iwl_mvm_exit [iwlmvm]
$ perf.d093603a05aa record -v --kcore -e intel_pt// --filter 'filter *' -- uname |& grep filter
Address filter: filter 0xffffffff93200000/0x2ceba000After:
$ perf.8fb0f7a01f8e record -v --kcore -e intel_pt// --filter 'filter *' -- uname |& grep filter
Address filter: filter 0xffffffff93200000/0x2e3e2000--- tools/perf/util/auxtrace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/auxtrace.c +4 -1
@@ -2449,6 +2449,7 @@ static int find_entire_kern_cb(void *arg char type, u64 start) {struct sym_args *args = arg; +u64 size;if (!kallsyms__is_function (type))return 0 ;
@@ -2458,7 +2459,9 @@ static int find_entire_kern_cb(void *arg args->start = start; }/* Don't know exactly where the kernel ends, so we add a page */ - args->size =round_up (start, page_size) + page_size - args->start; + size =round_up (start, page_size) + page_size - args->start; +if (size > args->size) + args->size = size;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 686/694 perf intel-pt: Fix CYC timestamps after standalone CBR
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 430635a0ef1ce958b7b4311f172694ece2c692b8 upstream.
After a standalone CBR (not associated with TSC), update the cycles reference timestamp and reset the cycle count, so that CYC timestamps are calculated relative to that point with the new frequency.
--- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +2 -0
@@ -1998,6 +1998,8 @@ static void intel_pt_calc_cbr(struct int decoder->cbr = cbr; decoder->cbr_cyc_to_tsc = decoder->max_non_turbo_ratio_fp / cbr; + decoder->cyc_ref_timestamp = decoder->timestamp; + decoder->cycle_cnt =0 ;intel_pt_mtc_cyc_cnt_cbr (decoder); }
Greg Kroah-Hartman
maintainerPATCH 687/694 io_uring/rsrc: check for nonconsecutive pages
In reply to Greg Kroah-HartmanFrom: Tobias Holl <[email protected]>
commit 776617db78c6d208780e7c69d4d68d1fa82913de upstream.
Pages that are from the same folio do not necessarily need to be consecutive. In that case, we cannot consolidate them into a single bvec entry. Before applying the huge page optimization from commit 57bebf807e2a ("io_uring/rsrc: optimise registered huge pages"), check that the memory is actually consecutive.
--- io_uring/rsrc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
io_uring/rsrc.c +6 -1
@@ -1230,7 +1230,12 @@ static int io_sqe_buffer_register(structif (nr_pages >1 ) { folio =page_folio (pages[0 ]);for (i =1 ; i < nr_pages; i++) { -if (page_folio (pages[i]) != folio) { +/* +* Pages must be consecutive and on the same folio for +* this to work +*/ +if (page_folio (pages[i]) != folio || + pages[i] != pages[i -1 ] +1 ) { folio =NULL ;break ; }
Greg Kroah-Hartman
maintainerPATCH 688/694 cifs: fix potential use-after-free bugs in TCP_Server_Info::hostname
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit 90c49fce1c43e1cc152695e20363ff5087897c09 upstream.
TCP_Server_Info::hostname may be updated once or many times during reconnect, so protect its access outside reconnect path as well and then prevent any potential use-after-free bugs.
--- fs/cifs/cifs_debug.c | 7 ++++++- fs/cifs/cifs_debug.h | 12 ++++++------ fs/cifs/connect.c | 10 +++++++--- fs/cifs/sess.c | 7 ++++--- 4 files changed, 23 insertions(+), 13 deletions(-)
fs/cifs/cifs_debug.c +6 -1
@@ -280,8 +280,10 @@ static int cifs_debug_data_proc_show(strseq_printf (m,"\n%d) ConnectionId: 0x%llx " , c, server->conn_id); +spin_lock (&server->srv_lock);if (server->hostname)seq_printf (m,"Hostname: %s " , server->hostname); +spin_unlock (&server->srv_lock);#ifdef CONFIG_CIFS_SMB_DIRECT if (!server->rdma) goto skip_rdma;
@@ -623,10 +625,13 @@ static int cifs_stats_proc_show(struct s server->fastest_cmd[j], server->slowest_cmd[j]);for (j =0 ; j <NUMBER_OF_SMB2_COMMANDS ; j++) -if (atomic_read (&server->smb2slowcmd[j])) +if (atomic_read (&server->smb2slowcmd[j])) { +spin_lock (&server->srv_lock);seq_printf (m," %d slow responses from %s for command %d\n" ,atomic_read (&server->smb2slowcmd[j]), server->hostname, j); +spin_unlock (&server->srv_lock); + }#endif /* STATS2 */ list_for_each_entry (ses, &server->smb_ses_list, smb_ses_list) {list_for_each_entry (tcon, &ses->tcon_list, tcon_list) {
fs/cifs/cifs_debug.h +6 -6
@@ -81,19 +81,19 @@ do { \#define cifs_server_dbg_func (ratefunc, type, fmt, ...) \ do { \ - const char *sn = ""; \ - if (server && server->hostname) \ - sn = server->hostname; \ + spin_lock(&server->srv_lock); \ if ((type) & FYI && cifsFYI & CIFS_INFO) { \ pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \ - __FILE__, sn, ##__VA_ARGS__); \ + __FILE__, server->hostname, \ + ##__VA_ARGS__); \ } else if ((type) & VFS) { \ pr_err_ ## ratefunc("VFS: \\\\%s " fmt, \ - sn, ##__VA_ARGS__); \ + server->hostname, ##__VA_ARGS__); \ } else if ((type) & NOISY && (NOISY != 0)) { \ pr_debug_ ## ratefunc("\\\\%s " fmt, \ - sn, ##__VA_ARGS__); \ + server->hostname, ##__VA_ARGS__); \ } \ + spin_unlock(&server->srv_lock); \ } while (0)#define cifs_server_dbg (type, fmt, ...) \
fs/cifs/connect.c +7 -3
@@ -403,8 +403,10 @@ static int __reconnect_target_unlocked(sif (server->hostname != target) { hostname =extract_hostname (target);if (!IS_ERR (hostname)) { +spin_lock (&server->srv_lock);kfree (server->hostname); server->hostname = hostname; +spin_unlock (&server->srv_lock); }else {cifs_dbg (FYI ,"%s: couldn't extract hostname or address from dfs target: %ld\n" , __func__,PTR_ERR (hostname));
@@ -561,9 +563,7 @@ cifs_echo_request(struct work_struct *wo goto requeue_echo; rc = server->ops->echo ? server->ops->echo (server) : -ENOSYS ; -if (rc) -cifs_dbg (FYI ,"Unable to send echo request to server: %s\n" , - server->hostname); +cifs_server_dbg (FYI ,"send echo request: rc = %d\n" , rc);/* Check witness registrations */ cifs_swn_check ();
@@ -1404,6 +1404,8 @@ static int match_server(struct TCP_Serve {struct sockaddr *addr = (struct sockaddr *)&ctx->dstaddr; +lockdep_assert_held (&server->srv_lock); +if (ctx->nosharesock)return 0 ;
@@ -1810,7 +1812,9 @@ cifs_setup_ipc(struct cifs_ses *ses, strif (tcon ==NULL )return -ENOMEM ; +spin_lock (&server->srv_lock);scnprintf (unc,sizeof (unc),"\\\\%s\\IPC$" , server->hostname); +spin_unlock (&server->srv_lock); xid =get_xid (); tcon->ses = ses;
fs/cifs/sess.c +4 -3
@@ -159,6 +159,7 @@ cifs_chan_is_iface_active(struct cifs_se/* returns number of channels added */ int cifs_try_adding_channels (struct cifs_sb_info *cifs_sb,struct cifs_ses *ses) { +struct TCP_Server_Info *server = ses->server;int old_chan_count, new_chan_count;int left;int rc =0 ;
@@ -178,16 +179,16 @@ int cifs_try_adding_channels(struct cifsreturn 0 ; } -if (ses->server->dialect <SMB30_PROT_ID ) { +if (server->dialect <SMB30_PROT_ID ) {spin_unlock (&ses->chan_lock);cifs_dbg (VFS ,"multichannel is not supported on this protocol version, use 3.0 or above\n" );return 0 ; } -if (!(ses->server->capabilities &SMB2_GLOBAL_CAP_MULTI_CHANNEL )) { +if (!(server->capabilities &SMB2_GLOBAL_CAP_MULTI_CHANNEL )) { ses->chan_max =1 ;spin_unlock (&ses->chan_lock); -cifs_dbg (VFS ,"server %s does not support multichannel\n" , ses->server->hostname); +cifs_server_dbg (VFS ,"no multichannel support\n" );return 0 ; }spin_unlock (&ses->chan_lock);
Greg Kroah-Hartman
maintainerPATCH 689/694 cifs: protect session status check in smb2_reconnect()
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit 5bff9f741af60b143a5ae73417a8ec47fd5ff2f4 upstream.
Use @ses->ses_lock to protect access of @ses->ses_status.
--- fs/cifs/smb2pdu.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
fs/cifs/smb2pdu.c +11 -4
@@ -175,8 +175,17 @@ smb2_reconnect(__le16 smb2_command, stru } }spin_unlock (&tcon->tc_lock); -if ((!tcon->ses) || (tcon->ses->ses_status ==SES_EXITING ) || - (!tcon->ses->server) || !server) + + ses = tcon->ses; +if (!ses) +return -EIO ; +spin_lock (&ses->ses_lock); +if (ses->ses_status ==SES_EXITING ) { +spin_unlock (&ses->ses_lock); +return -EIO ; + } +spin_unlock (&ses->ses_lock); +if (!ses->server || !server)return -EIO ;spin_lock (&server->srv_lock);
@@ -204,8 +213,6 @@ again:if (rc)return rc; - ses = tcon->ses; -spin_lock (&ses->chan_lock);if (!cifs_chan_needs_reconnect (ses, server) && !tcon->need_reconnect) {spin_unlock (&ses->chan_lock);
Greg Kroah-Hartman
maintainerPATCH 690/694 cifs: fix sharing of DFS connections
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit 8e3554150d6c80a84b3cb046615d1a0e943811dc upstream.
When matching DFS connections, we can't rely on the values set in cifs_sb_info::prepath and cifs_tcon::tree_name as they might change during DFS failover. The DFS referrals related to a specific DFS tcon are already matched earlier in match_server(), therefore we can safely skip those checks altogether as the connection is guaranteed to be unique for the DFS tcon.
Besides, when creating or finding an SMB session, make sure to also refcount any DFS root session related to it (cifs_ses::dfs_root_ses), so if a new DFS mount ends up reusing the connection from the old mount while there was an umount(2) still in progress (e.g. umount(2) -> cifs_umount() -> reconnect -> cifs_put_tcon()), the connection could potentially be put right after the umount(2) finished.
Patch has minor update to include fix for unused variable issue noted by the kernel test robot
--- fs/cifs/cifsglob.h | 1 fs/cifs/cifsproto.h | 44 +++++++++++++++++++ fs/cifs/connect.c | 116 ++++++++++++++++++++++++++-------------------------- fs/cifs/dfs.c | 62 +++++++++++++++++++-------- fs/cifs/ioctl.c | 2 fs/cifs/smb2pdu.c | 4 - 6 files changed, 148 insertions(+), 81 deletions(-)
fs/cifs/cifsglob.h +0 -1
@@ -1750,7 +1750,6 @@ struct cifs_mount_ctx {struct TCP_Server_Info *server;struct cifs_ses *ses;struct cifs_tcon *tcon; -char *origin_fullpath, *leaf_fullpath;struct list_head dfs_ses_list; };
fs/cifs/cifsproto.h +43 -1
60 lines not on this page · raw message
fs/cifs/connect.c +59 -57
229 lines not on this page · raw message
fs/cifs/dfs.c +43 -19
102 lines not on this page · raw message
fs/cifs/ioctl.c +1 -1
@@ -239,7 +239,7 @@ static int cifs_dump_full_key(struct cif* section, we need to make sure it won't be released * so increment its refcount */ - ses->ses_count++; +cifs_smb_ses_inc_refcount (ses); found = true; goto search_end; }
fs/cifs/smb2pdu.c +2 -2
@@ -3856,7 +3856,7 @@ void smb2_reconnect_server(struct work_sif (ses->tcon_ipc && ses->tcon_ipc->need_reconnect) {list_add_tail (&ses->tcon_ipc->rlist, &tmp_list); tcon_selected = tcon_exist = true; - ses->ses_count++; +cifs_smb_ses_inc_refcount (ses); }/* * handle the case where channel needs to reconnect
@@ -3867,7 +3867,7 @@ void smb2_reconnect_server(struct work_sif (!tcon_selected &&cifs_chan_needs_reconnect (ses, server)) {list_add_tail (&ses->rlist, &tmp_ses_list); ses_exist = true; - ses->ses_count++; +cifs_smb_ses_inc_refcount (ses); }spin_unlock (&ses->chan_lock); }
Greg Kroah-Hartman
maintainerPATCH 691/694 cifs: fix potential race when tree connecting ipc
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit ee20d7c6100752eaf2409d783f4f1449c29ea33d upstream.
Protect access of TCP_Server_Info::hostname when building the ipc tree name as it might get freed in cifsd thread and thus causing an use-after-free bug in __tree_connect_dfs_target(). Also, while at it, update status of IPC tcon on success and then avoid any extra tree connects.
--- fs/cifs/dfs.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 7 deletions(-)
fs/cifs/dfs.c +50 -7
@@ -398,6 +398,54 @@ static int target_share_matches_server(sreturn rc; } +static void __tree_connect_ipc (const unsigned int xid,char *tree, +struct cifs_sb_info *cifs_sb, +struct cifs_ses *ses) +{ +struct TCP_Server_Info *server = ses->server; +struct cifs_tcon *tcon = ses->tcon_ipc; +int rc; + +spin_lock (&ses->ses_lock); +spin_lock (&ses->chan_lock); +if (cifs_chan_needs_reconnect (ses, server) || + ses->ses_status !=SES_GOOD ) { +spin_unlock (&ses->chan_lock); +spin_unlock (&ses->ses_lock); +cifs_server_dbg (FYI ,"%s: skipping ipc reconnect due to disconnected ses\n" , + __func__); +return ; + } +spin_unlock (&ses->chan_lock); +spin_unlock (&ses->ses_lock); + +cifs_server_lock (server); +scnprintf (tree,MAX_TREE_SIZE ,"\\\\%s\\IPC$" , server->hostname); +cifs_server_unlock (server); + + rc = server->ops->tree_connect (xid, ses, tree, tcon, + cifs_sb->local_nls); +cifs_server_dbg (FYI ,"%s: tree_reconnect %s: %d\n" , __func__, tree, rc); +spin_lock (&tcon->tc_lock); +if (rc) { + tcon->status =TID_NEED_TCON ; + }else { + tcon->status =TID_GOOD ; + tcon->need_reconnect = false; + } +spin_unlock (&tcon->tc_lock); +} + +static void tree_connect_ipc (const unsigned int xid,char *tree, +struct cifs_sb_info *cifs_sb, +struct cifs_tcon *tcon) +{ +struct cifs_ses *ses = tcon->ses; + +__tree_connect_ipc (xid, tree, cifs_sb, ses); +__tree_connect_ipc (xid, tree, cifs_sb,CIFS_DFS_ROOT_SES (ses)); +} +static int __tree_connect_dfs_target (const unsigned int xid,struct cifs_tcon *tcon,struct cifs_sb_info *cifs_sb,char *tree,bool islink,struct dfs_cache_tgt_list *tl)
@@ -406,7 +454,6 @@ static int __tree_connect_dfs_target(construct TCP_Server_Info *server = tcon->ses->server;const struct smb_version_operations *ops = server->ops;struct cifs_ses *root_ses =CIFS_DFS_ROOT_SES (tcon->ses); -struct cifs_tcon *ipc = root_ses->tcon_ipc;char *share =NULL , *prefix =NULL ;struct dfs_cache_tgt_iterator *tit;bool target_match;
@@ -442,18 +489,14 @@ static int __tree_connect_dfs_target(con }dfs_cache_noreq_update_tgthint (server->current_fullpath +1 , tit); - -if (ipc->need_reconnect) { -scnprintf (tree,MAX_TREE_SIZE ,"\\\\%s\\IPC$" , server->hostname); - rc = ops->tree_connect (xid, ipc->ses, tree, ipc, cifs_sb->local_nls); -cifs_dbg (FYI ,"%s: reconnect ipc: %d\n" , __func__, rc); - } +tree_connect_ipc (xid, tree, cifs_sb, tcon);scnprintf (tree,MAX_TREE_SIZE ,"\\%s" , share);if (!islink) { rc = ops->tree_connect (xid, tcon->ses, tree, tcon, cifs_sb->local_nls);break ; } +/* * If no dfs referrals were returned from link target, then just do a TREE_CONNECT * to it. Otherwise, cache the dfs referral and then mark current tcp ses for
Greg Kroah-Hartman
maintainerPATCH 692/694 cifs: protect access of TCP_Server_Info::{origin,leaf}_fullpath
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit 3dc9c433c9dde15477d02b609ccb4328e2adb6dc upstream.
Protect access of TCP_Server_Info::{origin,leaf}_fullpath when matching DFS connections, and get rid of TCP_Server_Info::current_fullpath while we're at it.
--- fs/cifs/cifsglob.h | 20 +++++++++++++------- fs/cifs/connect.c | 10 ++++++---- fs/cifs/dfs.c | 14 ++++++++------ fs/cifs/dfs.h | 13 +++++++++++-- fs/cifs/dfs_cache.c | 6 +++++- 5 files changed, 43 insertions(+), 20 deletions(-)
fs/cifs/cifsglob.h +13 -7
@@ -736,17 +736,23 @@ struct TCP_Server_Info {#endif struct mutex refpath_lock;/* protects leaf_fullpath */ /* -* Canonical DFS full paths that were used to chase referrals in mount and reconnect. +* origin_fullpath: Canonical copy of smb3_fs_context::source. +* It is used for matching existing DFS tcons. * -* origin_fullpath: first or original referral path -* leaf_fullpath: last referral path (might be changed due to nested links in reconnect) +* leaf_fullpath: Canonical DFS referral path related to this +* connection. +* It is used in DFS cache refresher, reconnect and may +* change due to nested DFS links. * -* current_fullpath: pointer to either origin_fullpath or leaf_fullpath -* NOTE: cannot be accessed outside cifs_reconnect() and smb2_reconnect() +* Both protected by @refpath_lock and @srv_lock. The @refpath_lock is +* mosly used for not requiring a copy of @leaf_fullpath when getting +* cached or new DFS referrals (which might also sleep during I/O). +* While @srv_lock is held for making string and NULL comparions against +* both fields as in mount(2) and cache refresh. * -* format: \\HOST\SHARE\[OPTIONAL PATH] +* format: \\HOST\SHARE[\OPTIONAL PATH] */ -char *origin_fullpath, *leaf_fullpath, *current_fullpath; +char *origin_fullpath, *leaf_fullpath; };static inline bool is_smb1 (struct TCP_Server_Info *server)
fs/cifs/connect.c +6 -4
@@ -454,7 +454,6 @@ static int reconnect_target_unlocked(strstatic int reconnect_dfs_server (struct TCP_Server_Info *server) {int rc =0 ; -const char *refpath = server->current_fullpath +1 ;struct dfs_cache_tgt_list tl =DFS_CACHE_TGT_LIST_INIT (tl);struct dfs_cache_tgt_iterator *target_hint =NULL ;int num_targets =0 ;
@@ -467,8 +466,10 @@ static int reconnect_dfs_server(struct T* through /proc/fs/cifs/dfscache or the target list is empty due to server settings after * refreshing the referral, so, in this case, default it to 1. */ -if (!dfs_cache_noreq_find (refpath,NULL , &tl)) +mutex_lock (&server->refpath_lock); +if (!dfs_cache_noreq_find (server->leaf_fullpath +1 ,NULL , &tl)) num_targets =dfs_cache_get_nr_tgts (&tl); +mutex_unlock (&server->refpath_lock);if (!num_targets) num_targets =1 ;
@@ -512,7 +513,9 @@ static int reconnect_dfs_server(struct Tmod_delayed_work (cifsiod_wq, &server->reconnect,0 ); }while (server->tcpStatus == CifsNeedReconnect); -dfs_cache_noreq_update_tgthint (refpath, target_hint); +mutex_lock (&server->refpath_lock); +dfs_cache_noreq_update_tgthint (server->leaf_fullpath +1 , target_hint); +mutex_unlock (&server->refpath_lock);dfs_cache_free_tgts (&tl);/* Need to set up echo worker again once connection has been established */
@@ -1579,7 +1582,6 @@ cifs_get_tcp_session(struct smb3_fs_cont rc = -ENOMEM ; goto out_err; } - tcp_ses->current_fullpath = tcp_ses->leaf_fullpath; }if (ctx->nosharesock)
fs/cifs/dfs.c +8 -6
@@ -248,11 +248,12 @@ static int __dfs_mount_share(struct cifs tcon = mnt_ctx->tcon;mutex_lock (&server->refpath_lock); +spin_lock (&server->srv_lock);if (!server->origin_fullpath) { server->origin_fullpath = origin_fullpath; - server->current_fullpath = server->leaf_fullpath; origin_fullpath =NULL ; } +spin_unlock (&server->srv_lock);mutex_unlock (&server->refpath_lock);if (list_empty (&tcon->dfs_ses_list)) {
@@ -366,10 +367,11 @@ static int update_server_fullpath(struct rc =PTR_ERR (npath); }else {mutex_lock (&server->refpath_lock); +spin_lock (&server->srv_lock);kfree (server->leaf_fullpath); server->leaf_fullpath = npath; +spin_unlock (&server->srv_lock);mutex_unlock (&server->refpath_lock); - server->current_fullpath = server->leaf_fullpath; }return rc; }
@@ -474,7 +476,7 @@ static int __tree_connect_dfs_target(con share = prefix =NULL ;/* Check if share matches with tcp ses */ - rc =dfs_cache_get_tgt_share (server->current_fullpath +1 , tit, &share, &prefix); + rc =dfs_cache_get_tgt_share (server->leaf_fullpath +1 , tit, &share, &prefix);if (rc) {cifs_dbg (VFS ,"%s: failed to parse target share: %d\n" , __func__, rc);break ;
@@ -488,7 +490,7 @@ static int __tree_connect_dfs_target(concontinue ; } -dfs_cache_noreq_update_tgthint (server->current_fullpath +1 , tit); +dfs_cache_noreq_update_tgthint (server->leaf_fullpath +1 , tit);tree_connect_ipc (xid, tree, cifs_sb, tcon);scnprintf (tree,MAX_TREE_SIZE ,"\\%s" , share);
@@ -606,8 +608,8 @@ int cifs_tree_connect(const unsigned int cifs_sb =CIFS_SB (sb);/* If it is not dfs or there was no cached dfs referral, then reconnect to same share */ -if (!server->current_fullpath || -dfs_cache_noreq_find (server->current_fullpath +1 , &ref, &tl)) { +if (!server->leaf_fullpath || +dfs_cache_noreq_find (server->leaf_fullpath +1 , &ref, &tl)) { rc = ops->tree_connect (xid, tcon->ses, tcon->tree_name, tcon, cifs_sb->local_nls); goto out; }
fs/cifs/dfs.h +11 -2
@@ -43,8 +43,12 @@ static inline char *dfs_get_automount_desize_t len;char *s; -if (unlikely (!server->origin_fullpath)) +spin_lock (&server->srv_lock); +if (unlikely (!server->origin_fullpath)) { +spin_unlock (&server->srv_lock);return ERR_PTR (-EREMOTE ); + } +spin_unlock (&server->srv_lock); s =dentry_path_raw (dentry, page,PATH_MAX );if (IS_ERR (s))
@@ -53,13 +57,18 @@ static inline char *dfs_get_automount_deif (!s[1 ]) s++; +spin_lock (&server->srv_lock); len =strlen (server->origin_fullpath); -if (s < (char *)page + len) +if (s < (char *)page + len) { +spin_unlock (&server->srv_lock);return ERR_PTR (-ENAMETOOLONG ); + } s -= len;memcpy (s, server->origin_fullpath, len); +spin_unlock (&server->srv_lock);convert_delimiter (s,'/' ); +return s; }
fs/cifs/dfs_cache.c +5 -1
@@ -1278,8 +1278,12 @@ static void refresh_cache_worker(structspin_lock (&cifs_tcp_ses_lock);list_for_each_entry (server, &cifs_tcp_ses_list, tcp_ses_list) { -if (!server->leaf_fullpath) +spin_lock (&server->srv_lock); +if (!server->leaf_fullpath) { +spin_unlock (&server->srv_lock);continue ; + } +spin_unlock (&server->srv_lock);list_for_each_entry (ses, &server->smb_ses_list, smb_ses_list) {if (ses->tcon_ipc) {
Greg Kroah-Hartman
maintainerPATCH 693/694 cifs: avoid potential races when handling multiple dfs tcons
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit 6be2ea33a4093402252724a00c4af8033725184c upstream.
Now that a DFS tcon manages its own list of DFS referrals and sessions, there is no point in having a single worker to refresh referrals of all DFS tcons. Make it faster and less prone to race conditions when having several mounts by queueing a worker per DFS tcon that will take care of refreshing only the DFS referrals related to it.
--- fs/cifs/cifsglob.h | 2 fs/cifs/connect.c | 7 ++ fs/cifs/dfs.c | 4 + fs/cifs/dfs_cache.c | 137 ++++++++++++++++++++++------------------------------ fs/cifs/dfs_cache.h | 9 +++ 5 files changed, 80 insertions(+), 79 deletions(-)
fs/cifs/cifsglob.h +1 -1
@@ -1238,8 +1238,8 @@ struct cifs_tcon {struct cached_fids *cfids;/* BB add field for back pointer to sb struct(s)? */ #ifdef CONFIG_CIFS_DFS_UPCALL -struct list_head ulist;/* cache update list */ struct list_head dfs_ses_list; +struct delayed_work dfs_cache_work;#endif struct delayed_work query_interfaces;/* query interfaces workqueue job */ };
fs/cifs/connect.c +6 -1
@@ -2337,6 +2337,9 @@ cifs_put_tcon(struct cifs_tcon *tcon)/* cancel polling of interfaces */ cancel_delayed_work_sync (&tcon->query_interfaces); +#ifdef CONFIG_CIFS_DFS_UPCALL +cancel_delayed_work_sync (&tcon->dfs_cache_work); +#endif if (tcon->use_witness) {int rc;
@@ -2584,7 +2587,9 @@ cifs_get_tcon(struct cifs_ses *ses, struqueue_delayed_work (cifsiod_wq, &tcon->query_interfaces, (SMB_INTERFACE_POLL_INTERVAL *HZ )); } - +#ifdef CONFIG_CIFS_DFS_UPCALL +INIT_DELAYED_WORK (&tcon->dfs_cache_work, dfs_cache_refresh); +#endif spin_lock (&cifs_tcp_ses_lock);list_add (&tcon->tcon_list, &ses->tcon_list);spin_unlock (&cifs_tcp_ses_lock);
fs/cifs/dfs.c +4 -0
@@ -157,6 +157,8 @@ static int get_dfs_conn(struct cifs_moun rc =cifs_is_path_remote (mnt_ctx); } +dfs_cache_noreq_update_tgthint (ref_path +1 , tit); +if (rc == -EREMOTE && is_refsrv) { rc2 =add_root_smb_session (mnt_ctx);if (rc2)
@@ -259,6 +261,8 @@ static int __dfs_mount_share(struct cifsif (list_empty (&tcon->dfs_ses_list)) {list_replace_init (&mnt_ctx->dfs_ses_list, &tcon->dfs_ses_list); +queue_delayed_work (dfscache_wq, &tcon->dfs_cache_work, +dfs_cache_get_ttl () *HZ ); }else {dfs_put_root_smb_sessions (&mnt_ctx->dfs_ses_list); }
fs/cifs/dfs_cache.c +60 -77
250 lines not on this page · raw message
fs/cifs/dfs_cache.h +9 -0
@@ -13,6 +13,9 @@#include <linux/uuid.h> #include "cifsglob.h" +extern struct workqueue_struct *dfscache_wq; +extern atomic_t dfs_cache_ttl; +#define DFS_CACHE_TGT_LIST_INIT (var) { .tl_numtgts = 0, .tl_list = LIST_HEAD_INIT((var).tl_list), }struct dfs_cache_tgt_list {
@@ -42,6 +45,7 @@ int dfs_cache_get_tgt_share(char *path, char **prefix);char *dfs_cache_canonical_path (const char *path,const struct nls_table *cp,int remap);int dfs_cache_remount_fs (struct cifs_sb_info *cifs_sb); +void dfs_cache_refresh (struct work_struct *work);static inline struct dfs_cache_tgt_iterator * dfs_cache_get_next_tgt(struct dfs_cache_tgt_list *tl,
@@ -89,4 +93,9 @@ dfs_cache_get_nr_tgts(const struct dfs_c return tl ? tl->tl_numtgts : 0; } +static inline int dfs_cache_get_ttl (void ) +{ +return atomic_read (&dfs_cache_ttl); +} +#endif /* _CIFS_DFS_CACHE_H */
Greg Kroah-Hartman
maintainerPATCH 694/694 debugobject: Ensure pool refill (again)
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 0af462f19e635ad522f28981238334620881badc upstream.
The recent fix to ensure atomicity of lookup and allocation inadvertently broke the pool refill mechanism.
Prior to that change debug_objects_activate() and debug_objecs_assert_init() invoked debug_objecs_init() to set up the tracking object for statically initialized objects. That's not longer the case and debug_objecs_init() is now the only place which does pool refills.
Depending on the number of statically initialized objects this can be enough to actually deplete the pool, which was observed by Ido via a debugobjects OOM warning.
Restore the old behaviour by adding explicit refill opportunities to debug_objects_activate() and debug_objecs_assert_init().
--- lib/debugobjects.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
lib/debugobjects.c +15 -6
@@ -587,6 +587,16 @@ static struct debug_obj *lookup_object_oreturn NULL ; } +static void debug_objects_fill_pool (void ) +{ +/* +* On RT enabled kernels the pool refill must happen in preemptible +* context: +*/ +if (!IS_ENABLED (CONFIG_PREEMPT_RT ) ||preemptible ()) +fill_pool (); +} +static void __debug_object_init (void *addr,const struct debug_obj_descr *descr,int onstack) {
@@ -595,12 +605,7 @@ __debug_object_init(void *addr, const ststruct debug_obj *obj;unsigned long flags; -/* -* On RT enabled kernels the pool refill must happen in preemptible -* context: -*/ -if (!IS_ENABLED (CONFIG_PREEMPT_RT ) ||preemptible ()) -fill_pool (); +debug_objects_fill_pool (); db =get_bucket ((unsigned long ) addr);
@@ -685,6 +690,8 @@ int debug_object_activate(void *addr, coif (!debug_objects_enabled)return 0 ; +debug_objects_fill_pool (); + db =get_bucket ((unsigned long ) addr);raw_spin_lock_irqsave (&db->lock, flags);
@@ -894,6 +901,8 @@ void debug_object_assert_init(void *addrif (!debug_objects_enabled)return ; +debug_objects_fill_pool (); + db =get_bucket ((unsigned long ) addr);raw_spin_lock_irqsave (&db->lock, flags);
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.3.2 release. There are 694 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 10 May 2023 09:42:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.3.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.3.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.3.2 release. There are 694 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 10 May 2023 09:42:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.3.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.3.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.3.2 release. There are 694 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 10 May 2023 09:42:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.3.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.3.y
and the diffstat can be found below.thanks,
greg k-h
Tested rc1 against the Fedora build system (aarch64, ppc64le, s390x, x86_64), and boot tested x86_64. No regressions noted.
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.3.2 release. There are 694 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 10 May 2023 09:42:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.3.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.3.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.3.2 release. There are 694 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 10 May 2023 09:42:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.3.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.3.y
and the diffstat can be found below.thanks,
greg k-h
We also need to bring in this patch from upstream:
3522340199cc060b70f0094e3039bdb43c3f6ee1 ("arch_topology: Remove early cacheinfo error message if -ENOENT") otherwise we will be spitting out the "Early cacheinfo failed, ret = " messages on boot.
Thanks!
Signature · 1 line
Florian
Greg Kroah-Hartman
maintainerQuoted 17 lines · Florian Fainelli
Quoted 16 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.3.2 release. There are 694 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 10 May 2023 09:42:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.3.2-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.3.y
and the diffstat can be found below.thanks,
Quoted 7 lines
Quoted 1 line
greg k-h
We also need to bring in this patch from upstream:
3522340199cc060b70f0094e3039bdb43c3f6ee1("arch_topology: Remove early cacheinfo error message if-ENOENT") otherwise we will be spitting out the "Early cacheinfo failed, ret = " messages on boot.
Now queued up, thanks!
greg k-h
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.3.2 release. There are 694 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Successfully built bindeb-pkgs for my computer (Acer Aspire E15, Intel Core i3 Haswell) and booted. No noticeable regressions.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.3.2 release. There are 694 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 10 May 2023 09:42:40 +0000. Anything received after that time might be too late.
Hi Greg
6.3.2-rc1
compiles, boots and runs here on x86_64
(AMD Ryzen 5 PRO 4650G, Slackware64-15.0)