6.1.178-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 1026/1067 usb: iowarrior: remove inherent race with minor number
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit 56dd29088c9d9510c48a8ebad2465248fde36551 ]
The driver saves the minor number it gets upon registration in its descriptor for debugging purposes. However, there is inevitably a window between registration and saving the correct minor in a descriptor. During this window the debugging output will be wrong.
As wrong debug output is worse than no debug output, just remove it.
Stable-dep-of: c602254ba4c1 ("USB: iowarrior: fix use-after-free on disconnect race")
--- drivers/usb/misc/iowarrior.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/usb/misc/iowarrior.c +3 -14
@@ -74,7 +74,6 @@ struct iowarrior {struct mutex mutex;/* locks this structure */ struct usb_device *udev;/* save off the usb device pointer */ struct usb_interface *interface;/* the interface for this device */ -unsigned char minor;/* the starting minor number for this device */ struct usb_endpoint_descriptor *int_out_endpoint;/* endpoint for reading (needed for IOW56 only) */ struct usb_endpoint_descriptor *int_in_endpoint;/* endpoint for reading */ struct urb *int_in_urb;/* the urb for reading data */
@@ -246,7 +245,6 @@ static void iowarrior_write_callback(str*/ static inline void iowarrior_delete (struct iowarrior *dev) { -dev_dbg (&dev->interface->dev,"minor %d\n" , dev->minor);kfree (dev->int_in_buffer);usb_free_urb (dev->int_in_urb);kfree (dev->read_queue);
@@ -297,9 +295,6 @@ static ssize_t iowarrior_read(struct fil goto exit; } -dev_dbg (&dev->interface->dev,"minor %d, count = %zd\n" , - dev->minor, count); -/* read count must be packet size (+ time stamp) */ if ((count != dev->report_size) && (count != (dev->report_size +1 ))) {
@@ -379,8 +374,6 @@ static ssize_t iowarrior_write(struct fi retval = -ENODEV ; goto exit; } -dev_dbg (&dev->interface->dev,"minor %d, count = %zd\n" , - dev->minor, count);/* if count is 0 we're already done */ if (count ==0 ) { retval =0 ;
@@ -523,9 +516,6 @@ static long iowarrior_ioctl(struct file goto error_out; } -dev_dbg (&dev->interface->dev,"minor %d, cmd 0x%.4x, arg %ld\n" , - dev->minor, cmd, arg); - retval =0 ; io_res =0 ;switch (cmd) {
@@ -672,8 +662,6 @@ static int iowarrior_release(struct inodif (!dev)return -ENODEV ; -dev_dbg (&dev->interface->dev,"minor %d\n" , dev->minor); -/* lock our device */ mutex_lock (&dev->mutex);
@@ -776,6 +764,7 @@ static int iowarrior_probe(struct usb_instruct usb_host_interface *iface_desc;int retval = -ENOMEM ;int res; +int minor;/* allocate memory for our device state and initialize it */ dev =kzalloc (sizeof (struct iowarrior ),GFP_KERNEL );
@@ -891,12 +880,12 @@ static int iowarrior_probe(struct usb_in goto error; } - dev->minor = interface->minor; + minor = interface->minor;/* let the user know what node this device is now attached to */ dev_info (&interface->dev,"IOWarrior product=0x%x, serial=%s interface=%d " "now attached to iowarrior%d\n" , dev->product_id, dev->chip_serial, - iface_desc->desc.bInterfaceNumber, dev->minor -IOWARRIOR_MINOR_BASE ); + iface_desc->desc.bInterfaceNumber, minor -IOWARRIOR_MINOR_BASE );return retval; error:
Greg Kroah-Hartman
maintainerPATCH 1027/1067 usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauricio Faria de Oliveira <[email protected]>
[ Upstream commit e2674dfbed8a30d57e2bc872c4bfa6c3eec918bf ]
ueagle-atm uses the asynchronous request_firmware_nowait() in .probe(), but does not wait for its completion, not even in .disconnect(); so, if the device is unplugged meanwhile, its teardown runs concurrently with that.
Even though this inconsistency is worth addressing on its own, it has also triggered several bug reports in syzbot over the years (some auto-closed) where the firmware sysfs fallback mechanism (CONFIG_FW_LOADER_USER_HELPER) creates a firmware subdirectory in the device directory during its removal, which might hit unexpected conditions in kernfs, apparently, depending at which point the add and remove operations raced. (See links.)
The pattern is:
usb ?-?: Direct firmware load for ueagle-atm/eagle?.fw failed with error -2 usb ?-?: Falling back to sysfs fallback for: ueagle-atm/eagle?.fw <ERROR>
Call trace: ... kernfs_create_dir_ns sysfs_create_dir_ns create_dir kobject_add_internal kobject_add_varg kobject_add class_dir_create_and_add get_device_parent device_add fw_load_sysfs_fallback fw_load_from_user_helper firmware_fallback_sysfs _request_firmware request_firmware_work_func ...
(Some variations are observed, after fw_load_sysfs_fallback(), e.g., [1].)
While the kernfs side is being looked at, the ueagle-atm side can be fixed by waiting for the pre-firmware load in the .disconnect() handler.
This change has a similar approach to previous work by Andrey Tsygunka [2] (wait_for_completion() in .disconnect()), but it is relatively different in design/implementation; using the Originally-by tag for credit assignment.
This has been tested with:
- synthetic reproducer to check the error path;
- USB gadget (virtual device) to check the firmware upload path;
- QEMU device emulator to check the device ID re-enumeration path; (The latter two were written by Claude; no other code/text in this commit.)
Links (year first reported):
2025 https://syzbot.org/bug?extid=ce1e5a1b4e086b43e56d
2025 https://syzbot.org/bug?extid=9af8471255ac36e34fd4
2024 https://syzbot.org/bug?extid=306212936b13e520679d
2023 https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
2022 https://syzbot.org/bug?extid=782984d6f1701b526edb
2021 https://syzbot.org/bug?id=f3f221579f4ef7e9691281f3c6f56c05f83e8490
2021 https://syzbot.org/bug?id=84d86f0d71394829df6fc53daf6642c045983881
2021 https://syzbot.org/bug?id=3302dc1c0e2b9c94f2e8edb404eabc9267bc6f90
[1] https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
[2] https://lore.kernel.org/lkml/[email protected]/
--- drivers/usb/atm/ueagle-atm.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/usb/atm/ueagle-atm.c +31 -5
@@ -599,7 +599,9 @@ static int uea_send_modem_cmd(struct usbstatic void uea_upload_pre_firmware (const struct firmware *fw_entry,void *context) { -struct usb_device *usb = context; +struct usb_interface *intf = context; +struct usb_device *usb =interface_to_usbdev (intf); +struct completion *fw_done =usb_get_intfdata (intf);const u8 *pfw;u8 value;u32 crc =0 ;
@@ -670,15 +672,17 @@ err_fw_corrupted: err:release_firmware (fw_entry);uea_leaves (usb); +complete (fw_done); }/* * uea_load_firmware - Load usb firmware for pre-firmware devices. */ -static int uea_load_firmware (struct usb_device *usb,unsigned int ver) +static int uea_load_firmware (struct usb_interface *intf,unsigned int ver) {int ret;char *fw_name =EAGLE_FIRMWARE ; +struct usb_device *usb =interface_to_usbdev (intf);uea_enters (usb);uea_info (usb,"pre-firmware device, uploading firmware\n" );
@@ -702,7 +706,7 @@ static int uea_load_firmware(struct usb_ } ret =request_firmware_nowait (THIS_MODULE ,1 , fw_name, &usb->dev, -GFP_KERNEL , usb, +GFP_KERNEL , intf, uea_upload_pre_firmware);if (ret)uea_err (usb,"firmware %s is not available\n" , fw_name);
@@ -2598,8 +2602,23 @@ static int uea_probe(struct usb_interfacusb_reset_device (usb); -if (UEA_IS_PREFIRM (id)) -return uea_load_firmware (usb,UEA_CHIP_VERSION (id)); +if (UEA_IS_PREFIRM (id)) { +struct completion *fw_done; + +/* Wait for the firmware load to be done, in .disconnect() */ + fw_done =kzalloc (sizeof (*fw_done),GFP_KERNEL ); +if (!fw_done) +return -ENOMEM ; + +init_completion (fw_done); +usb_set_intfdata (intf, fw_done); + + ret =uea_load_firmware (intf,UEA_CHIP_VERSION (id)); +if (ret) +kfree (fw_done); + +return ret; + } ret =usbatm_usb_probe (intf, id, &uea_usbatm_driver);if (ret ==0 ) {
@@ -2630,6 +2649,13 @@ static void uea_disconnect(struct usb_inusbatm_usb_disconnect (intf);mutex_unlock (&uea_mutex);uea_info (usb,"ADSL device removed\n" ); + }else if (usb->config->desc.bNumInterfaces ==1 ) { +struct completion *fw_done =usb_get_intfdata (intf); + +uea_dbg (usb,"pre-firmware device, waiting firmware upload\n" ); +wait_for_completion (fw_done); +uea_dbg (usb,"pre-firmware device, finished waiting\n" ); +kfree (fw_done); }uea_leaves (usb);
Greg Kroah-Hartman
maintainerPATCH 1028/1067 usb: typec: tcpm: Fix VDM type for Enter Mode commands
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Yan <[email protected]>
[ Upstream commit 9cff680e47632b7723cb19f9c5e63669063c3417 ]
VDO() second parameter is VDM type (bit 15): 1 for SVDM, 0 for UVDM. Using 'vdo ? 2 : 1' corrupts SVID low bit when vdo is non-NULL (2 << 15 = BIT(16)). Enter Mode is always SVDM, hardcode to 1.
--- drivers/usb/typec/tcpm/tcpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
@@ -2231,7 +2231,7 @@ static int tcpm_altmode_enter(struct typif (svdm_version <0 )return svdm_version; - header =VDO (altmode->svid, vdo ?2 :1 , svdm_version,CMD_ENTER_MODE ); + header =VDO (altmode->svid,1 , svdm_version,CMD_ENTER_MODE ); header |=VDO_OPOS (altmode->mode);tcpm_queue_vdm_unlocked (port, header, vdo, vdo ?1 :0 );
Greg Kroah-Hartman
maintainerPATCH 1029/1067 usb: gadget: f_fs: initialize reset_work at allocation time
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyler Baker <[email protected]>
[ Upstream commit 3137b243c93982fe3460335e12f9247739766e10 ]
ffs_fs_kill_sb() unconditionally calls cancel_work_sync() on ffs->reset_work when a functionfs instance is unmounted:
ffs_data_reset(ffs); cancel_work_sync(&ffs->reset_work);
However ffs->reset_work is only ever initialized via INIT_WORK() in ffs_func_set_alt() and ffs_func_disable(), and only on the FFS_DEACTIVATED path. That state is reached solely by ffs_data_closed() when the instance is mounted with the "no_disconnect" option, so for the common case (no "no_disconnect", or mounted and unmounted without ever being deactivated) reset_work is never initialized.
ffs_data_new() allocates the ffs_data with kzalloc_obj() and does not initialize reset_work, and ffs_data_reset()/ffs_data_clear() do not touch it either, so reset_work.func is left NULL. cancel_work_sync() on such a work then trips the WARN_ON(!work->func) guard in __flush_work():
WARNING: kernel/workqueue.c:4301 at __flush_work+0x330/0x360, CPU#3: umount Call trace: __flush_work cancel_work_sync ffs_fs_kill_sb [usb_f_fs] deactivate_locked_super deactivate_super cleanup_mnt __cleanup_mnt task_work_run exit_to_user_mode_loop el0_svc
On older kernels cancel_work_sync() on a zero-initialized work struct was a silent no-op, which hid the missing initialization.
Initialize reset_work once in ffs_data_new() so it is always valid for the lifetime of the ffs_data, and drop the now-redundant INIT_WORK() calls from the two deactivation paths.
--- drivers/usb/gadget/function/f_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_fs.c +2 -1
@@ -255,6 +255,7 @@ static int ffs_acquire_dev(const char *dstatic void ffs_release_dev (struct ffs_dev *ffs_dev);static int ffs_ready (struct ffs_data *ffs);static void ffs_closed (struct ffs_data *ffs); +static void ffs_reset_work (struct work_struct *work);/* Misc helper functions ****************************************************/
@@ -1786,6 +1787,7 @@ static struct ffs_data *ffs_data_new(coninit_waitqueue_head (&ffs->ev.waitq);init_waitqueue_head (&ffs->wait);init_completion (&ffs->ep0req_completion); +INIT_WORK (&ffs->reset_work, ffs_reset_work);/* XXX REVISIT need to update it in some places, or do we? */ ffs->ev.can_stall =1 ;
@@ -3342,7 +3344,6 @@ static int ffs_func_set_alt(struct usb_fif (ffs->state ==FFS_DEACTIVATED ) { ffs->state =FFS_CLOSING ; -INIT_WORK (&ffs->reset_work, ffs_reset_work);schedule_work (&ffs->reset_work);return -ENODEV ; }
Greg Kroah-Hartman
maintainerPATCH 1030/1067 crypto: atmel-sha204a - Mark OF related data as maybe unused
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 75f3d950054389e2556277e42170e37dd97cd872 ]
The driver can be compile tested with !CONFIG_OF making certain data unused:
drivers/crypto/atmel-sha204a.c:129:34: error: ‘atmel_sha204a_dt_ids’ defined but not used [-Werror=unused-const-variable=]
Stable-dep-of: ea5e57cc9718 ("crypto: atmel-sha204a - drop hwrng quality reduction for ATSHA204A")
--- drivers/crypto/atmel-sha204a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/atmel-sha204a.c +1 -1
@@ -132,7 +132,7 @@ static void atmel_sha204a_remove(structkfree ((void *)i2c_priv->hwrng.priv); } -static const struct of_device_id atmel_sha204a_dt_ids[] = { +static const struct of_device_id atmel_sha204a_dt_ids[]__maybe_unused = { { .compatible ="atmel,atsha204" , }, { .compatible ="atmel,atsha204a" , }, {/* sentinel */ }
Greg Kroah-Hartman
maintainerPATCH 1031/1067 crypto: atmel - Drop explicit initialization of struct i2c_device_id::driver_data to 0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit d86ad3911a5d4549297ed810ee450e5772fd665f ]
These drivers don't use the driver_data member of struct i2c_device_id, so don't explicitly initialize this member.
This prepares putting driver_data in an anonymous union which requires either no initialization or named designators. But it's also a nice cleanup on its own.
Stable-dep-of: ea5e57cc9718 ("crypto: atmel-sha204a - drop hwrng quality reduction for ATSHA204A")
--- drivers/crypto/atmel-ecc.c | 2 +- drivers/crypto/atmel-sha204a.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/atmel-ecc.c +1 -1
@@ -381,7 +381,7 @@ MODULE_DEVICE_TABLE(of, atmel_ecc_dt_ids#endif static const struct i2c_device_id atmel_ecc_id[] = { - {"atecc508a" ,0 }, + {"atecc508a" }, { } };MODULE_DEVICE_TABLE (i2c, atmel_ecc_id);
drivers/crypto/atmel-sha204a.c +2 -2
@@ -140,8 +140,8 @@ static const struct of_device_id atmel_sMODULE_DEVICE_TABLE (of, atmel_sha204a_dt_ids);static const struct i2c_device_id atmel_sha204a_id[] = { - {"atsha204" ,0 }, - {"atsha204a" ,0 }, + {"atsha204" }, + {"atsha204a" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (i2c, atmel_sha204a_id);
Greg Kroah-Hartman
maintainerPATCH 1032/1067 crypto: atmel-sha204a - drop hwrng quality reduction for ATSHA204A
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit ea5e57cc97185329dcc5ebdcaae7e1500bf0ad0b ]
Commit 8006aff15516 ("crypto: atmel-sha204a - Set hwrng quality to lowest possible") reduced the hwrng quality to 1 based on a review by Bill Cox [1]. However, despite its title, the review only tested the ATSHA204, not the ATSHA204A.
In the same thread, Atmel engineer Landon Cox wrote "this behavior has been eliminated entirely"[2] in the ATSHA204A and "this problem does not affect the ATECC108 or the ATECC108A (or the ATSHA204A)"[3].
According to the official ATSHA204A datasheet [4], the device contains a high-quality hardware RNG that combines its output with an internal seed value stored in EEPROM or SRAM to generate random numbers. The device also implements all security functions using SHA-256, and the driver uses the chip's Random command in seed-update mode.
Keep 'quality = 1' for ATSHA204, but drop the explicit hwrng quality reduction for ATSHA204A and fall back to the hwrng core default.
[1] https://www.metzdowd.com/pipermail/cryptography/2014-December/023858.html
[2] https://www.metzdowd.com/pipermail/cryptography/2014-December/023852.html
[3] https://www.metzdowd.com/pipermail/cryptography/2014-December/023886.html
[4] https://ww1.microchip.com/downloads/en/DeviceDoc/ATSHA204A-Data-Sheet-40002025A.pdf
--- drivers/crypto/atmel-sha204a.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/crypto/atmel-sha204a.c +12 -7
@@ -18,6 +18,12 @@#include <linux/workqueue.h> #include "atmel-i2c.h" +/* +* According to review by Bill Cox [1], the ATSHA204 has very low entropy. +* [1] https://www.metzdowd.com/pipermail/cryptography/2014-December/023858.html +*/ +static const unsigned short atsha204_quality =1 ; +static void atmel_sha204a_rng_done (struct atmel_i2c_work_data *work_data,void *areq,int status) {
@@ -96,6 +102,7 @@ static int atmel_sha204a_probe(struct i2 const struct i2c_device_id *id) {struct atmel_i2c_client_priv *i2c_priv; +const unsigned short *quality;int ret; ret =atmel_i2c_probe (client, id);
@@ -109,11 +116,9 @@ static int atmel_sha204a_probe(struct i2 i2c_priv->hwrng.name =dev_name (&client->dev); i2c_priv->hwrng.read = atmel_sha204a_rng_read; -/* -* According to review by Bill Cox [1], this HWRNG has very low entropy. -* [1] https://www.metzdowd.com/pipermail/cryptography/2014-December/023858.html -*/ - i2c_priv->hwrng.quality =1 ; + quality =i2c_get_match_data (client); +if (quality) + i2c_priv->hwrng.quality = *quality; ret =devm_hwrng_register (&client->dev, &i2c_priv->hwrng);if (ret)
@@ -133,14 +138,14 @@ static void atmel_sha204a_remove(struct }static const struct of_device_id atmel_sha204a_dt_ids[]__maybe_unused = { - { .compatible ="atmel,atsha204" , }, + { .compatible ="atmel,atsha204" , .data = &atsha204_quality }, { .compatible ="atmel,atsha204a" , }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, atmel_sha204a_dt_ids);static const struct i2c_device_id atmel_sha204a_id[] = { - {"atsha204" }, + {"atsha204" , (kernel_ulong_t)&atsha204_quality }, {"atsha204a" }, {/* sentinel */ } };
Greg Kroah-Hartman
maintainerPATCH 1033/1067 nvmet: remove superfluous initialization
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaitanya Kulkarni <[email protected]>
[ Upstream commit 8d30528a170905ede9ab6ab81f229e441808590b ]
Remove superfluous initialization of status variable in nvmet_execute_admin_connect() and nvmet_execute_io_connect(), since it will get overwritten by nvmet_copy_from_sgl().
Stable-dep-of: 3a413ece2504 ("nvmet-auth: validate reply message payload bounds against transfer length")
--- drivers/nvme/target/fabrics-cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/target/fabrics-cmd.c +2 -2
@@ -209,7 +209,7 @@ static void nvmet_execute_admin_connect(struct nvmf_connect_command *c = &req->cmd->connect;struct nvmf_connect_data *d;struct nvmet_ctrl *ctrl =NULL ; -u16 status =0 ; +u16 status;int ret;if (!nvmet_check_transfer_len (req,sizeof (struct nvmf_connect_data )))
@@ -287,7 +287,7 @@ static void nvmet_execute_io_connect(strstruct nvmf_connect_data *d;struct nvmet_ctrl *ctrl;u16 qid =le16_to_cpu (c->qid); -u16 status =0 ; +u16 status;if (!nvmet_check_transfer_len (req,sizeof (struct nvmf_connect_data )))return ;
Greg Kroah-Hartman
maintainerPATCH 1034/1067 usb: gadget: f_fs: Tie read_buffer lifetime to ffs_epfile
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neill Kapron <[email protected]>
[ Upstream commit 8bdcf96eb135aebacac319667f87db034fb38406 ]
Currently, ffs_epfile_release unconditionally frees the endpoint's read_buffer when a file descriptor is closed. If userspace explicitly opens the endpoint multiple times and closes one, the read_buffer is destroyed. This can lead to silent data loss if other file descriptors are still actively reading from the endpoint.
By tying the lifetime of the read_buffer to the ffs_epfile structure itself (which is destroyed when the functionfs instance is torn down in ffs_epfiles_destroy), we eliminate the brittle dependency on open/release calls while correctly matching the conceptual lifetime of unread data on the hardware endpoint.
--- drivers/usb/gadget/function/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_fs.c +1 -1
@@ -1292,7 +1292,6 @@ ffs_epfile_release(struct inode *inode,ENTER (); -__ffs_epfile_read_buffer_free (epfile);ffs_data_closed (epfile->ffs);return 0 ;
@@ -1957,6 +1956,7 @@ static void ffs_epfiles_destroy(struct ffor (; count; --count, ++epfile) {BUG_ON (mutex_is_locked (&epfile->mutex)); +__ffs_epfile_read_buffer_free (epfile);if (epfile->dentry) {d_delete (epfile->dentry);dput (epfile->dentry);
Greg Kroah-Hartman
maintainerPATCH 1035/1067 crypto: qat - fix restarting state leak on allocation failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 7d3ed20f7e46b3e991936fedd7a28f3ff4aec8d2 ]
In adf_dev_aer_schedule_reset(), ADF_STATUS_RESTARTING is set before allocating reset_data. If the allocation fails, the function returns -ENOMEM without queuing reset work, so nothing ever clears the bit. This leaves the device permanently stuck in the restarting state, causing all subsequent reset attempts to be silently skipped.
Fix this by using test_and_set_bit() to atomically claim the RESTARTING state, preventing duplicate reset scheduling races under concurrent fatal error reporting. If the subsequent allocation fails, clear the bit to restore clean state so future reset attempts can proceed.
--- drivers/crypto/qat/qat_common/adf_aer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/adf_aer.c +4 -3
@@ -116,13 +116,14 @@ static int adf_dev_aer_schedule_reset(ststruct adf_reset_dev_data *reset_data;if (!adf_dev_started (accel_dev) || -test_bit (ADF_STATUS_RESTARTING , &accel_dev->status)) +test_and_set_bit (ADF_STATUS_RESTARTING , &accel_dev->status))return 0 ; -set_bit (ADF_STATUS_RESTARTING , &accel_dev->status); reset_data =kzalloc (sizeof (*reset_data),GFP_KERNEL ); -if (!reset_data) +if (!reset_data) { +clear_bit (ADF_STATUS_RESTARTING , &accel_dev->status);return -ENOMEM ; + } reset_data->accel_dev = accel_dev;init_completion (&reset_data->compl); reset_data->mode = mode;
Greg Kroah-Hartman
maintainerPATCH 1036/1067 btrfs: check and set EXTENT_DELALLOC_NEW before clearing EXTENT_DELALLOC
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 95ee2231896d5f2a31760411429075a99d6045a7 ]
[WARNING]
When running test cases with injected errors or shutdown, e.g. generic/388 or generic/475, there is a chance that the following kernel warning is triggered:
BTRFS info (device dm-2): first mount of filesystem d8a19a28-3232-4809-b0df-38df83e71bff BTRFS info (device dm-2): using crc32c checksum algorithm
BTRFS info (device dm-2): checking UUID tree
BTRFS info (device dm-2): turning on async discard
BTRFS info (device dm-2): enabling free space tree
BTRFS critical (device dm-2 state E): emergency shutdown
------------[ cut here ]------------ WARNING: extent_io.c:1742 at extent_writepage_io+0x437/0x520 [btrfs], CPU#2: kworker/u43:2/651591 CPU: 2 UID: 0 PID: 651591 Comm: kworker/u43:2 Tainted: G W OE 7.0.0-rc6-custom+ #365 PREEMPT(full) 5804053f02137e627472d94b5128cc9fcb110e88 RIP: 0010:extent_writepage_io+0x437/0x520 [btrfs] Call Trace: <TASK> extent_write_cache_pages+0x2a5/0x820 [btrfs 70299925d0856939e93b17d480651713b3cbba58] btrfs_writepages+0x74/0x130 [btrfs 70299925d0856939e93b17d480651713b3cbba58] do_writepages+0xd0/0x160 __writeback_single_inode+0x42/0x340 writeback_sb_inodes+0x22d/0x580 wb_writeback+0xc6/0x360 wb_workfn+0xbd/0x470 process_one_work+0x198/0x3b0 worker_thread+0x1c8/0x330 kthread+0xee/0x120 ret_from_fork+0x2a6/0x330 ret_from_fork_asm+0x11/0x20 </TASK> ---[ end trace 0000000000000000 ]--- BTRFS error (device dm-2 state E): root 5 ino 259 folio 1323008 is marked dirty without notifying the fs BTRFS error (device dm-2 state E): failed to submit blocks, root=5 inode=259 folio=1323008 submit_bitmap=0: -117 BTRFS info (device dm-2 state E): last unmount of filesystem d8a19a28-3232-4809-b0df-38df83e71bff
[CAUSE]
Inside btrfs we have the following pattern in several locations, for example inside btrfs_dirty_folio():
btrfs_clear_extent_bit(&inode->io_tree, start_pos, end_of_last_block, EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, cached); ret = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block, extra_bits, cached); if (ret) return ret;
However btrfs_set_extent_delalloc() can return IO errors other than -ENOMEM through the following callchain:
btrfs_set_extent_delalloc()
\- btrfs_find_new_delalloc_bytes()
\- btrfs_get_extent()
\- btrfs_lookup_file_extent()
\- btrfs_search_slot()When such IO error happened, the previous btrfs_clear_extent_bit() has cleared the EXTENT_DELALLOC for the range, and we're expecting btrfs_set_extent_delalloc() to re-set EXTENT_DELALLOC.
But since btrfs_set_extent_delalloc() failed before btrfs_set_extent_bit(), EXTENT_DELALLOC flag is no longer present.
And if the folio range is dirty before entering btrfs_set_extent_delalloc(), we got a dirty folio but no EXTENT_DELALLOC flag now.
Then we hit the folio writeback:
extent_writepage()
|- writepage_delalloc() | No ordered extent is created, as there is no EXTENT_DELALLOC set | for the folio range. | This also means the folio has no ordered flag set. | |- extent_writepage_io()
\- if (unlikely(!folio_test_ordered(folio))
Now we hit the warning.
[FIX]
Introduce a new helper, btrfs_reset_extent_delalloc() to replace the currently open-coded btrfs_clear_extent_bit() + btrfs_set_extent_delalloc() combination.
Instead of calling btrfs_clear_extent_bit() first, update EXTENT_DELALLOC_NEW first, as that part can fail due to metadata IO, meanwhile btrfs_clear_extent_bit() and btrfs_set_extent_bit() won't return any error but retry memory allocation until succeeded.
This allows us to fail early without clearing EXTENT_DELALLOC bit, so even if that new btrfs_reset_extent_delalloc() failed before touching EXTENT_DELALLOC, the existing dirty range will still have their old EXTENT_DELALLOC flag present, thus avoid the warning.
--- fs/btrfs/ctree.h | 2 + fs/btrfs/file.c | 12 +------- fs/btrfs/inode.c | 73 ++++++++++++++++++++++++++++++++++++++--------------- fs/btrfs/reflink.c | 5 --- 4 files changed, 58 insertions(+), 34 deletions(-)
fs/btrfs/ctree.h +2 -0
@@ -3327,6 +3327,8 @@ int btrfs_start_delalloc_roots(struct btint btrfs_set_extent_delalloc (struct btrfs_inode *inode,u64 start,u64 end,unsigned int extra_bits,struct extent_state **cached_state); +int btrfs_reset_extent_delalloc (struct btrfs_inode *inode,u64 start,u64 end, +unsigned int extra_bits,struct extent_state **cached_state);struct btrfs_new_inode_args {/* Input */ struct inode *dir;
fs/btrfs/file.c +2 -10
@@ -144,16 +144,8 @@ int btrfs_dirty_pages(struct btrfs_inode end_of_last_block = start_pos + num_bytes -1 ; -/* -* The pages may have already been dirty, clear out old accounting so -* we can set things up properly -*/ -clear_extent_bit (&inode->io_tree, start_pos, end_of_last_block, -EXTENT_DELALLOC |EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG , - cached); - - err =btrfs_set_extent_delalloc (inode, start_pos, end_of_last_block, - extra_bits, cached); + err =btrfs_reset_extent_delalloc (inode, start_pos, end_of_last_block, + extra_bits, cached);if (err)return err;
fs/btrfs/inode.c +53 -20
97 lines not on this page · raw message
fs/btrfs/reflink.c +1 -4
@@ -90,10 +90,7 @@ static int copy_inline_to_page(struct btif (ret <0 ) goto out_unlock; -clear_extent_bit (&inode->io_tree, file_offset, range_end, -EXTENT_DELALLOC |EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG , -NULL ); - ret =btrfs_set_extent_delalloc (inode, file_offset, range_end,0 ,NULL ); + ret =btrfs_reset_extent_delalloc (inode, file_offset, range_end,0 ,NULL );if (ret) goto out_unlock;
Greg Kroah-Hartman
maintainerPATCH 1037/1067 crypto: qat - validate RSA CRT component lengths
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Giovanni Cabiddu <[email protected]>
[ Upstream commit b3ac78756588059729b9195fcc9f4b37d54057a5 ]
The generic RSA key parser (rsa_helper.c) bounds each CRT component (p, q, dp, dq, qinv) by the modulus size n_sz, but qat_rsa_setkey_crt() allocates half-size DMA buffers (key_sz / 2) and right-aligns each component with:
memcpy(dst + half_key_sz - len, src, len)
When a CRT component is larger than half_key_sz the subtraction underflows and memcpy writes past the DMA buffer, causing memory corruption.
Add a len > half_key_sz check next to the existing !len check for each of the five CRT components so the driver falls back to the non-CRT path instead of writing out of bounds.
--- drivers/crypto/qat/qat_common/qat_asym_algs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/crypto/qat/qat_common/qat_asym_algs.c +5 -5
@@ -1032,7 +1032,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->p; len = rsa_key->p_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto err; ctx->p =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_p,GFP_KERNEL );if (!ctx->p)
@@ -1043,7 +1043,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->q; len = rsa_key->q_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto free_p; ctx->q =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_q,GFP_KERNEL );if (!ctx->q)
@@ -1054,7 +1054,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->dp; len = rsa_key->dp_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto free_q; ctx->dp =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_dp,GFP_KERNEL );
@@ -1066,7 +1066,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->dq; len = rsa_key->dq_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto free_dp; ctx->dq =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_dq,GFP_KERNEL );
@@ -1078,7 +1078,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->qinv; len = rsa_key->qinv_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto free_dq; ctx->qinv =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_qinv,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 1038/1067 audit: add audit_log_nf_skb helper function
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Robaina <[email protected]>
[ Upstream commit f19590b07cb620be1fcd5474c49515e21a05d406 ]
Netfilter code (net/netfilter/nft_log.c and net/netfilter/xt_AUDIT.c) have to be kept in sync. Both source files had duplicated versions of audit_ip4() and audit_ip6() functions, which can result in lack of consistency and/or duplicated work.
This patch adds a helper function in audit.c that can be called by netfilter code commonly, aiming to improve maintainability and consistency.
Stable-dep-of: 65dfde57d1e2 ("audit: fix potential integer overflow in audit_log_n_hex()")
--- include/linux/audit.h | 8 +++++ kernel/audit.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++ net/netfilter/nft_log.c | 58 ------------------------------------------ net/netfilter/xt_AUDIT.c | 58 ------------------------------------------ 4 files changed, 74 insertions(+), 114 deletions(-)
include/linux/audit.h +8 -0
@@ -177,6 +177,8 @@ extern void audit_log_lost(const chextern int audit_log_task_context (struct audit_buffer *ab);extern void audit_log_task_info (struct audit_buffer *ab); +extern int audit_log_nf_skb (struct audit_buffer *ab, +const struct sk_buff *skb,u8 nfproto);extern int audit_update_lsm_rules (void );
@@ -242,6 +244,12 @@ static inline int audit_log_task_contextstatic inline void audit_log_task_info (struct audit_buffer *ab) { } +static inline int audit_log_nf_skb (struct audit_buffer *ab, +const struct sk_buff *skb,u8 nfproto) +{ +return 0 ; +} +static inline kuid_t audit_get_loginuid (struct task_struct *tsk) {return INVALID_UID ;
kernel/audit.c +64 -0
76 lines not on this page · raw message
net/netfilter/nft_log.c +1 -57
74 lines not on this page · raw message
net/netfilter/xt_AUDIT.c +1 -57
74 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 1039/1067 audit: fix potential integer overflow in audit_log_n_hex()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Robaina <[email protected]>
[ Upstream commit 65dfde57d1e29ce2b76fc23dd565eccd5c0bc0f0 ]
The function calculates new_len as len << 1 for hex encoding. This has two overflow risks: the shift itself can overflow when len is large, and the result can be truncated when assigned to new_len (declared as int) from the size_t calculation.
Fix by using check_shl_overflow() to catch shift overflow and changing new_len and loop counter i to size_t to prevent truncation.
--- kernel/audit.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/audit.c +9 -2
@@ -61,6 +61,7 @@#include <net/netns/generic.h> #include <net/ip.h> #include <net/ipv6.h> +#include <linux/overflow.h> #include "audit.h"
@@ -2035,7 +2036,8 @@ void audit_log_format(struct audit_buffevoid audit_log_n_hex (struct audit_buffer *ab,const unsigned char *buf,size_t len) { -int i, avail, new_len; +int avail; +size_t i, new_len;unsigned char *ptr;struct sk_buff *skb;
@@ -2045,7 +2047,12 @@ void audit_log_n_hex(struct audit_bufferBUG_ON (!ab->skb); skb = ab->skb; avail =skb_tailroom (skb); - new_len = len<<1 ; + +if (check_shl_overflow (len,1 , &new_len)) { +audit_log_format (ab,"?" ); +return ; + } +if (new_len >= avail) {/* Round the buffer request up to the next multiple */ new_len =AUDIT_BUFSIZ *(((new_len-avail)/AUDIT_BUFSIZ ) +1 );
Greg Kroah-Hartman
maintainerPATCH 1040/1067 regulator: scmi: Simplify with scoped for each OF child loop
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 99cf5db9cdd39136fd5dbd10bda833aa0f870452 ]
Use scoped for_each_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler.
Stable-dep-of: fa11039d6cdf ("regulator: scmi: fix of_node refcount leak in scmi_regulator_probe()")
--- drivers/regulator/scmi-regulator.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/regulator/scmi-regulator.c +3 -5
@@ -298,7 +298,7 @@ static int process_scmi_regulator_of_nodstatic int scmi_regulator_probe (struct scmi_device *sdev) {int d, ret, num_doms; -struct device_node *np, *child; +struct device_node *np;const struct scmi_handle *handle = sdev->handle;struct scmi_regulator_info *rinfo;struct scmi_protocol_handle *ph;
@@ -346,13 +346,11 @@ static int scmi_regulator_probe(struct s*/ of_node_get (handle->dev->of_node); np =of_find_node_by_name (handle->dev->of_node,"regulators" ); -for_each_child_of_node (np, child) { +for_each_child_of_node_scoped (np, child) { ret =process_scmi_regulator_of_node (sdev, ph, child, rinfo);/* abort on any mem issue */ -if (ret == -ENOMEM ) { -of_node_put (child); +if (ret == -ENOMEM )return ret; - } }of_node_put (np);/*
Greg Kroah-Hartman
maintainerPATCH 1041/1067 regulator: scmi: fix of_node refcount leak in scmi_regulator_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit fa11039d6cdff84584a3ef8cc1f5e1b56e045da2 ]
scmi_regulator_probe() calls of_find_node_by_name() which takes a reference on the returned device node. On the error path where process_scmi_regulator_of_node() fails, the function returns without calling of_node_put() on the child node, leaking the reference.
Add of_node_put(np) on the error path to properly release the reference.
--- drivers/regulator/scmi-regulator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/regulator/scmi-regulator.c +3 -1
@@ -349,8 +349,10 @@ static int scmi_regulator_probe(struct sfor_each_child_of_node_scoped (np, child) { ret =process_scmi_regulator_of_node (sdev, ph, child, rinfo);/* abort on any mem issue */ -if (ret == -ENOMEM ) +if (ret == -ENOMEM ) { +of_node_put (np);return ret; + } }of_node_put (np);/*
Greg Kroah-Hartman
maintainerPATCH 1042/1067 btrfs: fix false IO failure after falling back to buffered write
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 66ff4d366e7eb4d31813d2acabf3af512ce03aa5 ]
[BUG]
The test case generic/362 will fail with "nodatasum" mount option (*):
MOUNT_OPTIONS -- -o nodatasum /dev/mapper/test-scratch1 /mnt/scratch
# generic/362 0s ... - output mismatch (see /home/adam/xfstests/results//generic/362.out.bad) # --- tests/generic/362.out 2024-08-24 15:31:37.200000000 +0930 # +++ /home/adam/xfstests/results//generic/362.out.bad 2026-05-27 10:21:17.574771567 +0930 # @@ -1,2 +1,3 @@ # QA output created by 362 # +First write failed: Input/output error # Silence is golden # ...
*: If the test case has been executed before with default data checksum, the failure will not reproduce. Need the following fix to make it reliably reproducible:
https://lore.kernel.org/linux-btrfs/[email protected]/
[CAUSE]
Inside __iomap_dio_rw(), the -EFAULT/-ENOTBLK error is not directly returned. Thus we never got an error pointer from __iomap_dio_rw().
The call chain looks like this:
btrfs_direct_write()
|- btrfs_dio_write()
|- __iomap_dio_rw()
| |- iomap_iter()
| | |- btrfs_dio_iomap_begin()
| | Now an ordered extent is allocated for the 4K write.
| |
| |- iomi.status = iomap_dio_iter()
| | Where iomap_dio_iter() returned -EFAULT.
| |
| |- ret = iomap_iter()
| | |- btrfs_dio_iomap_end()
| | | |- btrfs_finish_ordered_extent(uptodate = false)
| | | | |- can_finish_ordered_extent()
| | | | |- btrfs_mark_ordered_extent_error()
| | | | |- mapping_set_error()
| | | | Now the address space is marked error.
| | | | return -ENOTBLK
| | |- return -ENOTBLK
| |- if (ret == -ENOTBLK) { ret = 0; }
| Now the return value is reset to 0.
| Thus no error pointer will be returned.
|
|- ret = iomap_dio_complete()
| Since no byte is submitted, @ret is 0.
|
|- Fallback to buffered IO
| And the buffered write finished without error
|
|- filemap_fdatawait_range() |- filemap_check_errors()
The previous error is recorded, thus an error is returned
However the buffered write is properly submitted and finished, the error is from the btrfs_finish_ordered_extent() call with @uptodate = false.
[FIX]
When a short dio write happened, any range that is submitted will have btrfs_extract_ordered_extent() to be called, thus the submitted range will always have an OE just covering the submitted range.
The remaining OE range is never submitted, thus they should be treated as truncated, not an error. So that we can properly reclaim and not insert an unnecessary file extent item, without marking the mapping as error.
Extract a helper, btrfs_mark_ordered_extent_truncated(), and utilize that helper to mark the direct IO ordered extent as truncated, so it won't cause failure for the later buffered fallback.
[REASON FOR NO FIXES TAG]
The bug itself is pretty old, at commit f85781fb505e ("btrfs: switch to iomap for direct IO") we're already passing @uptodate=false finishing the OE.
But at that time OE with IOERR won't call mapping_set_error(), so it's not exposed.
Later commit d61bec08b904 ("btrfs: mark ordered extent and inode with error if we fail to finish") finally exposed the bug, but that commit is doing a correct job, not the root cause.
Anyway the bug is very old, dating back to 5.1x days, thus only CC to stable.
--- fs/btrfs/inode.c | 33 +++++++++++++++++++++++++-------- fs/btrfs/ordered-data.c | 12 ++++++++++++ fs/btrfs/ordered-data.h | 2 ++ 3 files changed, 39 insertions(+), 8 deletions(-)
fs/btrfs/inode.c +25 -8
@@ -8031,12 +8031,33 @@ static int btrfs_dio_iomap_end(struct inif (submitted < length) { pos += submitted; length -= submitted; -if (write) +if (write) { +struct btrfs_ordered_extent *ordered; + +/* +* We have a short write, and the ordered extent is +* not split at submission time on this tree, so it +* may cover both the submitted range and the range +* that was never submitted. +* +* Truncate the ordered extent to the part that was +* submitted properly, so the never submitted range +* is reclaimed without inserting a file extent item +* for it and without marking it as an IO error. +*/ + ordered =btrfs_lookup_ordered_extent (BTRFS_I (inode), + pos); +if (ordered) { +btrfs_mark_ordered_extent_truncated (ordered, + pos - ordered->file_offset); +btrfs_put_ordered_extent (ordered); + }btrfs_mark_ordered_io_finished (BTRFS_I (inode),NULL , - pos, length, false); -else + pos, length, true); + }else {unlock_extent (&BTRFS_I (inode)->io_tree, pos, pos + length -1 ,NULL ); + } ret = -ENOTBLK ; }
@@ -8560,11 +8581,7 @@ static void btrfs_invalidate_folio(strucEXTENT_LOCKED |EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, &cached_state); -spin_lock_irq (&inode->ordered_tree.lock); -set_bit (BTRFS_ORDERED_TRUNCATED , &ordered->flags); - ordered->truncated_len =min (ordered->truncated_len, - cur - ordered->file_offset); -spin_unlock_irq (&inode->ordered_tree.lock); +btrfs_mark_ordered_extent_truncated (ordered, cur - ordered->file_offset);/* * If the ordered extent has finished, we're safe to delete all
fs/btrfs/ordered-data.c +12 -0
@@ -279,6 +279,18 @@ void btrfs_add_ordered_sum(struct btrfs_spin_unlock_irq (&tree->lock); } +void btrfs_mark_ordered_extent_truncated (struct btrfs_ordered_extent *ordered, +u64 truncate_len) +{ +struct btrfs_inode *inode =BTRFS_I (ordered->inode); + +ASSERT (truncate_len <= ordered->num_bytes); +spin_lock_irq (&inode->ordered_tree.lock); +set_bit (BTRFS_ORDERED_TRUNCATED , &ordered->flags); + ordered->truncated_len =min (ordered->truncated_len, truncate_len); +spin_unlock_irq (&inode->ordered_tree.lock); +} +static void finish_ordered_fn (struct btrfs_work *work) {struct btrfs_ordered_extent *ordered_extent;
fs/btrfs/ordered-data.h +2 -0
@@ -209,6 +209,8 @@ void btrfs_lock_and_flush_ordered_range(bool btrfs_try_lock_ordered_range (struct btrfs_inode *inode,u64 start,u64 end);int btrfs_split_ordered_extent (struct btrfs_ordered_extent *ordered,u64 pre,u64 post); +void btrfs_mark_ordered_extent_truncated (struct btrfs_ordered_extent *ordered, +u64 truncate_len);int __init ordered_data_init (void );void __cold ordered_data_exit (void );
Greg Kroah-Hartman
maintainerPATCH 1043/1067 btrfs: fix incorrect buffered IO fallback for append direct writes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit ff66fe6662330226b3f486014c375538d91c44aa ]
[BUG]
With the previous bug of short direct writes fixed, test case generic/362 (*) still fails with the following error with nodatasum mount option:
# generic/362 0s ... - output mismatch (see /home/adam/xfstests/results//generic/362.out.bad) # - output mismatch (see /home/adam/xfstests/results//generic/362.out.bad) # --- tests/generic/362.out 2024-08-24 15:31:37.200000000 +0930 # +++ /home/adam/xfstests/results//generic/362.out.bad 2026-05-27 10:13:09.072485767 +0930 # @@ -1,2 +1,3 @@ # QA output created by 362 # +Wrong file size after first write, got 8192 expected 4096 # Silence is golden # ...
*: If the test case has been executed before with default data checksum, the failure will not reproduce. Need the following fix to make it reliably reproducible:
https://lore.kernel.org/linux-btrfs/[email protected]/
[CAUSE]
Inside btrfs_dio_iomap_begin() for a direct write, we increase the isize if it's beyond the current isize.
But if the direct io finished short, we do not revert the isize to the previous value nor to the short write end.
Then if we need to fall back to buffered writes, and the write has IOCB_APPEND flag, then the buffered write will be positioned at the incorrect isize.
The call chain looks like this:
btrfs_direct_write(pos=0, length=4K)
|- __iomap_dio_rw()
| |- iomap_iter()
| | |- btrfs_dio_iomap_begin()
| | |- btrfs_get_blocks_direct_write()
| | |- i_size_write()
| | Which updates the isize to the write end (4K).
| |
| |- iomap_dio_iter()
| | Failed with -EFAULT on the first page.
| |
| |- iomap_iter()
| | |- btrfs_dio_iomap_end()
| | Detects a short write, return -ENOTBLK
| |- if (ret == -ENOTBLK) { ret = 0;}
| Which resets the return value.
|
|- ret = iomap_dio_complet()
| Which returns 0.
|
|- btrfs_buffered_write(iocb, from); |- generic_write_checks()
|- iocb->ki_pos = i_size_read()
Which is still the new size (4K), other than the original isize 0.
[FIX]
Introduce the following btrfs_dio_data members:
- old_isize
- updated_isize
If the direct write has enlarged the isize.
Then if we got a short write, and btrfs_dio_data::updated_isize is set, revert to the correct isize based on old_isize and current file position.
And here we call i_size_write() without holding an extent lock, which is a very special case that we're safe to do:
- Only a single writer can be enlarging isize Enlarging isize will take the exclusive inode lock.
- Buffered readers need to wait for the OE we're holding Buffered readers will lock extent and wait for OE of the folio range. Sometimes we can skip the OE wait, but since all page cache is invalidated, the OE wait can not be skipped.
But I do not think this is the most elegant solution, nor covers all cases. E.g. if the bio is submitted but IO failed, we are unable to do the revert.
I believe the more elegant one would be extend the EXTENT_DIO_LOCKED lifespan for direct writes, so that we can update the isize when a write beyond EOF finished successfully.
However that change is too huge for a small bug fix. So only implement the minimal partial fix for now.
[REASON FOR NO FIXES TAG]
The bug is again very old, before commit f85781fb505e ("btrfs: switch to iomap for direct IO") we are already increasing isize without a proper rollback for short writes.
Thus only a CC to stable.
--- fs/btrfs/inode.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +42 -1
@@ -63,9 +63,11 @@ struct btrfs_iget_args {struct btrfs_dio_data {ssize_t submitted; +loff_t old_isize;struct extent_changeset *data_reserved;bool data_space_reserved;bool nocow_done; +bool updated_isize; };struct btrfs_dio_private {
@@ -7635,6 +7637,7 @@ static int btrfs_get_blocks_direct_writebool space_reserved = false;u64 len = *lenp;u64 prev_len; +loff_t old_isize;int ret =0 ;/*
@@ -7750,8 +7753,14 @@ static int btrfs_get_blocks_direct_write* Need to update the i_size under the extent lock so buffered * readers will get the updated i_size when we unlock. */ -if (start + len >i_size_read (inode)) + old_isize =i_size_read (inode); +if (start + len > old_isize) { +if (!dio_data->updated_isize) { + dio_data->old_isize = old_isize; + dio_data->updated_isize = true; + }i_size_write (inode, start + len); + } out:if (ret && space_reserved) {btrfs_delalloc_release_extents (BTRFS_I (inode), len);
@@ -8035,6 +8044,38 @@ static int btrfs_dio_iomap_end(struct instruct btrfs_ordered_extent *ordered;/* +* Got a short write and have updated the isize, need to +* revert the isize change. +* +* Normally we need to update isize with extent lock hold, +* but we're safe due to the following factors: +* +* - Only a single writer can be enlarging isize +* Enlarging isize will take the exclusive inode lock. +* +* - Buffered readers need to wait for the OE we're holding +* Buffered readers will lock extent and wait for OE +* of the folio range, and since page cache is invalidated +* the OE wait can not be skipped. +* +* So here we are safe to revert the isize before +* finishing the OE, and no reader of the remaining range +* can see the enlarged size. +* +* TODO: Extend the DIO_LOCKED lifespan for direct writes, +* and only enlarge isize after a successful write. +*/ +if (dio_data->updated_isize) { +u64 new_isize; + +if (submitted ==0 ) + new_isize = dio_data->old_isize; +else + new_isize =max (dio_data->old_isize, pos); +i_size_write (inode, new_isize); + dio_data->updated_isize = false; + } +/* * We have a short write, and the ordered extent is * not split at submission time on this tree, so it * may cover both the submitted range and the range
Greg Kroah-Hartman
maintainerPATCH 1044/1067 mm/damon/core: make charge_addr_from aware of end-address exclusivity
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 5a2d162e22bf33eb89d53e802d0fc1ec422e19b6 upstream.
DAMON region end address is exclusive one, but charge_addr_from is assigned assuming the end address is inclusive. As a result, DAMOS action to next up to min_region_sz memory can be skipped. This is quite negligible user impact. But, the bug is a bug that can be very simply fixed. Fix the wrong assignment to respect the exclusiveness of the address.
The issue was discovered [1] by Sashiko.
--- mm/damon/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/core.c +1 -1
@@ -803,7 +803,7 @@ static void damon_do_apply_schemes(struc quota->charged_sz += sz;if (quota->esz && quota->charged_sz >= quota->esz) { quota->charge_target_from = t; - quota->charge_addr_from = r->ar.end +1 ; + quota->charge_addr_from = r->ar.end; } }if (s->action !=DAMOS_STAT )
Greg Kroah-Hartman
maintainerPATCH 1045/1067 mm/damon/sysfs-schemes: fix dir put orders in access_pattern_add_dirs()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit d58fdbe37a829fd2e5803dd4e5a72992dd8c5368 upstream.
Patch series "mm/damon/sysfs-schemes: fix wrong directories put orders in error paths".
Error paths of damon_sysfs_access_pattern_add_dirs() and damon_sysfs_scheme_add_dirs() functions put references to directories in wrong orders. As a result, uninitialized memory dereference and/or memory leak can happen. Fix those.
This patch (of 2):
In access_pattern_add_dirs(), error handling path puts references starting from setup failed directories. If the failure happpened from the initial allication in the setup functions, uninitialized memory dereference happen. The allocation failures will not commonly happen, but the consequence is quite bad. Fix the wrong reference put orders.
The issue was discovered [1] by Sashiko.
--- mm/damon/sysfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
mm/damon/sysfs.c +3 -6
@@ -679,22 +679,19 @@ static int damon_sysfs_access_pattern_ad err =damon_sysfs_access_pattern_add_range_dir (access_pattern, &access_pattern->sz,"sz" );if (err) - goto put_sz_out; +return err; err =damon_sysfs_access_pattern_add_range_dir (access_pattern, &access_pattern->nr_accesses,"nr_accesses" );if (err) - goto put_nr_accesses_sz_out; + goto put_sz_out; err =damon_sysfs_access_pattern_add_range_dir (access_pattern, &access_pattern->age,"age" );if (err) - goto put_age_nr_accesses_sz_out; + goto put_nr_accesses_sz_out;return 0 ; -put_age_nr_accesses_sz_out: -kobject_put (&access_pattern->age->kobj); - access_pattern->age =NULL ; put_nr_accesses_sz_out:kobject_put (&access_pattern->nr_accesses->kobj); access_pattern->nr_accesses =NULL ;
Greg Kroah-Hartman
maintainerPATCH 1046/1067 KVM: Move kvm_io_bus_get_dev() locking responsibilities to callers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 3a07249981629ace483ebbef81ef6b34c2d2afec upstream.
kvm_io_bus_get_dev() returns a device that is only matched by the address, and nothing else. This can cause a lifetime issue if the matched device is not the expected type, as by the time the caller can introspect the object, it might be gone (the srcu lock having been dropped).
Given that there is only a single user of this helper, the simplest option is to move the locking responsibility to the caller, which can keep the srcu lock held for as long as it wants.
Note that this aligns with other kvm_io_bus*() helpers, which already require the srcu lock to be held by the callers.
--- arch/arm64/kvm/vgic/vgic-its.c | 2 ++ virt/kvm/kvm_main.c | 16 +++++----------- 2 files changed, 7 insertions(+), 11 deletions(-)
arch/arm64/kvm/vgic/vgic-its.c +2 -0
@@ -713,6 +713,8 @@ struct vgic_its *vgic_msi_to_its(struct address = (u64 )msi->address_hi <<32 | msi->address_lo; +guard (srcu)(&kvm->srcu); + kvm_io_dev =kvm_io_bus_get_dev (kvm,KVM_MMIO_BUS , address);if (!kvm_io_dev)return ERR_PTR (-EINVAL );
virt/kvm/kvm_main.c +5 -11
@@ -5465,25 +5465,19 @@ struct kvm_io_device *kvm_io_bus_get_dev gpa_t addr) {struct kvm_io_bus *bus; -int dev_idx, srcu_idx; -struct kvm_io_device *iodev =NULL ; +int dev_idx; - srcu_idx =srcu_read_lock (&kvm->srcu); +lockdep_assert_held (&kvm->srcu); bus =srcu_dereference (kvm->buses[bus_idx], &kvm->srcu);if (!bus) - goto out_unlock; +return NULL ; dev_idx =kvm_io_bus_get_first_dev (bus, addr,1 );if (dev_idx <0 ) - goto out_unlock; +return NULL ; - iodev = bus->range[dev_idx].dev; - -out_unlock: -srcu_read_unlock (&kvm->srcu, srcu_idx); - -return iodev; +return bus->range[dev_idx].dev; }EXPORT_SYMBOL_GPL (kvm_io_bus_get_dev);
Greg Kroah-Hartman
maintainerPATCH 1047/1067 seqlock: fix scoped_seqlock_read kernel-doc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
commit f88a31308db6a856229150039b0f56d59696ed31 upstream.
Eliminate all kernel-doc warnings in seqlock.h:
- correct the macro to have "()" immediately following the macro name
- don't include the macro parameters in the short description (first line)
- make the parameter names in the comments match the actual macro parameter names.
- use "::" for the Example
WARNING: include/linux/seqlock.h:1341 This comment starts with '/**', but isn't a kernel-doc comment. * scoped_seqlock_read (lock, ss_state) - execute the read side critical
Documentation/locking/seqlock:242: include/linux/seqlock.h:1351: WARNING:
Definition list ends without a blank line; unexpected unindent. [docutils]
Warning: include/linux/seqlock.h:1357 function parameter '_seqlock' not described in 'scoped_seqlock_read'
Warning: include/linux/seqlock.h:1357 function parameter '_target' not described in 'scoped_seqlock_read'
--- include/linux/seqlock.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
include/linux/seqlock.h +7 -8
@@ -1357,15 +1357,14 @@ __scoped_seqlock_next(struct ss_tmp *sst __scoped_seqlock_next(&_s, _seqlock, _target))/** -* scoped_seqlock_read (lock, ss_state) - execute the read side critical -* section without manual sequence -* counter handling or calls to other -* helpers -* @lock: pointer to seqlock_t protecting the data -* @ss_state: one of {ss_lock, ss_lock_irqsave, ss_lockless} indicating -* the type of critical read section +* scoped_seqlock_read() - execute the read-side critical section +* without manual sequence counter handling +* or calls to other helpers +* @_seqlock: pointer to seqlock_t protecting the data +* @_target: an enum ss_state: one of {ss_lock, ss_lock_irqsave, ss_lockless} +* indicating the type of critical read section * -* Example: +* Example:: * * scoped_seqlock_read (&lock, ss_lock) { * // read-side critical section
Greg Kroah-Hartman
maintainerPATCH 1048/1067 Bluetooth: L2CAP: Fix regressions caused by reusing ident
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
commit 761fb8ec8778f0caf2bba5a41e3cff1ea86974f3 upstream.
This attempt to fix regressions caused by reusing ident which apparently is not handled well on certain stacks causing the stack to not respond to requests, so instead of simple returning the first unallocated id this stores the last used tx_ident and then attempt to use the next until all available ids are exausted and then cycle starting over to 1.
--- include/net/bluetooth/l2cap.h | 1 + net/bluetooth/l2cap_core.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-)
include/net/bluetooth/l2cap.h +1 -0
@@ -654,6 +654,7 @@ struct l2cap_conn {struct sk_buff *rx_skb;__u32 rx_len;struct ida tx_ida; +__u8 tx_ident;struct sk_buff_head pending_rx;struct work_struct pending_rx_work;
net/bluetooth/l2cap_core.c +26 -3
@@ -960,16 +960,39 @@ int l2cap_chan_check_security(struct l2cstatic int l2cap_get_ident (struct l2cap_conn *conn) { +u8 max; +int ident; +/* LE link does not support tools like l2ping so use the full range */ if (conn->hcon->type ==LE_LINK ) -return ida_alloc_range (&conn->tx_ida,1 ,255 ,GFP_ATOMIC ); - + max =255 ;/* Get next available identificator. * 1 - 128 are used by kernel. * 129 - 199 are reserved. * 200 - 254 are used by utilities like l2ping, etc. */ -return ida_alloc_range (&conn->tx_ida,1 ,128 ,GFP_ATOMIC ); +else + max =128 ; + +/* Allocate ident using min as last used + 1 (cyclic) */ + ident =ida_alloc_range (&conn->tx_ida,READ_ONCE (conn->tx_ident) +1 , + max,GFP_ATOMIC ); +/* Force min 1 to start over */ +if (ident <=0 ) { + ident =ida_alloc_range (&conn->tx_ida,1 , max,GFP_ATOMIC ); +if (ident <=0 ) { +/* If all idents are in use, log an error, this is +* extremely unlikely to happen and would indicate a bug +* in the code that idents are not being freed properly. +*/ +BT_ERR ("Unable to allocate ident: %d" , ident); +return 0 ; + } + } + +WRITE_ONCE (conn->tx_ident, ident); + +return ident; } static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len,
Greg Kroah-Hartman
maintainerPATCH 1049/1067 Bluetooth: L2CAP: fix tx ident leak for commands without a response
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stig Hornang <[email protected]>
commit 6e1930ece855a4c256f1c7e6632d634cfb9888b5 upstream.
Commit 6c3ea155e5ee ("Bluetooth: L2CAP: Fix not tracking outstanding TX ident") changed ident allocation to use an IDA, releasing idents in l2cap_put_ident() when the matching response command is received.
But identifiers allocated for commands that have no response defined are never released. In particular L2CAP_LE_CREDITS is sent repeatedly for the lifetime of an LE CoC channel, so a peer streaming data to the host exhausts the 1-255 ident range after 254 credit packets. From then on l2cap_get_ident() fails:
kernel: Bluetooth: Unable to allocate ident: -28
and every subsequent L2CAP_LE_CREDITS packet is sent with ident 0, which is invalid (Core Spec, Vol 3, Part A, Section 4: "Signaling identifier 0x00 is an invalid identifier and shall never be used in any command"). Remote stacks that validate the ident drop these commands, never receive new credits, and the channel stalls permanently. With default socket buffers this happens after roughly 0.5 MB of received data (the exact amount depends on the socket receive buffer):
< ACL Data TX: Handle 2048 flags 0x00 dlen 12
LE L2CAP: LE Flow Control Credit (0x16) ident 0 len 4
Source CID: 64
Credits: 1
Release the ident immediately after sending L2CAP_LE_CREDITS since no response will ever release it. Use a local variable instead of chan->ident so that an ident that an EXT_FLOWCTL channel may be waiting on (e.g. a pending reconfigure) is not overwritten by a credit packet.
Also add the missing L2CAP_LE_CONN_RSP case to l2cap_put_ident() so idents allocated for outgoing L2CAP_LE_CONN_REQ commands are released when the response arrives.
--- net/bluetooth/l2cap_core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_core.c +13 -2
@@ -4895,6 +4895,7 @@ static void l2cap_put_ident(struct l2capcase L2CAP_ECHO_RSP :case L2CAP_INFO_RSP :case L2CAP_CONN_PARAM_UPDATE_RSP : +case L2CAP_LE_CONN_RSP :case L2CAP_ECRED_CONN_RSP :case L2CAP_ECRED_RECONF_RSP :/* The remote may send bogus ids that would make ida_free
@@ -6805,6 +6806,7 @@ static void l2cap_chan_le_send_credits(sstruct l2cap_conn *conn = chan->conn;struct l2cap_le_credits pkt;u16 return_credits =l2cap_le_rx_credits (chan); +int ident;if (chan->mode !=L2CAP_MODE_LE_FLOWCTL && chan->mode !=L2CAP_MODE_EXT_FLOWCTL )
@@ -6822,9 +6824,18 @@ static void l2cap_chan_le_send_credits(s pkt.cid =cpu_to_le16 (chan->scid); pkt.credits =cpu_to_le16 (return_credits); - chan->ident =l2cap_get_ident (conn); + ident =l2cap_get_ident (conn); + +l2cap_send_cmd (conn, ident,L2CAP_LE_CREDITS ,sizeof (pkt), &pkt); -l2cap_send_cmd (conn, chan->ident,L2CAP_LE_CREDITS ,sizeof (pkt), &pkt); +/* L2CAP_LE_CREDITS has no response so the ident is never released by +* l2cap_put_ident() - release it right away, otherwise the tx_ida +* range is exhausted after 254 packets and from then on credits are +* sent with the invalid ident 0, which some remote stacks ignore, +* stalling the channel. +*/ +if (ident >0 ) +ida_free (&conn->tx_ida, ident); }void l2cap_chan_rx_avail (struct l2cap_chan *chan,ssize_t rx_avail)
Greg Kroah-Hartman
maintainerPATCH 1050/1067 writeback: Fix use after free in inode_switch_wbs_work_fn()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 6689f01d6740cf358932b3e97ee968c6099800d9 upstream.
inode_switch_wbs_work_fn() has a loop like:
wb_get(new_wb);
while (1) {
list = llist_del_all(&new_wb->switch_wbs_ctxs);
/* Nothing to do? */
if (!list)
break;
... process the items ...
}Now adding of items to the list looks like:
wb_queue_isw()
if (llist_add(&isw->list, &wb->switch_wbs_ctxs))
queue_work(isw_wq, &wb->switch_work);
Because inode_switch_wbs_work_fn() loops when processing isw items, it can happen that wb->switch_work is pending while wb->switch_wbs_ctxs is empty. This is a problem because in that case wb can get freed (no isw items -> no wb reference) while the work is still pending causing use-after-free issues.
We cannot just fix this by cancelling work when freeing wb because that could still trigger problematic 0 -> 1 transitions on wb refcount due to wb_get() in inode_switch_wbs_work_fn(). It could be all handled with more careful code but that seems unnecessarily complex so let's avoid that until it is proven that the looping actually brings practical benefit. Just remove the loop from inode_switch_wbs_work_fn() instead. That way when wb_queue_isw() queues work, we are guaranteed we have added the first item to wb->switch_wbs_ctxs and nobody is going to remove it (and drop the wb reference it holds) until the queued work runs.
--- fs/fs-writeback.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)
fs/fs-writeback.c +19 -17
@@ -533,28 +533,30 @@ void inode_switch_wbs_work_fn(struct worstruct inode_switch_wbs_context *isw, *next_isw;struct llist_node *list; + list =llist_del_all (&new_wb->switch_wbs_ctxs);/* -* Grab out reference to wb so that it cannot get freed under us +* Nothing to do? That would be a problem as references held by isw +* items protect wb from freeing... +*/ +if (WARN_ON_ONCE (!list)) +return ; + +/* +* Grab our reference to wb so that it cannot get freed under us * after we process all the isw items. */ wb_get (new_wb); -while (1 ) { - list =llist_del_all (&new_wb->switch_wbs_ctxs); -/* Nothing to do? */ -if (!list) -break ; -/* -* In addition to synchronizing among switchers, I_WB_SWITCH -* tells the RCU protected stat update paths to grab the i_page -* lock so that stat transfer can synchronize against them. -* Let's continue after I_WB_SWITCH is guaranteed to be -* visible. -*/ -synchronize_rcu (); +/* +* In addition to synchronizing among switchers, I_WB_SWITCH +* tells the RCU protected stat update paths to grab the i_page +* lock so that stat transfer can synchronize against them. +* Let's continue after I_WB_SWITCH is guaranteed to be +* visible. +*/ +synchronize_rcu (); -llist_for_each_entry_safe (isw, next_isw, list, list) -process_inode_switch_wbs (new_wb, isw); - } +llist_for_each_entry_safe (isw, next_isw, list, list) +process_inode_switch_wbs (new_wb, isw);wb_put (new_wb); }
Greg Kroah-Hartman
maintainerPATCH 1051/1067 writeback: drop now-unnecessary rcu_barrier() in cgroup_writeback_umount()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit e90a6d668e26e00a72df2d09c173b563468f09c9 upstream.
Commit e1b849cfa6b6 ("writeback: Avoid contention on wb->list_lock when switching inodes") replaced the queue_rcu_work() based scheduling of inode wb switches with a plain queue_work(). Since then no switcher goes through call_rcu(), so rcu_barrier() in cgroup_writeback_umount() has no callbacks of its own to wait for. It still drains unrelated call_rcu() callbacks from other subsystems on busy systems, which incidentally slows umount down; drop it.
--- fs/fs-writeback.c | 5 ----- 1 file changed, 5 deletions(-)
fs/fs-writeback.c +0 -5
@@ -1187,11 +1187,6 @@ void cgroup_writeback_umount(void)* will then drain it. */ synchronize_rcu (); -/* -* Use rcu_barrier() to wait for all pending callbacks to -* ensure that all in-flight wb switches are in the workqueue. -*/ -rcu_barrier ();flush_workqueue (isw_wq); } }
Greg Kroah-Hartman
maintainerPATCH 1052/1067 jiffies: Define secs_to_jiffies()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Easwar Hariharan <[email protected]>
commit b35108a51cf7bab58d7eace1267d7965978bcdb8 upstream.
secs_to_jiffies() is defined in hci_event.c and cannot be reused by other call sites. Hoist it into the core code to allow conversion of the ~1150 usages of msecs_to_jiffies() that either:
- use a multiplier value of 1000 or equivalently MSEC_PER_SEC, or
- have timeouts that are denominated in seconds (i.e. end in 000)
It's implemented as a macro to allow usage in static initializers.
This will also allow conversion of yet more sites that use (sec * HZ) directly, and improve their readability.
--- include/linux/jiffies.h | 13 +++++++++++++ net/bluetooth/hci_event.c | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-)
include/linux/jiffies.h +13 -0
@@ -371,6 +371,19 @@ static __always_inline unsigned long mse } } +/** +* secs_to_jiffies: - convert seconds to jiffies +* @_secs: time in seconds +* +* Conversion is done by simple multiplication with HZ +* +* secs_to_jiffies() is defined as a macro rather than a static inline +* function so it can be used in static initializers. +* +* Return: jiffies value +*/ +#define secs_to_jiffies (_secs) ((_secs) * HZ) +extern unsigned long __usecs_to_jiffies (const unsigned int u);#if !(USEC_PER_SEC %HZ )static inline unsigned long _usecs_to_jiffies (const unsigned int u)
net/bluetooth/hci_event.c +0 -2
@@ -42,8 +42,6 @@#define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00" -#define secs_to_jiffies (_secs) msecs_to_jiffies((_secs) * 1000) -/* Handle HCI Event packets */ static void *hci_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb,
Greg Kroah-Hartman
maintainerPATCH 1053/1067 jiffies: Cast to unsigned long in secs_to_jiffies() conversion
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Easwar Hariharan <[email protected]>
commit bb2784d9ab49587ba4fbff37a319fff2924db289 upstream.
While converting users of msecs_to_jiffies(), lkp reported that some range checks would always be true because of the mismatch between the implied int value of secs_to_jiffies() vs the unsigned long return value of the msecs_to_jiffies() calls it was replacing.
Fix this by casting the secs_to_jiffies() input value to unsigned long.
--- include/linux/jiffies.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/jiffies.h +1 -1
@@ -382,7 +382,7 @@ static __always_inline unsigned long mse* * Return: jiffies value */ -#define secs_to_jiffies (_secs) ((_secs) * HZ) +#define secs_to_jiffies (_secs) (unsigned long)((_secs) * HZ)extern unsigned long __usecs_to_jiffies (const unsigned int u);#if !(USEC_PER_SEC %HZ )
Greg Kroah-Hartman
maintainerPATCH 1054/1067 driver core: Fix missing jiffies conversion in deferred_probe_extend_timeout()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danilo Krummrich <[email protected]>
commit f9e6da99fe49277979798a1c3b9790ae10aaa18a upstream.
mod_delayed_work() takes jiffies, not seconds. Thus, restore the dropped conversion.
While at it, fix incorrect indentation.
--- drivers/base/dd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/dd.c +1 -1
@@ -327,7 +327,7 @@ void deferred_probe_extend_timeout(void)* start a new one. */ if (mod_delayed_work (system_wq, &deferred_probe_timeout_work, - driver_deferred_probe_timeout)) +secs_to_jiffies (driver_deferred_probe_timeout)))pr_debug ("Extended deferred probe timeout by %d secs\n" , driver_deferred_probe_timeout); }
Greg Kroah-Hartman
maintainerPATCH 1055/1067 driver core: Guard deferred probe timeout extension with delayed_work_pending()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danilo Krummrich <[email protected]>
commit 557495bc879013c3d5e21d667e987e7ce3a514de upstream.
mod_delayed_work() unconditionally queues the work even when it wasn't previously pending, which can fire the timeout prematurely or restart it after it already fired. Add a delayed_work_pending() guard to restore the originally intended semantics.
Premature firing calls fw_devlink_drivers_done() before all built-in drivers have registered, causing fw_devlink to prematurely relax device links for suppliers whose drivers haven't loaded yet.
--- drivers/base/dd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/dd.c +2 -1
@@ -326,7 +326,8 @@ void deferred_probe_extend_timeout(void)* If the work hasn't been queued yet or if the work expired, don't * start a new one. */ -if (mod_delayed_work (system_wq, &deferred_probe_timeout_work, +if (delayed_work_pending (&deferred_probe_timeout_work) && +mod_delayed_work (system_wq, &deferred_probe_timeout_work,secs_to_jiffies (driver_deferred_probe_timeout)))pr_debug ("Extended deferred probe timeout by %d secs\n" , driver_deferred_probe_timeout);
Greg Kroah-Hartman
maintainerPATCH 1056/1067 ALSA: seq: Avoid confusion of aligned read size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 8c15a18331191b67bdce54d21af068baec044baf upstream.
Currently the read event packet size in snd_seq_read() is defined by client->midi_version value that is guaranteed to be zero if UMP isn't enabled. But the static analyzer doesn't know of the fact, and it still suspects as if it were leading to a potential overflow.
Add the more explicit check of CONFIG_SND_SEQ_UMP to determine the aligned_size value for avoiding the confusion.
--- sound/core/seq/seq_clientmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/seq_clientmgr.c +1 -1
@@ -441,7 +441,7 @@ static ssize_t snd_seq_read(struct file err =0 ;snd_seq_fifo_lock (fifo); -if (client->midi_version >0 ) +if (IS_ENABLED (CONFIG_SND_SEQ_UMP ) && client->midi_version >0 ) aligned_size =sizeof (struct snd_seq_ump_event );else aligned_size =sizeof (struct snd_seq_event );
Greg Kroah-Hartman
maintainerPATCH 1057/1067 tools/virtio: Add dma sync api for virtio test
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liming Wu <[email protected]>
commit e07744b43d3ad10b040f0ec464b6323ca96903d6 upstream.
also add dma sync api for virtio test.
Message-Id: <[email protected]>
--- tools/virtio/linux/dma-mapping.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tools/virtio/linux/dma-mapping.h +12 -0
@@ -24,11 +24,23 @@ enum dma_data_direction {#define dma_map_page (d, p, o, s, dir) (page_to_phys(p) + (o))#define dma_map_single (d, p, s, dir) (virt_to_phys(p)) +#define dma_map_single_attrs (d, p, s, dir, a) (virt_to_phys(p))#define dma_mapping_error (...) (0)#define dma_unmap_single (d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)#define dma_unmap_page (d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0) +#define sg_dma_address (sg) (0) +#define dma_need_sync (v, a) (0) +#define dma_unmap_single_attrs (d, a, s, r, t) do { \ + (void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \ +} while (0) +#define dma_sync_single_range_for_cpu (d, a, o, s, r) do { \ + (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \ +} while (0) +#define dma_sync_single_range_for_device (d, a, o, s, r) do { \ + (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \ +} while (0)#define dma_max_mapping_size (...) SIZE_MAX#endif
Greg Kroah-Hartman
maintainerPATCH 1058/1067 cifs: fix lock ordering while disabling multichannel
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit 5eef12c4e3230f2025dc46ad8c4a3bc19978e5d7 upstream.
The code to handle the case of server disabling multichannel was picking iface_lock with chan_lock held. This goes against the lock ordering rules, as iface_lock is a higher order lock (even if it isn't so obvious).
This change fixes the lock ordering by doing the following in that order for each secondary channel:
1. store iface and server pointers in local variable
2. remove references to iface and server in channels
3. unlock chan_lock
4. lock iface_lock
5. dec ref count for iface
6. unlock iface_lock
7. dec ref count for server
8. lock chan_lock again
Since this function can only be called in smb2_reconnect, and that cannot be called by two parallel processes, we should not have races due to dropping chan_lock between steps 3 and 8.
--- fs/smb/client/sess.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
fs/smb/client/sess.c +13 -9
@@ -303,28 +303,32 @@ cifs_disable_secondary_channels(struct c iface = ses->chans[i].iface; server = ses->chans[i].server; +/* +* remove these references first, since we need to unlock +* the chan_lock here, since iface_lock is a higher lock +*/ + ses->chans[i].iface =NULL ; + ses->chans[i].server =NULL ; +spin_unlock (&ses->chan_lock); +if (iface) {spin_lock (&ses->iface_lock);kref_put (&iface->refcount, release_iface); - ses->chans[i].iface =NULL ; iface->num_channels--;if (iface->weight_fulfilled) iface->weight_fulfilled--;spin_unlock (&ses->iface_lock); } -spin_unlock (&ses->chan_lock); -if (server && !server->terminate) { - server->terminate = true; -cifs_signal_cifsd_for_reconnect (server, false); - } -spin_lock (&ses->chan_lock); -if (server) { - ses->chans[i].server =NULL ; +if (!server->terminate) { + server->terminate = true; +cifs_signal_cifsd_for_reconnect (server, false); + }cifs_put_tcp_session (server, false); } +spin_lock (&ses->chan_lock); } done:
Greg Kroah-Hartman
maintainerPATCH 1059/1067 virtio_ring: fix syncs DMA memory with different direction
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuan Zhuo <[email protected]>
commit 1f475cd572ea77ae6474a17e693a96bca927efe9 upstream.
Now the APIs virtqueue_dma_sync_single_range_for_{cpu,device} ignore the parameter 'dir', that is a mistake.
[ 6.101666] ------------[ cut here ]------------ [ 6.102079] DMA-API: virtio-pci 0000:00:04.0: device driver syncs DMA memory with different direction [device address=0x00000000ae010000] [size=32752 bytes] [mapped with DMA_FROM_DEVICE] [synced with DMA_BIDIRECTIONAL] [ 6.103630] WARNING: CPU: 6 PID: 0 at kernel/dma/debug.c:1125 check_sync+0x53e/0x6c0 [ 6.107420] CPU: 6 PID: 0 Comm: swapper/6 Tainted: G E 6.6.0+ #290 [ 6.108030] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 [ 6.108936] RIP: 0010:check_sync+0x53e/0x6c0 [ 6.109289] Code: 24 10 e8 f5 d9 74 00 4c 8b 4c 24 10 4c 8b 44 24 18 48 8b 4c 24 20 48 89 c6 41 56 4c 89 ea 48 c7 c7 b0 f1 50 82 e8 32 fc f3 ff <0f> 0b 48 c7 c7 48 4b 4a 82 e8 74 d9 fc ff 8b 73 4c 48 8d 7b 50 31 [ 6.110750] RSP: 0018:ffffc90000180cd8 EFLAGS: 00010092 [ 6.111178] RAX: 00000000000000ce RBX: ffff888100aa5900 RCX: 0000000000000000 [ 6.111744] RDX: 0000000000000104 RSI: ffffffff824c3208 RDI: 00000000ffffffff [ 6.112316] RBP: ffffc90000180d40 R08: 0000000000000000 R09: 00000000fffeffff [ 6.112893] R10: ffffc90000180b98 R11: ffffffff82f63308 R12: ffffffff83d5af00 [ 6.113460] R13: ffff888100998200 R14: ffffffff824a4b5f R15: 0000000000000286 [ 6.114027] FS: 0000000000000000(0000) GS:ffff88842fd80000(0000) knlGS:0000000000000000 [ 6.114665] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 6.115128] CR2: 00007f10f1e03030 CR3: 0000000108272004 CR4: 0000000000770ee0 [ 6.115701] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 6.116272] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 6.116842] PKRU: 55555554 [ 6.117069] Call Trace: [ 6.117275] <IRQ> [ 6.117452] ? __warn+0x84/0x140 [ 6.117727] ? check_sync+0x53e/0x6c0 [ 6.118034] ? __report_bug+0xea/0x100 [ 6.118353] ? check_sync+0x53e/0x6c0 [ 6.118653] ? report_bug+0x41/0xc0 [ 6.118944] ? handle_bug+0x3c/0x70 [ 6.119237] ? exc_invalid_op+0x18/0x70 [ 6.119551] ? asm_exc_invalid_op+0x1a/0x20 [ 6.119900] ? check_sync+0x53e/0x6c0 [ 6.120199] ? check_sync+0x53e/0x6c0 [ 6.120499] debug_dma_sync_single_for_cpu+0x5c/0x70 [ 6.120906] ? dma_sync_single_for_cpu+0xb7/0x100 [ 6.121291] virtnet_rq_unmap+0x158/0x170 [virtio_net] [ 6.121716] virtnet_receive+0x196/0x220 [virtio_net] [ 6.122135] virtnet_poll+0x48/0x1b0 [virtio_net] [ 6.122524] __napi_poll+0x29/0x1b0 [ 6.123083] net_rx_action+0x282/0x360 [ 6.123612] __do_softirq+0xf3/0x2fb [ 6.124138] __irq_exit_rcu+0x8e/0xf0 [ 6.124663] common_interrupt+0xbc/0xe0 [ 6.125202] </IRQ>
We need to enable CONFIG_DMA_API_DEBUG and work with need sync mode(such as swiotlb) to reproduce this warn.
Message-Id: <[email protected]>
--- drivers/virtio/virtio_ring.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/virtio/virtio_ring.c +2 -4
@@ -3039,8 +3039,7 @@ void virtqueue_dma_sync_single_range_forif (!vq->use_dma_api)return ; -dma_sync_single_range_for_cpu (dev, addr, offset, size, -DMA_BIDIRECTIONAL ); +dma_sync_single_range_for_cpu (dev, addr, offset, size, dir); }EXPORT_SYMBOL_GPL (virtqueue_dma_sync_single_range_for_cpu);
@@ -3066,8 +3065,7 @@ void virtqueue_dma_sync_single_range_forif (!vq->use_dma_api)return ; -dma_sync_single_range_for_device (dev, addr, offset, size, -DMA_BIDIRECTIONAL ); +dma_sync_single_range_for_device (dev, addr, offset, size, dir); }EXPORT_SYMBOL_GPL (virtqueue_dma_sync_single_range_for_device);
Greg Kroah-Hartman
maintainerPATCH 1060/1067 iio: imu: inv_mpu6050: fix frequency setting when chip is off
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit daec424cc57b33a28f8621eb7ac85f8bd327bd6b upstream.
Track correctly FIFO state and apply ODR change before starting the chip. Without the fix, you cannot change ODR more than 1 time when data buffering is off. This restriction on a single pending ODR change should only apply when the FIFO is on.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +5 -0
@@ -111,6 +111,7 @@ int inv_mpu6050_prepare_fifo(struct inv_if (enable) {/* reset timestamping */ inv_sensors_timestamp_reset (&st->timestamp); +inv_sensors_timestamp_apply_odr (&st->timestamp,0 ,0 ,0 );/* reset FIFO */ d = st->chip_config.user_ctrl |INV_MPU6050_BIT_FIFO_RST ; ret =regmap_write (st->map, st->reg->user_ctrl, d);
@@ -184,6 +185,10 @@ static int inv_mpu6050_set_enable(structif (result) goto error_power_off; }else { + st->chip_config.gyro_fifo_enable =0 ; + st->chip_config.accl_fifo_enable =0 ; + st->chip_config.temp_fifo_enable =0 ; + st->chip_config.magn_fifo_enable =0 ; result =inv_mpu6050_prepare_fifo (st, false);if (result) goto error_power_off;
Greg Kroah-Hartman
maintainerPATCH 1061/1067 iio: invensense: fix odr switching to same value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 95444b9eeb8c5c0330563931d70c61ca3b101548 upstream.
ODR switching happens in 2 steps, update to store the new value and then apply when the ODR change flag is received in the data. When switching to the same ODR value, the ODR change flag is never happening, and frequency switching is blocked waiting for the never coming apply.
Fix the issue by preventing update to happen when switching to same ODR value.
--- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +5 -1
@@ -60,11 +60,15 @@ EXPORT_SYMBOL_NS_GPL(inv_sensors_timestaint inv_sensors_timestamp_update_odr (struct inv_sensors_timestamp *ts,uint32_t period,bool fifo) { +uint32_t mult; +/* when FIFO is on, prevent odr change if one is already pending */ if (fifo && ts->new_mult !=0 )return -EAGAIN ; - ts->new_mult = period / ts->chip.clock_period; + mult = period / ts->chip.clock_period; +if (mult != ts->mult) + ts->new_mult = mult;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 1062/1067 Bluetooth: Ignore too large handle values in BIG
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
commit 015d79c96d62cd8a4a359fcf5be40d58088c936b upstream.
hci_le_big_sync_established_evt is necessary to filter out cases where the handle value is belonging to ida id range, otherwise ida will be erroneously released in hci_conn_cleanup.
--- net/bluetooth/hci_event.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/hci_event.c +4 -0
@@ -6951,6 +6951,10 @@ static void hci_le_big_sync_established_ bis =hci_conn_hash_lookup_handle (hdev, handle);if (!bis) { +if (handle >HCI_CONN_HANDLE_MAX ) { +bt_dev_dbg (hdev,"ignore too large handle %u" , handle); +continue ; + } bis =hci_conn_add (hdev,ISO_LINK ,BDADDR_ANY ,HCI_ROLE_SLAVE , handle);if (!bis)
Greg Kroah-Hartman
maintainerPATCH 1063/1067 bluetooth/hci: disallow setting handle bigger than HCI_CONN_HANDLE_MAX
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Skripkin <[email protected]>
commit 1cc18c2ab2e8c54c355ea7c0423a636e415a0c23 upstream.
Syzbot hit warning in hci_conn_del() caused by freeing handle that was not allocated using ida allocator.
This is caused by handle bigger than HCI_CONN_HANDLE_MAX passed by hci_le_big_sync_established_evt(), which makes code think it's unset connection.
Add same check for handle upper bound as in hci_conn_set_handle() to prevent warning.
--- net/bluetooth/hci_conn.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
net/bluetooth/hci_conn.c +12 -3
@@ -988,8 +988,8 @@ static int hci_conn_hash_alloc_unset(str U16_MAX, GFP_ATOMIC); } -struct hci_conn *hci_conn_add (struct hci_dev *hdev,int type,bdaddr_t *dst, -u8 role,u16 handle) +static struct hci_conn *__hci_conn_add (struct hci_dev *hdev,int type,bdaddr_t *dst, +u8 role,u16 handle) {struct hci_conn *conn;
@@ -1096,7 +1096,16 @@ struct hci_conn *hci_conn_add_unset(struif (unlikely (handle <0 ))return NULL ; -return hci_conn_add (hdev, type, dst, role, handle); +return __hci_conn_add (hdev, type, dst, role, handle); +} + +struct hci_conn *hci_conn_add (struct hci_dev *hdev,int type,bdaddr_t *dst, +u8 role,u16 handle) +{ +if (handle >HCI_CONN_HANDLE_MAX ) +return ERR_PTR (-EINVAL ); + +return __hci_conn_add (hdev, type, dst, role, handle); }static bool hci_conn_unlink (struct hci_conn *conn)
Greg Kroah-Hartman
maintainerPATCH 1064/1067 ALSA: seq: Skip event type filtering for UMP events
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 32108c22ac619c32dd6db594319e259b63bfb387 upstream.
UMP events don't use the event type field, hence it's invalid to apply the filter, which may drop the events unexpectedly.
Skip the event filtering for UMP events, instead.
--- sound/core/seq/seq_clientmgr.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/seq/seq_clientmgr.c +3 -0
@@ -528,6 +528,9 @@ static struct snd_seq_client *get_event_return NULL ;if (! dest->accept_input) goto __not_avail; +if (snd_seq_ev_is_ump (event)) +return dest;/* ok - no filter checks */ +if ((dest->filter &SNDRV_SEQ_FILTER_USE_EVENT ) && !test_bit (event->type, dest->event_filter)) goto __not_avail;
Greg Kroah-Hartman
maintainerPATCH 1065/1067 ALSA: seq: Check UMP support for midi_version change
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 8765429279e7d3d68d39ace5f84af2815174bb1e upstream.
When the kernel is built without UMP support but a user-space app requires the midi_version > 0, the kernel should return an error. Otherwise user-space assumes as if it were possible to deal, eventually hitting serious errors later.
--- sound/core/seq/seq_clientmgr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
sound/core/seq/seq_clientmgr.c +10 -4
@@ -1329,10 +1329,16 @@ static int snd_seq_ioctl_set_client_infoif (client->type != client_info->type)return -EINVAL ; -/* check validity of midi_version field */ -if (client->user_pversion >=SNDRV_PROTOCOL_VERSION (1 ,0 ,3 ) && - client_info->midi_version >SNDRV_SEQ_CLIENT_UMP_MIDI_2_0 ) -return -EINVAL ; +if (client->user_pversion >=SNDRV_PROTOCOL_VERSION (1 ,0 ,3 )) { +/* check validity of midi_version field */ +if (client_info->midi_version >SNDRV_SEQ_CLIENT_UMP_MIDI_2_0 ) +return -EINVAL ; + +/* check if UMP is supported in kernel */ +if (!IS_ENABLED (CONFIG_SND_SEQ_UMP ) && + client_info->midi_version >0 ) +return -EINVAL ; + }/* fill the info fields */ if (client_info->name[0 ])
Greg Kroah-Hartman
maintainerPATCH 1066/1067 iio: imu: inv_icm42600: fix timestamp clock period by using lower value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 8b0b864c11a2e2ada470f9d5010e1c2bf1eceef2 upstream.
Clock period value is used for computing periods of sampling. There is no need for it to be higher than the maximum odr, otherwise we are losing precision in the computation for nothing.
Switch clock period value to maximum odr period (8kHz).
--- drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 4 ++-- drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +2 -2
@@ -720,10 +720,10 @@ struct iio_dev *inv_icm42600_accel_init(return ERR_PTR (-ENOMEM );/* -* clock period is 32kHz (31250ns) +* clock period is 8kHz (125000ns) * jitter is +/- 2% (20 per mille) */ - ts_chip.clock_period =31250 ; + ts_chip.clock_period =125000 ; ts_chip.jitter =20 ; ts_chip.init_period =inv_icm42600_odr_to_period (st->conf.accel.odr); ts =iio_priv (indio_dev);
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +2 -2
@@ -731,10 +731,10 @@ struct iio_dev *inv_icm42600_gyro_init(sreturn ERR_PTR (-ENOMEM );/* -* clock period is 32kHz (31250ns) +* clock period is 8kHz (125000ns) * jitter is +/- 2% (20 per mille) */ - ts_chip.clock_period =31250 ; + ts_chip.clock_period =125000 ; ts_chip.jitter =20 ; ts_chip.init_period =inv_icm42600_odr_to_period (st->conf.accel.odr); ts =iio_priv (indio_dev);
Greg Kroah-Hartman
maintainerPATCH 1067/1067 ALSA: seq: Fix uninitialised heap leak in snd_seq_event_dup()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
commit 435990e25bf1f4af3e6df12a6fbfd1f7ba4a97d4 upstream.
snd_seq_event_dup() copies an incoming event into a pool cell and, in the UMP-enabled build, clears the trailing cell->ump.raw.extra word that the memcpy() did not cover. The guard deciding whether to clear it compares the copied size against sizeof(cell->event):
memcpy(&cell->ump, event, size); if (size < sizeof(cell->event)) cell->ump.raw.extra = 0;
For a legacy (non-UMP) event, size == sizeof(struct snd_seq_event) == sizeof(cell->event), so the condition is false and the extra word keeps stale data. The cell pool is allocated with kvmalloc() (not zeroed) and cells are reused via a free list, so that word holds uninitialised heap or leftover event data.
When such a cell is delivered to a UMP client (client->midi_version > 0) that set SNDRV_SEQ_FILTER_NO_CONVERT -- so the legacy event reaches it unconverted -- snd_seq_read() reads it out as the larger struct snd_seq_ump_event and copies the stale word to user space, a 4-byte kernel heap infoleak to an unprivileged /dev/snd/seq client.
Compare against sizeof(cell->ump) instead, so the trailing word is zeroed for every event shorter than the UMP cell.
--- sound/core/seq/seq_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/seq_memory.c +1 -1
@@ -309,7 +309,7 @@ int snd_seq_event_dup(struct snd_seq_poo size =snd_seq_event_packet_size (event);memcpy (&cell->ump, event, size);#if IS_ENABLED (CONFIG_SND_SEQ_UMP ) -if (size <sizeof (cell->event)) +if (size <sizeof (cell->ump)) cell->ump.raw.extra =0 ;#endif
# Librecast Test Results
020/020 [ OK ] liblcrq
010/010 [ OK ] libmld
120/120 [ OK ] liblibrecast
CPU/kernel: Linux auntie 6.1.178-rc1-01068-g94b750943692 #1 SMP PREEMPT_DYNAMIC Tue Jul 21 20:33:52 -00 2026 x86_64 AMD Ryzen 9 9950X 16-Core Processor AuthenticAMD GNU/Linux
Am 21.07.2026 um 17:10 schrieb Greg Kroah-Hartman:
Quoted 4 lines
This is the start of the stable review cycle for the 6.1.178 release. There are 1067 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.
Builds, boots and works on my 2-socket Ivy Bridge Xeon E5-2697 v2 server. No dmesg oddities or regressions found.
Beste Grüße,
Peter Schneider
Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge, enjoy the air and behold the view. Climb it so you can see the world, not so the world can see you. -- David McCullough Jr. OpenPGP: 0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244 Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc https://keys.mailvelope.com/pks/lookup?op=get&[email protected] https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
Hello Greg
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.178 release. There are 1067 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.
It does not build to me.
file_offset in struct perf_sample missing?
07-21:17:58:43 | arm-tdx-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9=/usr/src/debug/perf/1.0-r9 -fdebug-prefix-map=/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9=/usr/src/debug/perf/1.0-r9 -fdebug-prefix-map=/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/recipe-sysroot= -fdebug-prefix-map=/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/recipe-sysroot-native= --sysroot=/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/recipe-sysroot -Wp,-MD,/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/perf-1.0/libbpf/staticobjs/.nlattr.o.d -Wp,-MT,/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/perf-1.0/libbpf/staticobjs/nlattr.o -ldw -std=gnu89 -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat -Wno-type-limits -Wstrict-aliasing=3 -Wshadow -Wno-switch-enum -Werror -Wall -I/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/perf-1.0/libbpf/ -I/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/perf-1.0/tools/include -I/workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/perf-1.0/tools/include/uapi -fvisibility=hidden -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D"BUILD_STR(s)=#s" -c -o /workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/perf-1.0/libbpf/staticobjs/nlattr.o nlattr.c 07-21:17:58:43 | In file included from builtin-sched.c:28: 07-21:17:58:43 | builtin-sched.c: In function 'latency_switch_event': 07-21:17:58:43 | builtin-sched.c:1182:34: error: 'struct perf_sample' has no member named 'file_offset' 07-21:17:58:43 | 1182 | sample->file_offset, cpu); 07-21:17:58:43 | | ^~ 07-21:17:58:43 | util/debug.h:24:44: note: in definition of macro 'pr_warning' 07-21:17:58:43 | 24 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) 07-21:17:58:43 | | ^~~~~~~~~~~ 07-21:17:58:43 | builtin-sched.c: In function 'latency_runtime_event': 07-21:17:58:43 | builtin-sched.c:1260:34: error: 'struct perf_sample' has no member named 'file_offset' 07-21:17:58:43 | 1260 | sample->file_offset, cpu); 07-21:17:58:43 | | ^~ 07-21:17:58:43 | util/debug.h:24:44: note: in definition of macro 'pr_warning' 07-21:17:58:43 | 24 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) 07-21:17:58:43 | | ^~~~~~~~~~~ 07-21:17:58:43 | builtin-sched.c: In function 'map_switch_event': 07-21:17:58:43 | builtin-sched.c:1622:34: error: 'struct perf_sample' has no member named 'file_offset' 07-21:17:58:43 | 1622 | sample->file_offset, this_cpu.cpu); 07-21:17:58:43 | | ^~ 07-21:17:58:43 | util/debug.h:24:44: note: in definition of macro 'pr_warning' 07-21:17:58:43 | 24 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) 07-21:17:58:43 | | ^~~~~~~~~~~ 07-21:17:58:43 | make -f /workdir/oe/tmp/work/apalis_imx6-tdx-linux-gnueabi/perf/1.0-r9/perf-1.0/tools/build/Makefile.build dir=./arch obj=perf
Francesco
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.178 release. There are 1067 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 Thu, 23 Jul 2026 15:23:00 +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.1.178-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.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.1.178 release. There are 1067 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 Thu, 23 Jul 2026 15:23:00 +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.1.178-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.1.178 release. There are 1067 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.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.1.y
Best regards,
Pavel