7.1.5-rc1 review
Subsystems (15)
Greg Kroah-Hartman
maintainerPATCH 2065/2077 usb: atm: ueagle-atm: use dev_dbg() for device found message
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauricio Faria de Oliveira <[email protected]>
[ Upstream commit 05c5075c3115010f97434c53d353d9a0d4b0e64e ]
Convert dev_info() to dev_dbg().
Per 'Documentation/process/coding-style.rst':
13) Printing kernel messages
... When drivers are working properly they are quiet, so prefer to use dev_dbg/pr_debug unless something is wrong.
While in there, correct the verb form and add 'with' for clarity.
Stable-dep-of: e2674dfbed8a ("usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()")
--- drivers/usb/atm/ueagle-atm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/atm/ueagle-atm.c +1 -1
@@ -2590,7 +2590,7 @@ static int uea_probe(struct usb_interfacint ret;uea_enters (usb); - uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) Rev (%#X): %s\n", + uea_dbg(usb, "ADSL device found with vid (%#X) pid (%#X) Rev (%#X): %s\n", le16_to_cpu(usb->descriptor.idVendor), le16_to_cpu(usb->descriptor.idProduct), le16_to_cpu(usb->descriptor.bcdDevice),
Greg Kroah-Hartman
maintainerPATCH 2066/2077 usb: atm: ueagle-atm: remove function entry/exit debug messages
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauricio Faria de Oliveira <[email protected]>
[ Upstream commit 1414b2242c2e9d670c4d8b83480f13db57627ba9 ]
Remove the driver-internal function entry/exit debug messages in favor of existing kernel-level function tracing mechanisms.
Stable-dep-of: e2674dfbed8a ("usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()")
--- drivers/usb/atm/ueagle-atm.c | 56 ++++--------------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-)
drivers/usb/atm/ueagle-atm.c +6 -50
@@ -51,12 +51,6 @@ "[ueagle-atm vdbg] " format, ##args); \ } while (0) -#define uea_enters (usb_dev) \ - uea_vdbg(usb_dev, "entering %s\n" , __func__) - -#define uea_leaves (usb_dev) \ - uea_vdbg(usb_dev, "leaving %s\n" , __func__) - #define uea_err(usb_dev, format, args...) \ dev_err(&(usb_dev)->dev , "[UEAGLE-ATM] " format , ##args)
@@ -606,7 +600,6 @@ static void uea_upload_pre_firmware(consu32 crc =0 ;int ret, size; -uea_enters (usb);if (!fw_entry) {uea_err (usb,"firmware is not available\n" ); goto err;
@@ -670,7 +663,6 @@ err_fw_corrupted:uea_err (usb,"firmware is corrupted\n" ); err:release_firmware (fw_entry); -uea_leaves (usb); }/*
@@ -681,7 +673,6 @@ static int uea_load_firmware(struct usb_int ret;char *fw_name =EAGLE_FIRMWARE ; -uea_enters (usb);uea_info (usb,"pre-firmware device, uploading firmware\n" );switch (ver) {
@@ -710,7 +701,6 @@ static int uea_load_firmware(struct usb_else uea_info (usb,"loading firmware %s\n" , fw_name); -uea_leaves (usb);return ret; }
@@ -1137,7 +1127,6 @@ static int uea_cmv_e1(struct uea_softc *struct cmv_e1 cmv;int ret; -uea_enters (INS_TO_USBDEV (sc)); uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Address : %c%c%c%c, " "offset : 0x%04x, data : 0x%08x\n", E1_FUNCTION_TYPE(function),
@@ -1164,9 +1153,8 @@ static int uea_cmv_e1(struct uea_softc * sizeof(cmv), &cmv);if (ret <0 )return ret; - ret =wait_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc)); -return ret; + +return wait_cmv_ack (sc); } static int uea_cmv_e4(struct uea_softc *sc,
@@ -1175,7 +1163,6 @@ static int uea_cmv_e4(struct uea_softc *struct cmv_e4 cmv;int ret; -uea_enters (INS_TO_USBDEV (sc));memset (&cmv,0 ,sizeof (cmv)); uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Group : 0x%04x, "
@@ -1199,9 +1186,8 @@ static int uea_cmv_e4(struct uea_softc * sizeof(cmv), &cmv);if (ret <0 )return ret; - ret =wait_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc)); -return ret; + +return wait_cmv_ack (sc); } static inline int uea_read_cmv_e1(struct uea_softc *sc,
@@ -1295,7 +1281,6 @@ static int uea_stat_e1(struct uea_softcu32 data;int ret; -uea_enters (INS_TO_USBDEV (sc)); data = sc->stats.phy.state; ret =uea_read_cmv_e1 (sc,E1_SA_STAT ,0 , &sc->stats.phy.state);
@@ -1438,7 +1423,6 @@ static int uea_stat_e4(struct uea_softcu32 tmp_arr[2 ];int ret; -uea_enters (INS_TO_USBDEV (sc)); data = sc->stats.phy.state;/* XXX only need to be done before operationnal... */
@@ -1805,7 +1789,6 @@ static int uea_start_reset(struct uea_sou16 zero =0 ;/* ;-) */ int ret; -uea_enters (INS_TO_USBDEV (sc));uea_info (INS_TO_USBDEV (sc),"(re)booting started\n" );/* mask interrupt */
@@ -1873,7 +1856,6 @@ static int uea_start_reset(struct uea_soreturn ret; sc->reset =0 ; -uea_leaves (INS_TO_USBDEV (sc));return ret; }
@@ -1889,7 +1871,6 @@ static int uea_kthread(void *data)int ret = -EAGAIN ;set_freezable (); -uea_enters (INS_TO_USBDEV (sc));while (!kthread_should_stop ()) {if (ret <0 || sc->reset) ret =uea_start_reset (sc);
@@ -1898,7 +1879,7 @@ static int uea_kthread(void *data)if (ret != -EAGAIN )uea_wait (sc,0 ,msecs_to_jiffies (1000 )); } -uea_leaves (INS_TO_USBDEV (sc)); +return ret; }
@@ -1911,8 +1892,6 @@ static int load_XILINX_firmware(struct uu8 value;char *fw_name =FPGA930_FIRMWARE ; -uea_enters (INS_TO_USBDEV (sc)); - ret =request_firmware (&fw_entry, fw_name, &sc->usb_dev->dev);if (ret) { uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n",
@@ -1956,7 +1935,6 @@ static int load_XILINX_firmware(struct u err1:release_firmware (fw_entry); err0: -uea_leaves (INS_TO_USBDEV (sc));return ret; }
@@ -1966,7 +1944,6 @@ static void uea_dispatch_cmv_e1(struct ustruct cmv_dsc_e1 *dsc = &sc->cmv_dsc.e1;struct cmv_e1 *cmv = &intr->u.e1.s2.cmv; -uea_enters (INS_TO_USBDEV (sc));if (le16_to_cpu (cmv->wPreamble) !=E1_PREAMBLE ) goto bad1;
@@ -1990,7 +1967,6 @@ static void uea_dispatch_cmv_e1(struct uif (cmv->bFunction ==E1_MAKEFUNCTION (E1_ADSLDIRECTIVE ,E1_MODEMREADY )) {wake_up_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc));return ; }
@@ -2004,7 +1980,6 @@ static void uea_dispatch_cmv_e1(struct u sc->data = sc->data <<16 | sc->data >>16 ;wake_up_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc));return ; bad2:
@@ -2012,14 +1987,12 @@ bad2:"Function : %d, Subfunction : %d\n" ,E1_FUNCTION_TYPE (cmv->bFunction), E1_FUNCTION_SUBTYPE(cmv->bFunction)); -uea_leaves (INS_TO_USBDEV (sc));return ; bad1:uea_err (INS_TO_USBDEV (sc),"invalid cmv received, " "wPreamble %d, bDirection %d\n" ,le16_to_cpu (cmv->wPreamble), cmv->bDirection); -uea_leaves (INS_TO_USBDEV (sc)); }/* The modem send us an ack. First with check if it right */
@@ -2028,7 +2001,6 @@ static void uea_dispatch_cmv_e4(struct ustruct cmv_dsc_e4 *dsc = &sc->cmv_dsc.e4;struct cmv_e4 *cmv = &intr->u.e4.s2.cmv; -uea_enters (INS_TO_USBDEV (sc)); uea_dbg(INS_TO_USBDEV(sc), "cmv %x %x %x %x %x %x\n", be16_to_cpu(cmv->wGroup), be16_to_cpu(cmv->wFunction), be16_to_cpu(cmv->wOffset), be16_to_cpu(cmv->wAddress),
@@ -2040,7 +2012,6 @@ static void uea_dispatch_cmv_e4(struct uif (be16_to_cpu (cmv->wFunction) ==E4_MAKEFUNCTION (E4_ADSLDIRECTIVE ,E4_MODEMREADY ,1 )) {wake_up_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc));return ; }
@@ -2053,7 +2024,6 @@ static void uea_dispatch_cmv_e4(struct u sc->data =be32_to_cpu (cmv->dwData[0 ]); sc->data1 =be32_to_cpu (cmv->dwData[1 ]);wake_up_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc));return ; bad2:
@@ -2061,7 +2031,6 @@ bad2:"Function : %d, Subfunction : %d\n" ,E4_FUNCTION_TYPE (cmv->wFunction), E4_FUNCTION_SUBTYPE(cmv->wFunction)); -uea_leaves (INS_TO_USBDEV (sc));return ; }
@@ -2089,8 +2058,6 @@ static void uea_intr(struct urb *urb)struct intr_pkt *intr = urb->transfer_buffer;int status = urb->status; -uea_enters (INS_TO_USBDEV (sc)); -if (unlikely (status <0 )) {uea_err (INS_TO_USBDEV (sc),"uea_intr() failed with %d\n" , status);
@@ -2130,8 +2097,6 @@ static int uea_boot(struct uea_softc *scint ret = -ENOMEM ;int size; -uea_enters (INS_TO_USBDEV (sc)); -if (UEA_CHIP_VERSION (sc) ==EAGLE_IV ) { size =E4_INTR_PKT_SIZE ; sc->dispatch_cmv = uea_dispatch_cmv_e4;
@@ -2188,7 +2153,6 @@ static int uea_boot(struct uea_softc *sc goto err2; } -uea_leaves (INS_TO_USBDEV (sc));return 0 ; err2:
@@ -2198,7 +2162,6 @@ err1: sc->urb_int =NULL ;kfree (intr); err0: -uea_leaves (INS_TO_USBDEV (sc));return ret; }
@@ -2208,7 +2171,7 @@ err0:static void uea_stop (struct uea_softc *sc) {int ret; -uea_enters (INS_TO_USBDEV (sc)); + ret =kthread_stop (sc->kthread);uea_dbg (INS_TO_USBDEV (sc),"kthread finish with status %d\n" , ret);
@@ -2222,7 +2185,6 @@ static void uea_stop(struct uea_softc *sflush_work (&sc->task);release_firmware (sc->dsp_firm); -uea_leaves (INS_TO_USBDEV (sc)); }/* syfs interface */
@@ -2495,8 +2457,6 @@ static int uea_bind(struct usbatm_data *int ret, ifnum = intf->altsetting->desc.bInterfaceNumber;unsigned int alt; -uea_enters (usb); -/* interface 0 is for firmware/monitoring */ if (ifnum !=UEA_INTR_IFACE_NO )return -ENODEV ;
@@ -2589,7 +2549,6 @@ static int uea_probe(struct usb_interfacstruct usb_device *usb =interface_to_usbdev (intf);int ret; -uea_enters (usb); uea_dbg(usb, "ADSL device found with vid (%#X) pid (%#X) Rev (%#X): %s\n", le16_to_cpu(usb->descriptor.idVendor), le16_to_cpu(usb->descriptor.idProduct),
@@ -2620,7 +2579,6 @@ static void uea_disconnect(struct usb_in {struct usb_device *usb =interface_to_usbdev (intf);int ifnum = intf->altsetting->desc.bInterfaceNumber; -uea_enters (usb);/* ADI930 has 2 interfaces and eagle 3 interfaces. * Pre-firmware device has one interface
@@ -2631,8 +2589,6 @@ static void uea_disconnect(struct usb_inmutex_unlock (&uea_mutex);uea_info (usb,"ADSL device removed\n" ); } - -uea_leaves (usb); }/*
Greg Kroah-Hartman
maintainerPATCH 2067/2077 usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()
In reply to Greg Kroah-Hartman7.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
@@ -594,7 +594,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 ;
@@ -663,15 +665,17 @@ err_fw_corrupted:uea_err (usb,"firmware is corrupted\n" ); err:release_firmware (fw_entry); +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_info (usb,"pre-firmware device, uploading firmware\n" );
@@ -694,7 +698,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);
@@ -2557,8 +2561,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_obj (*fw_done); +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 ) {
@@ -2588,6 +2607,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); } }
Greg Kroah-Hartman
maintainerPATCH 2068/2077 liveupdate: validate session type before performing operation
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Pratyush Yadav (Google)" <[email protected]>
[ Upstream commit 507e3b479f9c6d85135eb5e1a77fb3fddb259ad8 ]
The sessions ioctls are not applicable to all session types. PRESERVE_FD is only applicable to outgoing sessions. RETRIEVE_FD and FINISH are only valid for incoming session. Calling a incoming ioctl on an outgoing session is invalid and can cause file handlers to run into unexpected errors.
For example, a user can create a (outgoing) session, preserve a memfd, and then immediately do a retrieve without doing a kexec in between. This would result in memfd's retrieve handler to run. The handlers expects to be called from a post-kexec context, and will try to do a kho_restore_vmalloc() or kho_restore_folio() to try and restore memory.
KHO catches this (thanks to KHO_PAGE_MAGIC) and returns an error, but since this is considered an internal error and KHO throws out a bunch of WARN()s.
Associate a type with each ioctl op and validate the type in luo_session_ioctl() before dispatching the ioctl handler to make sure the op is being called for the right session type.
--- kernel/liveupdate/luo_session.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-)
kernel/liveupdate/luo_session.c +32 -5
@@ -330,32 +330,58 @@ union ucmd_buffer {struct liveupdate_session_retrieve_fd retrieve; }; +/* Type of sessions the ioctl applies to. */ +enum luo_ioctl_type { +LUO_IOCTL_INCOMING , +LUO_IOCTL_OUTGOING , +LUO_IOCTL_ALL , +}; +struct luo_ioctl_op {unsigned int size;unsigned int min_size;unsigned int ioctl_num; +enum luo_ioctl_type type;int (*execute)(struct luo_session *session,struct luo_ucmd *ucmd); }; -#define IOCTL_OP (_ioctl, _fn, _struct, _last) \ +#define IOCTL_OP (_ioctl, _fn, _struct, _last, _type) \ [_IOC_NR(_ioctl) - LIVEUPDATE_CMD_SESSION_BASE] = { \ .size = sizeof(_struct) + \ BUILD_BUG_ON_ZERO(sizeof(union ucmd_buffer) < \ sizeof(_struct)), \ .min_size = offsetofend(_struct, _last), \ .ioctl_num = _ioctl, \ + .type = _type, \ .execute = _fn, \ }static const struct luo_ioctl_op luo_session_ioctl_ops[] = {IOCTL_OP (LIVEUPDATE_SESSION_FINISH , luo_session_finish, - struct liveupdate_session_finish, reserved), + struct liveupdate_session_finish, reserved, LUO_IOCTL_INCOMING),IOCTL_OP (LIVEUPDATE_SESSION_PRESERVE_FD , luo_session_preserve_fd, - struct liveupdate_session_preserve_fd, token), + struct liveupdate_session_preserve_fd, token, LUO_IOCTL_OUTGOING),IOCTL_OP (LIVEUPDATE_SESSION_RETRIEVE_FD , luo_session_retrieve_fd, - struct liveupdate_session_retrieve_fd, token), + struct liveupdate_session_retrieve_fd, token, LUO_IOCTL_INCOMING), }; +static bool luo_ioctl_type_valid (struct luo_session *session, +const struct luo_ioctl_op *op) +{ +switch (op->type) { +case LUO_IOCTL_INCOMING : +/* Retrieved is only set on incoming sessions */ +return session->retrieved; +case LUO_IOCTL_OUTGOING : +return !session->retrieved; +case LUO_IOCTL_ALL : +return true; + } + +/* Catch-all. */ +return false; +} +static long luo_session_ioctl (struct file *filep,unsigned int cmd,unsigned long arg) {
@@ -380,6 +406,8 @@ static long luo_session_ioctl(struct fil op = &luo_session_ioctl_ops[nr -LIVEUPDATE_CMD_SESSION_BASE ];if (op->ioctl_num != cmd)return -ENOIOCTLCMD ; +if (!luo_ioctl_type_valid (session, op)) +return -EINVAL ;if (ucmd.user_size < op->min_size)return -EINVAL ;
@@ -659,4 +687,3 @@ err_undo:return err; } -
Greg Kroah-Hartman
maintainerPATCH 2069/2077 crypto: xilinx-trng - Remove crypto_rng interface
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 32b4d29280ed2a991dc196d5845b892acedc63b8 upstream.
Implementing the crypto_rng interface has no purpose, as it isn't used in practice. It's being removed from other drivers too. Just remove it. This leaves hwrng, which is actually used.
Tagging with 'Cc stable' due to the bugs that this removes:
- xtrng_trng_generate() sometimes returned success even when it didn't fill in all the bytes.
- It was possible for xtrng_trng_generate() and xtrng_hwrng_trng_read() to run concurrently and interfere with each other, as the locking code in xtrng_hwrng_trng_read() was broken.
--- drivers/crypto/Kconfig | 1 drivers/crypto/xilinx/xilinx-trng.c | 85 +----------------------------------- 2 files changed, 4 insertions(+), 82 deletions(-)
drivers/crypto/Kconfig +0 -1
@@ -721,7 +721,6 @@ config CRYPTO_DEV_XILINX_TRNG tristate "Support for Xilinx True Random Generator" depends on ZYNQMP_FIRMWARE || COMPILE_TEST select CRYPTO_DF80090A - select CRYPTO_RNG select HW_RANDOM help Xilinx Versal SoC driver provides kernel-side support for True Random Number
drivers/crypto/xilinx/xilinx-trng.c +4 -81
161 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 2070/2077 exfat: replace unsafe macros with static inline functions
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit f07db38084dc45162d5fe2871ed72674ddc0f9ae ]
The current exFAT driver relies on various macros for unit conversions between clusters, blocks, sectors, and directory entries. These macros are structurally unsafe as they lack type enforcement and are prone to potential integer overflows during bit-shift operations, especially on 64-bit architectures. Replace all arithmetic macros with static inline functions to provide strict type checking and explicit casting.
Stable-dep-of: 044472d5ee7d ("iomap: consolidate bio submission")
--- fs/exfat/balloc.c | 2 fs/exfat/dir.c | 48 ++++++++++---------- fs/exfat/exfat_fs.h | 122 +++++++++++++++++++++++++++++++++++++--------------- fs/exfat/fatent.c | 4 - fs/exfat/file.c | 8 +-- fs/exfat/inode.c | 19 ++++---- fs/exfat/namei.c | 26 +++++------ fs/exfat/super.c | 4 - 8 files changed, 147 insertions(+), 86 deletions(-)
fs/exfat/balloc.c +1 -1
@@ -112,7 +112,7 @@ static int exfat_allocate_bitmap(struct }if (exfat_test_bitmap_range (sb, sbi->map_clu, -EXFAT_B_TO_CLU_ROUND_UP (map_size, sbi)) == false) +exfat_bytes_to_cluster_round_up (sbi, map_size)) == false) goto err_out;return 0 ;
fs/exfat/dir.c +25 -23
149 lines not on this page · raw message
fs/exfat/exfat_fs.h +89 -33
140 lines not on this page · raw message
fs/exfat/fatent.c +2 -2
@@ -412,8 +412,8 @@ int exfat_zeroed_cluster(struct inode *dif (IS_DIRSYNC (dir))return sync_blockdev_range (sb->s_bdev, -EXFAT_BLK_TO_B (blknr, sb), -EXFAT_BLK_TO_B (last_blknr, sb) -1 ); +exfat_block_to_bytes (sb, blknr), +exfat_block_to_bytes (sb, last_blknr) -1 );return 0 ; }
fs/exfat/file.c +4 -4
@@ -33,9 +33,9 @@ static int exfat_cont_expand(struct inodif (ret)return ret; - num_clusters =EXFAT_B_TO_CLU (exfat_ondisk_size (inode), sbi); + num_clusters =exfat_bytes_to_cluster (sbi,exfat_ondisk_size (inode));/* integer overflow is already checked in inode_newsize_ok(). */ - new_num_clusters =EXFAT_B_TO_CLU_ROUND_UP (size, sbi); + new_num_clusters =exfat_bytes_to_cluster_round_up (sbi, size);if (new_num_clusters == num_clusters) goto out;
@@ -200,8 +200,8 @@ int __exfat_truncate(struct inode *inodeexfat_set_volume_dirty (sb); - num_clusters_new =EXFAT_B_TO_CLU_ROUND_UP (i_size_read (inode), sbi); - num_clusters_phys =EXFAT_B_TO_CLU (exfat_ondisk_size (inode), sbi); + num_clusters_new =exfat_bytes_to_cluster_round_up (sbi,i_size_read (inode)); + num_clusters_phys =exfat_bytes_to_cluster (sbi,exfat_ondisk_size (inode));exfat_chain_set (&clu, ei->start_clu, num_clusters_phys, ei->flags);
fs/exfat/inode.c +10 -9
@@ -135,7 +135,7 @@ static int exfat_map_cluster(struct inodunsigned int local_clu_offset = clu_offset;unsigned int num_to_be_allocated =0 , num_clusters; - num_clusters =EXFAT_B_TO_CLU (exfat_ondisk_size (inode), sbi); + num_clusters =exfat_bytes_to_cluster (sbi,exfat_ondisk_size (inode));if (clu_offset >= num_clusters) num_to_be_allocated = clu_offset - num_clusters +1 ;
@@ -216,7 +216,8 @@ static int exfat_map_cluster(struct inod *clu = new_clu.dir; - inode->i_blocks +=EXFAT_CLU_TO_B (num_to_be_allocated, sbi) >>9 ; + inode->i_blocks += +exfat_cluster_to_sectors (sbi, num_to_be_allocated);/* * Move *clu pointer along FAT chains (hole care) because the
@@ -254,12 +255,12 @@ static int exfat_get_block(struct inodemutex_lock (&sbi->s_lock); i_size =i_size_read (inode); - last_block =EXFAT_B_TO_BLK_ROUND_UP (i_size, sb); + last_block =exfat_bytes_to_block_round_up (sb, i_size);if (iblock >= last_block && !create) goto done;/* Is this block already allocated? */ - count =EXFAT_B_TO_CLU_ROUND_UP (bh_result->b_size, sbi); + count =exfat_bytes_to_cluster_round_up (sbi, bh_result->b_size); err =exfat_map_cluster (inode, iblock >> sbi->sect_per_clus_bits, &cluster, &count, create);if (err) {
@@ -296,9 +297,9 @@ static int exfat_get_block(struct inode* care the last nested block if valid_size is not equal to i_size. */ if (i_size == ei->valid_size || create || !bh_result->b_folio) - valid_blks =EXFAT_B_TO_BLK_ROUND_UP (ei->valid_size, sb); + valid_blks =exfat_bytes_to_block_round_up (sb, ei->valid_size);else - valid_blks =EXFAT_B_TO_BLK (ei->valid_size, sb); + valid_blks =exfat_bytes_to_block (sb, ei->valid_size);/* The range has been fully written, map it */ if (iblock + max_blocks < valid_blks)
@@ -313,7 +314,7 @@ static int exfat_get_block(struct inode/* The area has not been written, map and mark as new for create case */ if (create) {set_buffer_new (bh_result); - ei->valid_size =EXFAT_BLK_TO_B (iblock + max_blocks, sb); + ei->valid_size =exfat_block_to_bytes (sb, iblock + max_blocks);mark_inode_dirty (inode); goto done; }
@@ -343,7 +344,7 @@ static int exfat_get_block(struct inode goto done; } - pos =EXFAT_BLK_TO_B (iblock, sb); + pos =exfat_block_to_bytes (sb, iblock); size = ei->valid_size - pos; addr =folio_address (bh_result->b_folio) +offset_in_folio (bh_result->b_folio, pos);
@@ -374,7 +375,7 @@ static int exfat_get_block(struct inode*/ clear_buffer_mapped (bh_result); done: - bh_result->b_size =EXFAT_BLK_TO_B (max_blocks, sb); + bh_result->b_size =exfat_block_to_bytes (sb, max_blocks);if (err <0 )clear_buffer_mapped (bh_result); unlock_ret:
fs/exfat/namei.c +14 -12
@@ -208,7 +208,7 @@ static int exfat_search_empty_slot(strucint dentries_per_clu;struct exfat_chain clu;struct exfat_sb_info *sbi =EXFAT_SB (sb); -int total_entries =EXFAT_CLU_TO_DEN (p_dir->size, sbi); +unsigned int total_entries =exfat_cluster_to_dentries (sbi, p_dir->size); dentries_per_clu = sbi->dentries_per_clu;
@@ -266,7 +266,7 @@ static int exfat_search_empty_slot(strucstatic int exfat_check_max_dentries (struct inode *inode) { -if (EXFAT_B_TO_DEN (i_size_read (inode)) >=MAX_EXFAT_DENTRIES ) { +if (exfat_bytes_to_dentries (i_size_read (inode)) >=MAX_EXFAT_DENTRIES ) {/* * exFAT spec allows a dir to grow up to 8388608(256MB) * dentries
@@ -314,7 +314,8 @@ int exfat_find_empty_entry(struct inode }exfat_chain_set (p_dir, ei->start_clu, -EXFAT_B_TO_CLU (i_size_read (inode), sbi), ei->flags); +exfat_bytes_to_cluster (sbi,i_size_read (inode)), + ei->flags);while ((dentry =exfat_search_empty_slot (sb, &hint_femp, p_dir, num_entries, es)) <0 ) {
@@ -375,7 +376,7 @@ int exfat_find_empty_entry(struct inode hint_femp.cur.size++; p_dir->size++; - size =EXFAT_CLU_TO_B (p_dir->size, sbi); + size =exfat_cluster_to_bytes (sbi, p_dir->size);/* directory inode should be updated in here */ i_size_write (inode, size);
@@ -604,7 +605,7 @@ static int exfat_find(struct inode *dir,return ret;exfat_chain_set (&cdir, ei->start_clu, -EXFAT_B_TO_CLU (i_size_read (dir), sbi), ei->flags); +exfat_bytes_to_cluster (sbi,i_size_read (dir)), ei->flags);/* check the validation of hint_stat and initialize it if required */ if (ei->version != (inode_peek_iversion_raw (dir) &0xffffffff )) {
@@ -681,7 +682,7 @@ static int exfat_find(struct inode *dir,return -EIO ; } -if (unlikely (EXFAT_B_TO_CLU_ROUND_UP (info->size, sbi) > sbi->used_clusters)) { +if (unlikely (exfat_bytes_to_cluster_round_up (sbi, info->size) > sbi->used_clusters)) {exfat_fs_error (sb,"data size is invalid(%lld)" , info->size);return -EIO ; }
@@ -695,7 +696,8 @@ static int exfat_find(struct inode *dir,if (info->type ==TYPE_DIR ) {exfat_chain_set (&cdir, info->start_clu, -EXFAT_B_TO_CLU (info->size, sbi), info->flags); +exfat_bytes_to_cluster (sbi, info->size), + info->flags); count =exfat_count_dir_entries (sb, &cdir);if (count <0 )return -EIO ;
@@ -951,7 +953,7 @@ static int exfat_rmdir(struct inode *dir }exfat_chain_set (&clu_to_free, ei->start_clu, -EXFAT_B_TO_CLU_ROUND_UP (i_size_read (inode), sbi), ei->flags); +exfat_bytes_to_cluster_round_up (sbi,i_size_read (inode)), ei->flags); err =exfat_check_dir_empty (sb, &clu_to_free);if (err) {
@@ -1207,8 +1209,8 @@ static int __exfat_rename(struct inode * new_clu.dir = new_ei->start_clu; new_clu.size = -EXFAT_B_TO_CLU_ROUND_UP (i_size_read (new_inode), - sbi); +exfat_bytes_to_cluster_round_up (sbi, +i_size_read (new_inode)); new_clu.flags = new_ei->flags; ret =exfat_check_dir_empty (sb, &new_clu);
@@ -1252,8 +1254,8 @@ static int __exfat_rename(struct inode *struct exfat_chain new_clu_to_free;exfat_chain_set (&new_clu_to_free, new_ei->start_clu, -EXFAT_B_TO_CLU_ROUND_UP (i_size_read (new_inode), - sbi), new_ei->flags); +exfat_bytes_to_cluster_round_up (sbi,i_size_read (new_inode)), + new_ei->flags);if (exfat_free_cluster (new_inode, &new_clu_to_free)) {/* just set I/O error only */
fs/exfat/super.c +2 -2
@@ -369,7 +369,7 @@ static int exfat_read_root(struct inode ei->hint_stat.clu = sbi->root_dir; ei->hint_femp.eidx =EXFAT_HINT_NONE ; -i_size_write (inode,EXFAT_CLU_TO_B (root_clu->size, sbi)); +i_size_write (inode,exfat_cluster_to_bytes (sbi, root_clu->size)); num_subdirs =exfat_count_dir_entries (sb, root_clu);if (num_subdirs <0 )
@@ -538,7 +538,7 @@ static int exfat_read_boot_sector(struct* machines. */ sb->s_maxbytes =min (MAX_LFS_FILESIZE , -EXFAT_CLU_TO_B ((loff_t )EXFAT_MAX_NUM_CLUSTER , sbi)); +exfat_cluster_to_bytes (sbi, (loff_t )EXFAT_MAX_NUM_CLUSTER ));/* check logical sector size */ if (exfat_calibrate_blocksize (sb,1 << p_boot->sect_size_bits))
Greg Kroah-Hartman
maintainerPATCH 2071/2077 exfat: add balloc parameter to exfat_map_cluster() for iomap support
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 3474416bb9abafca2e79b7ff700a100b7e8bc766 ]
In preparation for supporting the iomap infrastructure, we need to know whether a new cluster was allocated or not in exfat_map_cluster().
Add an optional 'bool *balloc' output parameter. When a new cluster is allocated, *balloc is set to true. Pass NULL from exfat_get_block() to preserve the existing behavior.
Stable-dep-of: 044472d5ee7d ("iomap: consolidate bio submission")
--- fs/exfat/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/exfat/inode.c +5 -2
@@ -124,7 +124,8 @@ void exfat_sync_inode(struct inode *inod* *clu = (~0), if it's unable to allocate a new cluster */ static int exfat_map_cluster (struct inode *inode,unsigned int clu_offset, -unsigned int *clu,unsigned int *count,int create) +unsigned int *clu,unsigned int *count,int create, +bool *balloc) {int ret;unsigned int last_clu;
@@ -229,6 +230,8 @@ static int exfat_map_cluster(struct inodif (exfat_cluster_walk (sb, clu, num_to_be_allocated -1 , ei->flags))return -EIO ; *count =1 ; +if (balloc) + *balloc = true; }/* hint information */
@@ -262,7 +265,7 @@ static int exfat_get_block(struct inode/* Is this block already allocated? */ count =exfat_bytes_to_cluster_round_up (sbi, bh_result->b_size); err =exfat_map_cluster (inode, iblock >> sbi->sect_per_clus_bits, - &cluster, &count, create); + &cluster, &count, create,NULL );if (err) {if (err != -ENOSPC ) exfat_fs_error_ratelimit(sb,
Greg Kroah-Hartman
maintainerPATCH 2072/2077 exfat: add data_start_bytes and exfat_cluster_to_phys_bytes() helper
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 3b9450beeb961c7ddf4cccddba37fcfa6d1fcb7a ]
This caches the data area start offset in bytes (data_start_bytes) and introduces a helper function exfat_cluster_to_phys_bytes() to compute the physical byte position of a given cluster.
Stable-dep-of: 044472d5ee7d ("iomap: consolidate bio submission")
--- fs/exfat/exfat_fs.h | 8 ++++++++ fs/exfat/super.c | 1 + 2 files changed, 9 insertions(+)
fs/exfat/exfat_fs.h +8 -0
@@ -227,6 +227,7 @@ struct exfat_sb_info {unsigned long long FAT1_start_sector;/* FAT1 start sector */ unsigned long long FAT2_start_sector;/* FAT2 start sector */ unsigned long long data_start_sector;/* data area start sector */ +unsigned long long data_start_bytes;unsigned int num_FAT_sectors;/* num of FAT sectors */ unsigned int root_dir;/* root dir cluster */ unsigned int dentries_per_clu;/* num of dentries per cluster */
@@ -400,6 +401,13 @@ static inline loff_t exfat_ondisk_size(creturn ((loff_t )inode->i_blocks) <<9 ; } +static inline loff_t exfat_cluster_to_phys_bytes (struct exfat_sb_info *sbi, +unsigned int clus) +{ +return ((loff_t)(clus -EXFAT_RESERVED_CLUSTERS ) << sbi->cluster_size_bits) + + sbi->data_start_bytes; +} +/* * helpers for cluster size to byte conversion. */
fs/exfat/super.c +1 -0
@@ -499,6 +499,7 @@ static int exfat_read_boot_sector(structif (p_boot->num_fats ==2 ) sbi->FAT2_start_sector += sbi->num_FAT_sectors; sbi->data_start_sector =le32_to_cpu (p_boot->clu_offset); + sbi->data_start_bytes = sbi->data_start_sector << p_boot->sect_size_bits; sbi->num_sectors =le64_to_cpu (p_boot->vol_length);/* because the cluster index starts with 2 */ sbi->num_clusters = le32_to_cpu(p_boot->clu_count) +
Greg Kroah-Hartman
maintainerPATCH 2073/2077 exfat: fix implicit declaration of brelse()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit f0d1b2e1e02c11e29c953f22a485449e3da2a575 ]
exfat_cluster_walk() calls brelse(bh) without including the header that declares the function, causing the following build error:
fs/exfat/exfat_fs.h:542:9: error: implicit declaration of function ‘brelse’ [-Werror=implicit-function-declaration]
Fix this by adding the missing buffer_head.h in exfat_fs.h.
Stable-dep-of: 044472d5ee7d ("iomap: consolidate bio submission")
--- fs/exfat/exfat_fs.h | 1 + 1 file changed, 1 insertion(+)
fs/exfat/exfat_fs.h +1 -0
@@ -12,6 +12,7 @@#include <linux/blkdev.h> #include <linux/backing-dev.h> #include <uapi/linux/exfat.h> +#include <linux/buffer_head.h> #define EXFAT_ROOT_INO 1
Greg Kroah-Hartman
maintainerPATCH 2074/2077 iomap: consolidate bio submission
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit 044472d5ee7d71f918fa3f61bd65e4933a0c006e ]
Add a iomap_bio_submit_read_endio helper factored out of iomap_bio_submit_read to that all ->submit_read implementations for iomap_read_ops that use iomap_bio_read_folio_range can shared the logic.
Right now that logic is mostly trivial, but already has a bug for XFS because the XFS version is too trivial: file system integrity validation needs a workqueue context and thus can't happen from the default iomap bi_end_io I/O handler. Unfortunately the iomap refactoring just before fs integrity landed moved code around here and the call go misplaced, meaning it never got called. The PI information still is verified by the block layer, but the offloading is less efficient (and the future userspace interface can't get at it).
--- fs/iomap/bio.c | 13 ++++++++++--- fs/ntfs/aops.c | 6 ++---- fs/ntfs3/inode.c | 5 +---- fs/xfs/xfs_aops.c | 3 +-- include/linux/iomap.h | 2 ++ 5 files changed, 16 insertions(+), 13 deletions(-)
fs/iomap/bio.c +10 -3
@@ -78,15 +78,23 @@ u32 iomap_finish_ioend_buffered_read(strreturn __iomap_read_end_io (&ioend->io_bio, ioend->io_error); } -static void iomap_bio_submit_read (const struct iomap_iter *iter, -struct iomap_read_folio_ctx *ctx) +void iomap_bio_submit_read_endio (const struct iomap_iter *iter, +struct iomap_read_folio_ctx *ctx,bio_end_io_t end_io) {struct bio *bio = ctx->read_ctx; + bio->bi_end_io = end_io;if (iter->iomap.flags &IOMAP_F_INTEGRITY )fs_bio_integrity_alloc (bio);submit_bio (bio); } +EXPORT_SYMBOL_GPL (iomap_bio_submit_read_endio); + +static void iomap_bio_submit_read (const struct iomap_iter *iter, +struct iomap_read_folio_ctx *ctx) +{ +return iomap_bio_submit_read_endio (iter, ctx, iomap_read_end_io); +}static struct bio_set *iomap_read_bio_set (struct iomap_read_folio_ctx *ctx) {
@@ -127,7 +135,6 @@ static void iomap_read_alloc_bio(const sif (ctx->rac) bio->bi_opf |=REQ_RAHEAD ; bio->bi_iter.bi_sector =iomap_sector (iomap, iter->pos); - bio->bi_end_io = iomap_read_end_io;bio_add_folio_nofail (bio, folio, plen,offset_in_folio (folio, iter->pos)); ctx->read_ctx = bio;
fs/ntfs/aops.c +2 -4
@@ -38,11 +38,9 @@ static void ntfs_iomap_read_end_io(struc }static void ntfs_iomap_bio_submit_read (const struct iomap_iter *iter, -struct iomap_read_folio_ctx *ctx) +struct iomap_read_folio_ctx *ctx) { -struct bio *bio = ctx->read_ctx; - bio->bi_end_io = ntfs_iomap_read_end_io; -submit_bio (bio); +iomap_bio_submit_read_endio (iter, ctx, ntfs_iomap_read_end_io); }static const struct iomap_read_ops ntfs_iomap_bio_read_ops = {
fs/ntfs3/inode.c +1 -4
@@ -609,10 +609,7 @@ static void ntfs_iomap_read_end_io(strucstatic void ntfs_iomap_bio_submit_read (const struct iomap_iter *iter,struct iomap_read_folio_ctx *ctx) { -struct bio *bio = ctx->read_ctx; - - bio->bi_end_io = ntfs_iomap_read_end_io; -submit_bio (bio); +iomap_bio_submit_read_endio (iter, ctx, ntfs_iomap_read_end_io); }static const struct iomap_read_ops ntfs_iomap_bio_read_ops = {
fs/xfs/xfs_aops.c +1 -2
@@ -753,8 +753,7 @@ xfs_bio_submit_read(/* defer read completions to the ioend workqueue */ iomap_init_ioend (iter->inode, bio, ctx->read_ctx_file_offset,0 ); - bio->bi_end_io = xfs_end_bio; -submit_bio (bio); +iomap_bio_submit_read_endio (iter, ctx, xfs_end_bio); }static const struct iomap_read_ops xfs_iomap_read_ops = {
include/linux/iomap.h +2 -0
@@ -615,6 +615,8 @@ extern struct bio_set iomap_ioend_bioset#ifdef CONFIG_BLOCK int iomap_bio_read_folio_range (const struct iomap_iter *iter,struct iomap_read_folio_ctx *ctx,size_t plen); +void iomap_bio_submit_read_endio (const struct iomap_iter *iter, +struct iomap_read_folio_ctx *ctx,bio_end_io_t end_io);extern const struct iomap_read_ops iomap_bio_read_ops;
Greg Kroah-Hartman
maintainerPATCH 2075/2077 drm/amd/display: Fix Color Manager (3DLUT, Shaper, Blend)
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dillon Varone <[email protected]>
commit 12f58a6caad3be54d7788b338b3f57d7c17bbef7 upstream.
[WHY & HOW]
The original refactor and fixes are causing regressions. Revert them for now until they can be resolved
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 81 + drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 drivers/gpu/drm/amd/display/dc/dc.h | 58 - drivers/gpu/drm/amd/display/dc/dc_types.h | 24 drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c | 201 +--- drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.h | 23 drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.c | 78 - drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.h | 10 drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 389 +++++-- drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.c | 499 +++++++++- drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.h | 9 drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h | 35 drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h | 79 - drivers/gpu/drm/amd/display/dc/mpc/dcn401/dcn401_mpc.c | 177 +-- drivers/gpu/drm/amd/display/dc/mpc/dcn401/dcn401_mpc.h | 25 drivers/gpu/drm/amd/display/dc/mpc/dcn42/dcn42_mpc.c | 388 +++++++ drivers/gpu/drm/amd/display/dc/mpc/dcn42/dcn42_mpc.h | 49 drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c | 1 18 files changed, 1439 insertions(+), 689 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +50 -31
@@ -2956,27 +2956,16 @@ static struct surface_update_descriptorelevate_update_type (&overall_type,UPDATE_TYPE_FAST ,LOCK_DESCRIPTOR_STREAM ); } -if (u->cm || (u->gamma &&dce_use_lut (u->plane_info ? u->plane_info->format : u->surface->format))) { +if (u->blend_tf || (u->gamma &&dce_use_lut (u->plane_info ? u->plane_info->format : u->surface->format))) { update_flags->bits.gamma_change =1 ;elevate_update_type (&overall_type,UPDATE_TYPE_FAST ,LOCK_DESCRIPTOR_STREAM ); } -if (u->cm && (u->cm->flags.bits.lut3d_enable || u->surface->cm.flags.bits.lut3d_enable)) { +if (u->lut3d_func || u->func_shaper) { update_flags->bits.lut_3d =1 ;elevate_update_type (&overall_type,UPDATE_TYPE_FAST ,LOCK_DESCRIPTOR_STREAM ); } -if (u->cm && u->cm->flags.bits.lut3d_dma_enable != u->surface->cm.flags.bits.lut3d_dma_enable && - u->cm->flags.bits.lut3d_enable && u->surface->cm.flags.bits.lut3d_enable) { -/* Toggling 3DLUT loading between DMA and Host is illegal */ -BREAK_TO_DEBUGGER (); - } - -if (u->cm && u->cm->flags.bits.lut3d_enable && !u->cm->flags.bits.lut3d_dma_enable) { -/* Host loading 3DLUT requires full update but only stream lock */ -elevate_update_type (&overall_type,UPDATE_TYPE_FULL ,LOCK_DESCRIPTOR_STREAM ); - } -if (u->hdr_mult.value)if (u->hdr_mult.value != u->surface->hdr_mult.value) {// TODO: Should be fast?
@@ -2995,6 +2984,20 @@ static struct surface_update_descriptor update_flags->bits.cm_hist_change =1 ;elevate_update_type (&overall_type,UPDATE_TYPE_FAST ,LOCK_DESCRIPTOR_STREAM ); } +if (u->cm2_params) { +if (u->cm2_params->component_settings.shaper_3dlut_setting != u->surface->mcm_shaper_3dlut_setting + || u->cm2_params->component_settings.lut1d_enable != u->surface->mcm_lut1d_enable + || u->cm2_params->cm2_luts.lut3d_data.lut3d_src != u->surface->mcm_luts.lut3d_data.lut3d_src) { + update_flags->bits.mcm_transfer_function_enable_change =1 ; +elevate_update_type (&overall_type,UPDATE_TYPE_FULL ,LOCK_DESCRIPTOR_GLOBAL ); + } + } + +if (update_flags->bits.lut_3d && + u->surface->mcm_luts.lut3d_data.lut3d_src !=DC_CM2_TRANSFER_FUNC_SOURCE_VIDMEM ) { +elevate_update_type (&overall_type,UPDATE_TYPE_FULL ,LOCK_DESCRIPTOR_GLOBAL ); + } + if (check_config->enable_legacy_fast_update && (update_flags->bits.gamma_change || update_flags->bits.gamut_remap_change ||
@@ -3250,12 +3253,24 @@ static void copy_surface_update_to_plane sizeof(struct dc_transfer_func_distributed_points)); } -/* Shaper, 3DLUT, 1DLUT */ -if (srf_update->cm) { -memcpy (&surface->cm, srf_update->cm, -sizeof (surface->cm)); +if (srf_update->cm2_params) { + surface->mcm_shaper_3dlut_setting = srf_update->cm2_params->component_settings.shaper_3dlut_setting; + surface->mcm_lut1d_enable = srf_update->cm2_params->component_settings.lut1d_enable; + surface->mcm_luts = srf_update->cm2_params->cm2_luts; + } + +if (srf_update->func_shaper) { +memcpy (&surface->in_shaper_func, srf_update->func_shaper, +sizeof (surface->in_shaper_func)); + +if (surface->mcm_shaper_3dlut_setting >=DC_CM2_SHAPER_3DLUT_SETTING_ENABLE_SHAPER ) + surface->mcm_luts.shaper = &surface->in_shaper_func; } +if (srf_update->lut3d_func) +memcpy (&surface->lut3d_func, srf_update->lut3d_func, +sizeof (surface->lut3d_func)); +if (srf_update->hdr_mult.value) surface->hdr_mult = srf_update->hdr_mult;
@@ -3264,6 +3279,17 @@ static void copy_surface_update_to_plane surface->sdr_white_level_nits = srf_update->sdr_white_level_nits; +if (srf_update->blend_tf) { +memcpy (&surface->blend_tf, srf_update->blend_tf, +sizeof (surface->blend_tf)); + +if (surface->mcm_lut1d_enable) + surface->mcm_luts.lut1d_func = &surface->blend_tf; + } + +if (srf_update->cm2_params || srf_update->blend_tf) + surface->lut_bank_a = !surface->lut_bank_a; +if (srf_update->input_csc_color_matrix) surface->input_csc_color_matrix = *srf_update->input_csc_color_matrix;
@@ -4550,9 +4576,11 @@ static void commit_planes_for_stream(strif (!should_update_pipe_for_plane (context, pipe_ctx, plane_state))continue ; -if (srf_updates[i].cm && - srf_updates[i].cm->flags.bits.lut3d_enable && - srf_updates[i].cm->flags.bits.lut3d_dma_enable && +if (srf_updates[i].cm2_params && + srf_updates[i].cm2_params->cm2_luts.lut3d_data.lut3d_src == +DC_CM2_TRANSFER_FUNC_SOURCE_VIDMEM && + srf_updates[i].cm2_params->component_settings.shaper_3dlut_setting == +DC_CM2_SHAPER_3DLUT_SETTING_ENABLE_SHAPER_3DLUT && dc->hwss.trigger_3dlut_dma_load) dc->hwss.trigger_3dlut_dma_load (dc, pipe_ctx);
@@ -5209,12 +5237,6 @@ static bool full_update_required( const struct dc_stream_update *stream_update, const struct dc_stream_state *stream) { - const union dc_plane_cm_flags blend_only_flags = { - .bits = { - .blend_enable =1 , - } - }; - if (full_update_required_weak(dc, srf_updates, surface_count, stream_update, stream)) return true;
@@ -5229,10 +5251,7 @@ static bool full_update_required( srf_updates[i].in_transfer_func || srf_updates[i].surface->force_full_update || (srf_updates[i].flip_addr && - srf_updates[i].flip_addr->address.tmz_surface != srf_updates[i].surface->address.tmz_surface) || - (srf_updates[i].cm && - ((srf_updates[i].cm->flags.all != blend_only_flags.all && srf_updates[i].cm->flags.all !=0 ) || - (srf_updates[i].surface->cm.flags.all != blend_only_flags.all && srf_updates[i].surface->cm.flags.all != 0))))) + srf_updates[i].flip_addr->address.tmz_surface != srf_updates[i].surface->address.tmz_surface))) return true; }
@@ -6966,7 +6985,7 @@ bool dc_capture_register_software_state(struct dc_plane_state *plane_state = pipe_ctx->plane_state;/* MPCC blending tree and mode control - capture actual blend configuration */ - state->mpc.mpcc_mode[i] = (plane_state->cm.blend_func.type !=TF_TYPE_BYPASS ) ?1 :0 ; + state->mpc.mpcc_mode[i] = (plane_state->blend_tf.type !=TF_TYPE_BYPASS ) ?1 :0 ; state->mpc.mpcc_alpha_blend_mode[i] = plane_state->per_pixel_alpha ?1 :0 ; state->mpc.mpcc_alpha_multiplied_mode[i] = plane_state->pre_multiplied_alpha ?1 :0 ; state->mpc.mpcc_blnd_active_overlap_only[i] =0 ;/* Default - no overlap restriction */
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +2 -0
@@ -996,6 +996,7 @@ void dc_stream_release_3dlut_for_stream(if (rmcm_3dlut) { rmcm_3dlut->isInUse = false; rmcm_3dlut->stream =NULL ; + rmcm_3dlut->protection_bits =0 ; } }
@@ -1007,6 +1008,7 @@ void dc_stream_init_rmcm_3dlut(struct dcfor (int i =0 ; i < num_rmcm; i++) { dc->res_pool->rmcm_3dlut[i].isInUse = false; dc->res_pool->rmcm_3dlut[i].stream =NULL ; + dc->res_pool->rmcm_3dlut[i].protection_bits =0 ; } }
drivers/gpu/drm/amd/display/dc/dc.h +10 -48
94 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dc_types.h +0 -24
@@ -1493,28 +1493,4 @@ struct dc_validation_dpia_set { uint32_t required_bw; }; -enum dc_cm_lut_swizzle { -CM_LUT_3D_SWIZZLE_LINEAR_RGB , -CM_LUT_3D_SWIZZLE_LINEAR_BGR , -CM_LUT_1D_PACKED_LINEAR -}; - -enum dc_cm_lut_pixel_format { -CM_LUT_PIXEL_FORMAT_RGBA16161616_UNORM_12MSB , -CM_LUT_PIXEL_FORMAT_BGRA16161616_UNORM_12MSB , -CM_LUT_PIXEL_FORMAT_RGBA16161616_UNORM_12LSB , -CM_LUT_PIXEL_FORMAT_BGRA16161616_UNORM_12LSB , -CM_LUT_PIXEL_FORMAT_RGBA16161616_FLOAT_FP1_5_10 , -CM_LUT_PIXEL_FORMAT_BGRA16161616_FLOAT_FP1_5_10 -}; - -enum dc_cm_lut_size { -CM_LUT_SIZE_NONE , -CM_LUT_SIZE_999 , -CM_LUT_SIZE_171717 , -CM_LUT_SIZE_333333 , -CM_LUT_SIZE_454545 , -CM_LUT_SIZE_656565 , -}; -#endif /* DC_TYPES_H_ */
drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c +67 -134
260 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.h +19 -4
@@ -328,17 +328,32 @@ int hubp401_get_3dlut_fl_done(struct hubvoid hubp401_set_unbounded_requesting (struct hubp *hubp,bool enable); +void hubp401_update_3dlut_fl_bias_scale (struct hubp *hubp,uint16_t bias,uint16_t scale); +void hubp401_program_3dlut_fl_crossbar (struct hubp *hubp, -const enum dc_cm_lut_pixel_format format); +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_y_g, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cb_b, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cr_r); + +void hubp401_program_3dlut_fl_tmz_protected (struct hubp *hubp,uint8_t protection_bits); + +void hubp401_program_3dlut_fl_width (struct hubp *hubp,enum hubp_3dlut_fl_width width); + +void hubp401_program_3dlut_fl_addressing_mode (struct hubp *hubp,enum hubp_3dlut_fl_addressing_mode addr_mode);void hubp401_enable_3dlut_fl (struct hubp *hubp,bool enable);void hubp401_program_3dlut_fl_dlg_param (struct hubp *hubp,int refcyc_per_3dlut_group); -void hubp401_program_3dlut_fl_addr (struct hubp *hubp,const struct dc_plane_address *address); +void hubp401_program_3dlut_fl_addr (struct hubp *hubp,const struct dc_plane_address address); + +void hubp401_program_3dlut_fl_format (struct hubp *hubp,enum hubp_3dlut_fl_format format); + +void hubp401_program_3dlut_fl_mode (struct hubp *hubp,enum hubp_3dlut_fl_mode mode); -void hubp401_program_3dlut_fl_config (struct hubp *hubp, -const struct dc_3dlut_dma *config); +void hubp401_program_3dlut_fl_config ( +struct hubp *hubp, +struct hubp_fl_3dlut_config *cfg);void hubp401_clear_tiling (struct hubp *hubp);
drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.c +9 -69
103 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.h +5 -5
@@ -58,11 +58,11 @@ bool hubp42_construct(const struct dcn_hubp2_shift *hubp_shift, const struct dcn_hubp2_mask *hubp_mask); -void hubp42_program_3dlut_fl_crossbar (struct hubp *hubp, -const enum dc_cm_lut_pixel_format format); - -void hubp42_program_3dlut_fl_config (struct hubp *hubp, -const struct dc_3dlut_dma *config); +void hubp42_program_3dlut_fl_crossbar ( +struct hubp *hubp, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_r, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_g, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_b);void hubp42_read_state (struct hubp *hubp);
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c +257 -132
452 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.c +463 -36
574 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.h +8 -1
@@ -18,11 +18,18 @@ void dcn42_program_cm_hist(bool dcn42_set_mcm_luts (struct pipe_ctx *pipe_ctx,const struct dc_plane_state *plane_state); +void dcn42_populate_mcm_luts (struct dc *dc, +struct pipe_ctx *pipe_ctx, +struct dc_cm2_func_luts mcm_luts, +bool lut_bank_a); +bool dcn42_program_rmcm_luts (struct hubp *hubp,struct pipe_ctx *pipe_ctx, -const struct dc_plane_cm *cm, +enum dc_cm2_transfer_func_source lut3d_src, +struct dc_cm2_func_luts *mcm_luts,struct mpc *mpc, +bool lut_bank_a,int mpcc_id);void dcn42_hardware_release (struct dc *dc);
drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h +30 -5
@@ -89,7 +89,7 @@ enum hubp_3dlut_fl_addressing_mode {enum hubp_3dlut_fl_width { hubp_3dlut_fl_width_17 =17 , hubp_3dlut_fl_width_33 =33 , - hubp_3dlut_fl_width_17_transformed =4916 ,//mpc default + hubp_3dlut_fl_width_transformed =4916 ,//mpc default };enum hubp_3dlut_fl_crossbar_bit_slice {
@@ -99,6 +99,22 @@ enum hubp_3dlut_fl_crossbar_bit_slice { hubp_3dlut_fl_crossbar_bit_slice_48_63 =3 }; +struct hubp_fl_3dlut_config { +bool enabled; +enum hubp_3dlut_fl_width width; +enum hubp_3dlut_fl_mode mode; +enum hubp_3dlut_fl_format format; +uint16_t bias; +uint16_t scale; +struct dc_plane_address address; +enum hubp_3dlut_fl_addressing_mode addr_mode; +enum dc_cm2_gpu_mem_layout layout; +uint8_t protection_bits; +enum hubp_3dlut_fl_crossbar_bit_slice crossbar_bit_slice_y_g; +enum hubp_3dlut_fl_crossbar_bit_slice crossbar_bit_slice_cb_b; +enum hubp_3dlut_fl_crossbar_bit_slice crossbar_bit_slice_cr_r; +}; +struct hubp {const struct hubp_funcs *funcs;struct dc_context *ctx;
@@ -273,15 +289,24 @@ struct hubp_funcs {void (*hubp_wait_pipe_read_start)(struct hubp *hubp);void (*hubp_program_mcache_id_and_split_coordinate)(struct hubp *hubp,struct dml2_hubp_pipe_mcache_regs *mcache_regs); +void (*hubp_update_3dlut_fl_bias_scale)(struct hubp *hubp,uint16_t bias,uint16_t scale); +void (*hubp_program_3dlut_fl_mode)(struct hubp *hubp, +enum hubp_3dlut_fl_mode mode); +void (*hubp_program_3dlut_fl_format)(struct hubp *hubp, +enum hubp_3dlut_fl_format format);void (*hubp_program_3dlut_fl_addr)(struct hubp *hubp, -const struct dc_plane_address *address); -void (*hubp_program_3dlut_fl_config)(struct hubp *hubp, -const struct dc_3dlut_dma *config); +const struct dc_plane_address address);void (*hubp_program_3dlut_fl_dlg_param)(struct hubp *hubp,int refcyc_per_3dlut_group);void (*hubp_enable_3dlut_fl)(struct hubp *hubp,bool enable); +void (*hubp_program_3dlut_fl_addressing_mode)(struct hubp *hubp,enum hubp_3dlut_fl_addressing_mode addr_mode); +void (*hubp_program_3dlut_fl_width)(struct hubp *hubp,enum hubp_3dlut_fl_width width); +void (*hubp_program_3dlut_fl_tmz_protected)(struct hubp *hubp,uint8_t protection_bits);void (*hubp_program_3dlut_fl_crossbar)(struct hubp *hubp, -enum dc_cm_lut_pixel_format format); +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_y_g, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cb_b, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cr_r);int (*hubp_get_3dlut_fl_done)(struct hubp *hubp); +void (*hubp_program_3dlut_fl_config)(struct hubp *hubp,struct hubp_fl_3dlut_config *cfg);void (*hubp_clear_tiling)(struct hubp *hubp);uint32_t (*hubp_get_current_read_line)(struct hubp *hubp);uint32_t (*hubp_get_det_config_error)(struct hubp *hubp);
drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h +32 -47
136 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/mpc/dcn401/dcn401_mpc.c +77 -100
251 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/mpc/dcn401/dcn401_mpc.h +7 -18
@@ -206,32 +206,21 @@ void dcn401_mpc_construct(struct dcn401_ int num_rmu);void mpc401_set_movable_cm_location (struct mpc *mpc,enum mpcc_movable_cm_location location,int mpcc_id); -void mpc401_populate_lut (struct mpc *mpc, -const enum MCM_LUT_ID id, -const union mcm_lut_params *params, -bool lut_bank_a, -int mpcc_id); +void mpc401_populate_lut (struct mpc *mpc,const enum MCM_LUT_ID id,const union mcm_lut_params params, +bool lut_bank_a,int mpcc_id);void mpc401_program_lut_mode (struct mpc *mpc,const enum MCM_LUT_ID id, -const bool enable, -const bool lut_bank_a, -const enum dc_cm_lut_size size, -const int mpcc_id); - -void mpc401_get_lut_mode (struct mpc *mpc, -const enum MCM_LUT_ID id, -const int mpcc_id, -bool *enable, -bool *lut_bank_a); +const enum MCM_LUT_XABLE xable, +bool lut_bank_a, +int mpcc_id);void mpc401_program_lut_read_write_control (struct mpc *mpc,const enum MCM_LUT_ID id, -const bool lut_bank_a, -const unsigned int bit_depth, -const int mpcc_id); +bool lut_bank_a, +int mpcc_id); void mpc401_set_gamut_remap( struct mpc *mpc,
drivers/gpu/drm/amd/display/dc/mpc/dcn42/dcn42_mpc.c +356 -32
448 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/mpc/dcn42/dcn42_mpc.h +47 -2
71 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c +0 -1
@@ -666,7 +666,6 @@ static const struct resource_caps res_ca .num_vmid = 16, .num_mpc_3dlut = 2, .num_dsc = 4, - .num_rmcm = 2, };static const struct dc_plane_cap plane_cap = {
Greg Kroah-Hartman
maintainerPATCH 2076/2077 posix-timers: Expand timer_[re]arm() callbacks with a boolean return value
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 6fdb2677a594ab38eade927919bbd4d9688bfa1c upstream.
In order to catch expiry times which are already in the past the timer_arm() and timer_rearm() callbacks need to be able to report back to the caller whether the timer has been queued or not.
Change the function signature and let all implementations return true for now. While at it simplify posix_cpu_timer_rearm().
No functional change intended.
--- kernel/time/alarmtimer.c | 6 ++++-- kernel/time/posix-cpu-timers.c | 18 ++++++++++-------- kernel/time/posix-timers.c | 6 ++++-- kernel/time/posix-timers.h | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-)
kernel/time/alarmtimer.c +4 -2
@@ -525,12 +525,13 @@ static void alarm_handle_timer(struct al* alarm_timer_rearm - Posix timer callback for rearming timer * @timr: Pointer to the posixtimer data struct */ -static void alarm_timer_rearm (struct k_itimer *timr) +static bool alarm_timer_rearm (struct k_itimer *timr) {struct alarm *alarm = &timr->it.alarm.alarmtimer; timr->it_overrun +=alarm_forward_now (alarm, timr->it_interval);alarm_start (alarm, alarm->node.expires); +return true; }/**
@@ -586,7 +587,7 @@ static void alarm_timer_wait_running(str* @absolute: Expiry value is absolute time * @sigev_none: Posix timer does not deliver signals */ -static void alarm_timer_arm (struct k_itimer *timr,ktime_t expires, +static bool alarm_timer_arm (struct k_itimer *timr,ktime_t expires,bool absolute,bool sigev_none) {struct alarm *alarm = &timr->it.alarm.alarmtimer;
@@ -598,6 +599,7 @@ static void alarm_timer_arm(struct k_iti alarm->node.expires = expires; else alarm_start(&timr->it.alarm.alarmtimer, expires); +return true; }/**
kernel/time/posix-cpu-timers.c +10 -8
@@ -19,7 +19,7 @@#include "posix-timers.h" -static void posix_cpu_timer_rearm (struct k_itimer *timer); +static bool posix_cpu_timer_rearm (struct k_itimer *timer);void posix_cputimers_group_init (struct posix_cputimers *pct,u64 cpu_limit) {
@@ -1011,24 +1011,27 @@ static void check_process_timers(struct/* * This is called from the signal code (via posixtimer_rearm) * when the last timer signal was delivered and we have to reload the timer. +* +* Return true unconditionally so the core code assumes the timer to be +* armed. Otherwise it would requeue the signal. */ -static void posix_cpu_timer_rearm (struct k_itimer *timer) +static bool posix_cpu_timer_rearm (struct k_itimer *timer) {clockid_t clkid =CPUCLOCK_WHICH (timer->it_clock); -struct task_struct *p;struct sighand_struct *sighand; +struct task_struct *p;unsigned long flags;u64 now; -rcu_read_lock (); +guard (rcu)(); p =cpu_timer_task_rcu (timer);if (!p) - goto out; +return true;/* Protect timer list r/w in arm_timer() */ sighand =lock_task_sighand (p, &flags);if (unlikely (sighand ==NULL )) - goto out; +return true;/* * Fetch the current sample and update the timer's expiry time.
@@ -1045,8 +1048,7 @@ static void posix_cpu_timer_rearm(struct*/ arm_timer (timer, p);unlock_task_sighand (p, &flags); -out: -rcu_read_unlock (); +return true; }/**
kernel/time/posix-timers.c +4 -2
@@ -288,12 +288,13 @@ static inline int timer_overrun_to_int(sreturn (int )timr->it_overrun_last; } -static void common_hrtimer_rearm (struct k_itimer *timr) +static bool common_hrtimer_rearm (struct k_itimer *timr) {struct hrtimer *timer = &timr->it.real.timer; timr->it_overrun +=hrtimer_forward_now (timer, timr->it_interval);hrtimer_restart (timer); +return true; }static bool __posixtimer_deliver_signal (struct kernel_siginfo *info,struct k_itimer *timr)
@@ -795,7 +796,7 @@ SYSCALL_DEFINE1(timer_getoverrun, timer_return timer_overrun_to_int (scoped_timer); } -static void common_hrtimer_arm (struct k_itimer *timr,ktime_t expires, +static bool common_hrtimer_arm (struct k_itimer *timr,ktime_t expires,bool absolute,bool sigev_none) {struct hrtimer *timer = &timr->it.real.timer;
@@ -822,6 +823,7 @@ static void common_hrtimer_arm(struct k_if (!sigev_none)hrtimer_start_expires (timer,HRTIMER_MODE_ABS ); +return true; }static int common_hrtimer_try_to_cancel (struct k_itimer *timr)
kernel/time/posix-timers.h +2 -2
@@ -27,11 +27,11 @@ struct k_clock {int (*timer_del)(struct k_itimer *timr);void (*timer_get)(struct k_itimer *timr,struct itimerspec64 *cur_setting); -void (*timer_rearm)(struct k_itimer *timr); +bool (*timer_rearm)(struct k_itimer *timr);s64 (*timer_forward)(struct k_itimer *timr,ktime_t now);ktime_t (*timer_remaining)(struct k_itimer *timr,ktime_t now);int (*timer_try_to_cancel)(struct k_itimer *timr); -void (*timer_arm)(struct k_itimer *timr,ktime_t expires, +bool (*timer_arm)(struct k_itimer *timr,ktime_t expires,bool absolute,bool sigev_none);void (*timer_wait_running)(struct k_itimer *timr); };
Greg Kroah-Hartman
maintainerPATCH 2077/2077 posix-cpu-timers: Prevent UAF caused by non-leader exec() race
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 920f893f735e92ba3a1cd9256899a186b161928d upstream.
Wongi and Jungwoo decoded and reported a non-leader exec() related race which can result in an UAF:
sys_timer_delete() exec()
posix_cpu_timer_del()
// Observes old leader
p = pid_task(pid, pid_type); de_thread()
switch_leader();
release_task(old_leader)
__exit_signal(old_leader)
sighand = lock(old_leader, sighand);
posix_cpu_timers*_exit();
sighand = lock_task_sighand(p) unhash_task(old_leader);
sh = lock(p, sighand) old_leader->sighand = NULL;
unlock(sighand);
(p->sighand == NULL)
unlock(sh)
return NULL; // Returns without action
if(!sighand)
return 0;
free_posix_timer();This is "harmless" unless the deleted timer was armed and enqueued in p->signal because on exec() a TGID targeted timer is inherited.
As sys_timer_delete() freed the underlying posix timer object run_posix_cpu_timers() or any timerqueue related add/delete operations on other timers will access the freed object's timerqueue node, which results in an UAF.
There is a similar problem vs. posix_cpu_timer_set(). For regular posix timers it just transiently returns -ESRCH to user space, but for the use case in do_cpu_nanosleep() it's the same UAF just that the k_itimer is allocated on the stack.
Also posix_cpu_timer_rearm() fails to rearm the timer, which means it stops to expire.
While debating solutions Frederic pointed out another problem:
posix_cpu_timer_del(tmr)
__exit_signal(p)
posix_cpu_timers*_exit(p);
unhash_task(p);
p->sighand = NULL;
sh = lock_task_sighand(p)
sighand = p->sighand;
if (!sighand)
return NULL;
lock(sighand);
if (!sh)
WARN_ON_ONCE(timer_queued(tmr));On weakly ordered architectures it is not guaranteed that posix_cpu_timer_del() will observe the stores in posix_cpu_timers*_exit() when p->sighand is observed as NULL, which means the WARN() can be a false positive.
Solve these issues by:
1) Changing the store in __exit_signal() to smp_store_release().
2) Adding a smp_acquire__after_ctrl_dep() into the !sighand path of lock_task_sighand().
3) Creating a helper function for looking up the task and locking sighand which does not return when sighand == NULL. Instead it retries the task lookup and only if that fails it gives up.
4) Using that helper in the three affected functions.
observes all preceeding stores, i.e. the stores in posix_cpu_timers*_exit() and the ones in unhash_task().
gracefully. When the task lookup returns the old leader, but sighand == NULL then it retries. In the non-leader exec() case the subsequent task lookup will observe the new leader due to #1/#2. In normal exit() scenarios the subsequent lookup fails.
When the task lookup fails, the function also checks whether the timer is still enqueued and issues a warning if that's the case. Unfortunately there is nothing which can be done about it, but as the task is already not longer visible the timer should not be accessed anymore. This check also requires memory ordering, which is not provided when the first lookup fails. To achieve that the check is preceeded by a smp_rmb() which pairs with the smp_wmb() in write_seqlock() in __exit_signal(). That ensures that the stores in posix_cpu_timers*_exit() are visible.
The history of the non-leader exec() issue goes back to the early days of posix CPU timers, which stored a pointer to the group leader task in the timer. That obviously fails when a non-leader exec() switches the leader. commit e0a70217107e ("posix-cpu-timers: workaround to suppress the problems with mt exec") added a temporary workaround for that in 2010 which survived about 10 years. The fix for the workaround changed the task pointer to a pid pointer, but failed to see the subtle race described above. So the Fixes tag picks that commit, which seems to be halfways accurate.
Thanks to Frederic Weissbecker, Oleg Nesterov and Peter Zijlstra for review, feedback and suggestions and to Wongi and Jungwoo for the excellent bug report and analysis!
--- kernel/exit.c | 7 + kernel/signal.c | 10 ++ kernel/time/posix-cpu-timers.c | 173 +++++++++++++++++++++++++++-------------- 3 files changed, 130 insertions(+), 60 deletions(-)
kernel/exit.c +6 -1
@@ -212,7 +212,12 @@ static void __exit_signal(struct release__unhash_process (post, tsk, group_dead);write_sequnlock (&sig->stats_lock); - tsk->sighand =NULL ; +/* +* Ensure that all preceeding state is visible. Pairs with +* the smp_acquire__after_ctrl_dep() in the sighand == NULL +* path of lock_task_sighand(). +*/ +smp_store_release (&tsk->sighand,NULL );spin_unlock (&sighand->siglock);__cleanup_sighand (sighand);
kernel/signal.c +9 -1
@@ -1362,8 +1362,16 @@ struct sighand_struct *lock_task_sighandrcu_read_lock ();for (;;) { sighand =rcu_dereference (tsk->sighand); -if (unlikely (sighand ==NULL )) +if (unlikely (sighand ==NULL )) { +/* +* Pairs with the smp_store_release() in +* __exit_signal(). It ensures that all state +* modifications to the task preceeding the store are +* visible to the callers of lock_task_sighand(). +*/ +smp_acquire__after_ctrl_dep ();break ; + }/* * This sighand can be already freed and even reused, but
kernel/time/posix-cpu-timers.c +115 -58
236 lines not on this page · raw message
Hi
kernel build / boot test on x86_64 (Intel).
No regressions here.
Thanks
# Librecast Test Results
020/020 [ OK ] liblcrq
010/010 [ OK ] libmld
120/120 [ OK ] liblibrecast
CPU/kernel: Linux auntie 7.1.5-rc1-g06ed1e6c413d #1 SMP PREEMPT_DYNAMIC Tue Jul 21 20:46:10 -00 2026 x86_64 AMD Ryzen 9 9950X 16-Core Processor AuthenticAMD GNU/Linux
Am 21.07.2026 um 16:54 schrieb Greg Kroah-Hartman:
Quoted 4 lines
This is the start of the stable review cycle for the 7.1.5 release. There are 2077 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.
Wow, 2077 patches? That must have been the biggest stable RC patchset I have ever seen... Yet I found no problems testing it on my machine:
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]
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 7.1.5 release. There are 2077 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/v7.x/stable-review/patch-7.1.5-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-7.1.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Hi Greg
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 7.1.5 release. There are 2077 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/v7.x/stable-review/patch-7.1.5-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-7.1.y
and the diffstat can be found below.thanks,
greg k-h
Linux version 7.1.5-rc1 tested.
Build successfully completed.
Boot successfully completed.
No dmesg regressions.
Video output normal.
Sound output normal.
Lenovo ThinkPad X1 Carbon Gen10(Intel i7-1260P(x86_64) arch linux)
[ 0.000000] Linux version 7.1.5-rc1rv-g06ed1e6c413d
(takeshi@ThinkPadX1Gen10J0764) (gcc (GCC) 16.1.1 20260625, GNU ld (GNU Binutils) 2.46.1) #1 SMP PREEMPT_DYNAMIC Wed Jul 22 21:13:10 JST 2026
Thanks
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jon Hunter
maintainerQuoted 28 lines · Jon Hunter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 7.1.5 release. There are 2077 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/v7.x/stable-review/patch-7.1.5-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-7.1.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v7.1:
10 builds: 10 pass, 0 fail 28 boots: 28 pass, 0 fail 158 tests: 158 pass, 0 failLinux version: 7.1.5-rc1-g06ed1e6c413d
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
Quoted 7 lines
tegra186-p3509-0000+p3636-0001, tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000, tegra20-ventana, tegra210-p2371-2180, tegra210-p3450-0000, tegra234-p3737-0000+p3701-0000, tegra234-p3768-0000+p3767-0005, tegra30-cardhu-a04Tested-by Jon Hunter <[email protected]>
Ignore this duplicate report.
Jon
Signature · 1 line
nvpublic
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 7.1.5 release. There are 2077 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/v7.x/stable-review/patch-7.1.5-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-7.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 7.1.5 release. There are 2077 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-7.1.y
Best regards,
Pavel