7.2.6-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 490/1815 tlclk: if sscanf() fails, fall back to 0, not random value
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander A. Klimov <[email protected]>
[ Upstream commit 75f9481e0479c3faadf4d88baffe84b3d23d5763 ]
If sscanf(IN, FMT, &OUT) fails, OUT may be unchanged.
So if OUT was never initialized, it may be still uninitialized memory. To prevent such, initialize OUT=0 first.
--- drivers/char/tlclk.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/char/tlclk.c +18 -18
@@ -328,7 +328,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);static ssize_t store_received_ref_clk3a (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -350,7 +350,7 @@ static DEVICE_ATTR(received_ref_clk3a, (S_IWUSR|S_IWGRP), NULL,static ssize_t store_received_ref_clk3b (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -372,7 +372,7 @@ static DEVICE_ATTR(received_ref_clk3b, (S_IWUSR|S_IWGRP), NULL,static ssize_t store_enable_clk3b_output (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -394,7 +394,7 @@ static ssize_t store_enable_clk3a_output(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { unsigned long flags; -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;sscanf (buf,"%lX" , &tmp);
@@ -415,7 +415,7 @@ static ssize_t store_enable_clkb1_output(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { unsigned long flags; -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;sscanf (buf,"%lX" , &tmp);
@@ -437,7 +437,7 @@ static ssize_t store_enable_clka1_output(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { unsigned long flags; -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;sscanf (buf,"%lX" , &tmp);
@@ -458,7 +458,7 @@ static ssize_t store_enable_clkb0_output(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { unsigned long flags; -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;sscanf (buf,"%lX" , &tmp);
@@ -479,7 +479,7 @@ static ssize_t store_enable_clka0_output(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { unsigned long flags; -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;sscanf (buf,"%lX" , &tmp);
@@ -500,7 +500,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { unsigned long flags; -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;sscanf (buf,"%lX" , &tmp);
@@ -541,7 +541,7 @@ static DEVICE_ATTR(select_amcb2_transmit_clock, (S_IWUSR|S_IWGRP), NULL,static ssize_t store_select_amcb1_transmit_clock (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -583,7 +583,7 @@ static DEVICE_ATTR(select_amcb1_transmit_clock, (S_IWUSR|S_IWGRP), NULL,static ssize_t store_select_redundant_clock (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -604,7 +604,7 @@ static DEVICE_ATTR(select_redundant_clock, (S_IWUSR|S_IWGRP), NULL,static ssize_t store_select_ref_frequency (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -625,7 +625,7 @@ static DEVICE_ATTR(select_ref_frequency, (S_IWUSR|S_IWGRP), NULL,static ssize_t store_filter_select (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -645,7 +645,7 @@ static DEVICE_ATTR(filter_select, (S_IWUSR|S_IWGRP), NULL, store_filter_select);static ssize_t store_hardware_switching_mode (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -666,7 +666,7 @@ static DEVICE_ATTR(hardware_switching_mode, (S_IWUSR|S_IWGRP), NULL,static ssize_t store_hardware_switching (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -687,7 +687,7 @@ static DEVICE_ATTR(hardware_switching, (S_IWUSR|S_IWGRP), NULL,static ssize_t store_refalign (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned long flags;sscanf (buf,"%lX" , &tmp);
@@ -706,7 +706,7 @@ static DEVICE_ATTR(refalign, (S_IWUSR|S_IWGRP), NULL, store_refalign);static ssize_t store_mode_select (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
@@ -726,7 +726,7 @@ static DEVICE_ATTR(mode_select, (S_IWUSR|S_IWGRP), NULL, store_mode_select);static ssize_t store_reset (struct device *d,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long tmp; +unsigned long tmp =0 ;unsigned char val;unsigned long flags;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 491/1815 gpib: Move stuck SRQ update under lock
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
[ Upstream commit 7ddb521ab097413fbdff483b53b4a8c73a0e2b40 ]
Move the stuck SRQ state update into autopoll_all_devices() and keep it under big_gpib_mutex. Except for initialization, keep the stuck_srq users under this mutex.
autopoll_all_devices() is only called by autospoll_thread(), so there is no need to return to autospoll_thread() and set this state after dropping big_gpib_mutex.
Without the mutex, a newly opened device can clear stuck_srq and have that clear overwritten by the previous autospoll result:
autospoll: serial_poll_all() returns 0 and unlocks big_gpib_mutex
open_dev_ioctl: open new device and clear stuck_srq
with big_gpib_mutex held
autospoll: set stuck_srq
That leaves the board marked stuck again after the new device is opened. autospoll_wait_should_wake_up() then refuses to poll while stuck_srq is set, so later SRQ handling can be mistakenly suppressed.
Without the mutex, atomic_set() and set_bit() only make individual updates atomic. They do not order the two updates or make stuck_srq and status visible as a consistent pair. Taking big_gpib_mutex serializes the state transition with the other runtime users.
Keep the existing wakeup behavior unchanged and only move the stuck SRQ state update under the mutex.
--- drivers/gpib/common/gpib_os.c | 21 +++++++++++---------- drivers/gpib/common/iblib.c | 3 --- 2 files changed, 11 insertions(+), 13 deletions(-)
drivers/gpib/common/gpib_os.c +11 -10
@@ -289,18 +289,19 @@ int autopoll_all_devices(struct gpib_board *board)dev_dbg (board->gpib_dev,"autopoll has board lock\n" ); retval =serial_poll_all (board, serial_timeout); -if (retval <0 ) { -mutex_unlock (&board->big_gpib_mutex); -mutex_unlock (&board->user_mutex); -return retval; +if (retval >=0 ) { +dev_dbg (board->gpib_dev,"complete\n" ); +/* +* need to wake wait queue in case someone is +* waiting on RQS +*/ +wake_up_interruptible (&board->wait); } -dev_dbg (board->gpib_dev,"complete\n" ); -/* -* need to wake wait queue in case someone is -* waiting on RQS -*/ -wake_up_interruptible (&board->wait); +if (retval <=0 ) { +atomic_set (&board->stuck_srq,1 ); +set_bit (SRQI_NUM , &board->status); + }mutex_unlock (&board->big_gpib_mutex);mutex_unlock (&board->user_mutex);
drivers/gpib/common/iblib.c +0 -3
@@ -193,9 +193,6 @@ static int autospoll_thread(void *board_void) }if (retval <=0 ) {dev_err (board->gpib_dev,"stuck SRQ\n" ); - -atomic_set (&board->stuck_srq,1 );// XXX could be better -set_bit (SRQI_NUM , &board->status); } }return retval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 492/1815 gpib: use static inline instead of extern inline
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 6cc667892818fe44bef02193dfb9c3f843ade2b2 ]
With GNU inline semantics, an 'extern inline' function is only included in the build if it can be inlined. When the compiler for some reason decides against inlining it, this causes a link failure, as observed in one function in the tnt4882_gpib driver:
ld.lld: error: undefined symbol: mite_irq
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by tnt4882_gpib.c:974 (
/home/arnd/arm-soc/drivers/gpib/tnt4882/tnt4882_gpib.c:974)drivers/gpib/tnt4882/tnt4882_gpib.o:(ni_pci_attach) in archive vmlinux.a
Change all of the 'extern inline' definitions in gpib to the regular 'static inline' to avoid this.
--- drivers/gpib/include/amccs5933.h | 10 +++++----- drivers/gpib/tnt4882/mite.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpib/include/amccs5933.h +5 -5
@@ -13,7 +13,7 @@ enum { };// incoming mailbox 0-3 register offsets -extern inline int INCOMING_MAILBOX_REG (unsigned int mailbox) +static inline int INCOMING_MAILBOX_REG (unsigned int mailbox) {return (0x10 +4 * mailbox); };
@@ -29,25 +29,25 @@ enum { };// select byte 0 to 3 of incoming mailbox -extern inline int INBOX_BYTE_BITS (unsigned int byte) +static inline int INBOX_BYTE_BITS (unsigned int byte) {return (byte &0x3 ) <<8 ; };// select incoming mailbox 0 to 3 -extern inline int INBOX_SELECT_BITS (unsigned int mailbox) +static inline int INBOX_SELECT_BITS (unsigned int mailbox) {return (mailbox &0x3 ) <<10 ; };// select byte 0 to 3 of outgoing mailbox -extern inline int OUTBOX_BYTE_BITS (unsigned int byte) +static inline int OUTBOX_BYTE_BITS (unsigned int byte) {return (byte &0x3 ); };// select outgoing mailbox 0 to 3 -extern inline int OUTBOX_SELECT_BITS (unsigned int mailbox) +static inline int OUTBOX_SELECT_BITS (unsigned int mailbox) {return (mailbox &0x3 ) <<2 ; };
drivers/gpib/tnt4882/mite.h +2 -2
@@ -45,12 +45,12 @@ struct mite_struct {extern struct mite_struct *mite_devices; -extern inline unsigned int mite_irq (struct mite_struct *mite) +static inline unsigned int mite_irq (struct mite_struct *mite) {return mite->pcidev->irq; }; -extern inline unsigned int mite_device_id (struct mite_struct *mite) +static inline unsigned int mite_device_id (struct mite_struct *mite) {return mite->pcidev->device; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 493/1815 uio: Fix stale info pointer in failed registration path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 67b6fc084b034a91c3ec7907a3fed89a2450f30b ]
After device_add(), the UIO device is visible to userspace and /dev/uioX can be opened. If a later setup step fails, __uio_register_device() unwinds the device but leaves idev->info pointing at the caller-owned struct uio_info.
That is unsafe when an opener races with the failed registration path. The open file keeps a reference to the uio_device, while the caller sees registration failure and may free its struct uio_info. Later file operations can then follow idev->info and dereference freed memory.
Handle post-device_add() failures like unregister: remove UIO attributes while the info pointer is still valid, then clear idev->info under info_lock and wake existing waiters/async users before removing the device and minor. This makes already-open file descriptors observe the same "device gone" state as normal uio_unregister_device().
--- drivers/uio/uio.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/uio/uio.c +5 -0
@@ -1057,6 +1057,11 @@ int __uio_register_device(struct module *owner, err_request_irq:uio_dev_del_attributes (idev); err_uio_dev_add_attributes: +mutex_lock (&idev->info_lock); + idev->info =NULL ; +mutex_unlock (&idev->info_lock); +wake_up_interruptible (&idev->wait); +kill_fasync (&idev->async_queue,SIGIO ,POLL_HUP );device_del (&idev->dev); err_device_create:uio_free_minor (idev->minor);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 494/1815 accessibility: speakup: Fix incorrect string length computation in report_char_chartab_status()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit bce0e640623372520d9d90c42f33ddbfb576ce69 ]
snprintf() returns the "number of characters which *would* be generated for the given input", not the size *really* generated.
In order to avoid too large values for 'len' (and potential negative values for "sizeof(buf) - (len - 1)") use scnprintf() instead of snprintf().
--- drivers/accessibility/speakup/kobjects.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/accessibility/speakup/kobjects.c +3 -3
@@ -92,9 +92,9 @@ static void report_char_chartab_status(int reset, int received, int used,if (reset) {pr_info ("%s reset to defaults\n" , object_type[do_characters]); }else if (received) { - len =snprintf (buf,sizeof (buf), -" updated %d of %d %s\n" , - used, received, object_type[do_characters]); + len =scnprintf (buf,sizeof (buf), +" updated %d of %d %s\n" , + used, received, object_type[do_characters]);if (rejected) snprintf(buf + (len - 1), sizeof(buf) - (len - 1), " with %d reject%s\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 495/1815 speakup: keyhelp: guard letter_offsets possible out-of-range indexing
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Zhigulin <[email protected]>
[ Upstream commit 6a19ad4d68c95185308cd9e5d169b10a2cf236c8 ]
help_init() builds letter_offsets[] by using the first byte of each function name as an index via (start & 31) - 1. If function_names are overridden from sysfs (root) with a name starting outside [a–z], the index underflows or exceeds the array, leading to OOB write.
Function names can be overridden with the following commands as root:
modprobe speakup_soft
echo "0 _bad" > /sys/accessibility/speakup/i18n/function_names # then press Insert+2 on /dev/tty
This fix checks the first letter in help_init(), and if it is not in the [a–z] range the function returns an error to the caller. Eventually this error is propagated to drivers/accessibility/speakup/main.c:2217, which causes a bleep sound.
--- drivers/accessibility/speakup/keyhelp.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/accessibility/speakup/keyhelp.c +12 -5
@@ -8,6 +8,7 @@*/ #include <linux/keyboard.h> +#include <linux/ctype.h> #include "spk_priv.h" #include "speakup.h"
@@ -111,7 +112,7 @@ static void say_key(int key) spk_msg_get(MSG_KEYNAMES_START + (key - 1))); } -static int help_init (void ) +static void help_init (void ) {char start =SPACE ;int i;
@@ -120,13 +121,19 @@ static int help_init(void) state_tbl = spk_our_keys[0 ] +SHIFT_TBL_SIZE +2 ;for (i =0 ; i < num_funcs; i++) {char *cur_funcname =spk_msg_get (MSG_FUNCNAMES_START + i); +char first_letter; -if (start == *cur_funcname) + first_letter =tolower (*cur_funcname); + +/* Accept only 'a'..'z' to index letter_offsets[] safely */ +if (first_letter <'a' || first_letter >'z' ) +continue ; + +if (start == first_letter)continue ; - start = *cur_funcname; + start = first_letter; letter_offsets[(start &31 ) -1 ] = i; } -return 0 ; }int spk_handle_help (struct vc_data *vc,u_char type,u_char ch,u_short key)
@@ -144,7 +151,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)synth_printf ("%s\n" ,spk_msg_get (MSG_LEAVING_HELP ));return 1 ; } - ch |=32 ;/* lower case */ + ch =tolower (ch);if (ch <'a' || ch >'z' )return -1 ;if (letter_offsets[ch -'a' ] ==-1 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 496/1815 mei: lb: fix incorrect type in assignment
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
[ Upstream commit 0c419df9c190b80136cc774325f84238e430e905 ]
Fix the mix between __le32 and integer by casting the MEI_LB2_CMD constant as __le32 while using it.
Fixes sparse waring:drivers/misc/mei/mei_lb.c:284:32: sparse: sparse: restricted __le32 degrades to integerdrivers/misc/mei/mei_lb.c:330:40: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] command_id @@ got int @@drivers/misc/mei/mei_lb.c:330:40: sparse: expected restricted __le32 [usertype] command_iddrivers/misc/mei/mei_lb.c:330:40: sparse: got int
--- drivers/misc/mei/mei_lb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/mei/mei_lb.c +2 -2
@@ -281,7 +281,7 @@ static int mei_lb_check_response_v2(const struct device *dev, ssize_t bytes, bytes, sizeof(rsp->rheader));return -ENOMSG ; } -if (rsp->rheader.header.command_id !=MEI_LB2_CMD ) { +if (rsp->rheader.header.command_id !=cpu_to_le32 (MEI_LB2_CMD )) {dev_err (dev,"Mismatch command: 0x%x instead of 0x%x\n" , rsp->rheader.header.command_id,MEI_LB2_CMD );return -EPROTO ;
@@ -327,7 +327,7 @@ static int mei_lb_push_payload_v2(struct device *dev, struct mei_cl_device *cldeif (sent_data + chunk_size == payload_size) last_chunk =MEI_LB2_FLAG_LST_CHUNK ; - req->header.command_id =MEI_LB2_CMD ; + req->header.command_id =cpu_to_le32 (MEI_LB2_CMD ); req->type =cpu_to_le32 (type); req->flags =cpu_to_le32 (flags | first_chunk | last_chunk); req->reserved =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 497/1815 misc: pch_phub: Complete enum usage for device identification
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König (The Capable Hub) <[email protected]>
[ Upstream commit 077b4d1aa01a1b34c5b768b8c7a77c74b35b190b ]
Recently an enum was introduced to identify the different hardware variants instead of magic constants. The respective commit however missed to adapt one code location that still checks the old values.
As the values shifted by one this is a relevant fix.
--- drivers/misc/pch_phub.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/misc/pch_phub.c +10 -10
@@ -83,6 +83,14 @@#define PCH_PHUB_OROM_SIZE 15360 +enum pch_phub_type { +PCH_EG20T , +PCH_ML7213 , +PCH_ML7223M , +PCH_ML7223N , +PCH_ML7831 , +}; +/** * struct pch_phub_reg - PHUB register structure * @phub_id_reg: PHUB_ID register val
@@ -125,7 +133,7 @@ struct pch_phub_reg {void __iomem *pch_phub_extrom_base_address;u32 pch_mac_start_address;u32 pch_opt_rom_start_address; -int ioh_type; +enum pch_phub_type ioh_type;struct pci_dev *pdev; };
@@ -344,7 +352,7 @@ static int pch_phub_write_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)int retval;int i; -if ((chip->ioh_type ==1 ) || (chip->ioh_type ==5 ))/* EG20T or ML7831*/ +if (chip->ioh_type ==PCH_EG20T || chip->ioh_type ==PCH_ML7831 ) retval =pch_phub_gbe_serial_rom_conf (chip);else /* ML7223 */ retval =pch_phub_gbe_serial_rom_conf_mp (chip);
@@ -537,14 +545,6 @@ static const struct bin_attribute pch_bin_attr = { .write = pch_phub_bin_write, }; -enum { -PCH_EG20T , -PCH_ML7213 , -PCH_ML7223M , -PCH_ML7223N , -PCH_ML7831 , -}; -static int pch_phub_probe (struct pci_dev *pdev,const struct pci_device_id *id) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 498/1815 misc: bcm-vk: Use acquire/release for msgq_inited
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
[ Upstream commit 61b101c6a150057b6d512421ed108aed16e822ea ]
bcm_vk_sync_msgq() fills the message queue information and then sets msgq_inited. Readers call bcm_vk_drv_access_ok() before accessing the message queues and their cached queue information.
atomic_set()/atomic_read() do not order those accesses. A reader can see msgq_inited set while still seeing stale queue information. Use release when publishing the initialized queues and acquire when checking the gate.
Keep the clear in bcm_vk_blk_drv_access() as atomic_set(). It closes the gate and does not publish queue state to readers.
--- drivers/misc/bcm-vk/bcm_vk_msg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/misc/bcm-vk/bcm_vk_msg.c +4 -2
@@ -108,7 +108,8 @@ u32 msgq_avail_space(const struct bcm_vk_msgq __iomem *msgq,bool bcm_vk_drv_access_ok (struct bcm_vk *vk) { -return (!!atomic_read (&vk->msgq_inited)); +/* Pair with the release store after message queue initialization. */ +return !!atomic_read_acquire (&vk->msgq_inited); }void bcm_vk_set_host_alert (struct bcm_vk *vk,u32 bit_mask)
@@ -501,7 +502,8 @@ int bcm_vk_sync_msgq(struct bcm_vk *vk, bool force_sync) msgq++; } } -atomic_set (&vk->msgq_inited,1 ); +/* Publish message queue info before allowing driver access. */ +atomic_set_release (&vk->msgq_inited,1 );return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 499/1815 misc: rtsx: add missing write register handling
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gleb Markov <[email protected]>
[ Upstream commit 655faba1ccf195e22a7a83146ef6015e3271233c ]
If an error occurs at the stage of working with registers in conjunction with MCU_Block, it will not be processed.
The occurrence of errors at this stage may signal an impact on writes to the device's PCI registers and is a more global problem than a driver-level security problem, but adding a handler would be a good practice.
Add a missing error handling.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/misc/cardreader/rtsx_pcr.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/cardreader/rtsx_pcr.c +2 -0
@@ -1196,6 +1196,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)/* Gating real mcu clock */ err =rtsx_pci_write_register (pcr,RTS5261_FW_CFG1 ,RTS5261_MCU_CLOCK_GATING ,0 ); +if (err <0 ) +return err; err =rtsx_pci_write_register (pcr,RTS5261_REG_FPDCTL ,SSC_POWER_DOWN ,0 ); }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 500/1815 misc: ad525x_dpot: use driver core groups for sysfs files
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit e3a8557e88eb26278eda60bf64f2ef33ce7de8bf ]
ad_dpot_probe() creates per-RDAC sysfs files manually and then optionally creates the command sysfs group. This leaves probe responsible for rolling back partial sysfs state and makes remove responsible for matching every file that probe created.
Move the device attributes into driver core dev_groups for the I2C and SPI drivers and use an is_visible() callback to expose only the attributes supported by the probed device. With this shape, the driver core creates the sysfs files only after probe succeeds and removes them before the remove callback frees the driver data.
--- drivers/misc/ad525x_dpot-i2c.c | 1 + drivers/misc/ad525x_dpot-spi.c | 1 + drivers/misc/ad525x_dpot.c | 177 ++++++++++++++++++++------------- drivers/misc/ad525x_dpot.h | 3 + 4 files changed, 112 insertions(+), 70 deletions(-)
drivers/misc/ad525x_dpot-i2c.c +1 -0
@@ -105,6 +105,7 @@ MODULE_DEVICE_TABLE(i2c, ad_dpot_id);static struct i2c_driver ad_dpot_i2c_driver = { .driver = { .name ="ad_dpot" , + .dev_groups = ad_dpot_groups, }, .probe = ad_dpot_i2c_probe, .remove = ad_dpot_i2c_remove,
drivers/misc/ad525x_dpot-spi.c +1 -0
@@ -131,6 +131,7 @@ MODULE_DEVICE_TABLE(spi, ad_dpot_spi_id);static struct spi_driver ad_dpot_spi_driver = { .driver = { .name ="ad_dpot" , + .dev_groups = ad_dpot_groups, }, .probe = ad_dpot_spi_probe, .remove = ad_dpot_spi_remove,
drivers/misc/ad525x_dpot.c +107 -70
224 lines not on this page · raw message
drivers/misc/ad525x_dpot.h +3 -0
@@ -10,6 +10,8 @@#include <linux/types.h> +struct attribute_group ; +#define DPOT_CONF (features, wipers, max_pos, uid) \ (((features) << 18) | (((wipers) & 0xFF) << 10) | \ ((max_pos & 0xF) << 6) | (uid & 0x3F))
@@ -210,5 +212,6 @@ struct ad_dpot_bus_data {int ad_dpot_probe (struct device *dev,struct ad_dpot_bus_data *bdata,unsigned long devid,const char *name);void ad_dpot_remove (struct device *dev); +extern const struct attribute_group *ad_dpot_groups[];#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 501/1815 misc: lan966x_pci: depopulate children on populate failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit f6e2ed54db95286d9512b1cff38264e2f6299814 ]
lan966x_pci_probe() applies a device-tree overlay and then populates platform children from the overlaid node. If of_platform_default_populate() creates some children and then fails, the current error path only unloads the overlay.
Depopulate the children before unloading the overlay on that failure path, matching the remove path order.
--- drivers/misc/lan966x_pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/lan966x_pci.c +1 -0
@@ -183,6 +183,7 @@ static int lan966x_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ireturn 0 ; err_unload_overlay: +of_platform_depopulate (dev);lan966x_pci_unload_overlay (data);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 502/1815 cacheinfo: dont propagate DT/ACPI error when arch supplies info (arm64)
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 274259391c14166fcabae74f9fc0104223ff27a1 ]
cache_setup_properties() sets use_arch_info = true when DT/ACPI provide no cache nodes and the arch can derive the topology from CPU registers (e.g. arm64 reading CLIDR_EL1), but still returns the original -ENOENT. cache_shared_cpu_map_setup() bails on that error before the new flag can take effect, so the first CPU brought online always trips a misleading warning:
cacheinfo: Unable to detect cache hierarchy for CPU 0
Subsequent CPUs skip cache_setup_properties() entirely because use_arch_info is now true, which is why only CPU0 hits it. This is reproducible on arm64 with the QEMU 'virt' machine, whose default DT has no cache nodes.
Clear ret after setting use_arch_info so the caller proceeds and populates the shared cpu map via the arch-supplied leaves.
--- drivers/base/cacheinfo.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/base/cacheinfo.c +7 -2
@@ -401,9 +401,14 @@ static int cache_setup_properties(unsigned int cpu)else if (!acpi_disabled) ret =cache_setup_acpi (cpu); -// Assume there is no cache information available in DT/ACPI from now. -if (ret &&use_arch_cache_info ()) +/* +* No DT/ACPI cache nodes; fall back to arch-derived topology (e.g. +* arm64 CLIDR_EL1) and clear the error to avoid a spurious warning. +*/ +if (ret &&use_arch_cache_info ()) { use_arch_info = true; + ret =0 ; + }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 503/1815 ppdev: prevent overflow when setting port timeout
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 3c0cf801ea2fa40daa5e7d1e6d32adca5ff75ad9 ]
PPSETTIME64 supplies the timeval fields as s64 values, but pp_set_timeout() narrows tv_usec to int and calculates tv_sec * HZ in a signed long. Large positive values can therefore be truncated or overflow and install an unintended timeout.
Keep both fields as s64, reject a non-canonical microsecond value, and use timespec64_to_jiffies() to cap excessively large timeouts at MAX_JIFFY_OFFSET. This is a behavior change because both PPSETTIME ioctls could previously accept values with tv_usec >= USEC_PER_SEC. The validation follows the precedent set by sock_set_timeout().
--- drivers/char/ppdev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/char/ppdev.c +6 -4
@@ -340,15 +340,17 @@ static enum ieee1284_phase init_phase(int mode)return IEEE1284_PH_FWD_IDLE ; } -static int pp_set_timeout (struct pardevice *pdev,long tv_sec,int tv_usec) +static int pp_set_timeout (struct pardevice *pdev,s64 tv_sec,s64 tv_usec) { +struct timespec64 ts;long to_jiffies; -if ((tv_sec <0 ) || (tv_usec <0 )) +if (tv_sec <0 || tv_usec <0 || tv_usec >=USEC_PER_SEC )return -EINVAL ; - to_jiffies =usecs_to_jiffies (tv_usec); - to_jiffies += tv_sec *HZ ; + ts.tv_sec = tv_sec; + ts.tv_nsec = tv_usec *NSEC_PER_USEC ; + to_jiffies =timespec64_to_jiffies (&ts);if (to_jiffies <=0 )return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 504/1815 ipack: ipoctal: fix UAF, null-ptr-deref, and use-after-free in cleanup on remove
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit b6b5d64cb161a28347d64dc3168a636c4abb68d5 ]
Three issues arise when the device is removed while a tty session is still active:
1. UAF of struct ipoctal: the remove callback frees ipoctal via kfree() while tty ops may still access it. Fix by introducing kref-based lifetime management — kref is taken in install() when a tty is opened and released in cleanup() when the tty is finally destroyed; remove() uses kref_put() instead of kfree().
2. NULL dereference in ipoctal_write_tty(): __ipoctal_remove() frees xmit_buf via tty_port_free_xmit_buf() while a userspace process may still hold the tty fd and call write(). Fix by checking for NULL xmit_buf in ipoctal_write_tty().
3. UAF in ipoctal_cleanup(): ipack_put_carrier(ipoctal->dev) dereferences ipoctal->dev after the ipack_device has been freed by ipack_device_del(). Fix by caching ipoctal->carrier_owner during probe() and calling module_put() on the cached pointer directly in cleanup(), avoiding any access to ipoctal->dev.
Also introduce a "removed" flag in struct ipoctal, set at the start of __ipoctal_remove(), and checked in every tty op that accesses hardware resources (port_activate, write_tty, set_termios, hangup, shutdown). This prevents page faults when devm_ioremap() regions are unmapped after remove() returns.
--- drivers/ipack/devices/ipoctal.c | 56 ++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-)
drivers/ipack/devices/ipoctal.c +52 -4
@@ -10,6 +10,7 @@#include <linux/device.h> #include <linux/module.h> #include <linux/interrupt.h> +#include <linux/kref.h> #include <linux/sched.h> #include <linux/tty.h> #include <linux/serial.h>
@@ -25,6 +26,8 @@static const struct tty_operations ipoctal_fops; +static void ipoctal_release (struct kref *kref); +struct ipoctal_channel {struct ipoctal_stats stats;unsigned int nb_bytes;
@@ -49,6 +52,9 @@ struct ipoctal {struct tty_driver *tty_drv;u8 __iomem *mem8_space;u8 __iomem *int_space; +struct kref kref; +struct module *carrier_owner; +bool removed; }; static inline struct ipoctal *chan_to_ipoctal(struct ipoctal_channel *chan,
@@ -70,8 +76,14 @@ static void ipoctal_reset_channel(struct ipoctal_channel *channel)static int ipoctal_port_activate (struct tty_port *port,struct tty_struct *tty) {struct ipoctal_channel *channel; +struct ipoctal *ipoctal; channel =dev_get_drvdata (tty->dev); + ipoctal =chan_to_ipoctal (channel, tty->index); + + +if (ipoctal->removed) +return -ENODEV ;/* * Enable RX. TX will be enabled when
@@ -95,6 +107,7 @@ static int ipoctal_install(struct tty_driver *driver, struct tty_struct *tty)if (res) goto err_put_carrier; +kref_get (&ipoctal->kref); tty->driver_data = channel;return 0 ;
@@ -460,8 +473,13 @@ static ssize_t ipoctal_write_tty(struct tty_struct *tty, const u8 *buf, size_t count) {struct ipoctal_channel *channel = tty->driver_data; +struct ipoctal *ipoctal =chan_to_ipoctal (channel, tty->index);size_t char_copied; + +if (ipoctal->removed || !channel->tty_port.xmit_buf) +return 0 ; + char_copied =ipoctal_copy_write_buffer (channel, buf, count);/* As the IP-OCTAL 485 only supports half duplex, do it manually */
@@ -501,8 +519,13 @@ static void ipoctal_set_termios(struct tty_struct *tty,unsigned char mr2 =0 ;unsigned char csr =0 ;struct ipoctal_channel *channel = tty->driver_data; +struct ipoctal *ipoctal =chan_to_ipoctal (channel, tty->index);speed_t baud; + +if (ipoctal->removed) +return ; + cflag = tty->termios.c_cflag;/* Disable and reset everything before change the setup */
@@ -631,10 +654,16 @@ static void ipoctal_hangup(struct tty_struct *tty) {unsigned long flags;struct ipoctal_channel *channel = tty->driver_data; +struct ipoctal *ipoctal;if (channel ==NULL )return ; + ipoctal =chan_to_ipoctal (channel, tty->index); + +if (ipoctal->removed) +return ; +spin_lock_irqsave (&channel->lock, flags); channel->nb_bytes =0 ; channel->pointer_read =0 ;
@@ -651,10 +680,16 @@ static void ipoctal_hangup(struct tty_struct *tty)static void ipoctal_shutdown (struct tty_struct *tty) {struct ipoctal_channel *channel = tty->driver_data; +struct ipoctal *ipoctal;if (channel ==NULL )return ; + ipoctal =chan_to_ipoctal (channel, tty->index); + +if (ipoctal->removed) +return ; +ipoctal_reset_channel (channel);tty_port_set_initialized (&channel->tty_port, false); }
@@ -664,8 +699,9 @@ static void ipoctal_cleanup(struct tty_struct *tty)struct ipoctal_channel *channel = tty->driver_data;struct ipoctal *ipoctal =chan_to_ipoctal (channel, tty->index); -/* release the carrier driver */ -ipack_put_carrier (ipoctal->dev); +/* release the carrier driver via cached owner */ +module_put (ipoctal->carrier_owner); +kref_put (&ipoctal->kref, ipoctal_release); }static const struct tty_operations ipoctal_fops = {
@@ -683,6 +719,13 @@ static const struct tty_operations ipoctal_fops = { .cleanup = ipoctal_cleanup, }; +static void ipoctal_release (struct kref *kref) +{ + struct ipoctal *ipoctal = container_of(kref, struct ipoctal, kref); + +kfree (ipoctal); +} +static int ipoctal_probe (struct ipack_device *dev) {int res;
@@ -692,7 +735,10 @@ static int ipoctal_probe(struct ipack_device *dev)if (ipoctal ==NULL )return -ENOMEM ; +kref_init (&ipoctal->kref); + ipoctal->dev = dev; + ipoctal->carrier_owner = dev->bus->owner; res =ipoctal_inst_slot (ipoctal, dev->bus->bus_nr, dev->slot);if (res) goto out_uninst;
@@ -701,7 +747,7 @@ static int ipoctal_probe(struct ipack_device *dev)return 0 ; out_uninst: -kfree (ipoctal); +kref_put (&ipoctal->kref, ipoctal_release);return res; }
@@ -709,6 +755,8 @@ static void __ipoctal_remove(struct ipoctal *ipoctal) {int i; + ipoctal->removed = true; + ipoctal->dev->bus->ops->free_irq (ipoctal->dev);for (i =0 ; i <NR_CHANNELS ; i++) {
@@ -725,7 +773,7 @@ static void __ipoctal_remove(struct ipoctal *ipoctal)tty_unregister_driver (ipoctal->tty_drv);kfree (ipoctal->tty_drv->name);tty_driver_kref_put (ipoctal->tty_drv); -kfree (ipoctal); +kref_put (&ipoctal->kref, ipoctal_release); }static void ipoctal_remove (struct ipack_device *idev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 505/1815 char: xilinx_hwicap: unregister class on init errors
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit e7e12b4cc0f0c3a2782aea084d4215e23f5512b3 ]
hwicap_module_init() registers icap_class before reserving the character-device region and registering the platform driver. If either of those later steps fails, the init path must undo the successful class registration before returning an error.
Route the chrdev registration failure through a class unwind label, and let the platform-driver registration failure fall through the existing chrdev unwind before unregistering the class. The normal module exit path is unchanged.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/char/xilinx_hwicap/xilinx_hwicap.c +4 -1
@@ -760,7 +760,7 @@ static int __init hwicap_module_init(void)HWICAP_DEVICES , DRIVER_NAME);if (retval <0 ) -return retval; + goto failed_class; retval =platform_driver_register (&hwicap_platform_driver);if (retval)
@@ -771,6 +771,9 @@ static int __init hwicap_module_init(void) failed:unregister_chrdev_region (devt,HWICAP_DEVICES ); + failed_class: +class_unregister (&icap_class); +return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 506/1815 vfio: selftests: Avoid VLAs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Mastro <[email protected]>
[ Upstream commit 6bc73befe1b4143ebe6a991b2ab133e9f3087128 ]
Allocate VFIO ioctl requests dynamically instead of using VLAs. GCC 11.5.0 rejects initialized VLAs with:
error: variable-sized object may not be initialized
The replaced stack u8 arrays also do not guarantee native struct alignment for the aliased pointers.
--- .../selftests/vfio/lib/vfio_pci_device.c | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-)
tools/testing/selftests/vfio/lib/vfio_pci_device.c +15 -11
@@ -30,13 +30,11 @@static void vfio_pci_irq_set (struct vfio_pci_device *device,u32 index,u32 vector,u32 count,int *fds) { -u8 buf[sizeof (struct vfio_irq_set ) +sizeof (int ) * count]; -struct vfio_irq_set *irq = (void *)&buf; -int *irq_fds = (void *)&irq->data; +size_t argsz =sizeof (struct vfio_irq_set ) +sizeof (int ) * count; +struct vfio_irq_set *irq; -memset (buf,0 ,sizeof (buf)); - - irq->argsz =sizeof (buf); + irq =calloc_assert (1 , argsz); + irq->argsz = argsz; irq->flags =VFIO_IRQ_SET_ACTION_TRIGGER ; irq->index = index; irq->start = vector;
@@ -44,12 +42,13 @@ static void vfio_pci_irq_set(struct vfio_pci_device *device,if (count) { irq->flags |=VFIO_IRQ_SET_DATA_EVENTFD ; -memcpy (irq_fds, fds,sizeof (int ) * count); +memcpy (irq->data, fds,sizeof (int ) * count); }else { irq->flags |=VFIO_IRQ_SET_DATA_NONE ; }ioctl_assert (device->fd,VFIO_DEVICE_SET_IRQS , irq); +free (irq); }void vfio_pci_irq_trigger (struct vfio_pci_device *device,u32 index,u32 vector)
@@ -118,15 +117,20 @@ static void vfio_pci_irq_get(struct vfio_pci_device *device, u32 index,static int vfio_device_feature_ioctl (int fd,u32 flags,void *data,size_t data_size) { -u8 buffer[sizeof (struct vfio_device_feature ) + data_size] = {}; -struct vfio_device_feature *feature = (void *)buffer; +size_t argsz =sizeof (struct vfio_device_feature ) + data_size; +struct vfio_device_feature *feature; +int ret; + feature =calloc_assert (1 , argsz);memcpy (feature->data, data, data_size); - feature->argsz =sizeof (buffer); + feature->argsz = argsz; feature->flags = flags; -return ioctl (fd,VFIO_DEVICE_FEATURE , feature); + ret =ioctl (fd,VFIO_DEVICE_FEATURE , feature); +free (feature); + +return ret; }static void vfio_device_feature_set (int fd,u16 feature,void *data,size_t data_size)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 507/1815 vfio/pci: clear vdev->msi_perm after freeing it on init failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit dc77acfeb979dded39b247b60fef0399536bfa77 ]
vfio_msi_cap_len() lazily allocates the per-device MSI permission table:
vdev->msi_perm = kmalloc_obj(struct perm_bits, GFP_KERNEL_ACCOUNT);
if (!vdev->msi_perm)
return -ENOMEM;
ret = init_pci_cap_msi_perm(vdev->msi_perm, len, flags);
if (ret) {
kfree(vdev->msi_perm);
return ret; /* vdev->msi_perm left dangling */
}When init_pci_cap_msi_perm() -> alloc_perm_bits() fails with -ENOMEM, the error path frees vdev->msi_perm but leaves the freed pointer stored in it. vdev->msi_perm is not re-zeroed later because struct vfio_pci_core_device is per-device and persists across open/close cycles, and the vfio_config_init() error path returns without calling vfio_config_free(). So the dangling pointer outlives the failed open.
That leads to two use-after-frees on the same device:
1. Reuse. The next vfio_config_init() sees the stale pointer at "if (vdev->msi_perm) return len;" and reuses the freed object. MSI config accesses in vfio_pci_config_rw_single() then dereference and call the freed perm->readfn / perm->writefn function pointers.
2. Double free. A later vfio_config_free() runs free_perm_bits() and kfree() on the already-freed object.
Fix it by NULLing vdev->msi_perm after the kfree(), matching the NULL-after-free discipline already used in free_perm_bits() and vfio_config_free().
BUG: KASAN: slab-use-after-free in vfio_pci_config_rw_single (drivers/vfio/pci/vfio_pci_config.c:1961) Read of size 8 at addr ffff88800fcc88d0 by task exploit/143 Call Trace: ... kasan_report (mm/kasan/report.c:595) vfio_pci_config_rw_single (drivers/vfio/pci/vfio_pci_config.c:1961) vfio_pci_config_rw (drivers/vfio/pci/vfio_pci_config.c:1986) vfio_pci_rw (drivers/vfio/pci/vfio_pci_core.c:1599) vfs_read (fs/read_write.c:572) __x64_sys_pread64 (fs/read_write.c:764) do_syscall_64 (arch/x86/entry/syscall_64.c:94) ...
Followed on device close by a double free of the same object:
Oops: general protection fault, probably for non-canonical address
0x1f63e0e8000008: 0000 [#1] SMP KASAN NOPTI
RIP: 0010:kfree (mm/slub.c:6711)
Call Trace:
vfio_config_free (drivers/vfio/pci/vfio_pci_config.c:1861)
vfio_pci_core_disable (drivers/vfio/pci/vfio_pci_core.c:685)
vfio_pci_core_close_device (drivers/vfio/pci/vfio_pci_core.c:777)
vfio_df_close (drivers/vfio/vfio_main.c:602)
vfio_device_fops_release (drivers/vfio/vfio_main.c:648)
__fput (fs/file_table.c:512)
__x64_sys_close (fs/open.c:1496)
do_syscall_64 (arch/x86/entry/syscall_64.c:94)
...
Kernel panic - not syncing: Fatal exception--- drivers/vfio/pci/vfio_pci_config.c | 1 + 1 file changed, 1 insertion(+)
drivers/vfio/pci/vfio_pci_config.c +1 -0
@@ -1272,6 +1272,7 @@ static int vfio_msi_cap_len(struct vfio_pci_core_device *vdev, u8 pos) ret =init_pci_cap_msi_perm (vdev->msi_perm, len, flags);if (ret) {kfree (vdev->msi_perm); + vdev->msi_perm =NULL ;return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 508/1815 soc: ti: knav_qmss: Remove debugfs file on teardown
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 3c817862759913097f11467ed4ed2bbf974dabaf ]
knav_queue_probe() creates the global qmss debugfs file whose show callback reads the global knav_qdev state. knav_queue_remove() tears down the queue manager resources but leaves the debugfs file published.
Save the debugfs dentry in struct knav_device and remove it during teardown before the resources used by the show callback are released. While touching the debugfs_create_file() call, spell the unchanged read- only file mode as 0444.
--- drivers/soc/ti/knav_qmss.h | 1 + drivers/soc/ti/knav_qmss_queue.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/soc/ti/knav_qmss.h +1 -0
@@ -304,6 +304,7 @@ struct knav_device {struct list_head pools;struct list_head pdsps;struct list_head qmgrs; +struct dentry *debugfs_file;enum qmss_version version; };
drivers/soc/ti/knav_qmss_queue.c +5 -2
@@ -1849,8 +1849,9 @@ static int knav_queue_probe(struct platform_device *pdev) goto err; } -debugfs_create_file ("qmss" ,S_IFREG |S_IRUGO ,NULL ,NULL , - &knav_queue_debug_fops); + knav_qdev->debugfs_file = +debugfs_create_file ("qmss" ,0444 ,NULL ,NULL , + &knav_queue_debug_fops); device_ready = true;return 0 ;
@@ -1868,6 +1869,8 @@ static void knav_queue_remove(struct platform_device *pdev)struct knav_device *kdev =platform_get_drvdata (pdev); device_ready = false; +debugfs_remove (kdev->debugfs_file); + kdev->debugfs_file =NULL ;knav_queue_stop_pdsps (kdev);knav_queue_free_regions (kdev);knav_free_queue_ranges (kdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 509/1815 mtd: intel-dg: Fix runtime PM error path in probe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit df6f582df3377af316a60ca8ee0d590b2d03924d ]
intel_dg_mtd_probe() allocates region names before enabling runtime PM and before calling pm_runtime_resume_and_get().
If kasprintf() fails while building a region name, the error path jumps to err, which calls pm_runtime_put(). At that point there has not been a successful pm_runtime_resume_and_get() call to balance, so the runtime PM usage count can underflow.
Jump to err_norpm from the kasprintf() failure path, as the runtime PM reference has not been acquired yet.
--- drivers/mtd/devices/mtd_intel_dg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/devices/mtd_intel_dg.c +1 -1
@@ -780,7 +780,7 @@ static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev, dev_name(&aux_dev->dev), invm->regions[i].name);if (!name) { ret = -ENOMEM ; - goto err; + goto err_norpm; } nvm->regions[n].name = name;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 510/1815 mtd: mtdswap: Avoid freeing registered blktrans device twice
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 779aa4c66a96bf43d2d62982ea1a9096a9128d87 ]
In mtdswap_add_mtd(), debugfs setup failure after successful blktrans registration can free mbd_dev twice.
add_mtd_blktrans_dev() initializes the blktrans device reference and publishes the disk. Once that succeeds, del_mtd_blktrans_dev() tears the disk down and drops the blktrans reference; when that reference reaches zero, blktrans_dev_release() frees the mtd_blktrans_dev.
The debugfs failure path called del_mtd_blktrans_dev(mbd_dev), then fell through the common cleanup label and called kfree(mbd_dev) again. Clear the local pointer after deregistration so the common cleanup can still release the mtdswap state without freeing the blktrans object twice.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/mtd/mtdswap.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/mtdswap.c +1 -0
@@ -1452,6 +1452,7 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) debugfs_failed:del_mtd_blktrans_dev (mbd_dev); + mbd_dev =NULL ; cleanup:mtdswap_cleanup (d);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 511/1815 mtd: part: reject MTDPART_OFS_RETAIN in mtd_add_partition()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: zhouminqiang <[email protected]>
[ Upstream commit b759d5bb6265419344ee9729fd0dc07ad85719d8 ]
mtd_add_partition() does not reject the special offset value MTDPART_OFS_RETAIN (-3), which leads to a WARN_ON in add_mtd_device() when called through the BLKPG ioctl on NAND devices. The RETAIN value depends on cur_offset being the end of the previous partition, but in the dynamic partition path cur_offset equals the offset argument itself, causing undefined behavior.
Commit 5daa7b21496a ("mtd: prepare partition add and del functions for ioctl requests") introduced mtd_add_partition() and correctly rejected MTDPART_OFS_APPEND (-1) and MTDPART_OFS_NXTBLK (-2), since those special offsets rely on cur_offset tracking the previous partition's end. However, commit 1a31368bf92e ("mtd: add a flags for partitions which should just leave smth. after them") later added MTDPART_OFS_RETAIN (-3) for the static
partition table path without updating mtd_add_partition() to also reject this value.
With offset=-3 passed via BLKPG, the RETAIN size calculation in allocate_partition() underflows (parent_size - 0xFFFFFFFFFFFFFFFD = parent_size + 3). If the underflow result does not appear to leave enough space, allocate_partition() jumps to out_register via goto, skipping erasesize initialization. This results in erasesize=0, which triggers:
WARN_ON((!mtd->erasesize || !master->_erase) &&
!(mtd->flags & MTD_NO_ERASE))
in add_mtd_device(). If the underflow result appears to leave enough space, a bogus partition size is calculated, but the "out of reach" sanity check catches the invalid offset and creates a disabled empty partition (offset=0, size=0) instead of returning an error.
Fix this by adding MTDPART_OFS_RETAIN to the rejection list in mtd_add_partition(), consistent with the existing handling of APPEND and NXTBLK.
--- drivers/mtd/mtdpart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/mtdpart.c +2 -1
@@ -258,7 +258,8 @@ int mtd_add_partition(struct mtd_info *parent, const char *name,/* the direct offset is expected */ if (offset ==MTDPART_OFS_APPEND || - offset ==MTDPART_OFS_NXTBLK ) + offset ==MTDPART_OFS_NXTBLK || + offset ==MTDPART_OFS_RETAIN )return -EINVAL ;if (length ==MTDPART_SIZ_FULL )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 512/1815 perf ui hists: Fix uninitialized stack memory free on pstack allocation failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit d5fdde1c426922efabe86a515f0782b3eba40577 ]
Fixes heap corruption by initializing the options and actions arrays before the pstack allocation check, preventing an uninitialized stack pointer from being passed to free_popup_options() if the allocation fails.
--- tools/perf/ui/browsers/hists.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/ui/browsers/hists.c +3 -3
@@ -3064,15 +3064,15 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *h browser->min_pcnt = min_pcnt;hist_browser__update_nr_entries (browser); +memset (options,0 ,sizeof (options)); +memset (actions,0 ,sizeof (actions)); + browser->pstack =pstack__new (3 );if (browser->pstack ==NULL ) goto out;ui_helpline__push (helpline); -memset (options,0 ,sizeof (options)); -memset (actions,0 ,sizeof (actions)); -if (symbol_conf.col_width_list_str)perf_hpp__set_user_width (symbol_conf.col_width_list_str);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 513/1815 perf build: Fix compiler errors with old capstone
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit e01c7bd5b1eece254bcbf282db066b12c4815d21 ]
It seems RISCV was added in capstone version 5 (released Jul 2023). Unfortunately they are enum constants so cannot check with #ifdef but anyway we can define the symbols. Let's do it using the version number to avoid build errors. It'll fail at runtime though.
util/capstone.c: In function 'e_machine_to_capstone':
util/capstone.c:186:25: error: 'CS_ARCH_RISCV' undeclared (first use in this function);
did you mean 'CS_ARCH_SYSZ'?
186 | *arch = CS_ARCH_RISCV;
| ^~~~~~~~~~~~~
| CS_ARCH_SYSZ util/capstone.c:186:25: note: each undeclared identifier is reported only once for each function it appears in
util/capstone.c:187:34: error: 'CS_MODE_RISCV64' undeclared (first use in this function);
did you mean 'CS_MODE_MIPS64'?
187 | *mode |= (is64 ? CS_MODE_RISCV64 : CS_MODE_RISCV32) | CS_MODE_RISCVC;
| ^~~~~~~~~~~~~~~
| CS_MODE_MIPS64Also note that capstone renamed CS_MODE_RISCVC to CS_MODE_RISCV_C which would cause a different build failure on latest versions. It's reported in https://github.com/capstone-engine/capstone/issues/2977 so I think they will add compatibility layer to prevent the error.
--- tools/perf/util/capstone.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/perf/util/capstone.c +7 -0
@@ -24,6 +24,13 @@#include "symbol.h" #include "thread.h" +#if CS_VERSION_MAJOR <5 +#define CS_ARCH_RISCV 15 +#define CS_MODE_RISCV32 1 +#define CS_MODE_RISCV64 2 +#define CS_MODE_RISCVC 4 +#endif +#ifdef LIBCAPSTONE_DLOPEN static void *perf_cs_dll_handle (void ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 514/1815 drm/v3d: Drop unused drm_encoder.h include from v3d_drv.h
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit cc29c864ee50b9c145fa847406b3535026511917 ]
The V3D driver has no display pipeline, so nothing in the driver requires drm_encoder.h. Remove the stale include.
Stable-dep-of: fa98563ab00d ("drm/v3d: Associate BOs with every job that accesses them")
--- drivers/gpu/drm/v3d/v3d_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/v3d/v3d_drv.h +1 -1
@@ -7,7 +7,7 @@#include <linux/spinlock_types.h> #include <linux/workqueue.h> -#include <drm/drm_encoder.h> +#include <drm/drm_device.h> #include <drm/drm_gem.h> #include <drm/drm_gem_shmem_helper.h> #include <drm/gpu_scheduler.h>
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 515/1815 drm/v3d: Extract v3d_job_add_syncobjs() helper
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit 57d78cbc16c930f698616d4db16aa85a49a356f7 ]
Move the syncobj dependency setup out of v3d_job_init() into its own v3d_job_add_syncobjs() helper and make the queue that the job was submitted a variable in struct v3d_job, so that v3d_job_add_syncobjs() can use it. No functional change.
This prepares for the next commit which changes the error handling, and for a later consolidation that separates job allocation from syncobj attachment.
Stable-dep-of: fa98563ab00d ("drm/v3d: Associate BOs with every job that accesses them")
--- drivers/gpu/drm/v3d/v3d_drv.h | 3 ++ drivers/gpu/drm/v3d/v3d_submit.c | 72 +++++++++++++++++++------------- 2 files changed, 47 insertions(+), 28 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.h +3 -0
@@ -301,6 +301,9 @@ struct v3d_job {struct v3d_dev *v3d; +/* The queue that the job was submitted on. */ +enum v3d_queue queue; +/* This is the array of BOs that were looked up at the start * of submission. */
drivers/gpu/drm/v3d/v3d_submit.c +44 -28
93 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 516/1815 drm/v3d: Migrate BO reservation locking to DRM exec
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit e4a131d1851e217a0ebbd8632a705f6bb5a67672 ]
Replace the drm_gem_(un)lock_reservations() + ww_acquire_ctx pattern with DRM exec across all submit ioctls. Just a straightforward conversion; no functional change.
Stable-dep-of: fa98563ab00d ("drm/v3d: Associate BOs with every job that accesses them")
--- drivers/gpu/drm/v3d/Kconfig | 1 + drivers/gpu/drm/v3d/v3d_drv.h | 3 +- drivers/gpu/drm/v3d/v3d_submit.c | 69 ++++++++++++++------------------ 3 files changed, 33 insertions(+), 40 deletions(-)
drivers/gpu/drm/v3d/Kconfig +1 -0
@@ -5,6 +5,7 @@ config DRM_V3D depends on DRM depends on COMMON_CLK depends on MMU + select DRM_EXEC select DRM_SCHED select DRM_GEM_SHMEM_HELPER help
drivers/gpu/drm/v3d/v3d_drv.h +2 -1
@@ -8,6 +8,7 @@#include <linux/workqueue.h> #include <drm/drm_device.h> +#include <drm/drm_exec.h> #include <drm/drm_gem.h> #include <drm/drm_gem_shmem_helper.h> #include <drm/gpu_scheduler.h>
@@ -428,7 +429,7 @@ struct v3d_indirect_csd_info {struct drm_gem_object *indirect;/* Context of the Indirect CSD job */ -struct ww_acquire_ctx acquire_ctx; +struct drm_exec exec; };struct v3d_timestamp_query_info {
drivers/gpu/drm/v3d/v3d_submit.c +30 -39
213 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 517/1815 drm/v3d: Introduce struct v3d_submit and convert CL/TFU/CSD ioctls
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit 57df8fa619c75928aa962683ad4f8026a26f9b76 ]
As the V3D driver grew with time, different types of submission were added and the submission code grew more complex, but the driver stuck with the same abstractions.
Nowadays, the submission ioctls don't submit a single job, but a chain of jobs:
1. v3d_submit_cl_ioctl() submits a BIN job (optional), RENDER job (mandatory), and a CLEAN_CACHE job (optional).
2. v3d_submit_csd_ioctl() submits a CSD, and a CLEAN_CACHE job.
3. v3d_submit_tfu_ioctl() submits a TFU job.
Therefore, each ioctl submits a chain of jobs in which each job depends on the previous one. However, this concept is not well represented in software at the moment.
To address this, introduce a new concept: the struct v3d_submit, which groups the submission state and represents the submission chain formed by an ordered array of jobs.
Add new helpers to allocate, add jobs to the chain and submit jobs to the scheduler, all based on the new struct. Convert v3d_submit_cl_ioctl(), v3d_submit_tfu_ioctl() and v3d_submit_csd_ioctl() to the new pattern. Each ioctl now follows the same flow: add jobs -> attach perfmon -> lookup BOs -> lock reservations -> submit chain -> attach fences -> put jobs.
The CPU ioctl is left on the old helpers for now; its indirect CSD path requires some restructuring that will be addressed in the next few commits.
Stable-dep-of: fa98563ab00d ("drm/v3d: Associate BOs with every job that accesses them")
--- drivers/gpu/drm/v3d/v3d_drv.h | 21 ++ drivers/gpu/drm/v3d/v3d_submit.c | 384 ++++++++++++++++++------------- 2 files changed, 240 insertions(+), 165 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.h +21 -0
@@ -295,6 +295,27 @@ to_v3d_fence(struct dma_fence *fence)#define V3D_CORE_READ (core, offset) readl(v3d->core_regs[core] + offset)#define V3D_CORE_WRITE (core, offset, val) writel(val, v3d->core_regs[core] + offset) +#define V3D_MAX_JOBS_PER_SUBMISSION 3 + +/* Per-ioctl submission context */ +struct v3d_submit { +struct v3d_dev *v3d; + +struct drm_file *file_priv; + +/* DRM exec context for this submission. */ +struct drm_exec exec; + +/* Ordered array of jobs forming the submission chain. Jobs are +* appended via v3d_submit_add_job(), then chained and pushed to +* the scheduler by v3d_submit_jobs(). +*/ +struct v3d_job *jobs[V3D_MAX_JOBS_PER_SUBMISSION ]; + +/* Number of jobs currently in @jobs. */ +u32 job_count; +}; +struct v3d_job {struct drm_sched_job base;
drivers/gpu/drm/v3d/v3d_submit.c +219 -165
522 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 518/1815 drm/v3d: Make v3d_get_cpu_indirect_csd_params() a pure parser
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit 719ea1f03984f959700326aaec04b5bcdf3ca982 ]
v3d_get_cpu_indirect_csd_params() currently does double duty: it parses the indirect CSD extension and, while still inside the extension parser, also creates the CSD/clean jobs and locks their BOs through a separate DRM exec context. This nested submission deviates from the standard flow and makes it hard to fold the indirect CSD path into the unified submit chain.
Stash the parsed drm_v3d_submit_csd args in struct v3d_indirect_csd_info and have the parser only fill in the parameters. Then, move job creation (v3d_setup_csd_jobs_and_bos()) into v3d_submit_cpu_ioctl(), where is the proper place to create jobs.
No functional change, but prepares to move the CPU ioctl into the unified submission chain.
Stable-dep-of: fa98563ab00d ("drm/v3d: Associate BOs with every job that accesses them")
--- drivers/gpu/drm/v3d/v3d_drv.h | 5 +++++ drivers/gpu/drm/v3d/v3d_submit.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.h +5 -0
@@ -435,6 +435,11 @@ struct v3d_indirect_csd_info {/* Clean cache job associated to the Indirect CSD job */ struct v3d_job *clean_job; +/* Indirect CSD args, stashed by the extension parser and later used +* to create the CSD job from them. +*/ +struct drm_v3d_submit_csd args; +/* Offset within the BO where the workgroup counts are stored */ u32 offset;
drivers/gpu/drm/v3d/v3d_submit.c +13 -3
@@ -631,6 +631,7 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv, } job->job_type =V3D_CPU_JOB_TYPE_INDIRECT_CSD ; + info->args = indirect_csd.submit; info->offset = indirect_csd.offset; info->wg_size = indirect_csd.wg_size; memcpy(&info->wg_uniform_offsets, &indirect_csd.wg_uniform_offsets,
@@ -640,9 +641,7 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv,if (!info->indirect)return -ENOENT ; -return v3d_setup_csd_jobs_and_bos (file_priv, v3d, &indirect_csd.submit, - &info->job, &info->clean_job, -NULL , &info->exec); +return 0 ; }/* Get data for the query timestamp job submission. */
@@ -1405,6 +1404,17 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data, goto fail; } +if (cpu_job->job_type ==V3D_CPU_JOB_TYPE_INDIRECT_CSD ) { + ret =v3d_setup_csd_jobs_and_bos (file_priv, v3d, + &cpu_job->indirect_csd.args, + &cpu_job->indirect_csd.job, + &cpu_job->indirect_csd.clean_job, +NULL , + &cpu_job->indirect_csd.exec); +if (ret) + goto fail; + } + clean_job = cpu_job->indirect_csd.clean_job; csd_job = cpu_job->indirect_csd.job;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 519/1815 drm/v3d: Convert submit helpers to operate on struct v3d_submit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit f59d986943afbb97443cf91f45b1dc2c6fb6bebc ]
Generalize the submission helpers so they act on a whole struct v3d_submit (the entire job chain) rather than on individual jobs and a drm_exec. This lets a submission of several chained jobs be locked, fenced, and finalized as a single unit, and is the groundwork for collapsing the indirect CSD path into one chain.
The following helpers were generalized:
- v3d_lookup_bos()
- v3d_lock_bo_reservations() (renamed to v3d_submit_lock_reservations()):
- v3d_attach_fences_and_unlock_reservation()
- v3d_setup_csd_jobs_and_bos()
Now, the locking helper now iterates over all jobs and locks the union of their BOs under one DRM exec, using DRM_EXEC_IGNORE_DUPLICATES to tolerate shared BO references. The fence-attach helper similarly walks every job and attaches the chain's last fence to all touched BOs.
Also, v3d_submit_jobs() becomes the single submit-and-finalize entry point and callers no longer need to open-code fence attachment, reservation unlocking, etc.
Update CL/TFU/CSD/CPU ioctls to use the new helper signatures. The CPU ioctl still uses two struct v3d_submit instances (one for the CPU job, one for the indirect CSD jobs) and keeps its manual two-pass fence-attach flow. Converting the indirect CSD path into the unified chain is done in the next commit.
No functional change.
Stable-dep-of: fa98563ab00d ("drm/v3d: Associate BOs with every job that accesses them")
--- drivers/gpu/drm/v3d/v3d_submit.c | 338 ++++++++++++------------------- 1 file changed, 127 insertions(+), 211 deletions(-)
drivers/gpu/drm/v3d/v3d_submit.c +127 -211
@@ -20,32 +20,51 @@* to v3d, so we don't attach dma-buf fences to them. */ static int -v3d_lock_bo_reservations (struct v3d_job *job,struct drm_exec *exec) +v3d_submit_lock_reservations (struct v3d_submit *submit) { -int i, ret; - -drm_exec_init (exec,DRM_EXEC_INTERRUPTIBLE_WAIT , job->bo_count); -drm_exec_until_all_locked (exec) { - ret =drm_exec_prepare_array (exec, job->bo, job->bo_count,1 ); - } +int i, j, ret; -if (ret) - goto fail; +drm_exec_init (&submit->exec, +DRM_EXEC_INTERRUPTIBLE_WAIT |DRM_EXEC_IGNORE_DUPLICATES ,0 ); + drm_exec_until_all_locked(&submit->exec) { +for (i =0 ; i < submit->job_count; i++) { +struct v3d_job *job = submit->jobs[i]; -for (i =0 ; i < job->bo_count; i++) { - ret =drm_sched_job_add_implicit_dependencies (&job->base, - job->bo[i], true); + ret =drm_exec_prepare_array (&submit->exec, job->bo, + job->bo_count,1 ); +if (ret) +break ; + } +drm_exec_retry_on_contention (&submit->exec);if (ret) goto fail; } +for (i =0 ; i < submit->job_count; i++) { +struct v3d_job *job = submit->jobs[i]; + +for (j =0 ; j < job->bo_count; j++) { + ret =drm_sched_job_add_implicit_dependencies (&job->base, + job->bo[j], + true); +if (ret) + goto fail; + } + } +return 0 ; fail: -drm_exec_fini (exec); +drm_exec_fini (&submit->exec);return ret; } +static void +v3d_submit_unlock_reservations (struct v3d_submit *submit) +{ +drm_exec_fini (&submit->exec); +} +/** * v3d_lookup_bos() - Sets up job->bo[] with the GEM objects * referenced by the job.
@@ -63,25 +82,23 @@ v3d_lock_bo_reservations(struct v3d_job *job, struct drm_exec *exec)* failure, because that will happen at `v3d_job_free()`. */ static int -v3d_lookup_bos (struct drm_device *dev, -struct drm_file *file_priv, -struct v3d_job *job, -u64 bo_handles, -u32 bo_count) +v3d_lookup_bos (struct v3d_submit *submit,u64 bo_handles,u32 bo_count) { - job->bo_count = bo_count; +struct v3d_job *last_job = submit->jobs[submit->job_count -1 ]; -if (!job->bo_count) { + last_job->bo_count = bo_count; + +if (!last_job->bo_count) {/* See comment on bo_index for why we have to check * this. */ -drm_warn (dev,"Rendering requires BOs\n" ); +drm_warn (&submit->v3d->drm,"Rendering requires BOs\n" );return -EINVAL ; } -return drm_gem_objects_lookup (file_priv, +return drm_gem_objects_lookup (submit->file_priv, (void __user *)(uintptr_t )bo_handles, - job->bo_count, &job->bo); + last_job->bo_count, &last_job->bo); } static void
@@ -160,25 +177,6 @@ void v3d_job_put(struct v3d_job *job)kref_put (&job->refcount, job->free); } -static int -v3d_job_allocate (struct v3d_dev *v3d,void **container,size_t size) -{ - *container =kcalloc (1 , size,GFP_KERNEL ); -if (!*container) { -drm_err (&v3d->drm,"Cannot allocate memory for V3D job.\n" ); -return -ENOMEM ; - } - -return 0 ; -} - -static void -v3d_job_deallocate (void **container) -{ -kfree (*container); - *container =NULL ; -} -static int v3d_job_add_syncobjs (struct v3d_job *job,struct drm_file *file_priv,u32 in_sync,struct v3d_submit_ext *se)
@@ -218,48 +216,6 @@ v3d_job_add_syncobjs(struct v3d_job *job, struct drm_file *file_priv,return 0 ; } -static int -v3d_job_init (struct v3d_dev *v3d,struct drm_file *file_priv, -struct v3d_job *job,void (*free)(struct kref *ref), -u32 in_sync,struct v3d_submit_ext *se,enum v3d_queue queue) -{ -struct v3d_file_priv *v3d_priv = file_priv->driver_priv; -int ret; - - job->v3d = v3d; - job->free = free; - job->queue = queue; - job->file_priv = v3d_priv; - - ret =drm_sched_job_init (&job->base, &v3d_priv->sched_entity[queue], -1 , v3d_priv, file_priv->client_id); -if (ret) -return ret; - - ret =v3d_job_add_syncobjs (job, file_priv, in_sync, se); -if (ret) - goto fail_job_init; - -/* CPU jobs don't require hardware resources */ -if (queue !=V3D_CPU ) { - ret =v3d_pm_runtime_get (v3d); -if (ret) - goto fail_job_init; - job->has_pm_ref = true; - } - -kref_init (&job->refcount); - - job->client_stats =v3d_stats_get (v3d_priv->stats[queue]); - job->global_stats =v3d_stats_get (v3d->queue[queue].stats); - -return 0 ; - -fail_job_init: -drm_sched_job_cleanup (&job->base); -return ret; -} - static const struct { size_t size; void (*free)(struct kref *ref);
@@ -362,31 +318,34 @@ v3d_attach_perfmon_to_jobs(struct v3d_submit *submit, u32 perfmon_id) }static void -v3d_attach_fences_and_unlock_reservation (struct drm_file *file_priv, -struct v3d_job *job, -struct drm_exec *exec, -u32 out_sync, -struct v3d_submit_ext *se, -struct dma_fence *done_fence) +v3d_attach_fences_and_unlock_reservation (struct v3d_submit *submit, +u32 out_sync,struct v3d_submit_ext *se) { -struct drm_syncobj *sync_out;bool has_multisync = se && (se->flags &DRM_V3D_EXT_ID_MULTI_SYNC ); -int i; +struct v3d_job *last_job = submit->jobs[submit->job_count -1 ]; +struct drm_syncobj *sync_out; -for (i =0 ; i < job->bo_count; i++) { -/* XXX: Use shared fences for read-only objects. */ -dma_resv_add_fence (job->bo[i]->resv, job->done_fence, -DMA_RESV_USAGE_WRITE ); +/* The submission's last fence covers the entire submission. Attach it +* to every BO touched by any job in the submission. +*/ +for (int i =0 ; i < submit->job_count; i++) { +struct v3d_job *job = submit->jobs[i]; + +for (int j =0 ; j < job->bo_count; j++) { +/* XXX: Use shared fences for read-only objects. */ +dma_resv_add_fence (job->bo[j]->resv, last_job->done_fence, +DMA_RESV_USAGE_WRITE ); + } } -drm_exec_fini (exec); +v3d_submit_unlock_reservations (submit);/* Update the return sync object for the job */ /* If it only supports a single signal semaphore*/ if (!has_multisync) { - sync_out =drm_syncobj_find (file_priv, out_sync); + sync_out =drm_syncobj_find (submit->file_priv, out_sync);if (sync_out) { -drm_syncobj_replace_fence (sync_out, done_fence); +drm_syncobj_replace_fence (sync_out, last_job->done_fence);drm_syncobj_put (sync_out); }return ;
@@ -394,9 +353,9 @@ v3d_attach_fences_and_unlock_reservation(struct drm_file *file_priv,/* If multiple semaphores extension is supported */ if (se->out_sync_count) { -for (i =0 ; i < se->out_sync_count; i++) { +for (int i =0 ; i < se->out_sync_count; i++) {drm_syncobj_replace_fence (se->out_syncs[i].syncobj, - done_fence); + last_job->done_fence);drm_syncobj_put (se->out_syncs[i].syncobj); }kvfree (se->out_syncs);
@@ -417,7 +376,8 @@ v3d_push_job(struct v3d_job *job) }static int -v3d_submit_jobs (struct v3d_submit *submit) +v3d_submit_jobs (struct v3d_submit *submit,u32 out_sync, +struct v3d_submit_ext *se) {struct v3d_dev *v3d = submit->v3d;int ret =0 ;
@@ -437,52 +397,42 @@ v3d_submit_jobs(struct v3d_submit *submit) } } +mutex_unlock (&v3d->sched_lock); + +v3d_attach_fences_and_unlock_reservation (submit, out_sync, se); +v3d_submit_put_jobs (submit); + +return 0 ; + err:mutex_unlock (&v3d->sched_lock);return ret; }static int -v3d_setup_csd_jobs_and_bos (struct drm_file *file_priv, -struct v3d_dev *v3d, +v3d_setup_csd_jobs_and_bos (struct v3d_submit *submit,struct drm_v3d_submit_csd *args, -struct v3d_csd_job **job, -struct v3d_job **clean_job, -struct v3d_submit_ext *se, -struct drm_exec *exec) +struct v3d_submit_ext *se) { +struct v3d_csd_job *job; +struct v3d_job *clean_job;int ret; - ret =v3d_job_allocate (v3d, (void *)job,sizeof (**job)); -if (ret) -return ret; - - ret =v3d_job_init (v3d, file_priv, &(*job)->base, - v3d_job_free, args->in_sync, se,V3D_CSD ); -if (ret) { -v3d_job_deallocate ((void *)job); -return ret; - } + job = (struct v3d_csd_job *)v3d_submit_add_job (submit,V3D_CSD ); +if (IS_ERR (job)) +return PTR_ERR (job); - ret =v3d_job_allocate (v3d, (void *)clean_job,sizeof (**clean_job)); + ret =v3d_job_add_syncobjs (&job->base, submit->file_priv, args->in_sync, se);if (ret)return ret; - ret =v3d_job_init (v3d, file_priv, *clean_job, - v3d_job_free,0 ,NULL ,V3D_CACHE_CLEAN ); -if (ret) { -v3d_job_deallocate ((void *)clean_job); -return ret; - } - - (*job)->args = *args; + job->args = *args; - ret =v3d_lookup_bos (&v3d->drm, file_priv, *clean_job, - args->bo_handles, args->bo_handle_count); -if (ret) -return ret; + clean_job =v3d_submit_add_job (submit,V3D_CACHE_CLEAN ); +if (IS_ERR (clean_job)) +return PTR_ERR (clean_job); -return v3d_lock_bo_reservations (*clean_job, exec); +return v3d_lookup_bos (submit, args->bo_handles, args->bo_handle_count); } static void
@@ -1124,33 +1074,22 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,if (ret) goto fail; - ret =v3d_lookup_bos (dev, file_priv, - submit.jobs[submit.job_count -1 ], - args->bo_handles, args->bo_handle_count); + ret =v3d_lookup_bos (&submit, args->bo_handles, args->bo_handle_count);if (ret) goto fail; - ret =v3d_lock_bo_reservations (submit.jobs[submit.job_count -1 ], - &submit.exec); + ret =v3d_submit_lock_reservations (&submit);if (ret) goto fail; - ret =v3d_submit_jobs (&submit); + ret =v3d_submit_jobs (&submit, args->out_sync, &se);if (ret) goto fail_unreserve; -v3d_attach_fences_and_unlock_reservation (file_priv, - submit.jobs[submit.job_count -1 ], - &submit.exec, - args->out_sync, &se, - submit.jobs[submit.job_count -1 ]->done_fence); - -v3d_submit_put_jobs (&submit); -return 0 ; fail_unreserve: -drm_exec_fini (&submit.exec); +v3d_submit_unlock_reservations (&submit); fail:v3d_submit_cleanup_jobs (&submit);v3d_put_multisync_post_deps (&se);
@@ -1229,25 +1168,18 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data, job->base.bo[job->base.bo_count] = bo; } - ret =v3d_lock_bo_reservations (&job->base, &submit.exec); + ret =v3d_submit_lock_reservations (&submit);if (ret) goto fail; - ret =v3d_submit_jobs (&submit); + ret =v3d_submit_jobs (&submit, args->out_sync, &se);if (ret) goto fail_unreserve; -v3d_attach_fences_and_unlock_reservation (file_priv, - &job->base, &submit.exec, - args->out_sync, &se, - job->base.done_fence); - -v3d_submit_put_jobs (&submit); -return 0 ; fail_unreserve: -drm_exec_fini (&submit.exec); +v3d_submit_unlock_reservations (&submit); fail:v3d_submit_cleanup_jobs (&submit);v3d_put_multisync_post_deps (&se);
@@ -1271,8 +1203,6 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,struct v3d_submit submit = { .v3d =to_v3d_dev (dev), .file_priv = file_priv };struct drm_v3d_submit_csd *args = data;struct v3d_submit_ext se = {0 }; -struct v3d_csd_job *job =NULL ; -struct v3d_job *clean_job =NULL ;int ret;trace_v3d_submit_csd_ioctl (dev, args->cfg[5 ], args->cfg[6 ]);
@@ -1298,34 +1228,26 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data, } } - ret =v3d_setup_csd_jobs_and_bos (file_priv, submit.v3d, args, - &job, &clean_job, &se, &submit.exec); + ret =v3d_setup_csd_jobs_and_bos (&submit, args, &se);if (ret) goto fail; - submit.jobs[submit.job_count++] = &job->base; - submit.jobs[submit.job_count++] = clean_job; - ret =v3d_attach_perfmon_to_jobs (&submit, args->perfmon_id);if (ret) - goto fail_unreserve; + goto fail; - ret =v3d_submit_jobs (&submit); + ret =v3d_submit_lock_reservations (&submit);if (ret) - goto fail_unreserve; - -v3d_attach_fences_and_unlock_reservation (file_priv, - clean_job, - &submit.exec, - args->out_sync, &se, - clean_job->done_fence); + goto fail; -v3d_submit_put_jobs (&submit); + ret =v3d_submit_jobs (&submit, args->out_sync, &se); +if (ret) + goto fail_unreserve;return 0 ; fail_unreserve: -drm_exec_fini (&submit.exec); +v3d_submit_unlock_reservations (&submit); fail:v3d_submit_cleanup_jobs (&submit);v3d_put_multisync_post_deps (&se);
@@ -1356,13 +1278,14 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) {struct v3d_dev *v3d =to_v3d_dev (dev); +struct v3d_submit submit = { .v3d =to_v3d_dev (dev), .file_priv = file_priv }; +struct v3d_submit indirect_submit = { .v3d =to_v3d_dev (dev), .file_priv = file_priv };struct drm_v3d_submit_cpu *args = data;struct v3d_submit_ext se = {0 };struct v3d_submit_ext *out_se =NULL ;struct v3d_cpu_job *cpu_job =NULL ;struct v3d_csd_job *csd_job =NULL ;struct v3d_job *clean_job =NULL ; -struct drm_exec exec;int ret;if (args->flags && !(args->flags &DRM_V3D_SUBMIT_EXTENSION )) {
@@ -1370,9 +1293,9 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data,return -EINVAL ; } - ret =v3d_job_allocate (v3d, (void *)&cpu_job,sizeof (*cpu_job)); -if (ret) -return ret; + cpu_job = (struct v3d_cpu_job *)v3d_submit_add_job (&submit,V3D_CPU ); +if (IS_ERR (cpu_job)) +return PTR_ERR (cpu_job);if (args->flags &DRM_V3D_SUBMIT_EXTENSION ) { ret =v3d_get_extensions (file_priv, args->extensions, &se, cpu_job);
@@ -1397,34 +1320,35 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data,trace_v3d_submit_cpu_ioctl (&v3d->drm, cpu_job->job_type); - ret =v3d_job_init (v3d, file_priv, &cpu_job->base, - v3d_cpu_job_free,0 , &se,V3D_CPU ); -if (ret) { -v3d_job_deallocate ((void *)&cpu_job); + ret =v3d_job_add_syncobjs (&cpu_job->base, file_priv,0 , &se); +if (ret) goto fail; - }if (cpu_job->job_type ==V3D_CPU_JOB_TYPE_INDIRECT_CSD ) { - ret =v3d_setup_csd_jobs_and_bos (file_priv, v3d, + ret =v3d_setup_csd_jobs_and_bos (&indirect_submit, &cpu_job->indirect_csd.args, - &cpu_job->indirect_csd.job, - &cpu_job->indirect_csd.clean_job, -NULL , - &cpu_job->indirect_csd.exec); +NULL );if (ret) goto fail; - } - clean_job = cpu_job->indirect_csd.clean_job; - csd_job = cpu_job->indirect_csd.job; + ret =v3d_submit_lock_reservations (&indirect_submit); +if (ret) + goto fail; + + cpu_job->indirect_csd.job =container_of (indirect_submit.jobs[0 ], + struct v3d_csd_job, base); + cpu_job->indirect_csd.clean_job = indirect_submit.jobs[1 ]; + + clean_job = cpu_job->indirect_csd.clean_job; + csd_job = cpu_job->indirect_csd.job; + }if (args->bo_handle_count) { - ret =v3d_lookup_bos (dev, file_priv, &cpu_job->base, - args->bo_handles, args->bo_handle_count); + ret =v3d_lookup_bos (&submit, args->bo_handles, args->bo_handle_count);if (ret) goto fail; - ret =v3d_lock_bo_reservations (&cpu_job->base, &exec); + ret =v3d_submit_lock_reservations (&submit);if (ret) goto fail; }
@@ -1456,36 +1380,28 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data, out_se = (cpu_job->job_type ==V3D_CPU_JOB_TYPE_INDIRECT_CSD ) ?NULL : &se; -v3d_attach_fences_and_unlock_reservation (file_priv, - &cpu_job->base, - &exec,0 , - out_se, cpu_job->base.done_fence); +v3d_attach_fences_and_unlock_reservation (&submit,0 , out_se);switch (cpu_job->job_type) {case V3D_CPU_JOB_TYPE_INDIRECT_CSD : -v3d_attach_fences_and_unlock_reservation (file_priv, - clean_job, - &cpu_job->indirect_csd.exec, -0 , &se, clean_job->done_fence); +v3d_attach_fences_and_unlock_reservation (&indirect_submit,0 , &se);break ;default :break ; } -v3d_job_put (&cpu_job->base); -v3d_job_put (&csd_job->base); -v3d_job_put (clean_job); +v3d_submit_put_jobs (&submit); +v3d_submit_put_jobs (&indirect_submit);return 0 ; fail_unreserve:mutex_unlock (&v3d->sched_lock); -drm_exec_fini (&exec); -drm_exec_fini (&cpu_job->indirect_csd.exec); +v3d_submit_unlock_reservations (&submit); +v3d_submit_unlock_reservations (&indirect_submit); fail: -v3d_job_cleanup ((void *)cpu_job); -v3d_job_cleanup ((void *)csd_job); -v3d_job_cleanup (clean_job); +v3d_submit_cleanup_jobs (&submit); +v3d_submit_cleanup_jobs (&indirect_submit);v3d_put_multisync_post_deps (&se);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 520/1815 drm/v3d: Associate BOs with every job that accesses them
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit fa98563ab00dbe62fcedfef6bdd34ded7a860d9f ]
A submission can expand into a chain of jobs (e.g. bin + render + cache clean). Implicit synchronization in v3d_submit_lock_reservations() is gated on each job's bo[], but the BO list was only ever attached to the last job of the chain. When that last job is a trailing CACHE_CLEAN job, the job that actually consumes the BOs (that is, a RENDER or CSD job) was left with bo_count == 0 and picked up no implicit dependencies. It could therefore be dispatched to the hardware and read a BO while another context was still writing it, leading to data corruption.
Attach the BOs to the job that consumes them, so (1) it acquires the correct implicit dependencies during reservation locking and (2) they are kept mapped until the end of the submission. Give it references to all consuming job's BOs through v3d_job_reference_bos() instead of looking the handles up a second time; that avoids a redundant lookup and guarantees both jobs reference the exact same objects.
As the CACHE_CLEAN job now carries a BO array as well, add a per-job has_implicit_dep flag so that only the consuming jobs take implicit dependencies. The CACHE_CLEAN job (a global flush) and the BIN job (binning waiting on another context is not a realistic scenario) are excluded.
--- drivers/gpu/drm/v3d/v3d_drv.h | 5 ++ drivers/gpu/drm/v3d/v3d_submit.c | 92 +++++++++++++++++++++++--------- 2 files changed, 72 insertions(+), 25 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.h +5 -0
@@ -358,6 +358,11 @@ struct v3d_job {void (*free)(struct kref *ref);bool has_pm_ref; + +/* Whether the job needs implicit dependencies, i.e. must wait for +* other contexts still writing its BOs. +*/ +bool has_implicit_dep; };struct v3d_bin_job {
drivers/gpu/drm/v3d/v3d_submit.c +67 -25
164 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 521/1815 drivers: base: Remove statistics group if encryption group not created
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ewan D. Milne <[email protected]>
[ Upstream commit 6e328b4a208f7a06df3c1df18d7645c74c90f5f3 ]
If transport_add_class_device() gets an error from sysfs_create_group() when creating the encryption group, it does not remove the statistics group in the error path. Adjust the error path to do this properly.
v2: Only remove statistics group if tcont->statistics is non-NULL
--- drivers/base/transport_class.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/base/transport_class.c +4 -1
@@ -168,11 +168,14 @@ static int transport_add_class_device(struct attribute_container *cont,if (tcont->encryption) { error =sysfs_create_group (&classdev->kobj, tcont->encryption);if (error) - goto err_del; + goto err_del_statistics; }return 0 ; +err_del_statistics: +if (tcont->statistics) +sysfs_remove_group (&classdev->kobj, tcont->statistics); err_del:attribute_container_class_device_del (classdev); err_remove:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 522/1815 software node: Fix software_node_get_reference_args() with index -1
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alban Bedel <[email protected]>
[ Upstream commit ba3dedcf3bd47017307595a7e54924198f018246 ]
The bounds check for the index passed to software_node_get_reference_args() was failing when passed UINT_MAX, this in turn would lead to an out of bound access in the property array. Fix the bound check to also cover the UINT_MAX case.
--- drivers/base/swnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/swnode.c +1 -1
@@ -537,7 +537,7 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,if (prop->is_inline)return -EINVAL ; -if ((index +1 ) *sizeof (*ref) > prop->length) +if (index >= prop->length /sizeof (*ref))return -ENOENT ; ref_array = prop->pointer;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 523/1815 driver core: soc: Unregister bus on early device registration failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 45dfa004893dfeae182ec27eddbd153c6d4ddbf9 ]
soc_bus_register() registers the SoC bus before registering a deferred early SoC device. If soc_device_register() fails in that path, the function returns the error directly and leaves the bus registered.
Store the returned SoC device pointer explicitly so the success and error cases are handled separately. On failure, clear soc_bus_registered and unregister the bus before returning the error.
--- drivers/base/soc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/base/soc.c +13 -2
@@ -191,6 +191,7 @@ EXPORT_SYMBOL_GPL(soc_device_unregister);static int __init soc_bus_register (void ) { +struct soc_device *soc_dev;int ret; ret =bus_register (&soc_bus_type);
@@ -198,10 +199,20 @@ static int __init soc_bus_register(void)return ret; soc_bus_registered = true; -if (early_soc_dev_attr) -return PTR_ERR (soc_device_register (early_soc_dev_attr)); +if (early_soc_dev_attr) { + soc_dev =soc_device_register (early_soc_dev_attr); +if (IS_ERR (soc_dev)) { + ret =PTR_ERR (soc_dev); + goto err_unregister_bus; + } + }return 0 ; + +err_unregister_bus: + soc_bus_registered = false; +bus_unregister (&soc_bus_type); +return ret; }core_initcall (soc_bus_register);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 524/1815 drm/msm/a6xx: Fix RBBM_CLOCK_CNTL3_TP0 value in a730_hwcg
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puranam V G Tejaswi <[email protected]>
[ Upstream commit 01bcc0398f43099acb407a6067481e635c3e1b84 ]
The RBBM_CLOCK_CNTL3_TP0 entry in a730_hwcg has bits[19:16] set to 2 (clock gating enabled for that TP0 stage). As per the latest recommendation, clear this nibble to disable clock gating for this particular stage.
Patchwork: https://patchwork.freedesktop.org/patch/740955/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_catalog.c +1 -1
@@ -1199,7 +1199,7 @@ static const struct adreno_reglist a730_hwcg[] = { { REG_A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000080 }, { REG_A6XX_RBBM_CLOCK_CNTL_TP0, 0x22222220 }, { REG_A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222 }, - { REG_A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222 }, + { REG_A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22220222 }, { REG_A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00222222 }, { REG_A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777 }, { REG_A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777 },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 525/1815 arm64: dts: qcom: glymur: Add CX power domain to GCC
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit 2edbea82d8edbddb2a235b8f988f17b86f075476 ]
The GCC GDSCs on Glymur are backed by the RPMh CX power domain. Without describing that parent domain, consumers of GCC-provided GDSCs can enable their local domain without causing the required CX vote to be held.
Add the CX power-domain reference to the GCC node so votes from GCC GDSC consumers can propagate to RPMh CX.
--- arch/arm64/boot/dts/qcom/glymur.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/glymur.dtsi +1 -0
@@ -797,6 +797,7 @@ gcc: clock-controller@100000 { #clock-cells = <1>; #reset-cells = <1>; #power-domain-cells = <1>; + power-domains = <&rpmhpd RPMHPD_CX>; }; gpi_dma2: dma-controller@800000 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 526/1815 bpf: Reject arena frees below the arena base
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yiyang Chen <[email protected]>
[ Upstream commit b5a71cb2db6d84ac0042549dcec266b18429d41e ]
bpf_arena_free_pages() accepts scalar arena addresses. The runtime masks the address to the low 32 bits and reconstructs a full user address from the arena base before returning the range to the arena free tree.
When the scalar value is below the low 32 bits of the arena base, full_uaddr falls below user_vm_start. The existing upper-end clipping then turns this into an out-of-range free-tree offset. A later allocation can reuse that offset and return an address below the arena mapping.
Reject such frees before computing the clipped range.
--- kernel/bpf/arena.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/bpf/arena.c +2 -0
@@ -853,6 +853,8 @@ static void arena_free_pages(struct bpf_arena *arena, long uaddr, long page_cnt, uaddr &=PAGE_MASK ; kaddr =bpf_arena_get_kern_vm_start (arena) + uaddr; full_uaddr =clear_lo32 (arena->user_vm_start) + uaddr; +if (full_uaddr < arena->user_vm_start) +return ; uaddr_end =min (arena->user_vm_end, full_uaddr + (page_cnt <<PAGE_SHIFT ));if (full_uaddr >= uaddr_end)return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 527/1815 bpf: Disallow interpreter fallback for arena-related insns
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 34746b5a84ec37c0ea2bf6808c65c5ed8790eb51 ]
Since the interpreter does not support the arena-related insns, interpreter fallback should not be allowed for these insns in core.c::__bpf_prog_select_runtime().
Currently, when the interpreter executes the arena ST/LDX/STX insns, it would hit the BUG_ON() in ___bpf_prog_run() at run time.
[ 2.579196] BPF interpreter: unknown opcode a2 (imm: 0x0) [ 2.579998] ------------[ cut here ]------------ [ 2.580652] kernel BUG at kernel/bpf/core.c:2349! [ 2.581314] Oops: invalid opcode: 0000 [#1] SMP PTI
Set jit_required as true when arena map is used in the prog to disallow interpreter fallback for arena-related insns.
--- kernel/bpf/verifier.c | 1 + 1 file changed, 1 insertion(+)
kernel/bpf/verifier.c +1 -0
@@ -17851,6 +17851,7 @@ static int check_map_prog_compatibility(struct bpf_verifier_env *env,return -EOPNOTSUPP ; } env->prog->aux->arena = (void *)map; + env->prog->jit_required = true;if (!bpf_arena_get_user_vm_start (env->prog->aux->arena)) {verbose (env,"arena's user address must be set via map_extra or mmap()\n" );return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 528/1815 bpf: Disallow interpreter fallback for gotox insn
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 905f716362e1186c1a23447ca279e6d21f795cdb ]
The interpreter does not recognize the BPF_JMP|BPF_JA|BPF_X insn, which is used for insn_array map. Thereafter, it would hit the BUG_ON() in ___bpf_prog_run() at run time.
[ 2.563726] BPF interpreter: unknown opcode 0d (imm: 0x0) [ 2.564557] ------------[ cut here ]------------ [ 2.565206] kernel BUG at kernel/bpf/core.c:2349! [ 2.565882] Oops: invalid opcode: 0000 [#1] SMP PTI
Set jit_required as true when insn_array map is used in the prog in order to disallow interpreter fallback for gotox insn in core.c::__bpf_prog_select_runtime().
--- kernel/bpf/verifier.c | 1 + 1 file changed, 1 insertion(+)
kernel/bpf/verifier.c +1 -0
@@ -17899,6 +17899,7 @@ static int __add_used_map(struct bpf_verifier_env *env, struct bpf_map *map)return err; } env->insn_array_maps[env->insn_array_map_cnt++] = map; + env->prog->jit_required = true; }return env->used_map_cnt -1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 529/1815 bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 7a0855e73757ee9cf25ba635a1c735018ecba742 ]
The BPF_MOV64_PERCPU_REG insn requires JIT to emit native code to for 'dst_reg = src_reg + <percpu_base_off>'.
However, the interpreter ignores the 'off' at its ALU64_MOV_X label. The 'off' indicates the insn is BPF_MOV64_PERCPU_REG insn. Then, when the interpreter loads memory from the register, it will hit a page fault.
[ 2.545572] BUG: unable to handle page fault for address: ffffffffacaaf034 [ 2.546485] #PF: supervisor read access in kernel mode [ 2.547167] #PF: error_code(0x0000) - not-present page [ 2.547850] PGD 134e63067 P4D 134e63067 PUD 134e64063 PMD 10021c063 PTE 800ffffeca550062 [ 2.548912] Oops: Oops: 0000 [#1] SMP PTI
Set jit_required as true in order to disallow interpreter fallback in core.c::__bpf_prog_select_runtime(), if any BPF_ADDR_PERCPU insn is patched to the prog.
BTW, rename the helper bpf_map_supports_cpu_flags() to bpf_map_is_percpu_map().
--- include/linux/bpf.h | 4 ++-- kernel/bpf/fixups.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
include/linux/bpf.h +2 -2
@@ -4164,7 +4164,7 @@ bpf_prog_update_insn_ptrs(struct bpf_prog *prog, u32 *offsets, void *image) }#endif -static inline bool bpf_map_supports_cpu_flags (enum bpf_map_type map_type) +static inline bool bpf_map_is_percpu_map (enum bpf_map_type map_type) {switch (map_type) {case BPF_MAP_TYPE_PERCPU_ARRAY :
@@ -4191,7 +4191,7 @@ static inline int bpf_map_check_op_flags(struct bpf_map *map, u64 flags, u64 allreturn -EINVAL ;if (flags & (BPF_F_CPU |BPF_F_ALL_CPUS )) { -if (!bpf_map_supports_cpu_flags (map->map_type)) +if (!bpf_map_is_percpu_map (map->map_type))return -EINVAL ;if ((flags &BPF_F_CPU ) && (flags &BPF_F_ALL_CPUS ))return -EINVAL ;
kernel/bpf/fixups.c +5 -0
@@ -2008,6 +2008,9 @@ int bpf_do_misc_fixups(struct bpf_verifier_env *env)return -EFAULT ; } +if (bpf_map_is_percpu_map (map_ptr->map_type)) + prog->jit_required = true; + new_prog =bpf_patch_insn_data (env, i + delta, insn_buf, cnt);if (!new_prog)
@@ -2112,6 +2115,7 @@ int bpf_do_misc_fixups(struct bpf_verifier_env *env)* way, it's fine to back out this inlining logic */ #ifdef CONFIG_SMP + prog->jit_required = true; insn_buf[0 ] =BPF_MOV64_IMM (BPF_REG_0 , (u32 )(unsigned long )&cpu_number); insn_buf[1 ] =BPF_MOV64_PERCPU_REG (BPF_REG_0 ,BPF_REG_0 ); insn_buf[2 ] =BPF_LDX_MEM (BPF_W ,BPF_REG_0 ,BPF_REG_0 ,0 );
@@ -2133,6 +2137,7 @@ int bpf_do_misc_fixups(struct bpf_verifier_env *env)/* Implement bpf_get_current_task() and bpf_get_current_task_btf() inline. */ if ((insn->imm == BPF_FUNC_get_current_task || insn->imm == BPF_FUNC_get_current_task_btf) &&bpf_verifier_inlines_helper_call (env, insn->imm)) { + prog->jit_required = true; insn_buf[0 ] =BPF_MOV64_IMM (BPF_REG_0 , (u32 )(unsigned long )¤t_task); insn_buf[1 ] =BPF_MOV64_PERCPU_REG (BPF_REG_0 ,BPF_REG_0 ); insn_buf[2 ] =BPF_LDX_MEM (BPF_DW ,BPF_REG_0 ,BPF_REG_0 ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 530/1815 dmaengine: dw-edma: Terminate all descriptors without callbacks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit 99109a51efd28c9a661fbfb9469b023c517b31d1 ]
The DMA Engine client documentation says in the "Terminate APIs" section of Documentation/driver-api/dmaengine/client.rst:
"No callback functions will be called for any incomplete transfers."
dw-edma instead calls vchan_cookie_complete() when a deferred STOP reaches the interrupt handler. This schedules a callback for the active descriptor and leaves other issued or submitted descriptors queued. A late callback after dmaengine_terminate_sync() can dereference client state that has already been freed, while leftover descriptors may later restart into reused buffers or leak.
Move all issued and submitted descriptors to the terminated list whenever termination completes. For a pending STOP, do this from both the DONE and ABORT paths. Complete their cookies in order without scheduling callbacks.
A STOP can remain pending until the running transfer raises an interrupt. Make device_synchronize() wait for such a pending STOP to complete before releasing terminated descriptors. Reuse it from free_chan_resources(), then release the remaining virt-dma resources. Sleep instead of busy-polling while waiting, and warn if the existing timeout expires.
--- drivers/dma/dw-edma/dw-edma-core.c | 90 +++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 14 deletions(-)
drivers/dma/dw-edma/dw-edma-core.c +76 -14
@@ -7,6 +7,7 @@*/ #include <linux/module.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/kernel.h> #include <linux/dmaengine.h>
@@ -201,6 +202,35 @@ static int dw_edma_start_transfer(struct dw_edma_chan *chan)return 1 ; } +static void dw_edma_terminate_vdesc (struct virt_dma_desc *vd) +{ +list_del (&vd->node); +dma_cookie_complete (&vd->tx); +vchan_terminate_vdesc (vd); +} + +static void dw_edma_terminate_vdesc_list (struct list_head *head) +{ +struct virt_dma_desc *vd, *_vd; + +list_for_each_entry_safe (vd, _vd, head, node) +dw_edma_terminate_vdesc (vd); +} + +/* Must be called with vc.lock held. */ +static void dw_edma_terminate_all_descs (struct dw_edma_chan *chan) +{ +/* +* This order must not be reversed. Cookies are assigned when +* descriptors are submitted, so desc_issued contains older cookies +* than desc_submitted. Completing desc_submitted first could move +* chan->vc.chan.completed_cookie backwards when desc_issued is +* terminated afterwards. +*/ +dw_edma_terminate_vdesc_list (&chan->vc.desc_issued); +dw_edma_terminate_vdesc_list (&chan->vc.desc_submitted); +} +static void dw_edma_device_caps (struct dma_chan *dchan,struct dma_slave_caps *caps) {
@@ -309,20 +339,22 @@ static int dw_edma_device_terminate_all(struct dma_chan *dchan)struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan);int err =0 ; +guard (spinlock_irqsave)(&chan->vc.lock); +if (!chan->configured) { -/* Do nothing */ +dw_edma_terminate_all_descs (chan); }else if (chan->status ==EDMA_ST_PAUSE ) { +dw_edma_terminate_all_descs (chan); chan->status =EDMA_ST_IDLE ; - chan->configured = false; }else if (chan->status ==EDMA_ST_IDLE ) { - chan->configured = false; +dw_edma_terminate_all_descs (chan); }else if (dw_edma_core_ch_status (chan) ==DMA_COMPLETE ) {/* * The channel is in a false BUSY state, probably didn't * receive or lost an interrupt */ +dw_edma_terminate_all_descs (chan); chan->status =EDMA_ST_IDLE ; - chan->configured = false; }else if (chan->request >EDMA_REQ_PAUSE ) { err = -EPERM ; }else {
@@ -686,8 +718,7 @@ static void dw_edma_done_interrupt(struct dw_edma_chan *chan)break ;case EDMA_REQ_STOP : -list_del (&vd->node); -vchan_cookie_complete (vd); +dw_edma_terminate_all_descs (chan); chan->request =EDMA_REQ_NONE ; chan->status =EDMA_ST_IDLE ;break ;
@@ -706,7 +737,9 @@ static void dw_edma_abort_interrupt(struct dw_edma_chan *chan)spin_lock_irqsave (&chan->vc.lock, flags); vd =vchan_next_desc (&chan->vc); -if (vd) { +if (vd && chan->request ==EDMA_REQ_STOP ) { +dw_edma_terminate_all_descs (chan); + }else if (vd) {dw_hdma_set_callback_result (vd,DMA_TRANS_ABORTED );list_del (&vd->node);vchan_cookie_complete (vd);
@@ -865,21 +898,49 @@ static int dw_edma_alloc_chan_resources(struct dma_chan *dchan)return 0 ; } -static void dw_edma_free_chan_resources (struct dma_chan *dchan) +static void dw_edma_wait_termination (struct dma_chan *dchan) { +struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan);unsigned long timeout = jiffies +msecs_to_jiffies (5000 ); -int ret; +bool stopping; +/* +* A STOP may be deferred to a later interrupt while the channel is still +* running. Wait until that handler completes the termination. +*/ while (time_before (jiffies, timeout)) { - ret =dw_edma_device_terminate_all (dchan); -if (!ret) -break ; +scoped_guard (spinlock_irqsave, &chan->vc.lock) + stopping = chan->request == EDMA_REQ_STOP; -if (time_after_eq (jiffies, timeout)) +if (!stopping)return ; -cpu_relax (); +fsleep (1000 ); } + +dev_warn (chan->dw->chip->dev, +"timeout waiting for channel termination\n" ); +} + +static void dw_edma_device_synchronize (struct dma_chan *dchan) +{ +struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan); + +dw_edma_wait_termination (dchan); +vchan_synchronize (&chan->vc); +} + +static void dw_edma_free_chan_resources (struct dma_chan *dchan) +{ +struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan); + +dw_edma_device_terminate_all (dchan); +dw_edma_device_synchronize (dchan); + +scoped_guard (spinlock_irqsave, &chan->vc.lock) + chan->configured = false; + +vchan_free_chan_resources (&chan->vc); }static int dw_edma_channel_setup (struct dw_edma *dw,u32 wr_alloc,u32 rd_alloc)
@@ -976,6 +1037,7 @@ static int dw_edma_channel_setup(struct dw_edma *dw, u32 wr_alloc, u32 rd_alloc) dma->device_pause = dw_edma_device_pause; dma->device_resume = dw_edma_device_resume; dma->device_terminate_all = dw_edma_device_terminate_all; + dma->device_synchronize = dw_edma_device_synchronize; dma->device_issue_pending = dw_edma_device_issue_pending; dma->device_tx_status = dw_edma_device_tx_status; dma->device_prep_slave_sg = dw_edma_device_prep_slave_sg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 531/1815 dmaengine: dw-edma: Serialize abort state updates
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit dd80e259f65d932634e26d366570d71669ef6654 ]
dw_edma_abort_interrupt() drops vc.lock before changing request and status. issue_pending() can acquire the lock in that small window, observe the old busy state, and skip starting queued descriptors. Then the abort handler overwrites the channel status as idle, leaving the new descriptors stranded for good.
Keep descriptor completion and the state transition in the same critical section.
--- drivers/dma/dw-edma/dw-edma-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dw-edma/dw-edma-core.c +1 -1
@@ -744,9 +744,9 @@ static void dw_edma_abort_interrupt(struct dw_edma_chan *chan)list_del (&vd->node);vchan_cookie_complete (vd); } -spin_unlock_irqrestore (&chan->vc.lock, flags); chan->request =EDMA_REQ_NONE ; chan->status =EDMA_ST_IDLE ; +spin_unlock_irqrestore (&chan->vc.lock, flags); }static void dw_edma_emul_irq_ack (struct irq_data *d)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 532/1815 dmaengine: dw-edma: Serialize channel state checks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit f7d1619f3e10c619b62c6cd6d95371b5c526c85a ]
pause() and resume() read and update channel state without holding vc.lock, while the interrupt handlers update the same state under it. Take the same lock around those state checks so that request, status, and configured stay consistent.
For example, pause() can observe EDMA_ST_BUSY right before the interrupt handler completes the final descriptor and moves the channel to EDMA_ST_IDLE, and then record EDMA_REQ_PAUSE on an already idle channel. No further interrupt will acknowledge the request, and since issue_pending() requires EDMA_REQ_NONE, the channel is wedged for good: terminate_all() leaves the stale request behind, so even reconfiguring the channel does not recover it.
issue_pending() already runs under vc.lock, but it tests configured before taking it. Move that test under the lock as well, so configured, request, and status are evaluated as one channel-state snapshot.
--- drivers/dma/dw-edma/dw-edma-core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/dma/dw-edma/dw-edma-core.c +6 -4
@@ -302,6 +302,8 @@ static int dw_edma_device_pause(struct dma_chan *dchan)struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan);int err =0 ; +guard (spinlock_irqsave)(&chan->vc.lock); +if (!chan->configured) err = -EPERM ;else if (chan->status !=EDMA_ST_BUSY )
@@ -319,6 +321,8 @@ static int dw_edma_device_resume(struct dma_chan *dchan)struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan);int err =0 ; +guard (spinlock_irqsave)(&chan->vc.lock); +if (!chan->configured) { err = -EPERM ; }else if (chan->status !=EDMA_ST_PAUSE ) {
@@ -369,11 +373,9 @@ static void dw_edma_device_issue_pending(struct dma_chan *dchan)struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan);unsigned long flags; -if (!chan->configured) -return ; -spin_lock_irqsave (&chan->vc.lock, flags); -if (vchan_issue_pending (&chan->vc) && chan->request ==EDMA_REQ_NONE && +if (chan->configured &&vchan_issue_pending (&chan->vc) && + chan->request ==EDMA_REQ_NONE && chan->status ==EDMA_ST_IDLE ) { chan->status =EDMA_ST_BUSY ;dw_edma_start_transfer (chan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 533/1815 dmaengine: dw-edma: Clear stale requests on termination
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit c0d9c6275adcca7c0ca5f4270bf88026f9864bd1 ]
terminate_all() can finish immediately when the channel is unconfigured, paused, idle, or already stopped in hardware. A pending PAUSE request can survive these paths and block issue_pending() even after termination.
Clear the request whenever termination leaves the channel idle. A running channel keeps its STOP request until the interrupt handler consumes it.
--- drivers/dma/dw-edma/dw-edma-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/dma/dw-edma/dw-edma-core.c +2 -0
@@ -364,6 +364,8 @@ static int dw_edma_device_terminate_all(struct dma_chan *dchan) }else { chan->request =EDMA_REQ_STOP ; } +if (chan->status ==EDMA_ST_IDLE ) + chan->request =EDMA_REQ_NONE ;return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 534/1815 ASoC: meson: Keep link pointers valid on realloc failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 2aaa41cf974f83a6fb105422bac4e2f107150774 ]
meson_card_reallocate_links() grows the DAI link and private data arrays with two consecutive krealloc() calls and updates the owner pointers only after both calls have succeeded.
A successful krealloc() may move the data: it frees the old block and returns a new one. When that happens for the link array and the second krealloc() then fails, card->dai_link still points to the block that krealloc() already freed, and the error path frees the new block too. The probe error path then calls meson_card_clean_references(), which dereferences card->dai_link and kfree()s it again, resulting in a use-after-free and a double free.
Commit card->dai_link and card->num_links right after the first krealloc() succeeds, so the pointer always refers to a valid allocation that meson_card_clean_references() can walk and free. krealloc() with __GFP_ZERO zero-initializes the added entries, so walking them on the error path is safe. With both failure paths reduced to a plain return, drop the goto labels and the error message.
--- sound/soc/meson/meson-card-utils.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
sound/soc/meson/meson-card-utils.c +6 -11
@@ -50,25 +50,20 @@ int meson_card_reallocate_links(struct snd_soc_card *card, num_links *sizeof (*priv->card.dai_link), GFP_KERNEL | __GFP_ZERO);if (!links) - goto err_links; +return -ENOMEM ; + + priv->card.dai_link = links; + priv->card.num_links = num_links; ldata =krealloc (priv->link_data, num_links *sizeof (*priv->link_data),GFP_KERNEL | __GFP_ZERO); +/* meson_card_clean_references() will free the links on this error path */ if (!ldata) - goto err_ldata; +return -ENOMEM ; - priv->card.dai_link = links; priv->link_data = ldata; - priv->card.num_links = num_links;return 0 ; - -err_ldata: -kfree (links); -err_links: -dev_err (priv->card.dev,"failed to allocate links\n" ); -return -ENOMEM ; - }EXPORT_SYMBOL_GPL (meson_card_reallocate_links);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 535/1815 iio: dac: ad5686: missing NULL check on match data
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Alencar <[email protected]>
[ Upstream commit 572a008526359cdac2fa935dad75e9d50a79792f ]
Verify that chip_info pointer is not NULL. If a user binds the driver using driver_override via sysfs with a device name not present in the id_table or of_match_table, match data will be NULL.
--- drivers/iio/dac/ad5686-spi.c | 9 +++++++-- drivers/iio/dac/ad5696-i2c.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/iio/dac/ad5686-spi.c +7 -2
@@ -98,8 +98,13 @@ static const struct ad5686_bus_ops ad5686_spi_ops = {static int ad5686_spi_probe (struct spi_device *spi) { -return ad5686_probe (&spi->dev,spi_get_device_match_data (spi), - spi->modalias, &ad5686_spi_ops); +const struct ad5686_chip_info *info; + + info =spi_get_device_match_data (spi); +if (!info) +return -ENODATA ; + +return ad5686_probe (&spi->dev, info, spi->modalias, &ad5686_spi_ops); }static const struct spi_device_id ad5686_spi_id[] = {
drivers/iio/dac/ad5696-i2c.c +7 -2
@@ -68,8 +68,13 @@ static const struct ad5686_bus_ops ad5686_i2c_ops = {static int ad5686_i2c_probe (struct i2c_client *i2c) { -return ad5686_probe (&i2c->dev,i2c_get_match_data (i2c), - i2c->name, &ad5686_i2c_ops); +const struct ad5686_chip_info *info; + + info =i2c_get_match_data (i2c); +if (!info) +return -ENODATA ; + +return ad5686_probe (&i2c->dev, info, i2c->name, &ad5686_i2c_ops); }static const struct i2c_device_id ad5686_i2c_id[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 536/1815 phy: starfive: Fix runtime PM cleanup in JH7110 DPHY TX probe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Can Peng <[email protected]>
[ Upstream commit f40b0241f3a382e99c14de2f28f14a44973407c1 ]
stf_dphy_probe() enables runtime PM before getting the clock and reset controls, creating the PHY and registering the PHY provider. If any of those steps fails, probe returns with runtime PM still enabled.
The driver also has no remove callback, so runtime PM is left enabled on driver unbind after a successful probe.
Use devm_pm_runtime_enable() so runtime PM is disabled automatically on later probe failures and on driver unbind.
--- drivers/phy/starfive/phy-jh7110-dphy-tx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/phy/starfive/phy-jh7110-dphy-tx.c +4 -1
@@ -392,6 +392,7 @@ static int stf_dphy_probe(struct platform_device *pdev) {struct phy_provider *phy_provider;struct stf_dphy *dphy; +int ret; dphy =devm_kzalloc (&pdev->dev,sizeof (*dphy),GFP_KERNEL );if (!dphy)
@@ -406,7 +407,9 @@ static int stf_dphy_probe(struct platform_device *pdev)if (IS_ERR (dphy->topsys))return PTR_ERR (dphy->topsys); -pm_runtime_enable (&pdev->dev); + ret =devm_pm_runtime_enable (&pdev->dev); +if (ret) +return ret; dphy->txesc_clk =devm_clk_get (&pdev->dev,"txesc" );if (IS_ERR (dphy->txesc_clk))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 537/1815 phy: starfive: Fix runtime PM cleanup in JH7110 DPHY RX probe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Can Peng <[email protected]>
[ Upstream commit 97bed336f6a25c9d1115ca95e3aa00e05c3bc271 ]
stf_dphy_probe() enables runtime PM before registering the PHY provider. If devm_of_phy_provider_register() fails, probe returns with runtime PM still enabled.
The driver also has no remove callback, so runtime PM is left enabled on driver unbind after a successful probe.
Use devm_pm_runtime_enable() so runtime PM is disabled automatically on later probe failures and on driver unbind.
--- drivers/phy/starfive/phy-jh7110-dphy-rx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/phy/starfive/phy-jh7110-dphy-rx.c +4 -1
@@ -150,6 +150,7 @@ static int stf_dphy_probe(struct platform_device *pdev) {struct phy_provider *phy_provider;struct stf_dphy *dphy; +int ret; dphy =devm_kzalloc (&pdev->dev,sizeof (*dphy),GFP_KERNEL );if (!dphy)
@@ -190,7 +191,9 @@ static int stf_dphy_probe(struct platform_device *pdev)return PTR_ERR (dphy->phy); } -pm_runtime_enable (&pdev->dev); + ret =devm_pm_runtime_enable (&pdev->dev); +if (ret) +return ret;phy_set_drvdata (dphy->phy, dphy); phy_provider = devm_of_phy_provider_register(&pdev->dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 538/1815 arm64: dts: amlogic: meson-axg: Add missing nand_rb0 pin to nand_all_pins
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yan <[email protected]>
[ Upstream commit 45eb76f9ab6854f79690d56d04df227429a536b8 ]
The nand_all_pins pinctrl node was missing the nand_rb0 (ready/busy) pin description, which is required for NAND controller operation.
Add it to the pinmux list.
--- arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +2 -1
@@ -481,7 +481,8 @@ mux { "nand_ale", "nand_cle", "nand_wen_clk", - "nand_ren_wr"; + "nand_ren_wr", + "nand_rb0"; function = "nand"; input-enable; bias-pull-up;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 539/1815 arm64: dts: amlogic: meson-axg-s400: enable mipi_pcie_analog_dphy for PCIe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yan <[email protected]>
[ Upstream commit 7f1d0cc86cb70fa550163b6f70fd1d484c03218e ]
The PCIe PHY node references mipi_pcie_analog_dphy via its phys property. Enable this analog PHY node to make PCIe functionally viable.
--- arch/arm64/boot/dts/amlogic/meson-axg-s400.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/amlogic/meson-axg-s400.dts +4 -0
@@ -431,6 +431,10 @@ gpio_speaker: gpio-controller@1f { }; }; +&mipi_pcie_analog_dphy { + status = "okay"; +}; + &pdm { pinctrl-0 = <&pdm_dclk_a14_pins>, <&pdm_din0_pins>, <&pdm_din1_pins>, <&pdm_din2_pins>, <&pdm_din3_pins>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 540/1815 RDMA/hfi1: Propagate sdma_txinit_ahg() errors
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danila Chernetsov <[email protected]>
[ Upstream commit 091c6162c022cbdfb64219708a71728cfd1d4600 ]
set_txreq_header_ahg() ignores the return value of sdma_txinit_ahg().
If sdma_txinit_ahg() fails, it returns before initializing tx->txreq. However, set_txreq_header_ahg() ignores the error and returns the AHG change count, causing the caller to continue processing the request as though initialization had succeeded.
Propagate sdma_txinit_ahg() failures to the caller and abort request processing when initialization fails.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/hw/hfi1/user_sdma.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hfi1/user_sdma.c +8 -5
@@ -1026,6 +1026,7 @@ static int set_txreq_header_ahg(struct user_sdma_request *req, struct user_sdma_txreq *tx, u32 datalen) {u32 ahg[AHG_KDETH_ARRAY_SIZE ]; +int ret;int idx =0 ;u8 omfactor;/* KDETH.OM */ struct hfi1_user_sdma_pkt_q *pq = req->pq;
@@ -1130,11 +1131,13 @@ static int set_txreq_header_ahg(struct user_sdma_request *req,trace_hfi1_sdma_user_header_ahg (pq->dd, pq->ctxt, pq->subctxt, req->info.comp_idx, req->sde->this_idx, req->ahg_idx, ahg, idx, tidval); -sdma_txinit_ahg (&tx->txreq, -SDMA_TXREQ_F_USE_AHG , - datalen, req->ahg_idx, idx, - ahg,sizeof (req->hdr), - user_sdma_txreq_cb); + ret =sdma_txinit_ahg (&tx->txreq, +SDMA_TXREQ_F_USE_AHG , + datalen, req->ahg_idx, idx, + ahg,sizeof (req->hdr), + user_sdma_txreq_cb); +if (ret) +return ret;return idx; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 541/1815 RDMA/rxe: Validate num_sge/cur_sge before indexing wqe->dma.sge[]
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ibrahim Hashimov <[email protected]>
[ Upstream commit 126c757e4cd46f866ddc283143b58eb4d9bf52cd ]
For a user QP, qp->sq.queue is a ring the application writes directly, so rxe_post_send() takes the is_user branch and only schedules send_task without validating the WQE. rxe_requester() consumes it in place via req_next_wqe() and calls copy_data(), which indexes &wqe->dma.sge[cur_sge] with the attacker-controlled num_sge/cur_sge. Only the kernel path bounds num_sge (validate_send_wr()); the user WQE is never checked, so a local unprivileged user can post a WQE with an out-of-range cur_sge or oversized num_sge and force an out-of-bounds read of the per-WQE sge array in copy_data() (vmalloc OOB read, local DoS).
Bound num_sge to qp->sq.max_sge in rxe_requester() before use, the way get_srq_wqe() already guards SRQ entries, and bound cur_sge only when the WQE carries payload (dma.resid): copy_data() returns early on a zero-length copy before touching dma->sge[], so a zero-payload WQE -- the only kind a max_sge == 0 QP can post -- stays valid.
Reproduced under KASAN; the vmalloc-out-of-bounds in copy_data() is gone.
--- drivers/infiniband/sw/rxe/rxe_req.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/infiniband/sw/rxe/rxe_req.c +15 -0
@@ -701,6 +701,21 @@ int rxe_requester(struct rxe_qp *qp)if (unlikely (!wqe)) goto exit; +/* +* Don't trust user space data: a user QP's WQE comes from an mmap'd +* ring, so num_sge/cur_sge are attacker-controlled. Bound num_sge like +* get_srq_wqe(); bound cur_sge only when payload exists (dma.resid), +* since copy_data() skips dma->sge[] on a zero-length copy (all a +* max_sge == 0 QP can post). +*/ +if (unlikely (wqe->dma.num_sge > qp->sq.max_sge || + (wqe->dma.resid && + wqe->dma.cur_sge >= qp->sq.max_sge))) { +rxe_dbg_qp (qp,"invalid num_sge/cur_sge in send wqe\n" ); + wqe->status =IB_WC_LOC_QP_OP_ERR ; + goto err; + } +if (rxe_wqe_is_fenced (qp, wqe)) { qp->req.wait_fence =1 ; goto exit;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 542/1815 RDMA/core: Add ib_no_udata_io() helper
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit a833ce42d05624f27ac9b32e939df9caa7b06af3 ]
In many cases, a driver op accepts no input data and provides no response. This helper can be used in those handlers to adhere to the uAPI forward/backward compat rules by failing early if invalid udata is provided (whether input or output).
Stable-dep-of: d38c835925d4 ("RDMA/bnxt_re: Validate udata before executing commands")
--- include/rdma/uverbs_ioctl.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/rdma/uverbs_ioctl.h +20 -0
@@ -1151,4 +1151,24 @@ static inline int ib_respond_empty_udata(struct ib_udata *udata) return 0; } +/** +* ib_no_udata_io - Ensure no input data and zero fill the response buffer +* @udata: The system call's ib_udata struct +* +* Driver ops which do not accept any input data and do not provide any response +* data may call this at the beginning of their handler to fully adhere to the +* uAPI forward/backward compatibility rules. +* +* Return: Negative failure code if the op should be denied, 0 otherwise. +*/ +static inline int ib_no_udata_io (struct ib_udata *udata) +{ +int ret =ib_is_udata_in_empty (udata); + +if (ret) +return ret; + +return ib_respond_empty_udata (udata); +} +#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 543/1815 RDMA/bnxt_re: Validate udata before executing commands
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit d38c835925d4a3bfdf0a85ff2829ee90c709c561 ]
The destroy callbacks currently zero the udata output after tearing down driver resources. If the userspace access fails, uverbs preserves the uobject and allows the destroy callback to run again, even though the driver resource has already been freed.
Call ib_no_udata_io() before teardown so udata failures are detected while the resource is still intact, then return success after teardown completes.
As part of this change, move ib_respond_empty_udata() to the start of the create and modify flows. While this is not strictly required for general create flows, as the core layer unwinds uobjects on failure, it is necessary for create AH. In _rdma_create_ah(), the HW object is otherwise leaked.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 65 +++++++++++------------- 1 file changed, 30 insertions(+), 35 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +30 -35
@@ -695,7 +695,7 @@ int bnxt_re_dealloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata)struct bnxt_re_dev *rdev = pd->rdev;int ret; - ret =ib_is_udata_in_empty (udata); + ret =ib_no_udata_io (udata);if (ret)return ret;
@@ -712,7 +712,7 @@ int bnxt_re_dealloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata) &pd->qplib_pd))atomic_dec (&rdev->stats.res.pd_count); } -return ib_respond_empty_udata (udata); +return 0 ; }int bnxt_re_alloc_pd (struct ib_pd *ibpd,struct ib_udata *udata)
@@ -844,7 +844,7 @@ int bnxt_re_create_ah(struct ib_ah *ib_ah, struct rdma_ah_init_attr *init_attr,u8 nw_type;int rc; - rc =ib_is_udata_in_empty (udata); + rc =ib_no_udata_io (udata);if (rc)return rc;
@@ -901,7 +901,7 @@ int bnxt_re_create_ah(struct ib_ah *ib_ah, struct rdma_ah_init_attr *init_attr,if (active_ahs > rdev->stats.res.ah_watermark) rdev->stats.res.ah_watermark = active_ahs; -return ib_respond_empty_udata (udata); +return 0 ; }int bnxt_re_query_ah (struct ib_ah *ib_ah,struct rdma_ah_attr *ah_attr)
@@ -1015,7 +1015,7 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)unsigned int flags;int rc; - rc =ib_is_udata_in_empty (udata); + rc =ib_no_udata_io (udata);if (rc)return rc;
@@ -1064,7 +1064,7 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)if (scq_nq != rcq_nq)bnxt_re_synchronize_nq (rcq_nq); -return ib_respond_empty_udata (udata); +return 0 ; }static u8 __from_ib_qp_type (enum ib_qp_type type)
@@ -2148,7 +2148,7 @@ int bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)struct bnxt_qplib_srq *qplib_srq = &srq->qplib_srq;int ret; - ret =ib_is_udata_in_empty (udata); + ret =ib_no_udata_io (udata);if (ret)return ret;
@@ -2159,7 +2159,7 @@ int bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)free_page ((unsigned long )srq->uctx_srq_page);ib_umem_release (srq->umem);atomic_dec (&rdev->stats.res.srq_count); -return ib_respond_empty_udata (udata); +return 0 ; } static int bnxt_re_init_user_srq(struct bnxt_re_dev *rdev,
@@ -2297,34 +2297,25 @@ int bnxt_re_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr, { struct bnxt_re_srq *srq = container_of(ib_srq, struct bnxt_re_srq, ib_srq); -struct bnxt_re_dev *rdev = srq->rdev;int ret; - ret =ib_is_udata_in_empty (udata); + ret =ib_no_udata_io (udata);if (ret)return ret; -switch (srq_attr_mask) { -case IB_SRQ_MAX_WR : -/* SRQ resize is not supported */ +if (srq_attr_mask !=IB_SRQ_LIMIT )return -EINVAL ; -case IB_SRQ_LIMIT : -/* Change the SRQ threshold */ -if (srq_attr->srq_limit > srq->qplib_srq.max_wqe) -return -EINVAL ; - srq->qplib_srq.threshold = srq_attr->srq_limit; -bnxt_qplib_srq_arm_db (&srq->qplib_srq.dbinfo, srq->qplib_srq.threshold); - -/* On success, update the shadow */ - srq->srq_limit = srq_attr->srq_limit; -/* No need to Build and send response back to udata */ -return ib_respond_empty_udata (udata); -default : -ibdev_err (&rdev->ibdev, -"Unsupported srq_attr_mask 0x%x" , srq_attr_mask); +if (srq_attr->srq_limit > srq->qplib_srq.max_wqe)return -EINVAL ; - } + + srq->qplib_srq.threshold = srq_attr->srq_limit; +bnxt_qplib_srq_arm_db (&srq->qplib_srq.dbinfo, srq->qplib_srq.threshold); + +/* On success, update the shadow */ + srq->srq_limit = srq_attr->srq_limit; +/* No need to Build and send response back to udata */ +return 0 ; }int bnxt_re_query_srq (struct ib_srq *ib_srq,struct ib_srq_attr *srq_attr)
@@ -2437,7 +2428,7 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,unsigned int flags;u8 nw_type; - rc =ib_is_udata_in_empty (udata); + rc =ib_no_udata_io (udata);if (rc)return rc;
@@ -2689,7 +2680,7 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,if (rc)return rc; } -return ib_respond_empty_udata (udata); +return 0 ; } int bnxt_re_query_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
@@ -3471,7 +3462,7 @@ int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) nq = cq->qplib_cq.nq; cctx = rdev->chip_ctx; - ret =ib_is_udata_in_empty (udata); + ret =ib_no_udata_io (udata);if (ret)return ret;
@@ -3486,7 +3477,7 @@ int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)atomic_dec (&rdev->stats.res.cq_count);kfree (cq->cql);ib_umem_release (cq->umem); -return ib_respond_empty_udata (udata); +return 0 ; } int bnxt_re_create_user_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
@@ -3688,6 +3679,10 @@ int bnxt_re_resize_cq(struct ib_cq *ibcq, unsigned int cqe,if (rc) goto fail; + rc =ib_respond_empty_udata (udata); +if (rc) + goto fail; + cq->resize_umem =ib_umem_get_va (&rdev->ibdev, req.cq_va, entries *sizeof (struct cq_base ),IB_ACCESS_LOCAL_WRITE );
@@ -3717,7 +3712,7 @@ int bnxt_re_resize_cq(struct ib_cq *ibcq, unsigned int cqe, cq->ib_cq.cqe = cq->resize_cqe;atomic_inc (&rdev->stats.res.resize_count); -return ib_respond_empty_udata (udata); +return 0 ; fail:if (cq->resize_umem) {
@@ -4449,7 +4444,7 @@ int bnxt_re_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)struct bnxt_re_dev *rdev = mr->rdev;int rc; - rc =ib_is_udata_in_empty (udata); + rc =ib_no_udata_io (udata);if (rc)return rc;
@@ -4472,7 +4467,7 @@ int bnxt_re_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)atomic_dec (&rdev->stats.res.mr_count);if (rc)return rc; -return ib_respond_empty_udata (udata); +return 0 ; }static int bnxt_re_set_page (struct ib_mr *ib_mr,u64 addr)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 544/1815 RDMA/srpt: Fix srpt_alloc_rw_ctxs() unwind counters
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: TanZheng <[email protected]>
[ Upstream commit b38f98e176050850f41bb6415f3a71400056623e ]
When srpt_alloc_rw_ctxs() fails partway through a multi-buffer indirect descriptor, the unwind path destroys RDMA contexts but leaves stale n_rw_ctx and n_rdma values (and a dangling rw_ctxs pointer). Later sq_wr_avail accounting in srpt_queue_response() or srpt_write_pending() can then subtract the wrong number of send queue credits.
Reset the counters and clear rw_ctxs after freeing the heap allocation before returning an error.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/infiniband/ulp/srpt/ib_srpt.c +7 -0
@@ -960,6 +960,7 @@ static int srpt_alloc_rw_ctxs(struct srpt_send_ioctx *ioctx,struct srpt_rdma_ch *ch = ioctx->ch;struct scatterlist *prev =NULL ;unsigned prev_nents; +u8 n_rdma, n_rw_ctx;int ret, i;if (nbufs ==1 ) {
@@ -970,6 +971,9 @@ static int srpt_alloc_rw_ctxs(struct srpt_send_ioctx *ioctx,return -ENOMEM ; } + n_rw_ctx = ioctx->n_rw_ctx; + n_rdma = ioctx->n_rdma; +for (i = ioctx->n_rw_ctx; i < nbufs; i++, db++) {struct srpt_rw_ctx *ctx = &ioctx->rw_ctxs[i];u64 remote_addr =be64_to_cpu (db->va);
@@ -1016,6 +1020,9 @@ static int srpt_alloc_rw_ctxs(struct srpt_send_ioctx *ioctx, }if (ioctx->rw_ctxs != &ioctx->s_rw_ctx)kfree (ioctx->rw_ctxs); + ioctx->rw_ctxs =NULL ; + ioctx->n_rw_ctx = n_rw_ctx; + ioctx->n_rdma = n_rdma;return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 545/1815 kcsan: avoid unintended access checking in NMIs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Elver <[email protected]>
[ Upstream commit a8488ecbd7ba44d65b912dfe88a73f438eba2447 ]
If a watcher deliberately disables interrupts (either by user choice, or because we're dealing with a scoped reordered access) to avoid detecting any data races in interrupts, NMIs are still able to fire.
When we set up a watchpoint on a scoped reordered access, we disabled interrupts because the same CPU cannot observe reordering of its own accesses. To ensure we observe no false positives from NMIs, disable access checking for interrupt contexts as well.
--- kernel/kcsan/core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
kernel/kcsan/core.c +10 -2
@@ -585,8 +585,14 @@ kcsan_setup_watchpoint(const volatile void *ptr, size_t size, int type, unsigned* information is lost if dirtied by KCSAN. */ kcsan_save_irqtrace (current); -if (!interrupt_watcher) +if (!interrupt_watcher) {local_irq_save (irq_flags); +/* +* NMIs can still fire, disable checking for all interrupt +* contexts. +*/ +raw_cpu_ptr (&kcsan_cpu_ctx)->disable_count++; + } watchpoint =insert_watchpoint ((unsigned long )ptr, size, is_write);if (watchpoint ==NULL ) {
@@ -699,8 +705,10 @@ kcsan_setup_watchpoint(const volatile void *ptr, size_t size, int type, unsignedatomic_long_dec (&kcsan_counters[KCSAN_COUNTER_USED_WATCHPOINTS ]); out_unlock: -if (!interrupt_watcher) +if (!interrupt_watcher) { +raw_cpu_ptr (&kcsan_cpu_ctx)->disable_count--;local_irq_restore (irq_flags); + }kcsan_restore_irqtrace (current); ctx->disable_scoped--;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 546/1815 arm64: dts: imx8-ss-audio: Fix LPCG clock indices for ASRC0
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 8563591f76ca02c1a6fd70ce986df1d0dde8d249 ]
The LPCG clock indices for ASRC0 and AUD_PLL_DIV0 are swapped. The ASRC0 LPCG provides only IMX_LPCG_CLK_4, so update the ASRC0 clock consumer to use IMX_LPCG_CLK_4 instead of the non-existent IMX_LPCG_CLK_0.
Likewise, the AUD_PLL_DIV0 LPCG provides only IMX_LPCG_CLK_0, so update its clock consumer to use IMX_LPCG_CLK_0 instead of the non-existent IMX_LPCG_CLK_4.
--- arch/arm64/boot/dts/freescale/imx8-ss-audio.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/freescale/imx8-ss-audio.dtsi +4 -4
@@ -124,10 +124,10 @@ asrc0: asrc@59000000 { compatible = "fsl,imx8qm-asrc"; reg = <0x59000000 0x10000>; interrupts = <GIC_SPI 372 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&asrc0_lpcg IMX_LPCG_CLK_0>, - <&asrc0_lpcg IMX_LPCG_CLK_0>, - <&aud_pll_div0_lpcg IMX_LPCG_CLK_4>, - <&aud_pll_div1_lpcg IMX_LPCG_CLK_4>, + clocks = <&asrc0_lpcg IMX_LPCG_CLK_4>, + <&asrc0_lpcg IMX_LPCG_CLK_4>, + <&aud_pll_div0_lpcg IMX_LPCG_CLK_0>, + <&aud_pll_div1_lpcg IMX_LPCG_CLK_0>, <&acm IMX_ADMA_ACM_AUD_CLK0_SEL>, <&acm IMX_ADMA_ACM_AUD_CLK1_SEL>, <&clk_dummy>,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 547/1815 x86/bugs: Dont use cpu-type matching in cpu_vuln_blacklist
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pawan Gupta <[email protected]>
[ Upstream commit a4c714fe9746bf5a434bb798b26ebba278b798c1 ]
Thomas Gleixner pointed out that cpu-type is a per-CPU property while hybrid is a system property; conflating the two in the CPU matching infrastructure is wrong. Currently, on a hybrid system x86_match_cpu() matches any cpu-type. This works if the intent is to find the possibility of a cpu-type in a system. But fails if matching for the cpu-type of a given CPU.
Borislav posted a cleanup here:
https://lore.kernel.org/all/20260703193222.GFakgORjvxwnZTPRnI@fat_crate.local
To make way for the cleanup stop matching cpu-type in cpu_vuln_blacklist. RFDS is the only user, so drop the VULNBL_INTEL_TYPE entries and fold their RFDS bit into the base Alder Lake (0x97) and Raptor Lake (0xB7) blacklist entries. For now open-code cpu-type check in vulnerable_to_rfds(). In the future, if more vulnerabilities need cpu-type matching a helper can be added.
No functional change intended.
--- arch/x86/kernel/cpu/common.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/common.c +17 -8
@@ -1251,9 +1251,6 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {#define VULNBL_INTEL_STEPS (vfm, max_stepping, issues) \ X86_MATCH_VFM_STEPS(vfm, X86_STEP_MIN, max_stepping, issues) -#define VULNBL_INTEL_TYPE (vfm, cpu_type, issues) \ - X86_MATCH_VFM_CPU_TYPE(vfm, INTEL_CPU_TYPE_##cpu_type, issues) -#define VULNBL_AMD (family, blacklist) \ VULNBL(AMD, family, X86_MODEL_ANY, blacklist)
@@ -1316,11 +1313,9 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {VULNBL_INTEL_STEPS (INTEL_TIGERLAKE ,X86_STEP_MAX ,GDS |ITS |ITS_NATIVE_ONLY ),VULNBL_INTEL_STEPS (INTEL_LAKEFIELD ,X86_STEP_MAX ,MMIO |MMIO_SBDS |RETBLEED ),VULNBL_INTEL_STEPS (INTEL_ROCKETLAKE ,X86_STEP_MAX ,MMIO |RETBLEED |GDS |ITS |ITS_NATIVE_ONLY ), -VULNBL_INTEL_TYPE (INTEL_ALDERLAKE ,ATOM ,RFDS |VMSCAPE ), -VULNBL_INTEL_STEPS (INTEL_ALDERLAKE ,X86_STEP_MAX ,VMSCAPE ), +VULNBL_INTEL_STEPS (INTEL_ALDERLAKE ,X86_STEP_MAX ,RFDS |VMSCAPE ),VULNBL_INTEL_STEPS (INTEL_ALDERLAKE_L ,X86_STEP_MAX ,RFDS |VMSCAPE ), -VULNBL_INTEL_TYPE (INTEL_RAPTORLAKE ,ATOM ,RFDS |VMSCAPE ), -VULNBL_INTEL_STEPS (INTEL_RAPTORLAKE ,X86_STEP_MAX ,VMSCAPE ), +VULNBL_INTEL_STEPS (INTEL_RAPTORLAKE ,X86_STEP_MAX ,RFDS |VMSCAPE ),VULNBL_INTEL_STEPS (INTEL_RAPTORLAKE_P ,X86_STEP_MAX ,RFDS |VMSCAPE ),VULNBL_INTEL_STEPS (INTEL_RAPTORLAKE_S ,X86_STEP_MAX ,RFDS |VMSCAPE ), VULNBL_INTEL_STEPS(INTEL_METEORLAKE_L, X86_STEP_MAX, VMSCAPE),
@@ -1388,7 +1383,21 @@ static bool __init vulnerable_to_rfds(u64 x86_arch_cap_msr)return true;/* Only consult the blacklist when there is no enumeration: */ -return cpu_matches (cpu_vuln_blacklist,RFDS ); +if (!cpu_matches (cpu_vuln_blacklist,RFDS )) +return false; + +/* +* ADL and RPL are affected only if they have Atom CPUs. Hybrids have +* both Core and Atom CPUs. Mark unaffected when Atom CPUs are not +* present. +*/ +if ((boot_cpu_data.x86_model ==0x97 || + boot_cpu_data.x86_model ==0xB7 ) && + boot_cpu_data.topo.intel_type !=INTEL_CPU_TYPE_ATOM && + !boot_cpu_has (X86_FEATURE_HYBRID_CPU )) +return false; + +return true; }static bool __init vulnerable_to_its (u64 x86_arch_cap_msr)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 548/1815 selftests/bpf: Check malloc result with ASSERT_NEQ in test_loader
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viktor Malik <[email protected]>
[ Upstream commit 40f986aed81ff4d137ec101c6babbbc642690eac ]
Replace ASSERT_OK_PTR by ASSERT_NEQ(res, NULL, ...) when checking the result of malloc. It is more accurate since malloc returns NULL, not an error code, on failure and it also prevents the following false GCC warning when compiling BPF selftests with -O2:
In file included from test_loader.c:6:
test_loader.c: In function ‘verify_stderr’:
/bpf-next/tools/testing/selftests/bpf/test_progs.h:393:22: error: ‘buf’ may be used uninitialized [-Werror=maybe-uninitialized]
393 | int ___err = libbpf_get_error(___res); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
test_loader.c:810:14: note: in expansion of macro ‘ASSERT_OK_PTR’
810 | if (!ASSERT_OK_PTR(buf, "malloc"))
| ^~~~~~~~~~~~~
In file included from /bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf.h:32,
from /bpf-next/tools/testing/selftests/bpf/test_progs.h:37:
/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/libbpf_legacy.h:113:17: note: by argument 1 of type ‘const void *’ to ‘libbpf_get_error’ declared here
113 | LIBBPF_API long libbpf_get_error(const void *ptr);
| ^~~~~~~~~~~~~~~~
--- tools/testing/selftests/bpf/test_loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/test_loader.c +1 -1
@@ -807,7 +807,7 @@ static void verify_stderr(int prog_fd, struct expected_msgs *msgs)return ; buf =malloc (TEST_LOADER_LOG_BUF_SZ ); -if (!ASSERT_OK_PTR (buf,"malloc" )) +if (!ASSERT_NEQ (buf,NULL ,"malloc" ))return ; ret = bpf_prog_stream_read(prog_fd, 2, buf, TEST_LOADER_LOG_BUF_SZ - 1,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 549/1815 selftests/bpf: Check malloc result with ASSERT_NEQ in test_sha256
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viktor Malik <[email protected]>
[ Upstream commit eb5cd154f174f42079a45f4bd7ee8bc20f2ba6f3 ]
Replace ASSERT_OK_PTR by ASSERT_NEQ(res, NULL, ...) when checking the result of malloc. It is more accurate since malloc returns NULL, not an error code, on failure and it also prevents the following false GCC warning when compiling BPF selftests with -O2:
In file included from /bpf-next/tools/testing/selftests/bpf/prog_tests/sha256.c:4:
/bpf-next/tools/testing/selftests/bpf/prog_tests/sha256.c: In function ‘test_sha256’:
./test_progs.h:393:22: error: ‘data’ may be used uninitialized [-Werror=maybe-uninitialized]
393 | int ___err = libbpf_get_error(___res); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
/bpf-next/tools/testing/selftests/bpf/prog_tests/sha256.c:28:14: note: in expansion of macro ‘ASSERT_OK_PTR’
28 | if (!ASSERT_OK_PTR(data, "malloc"))
| ^~~~~~~~~~~~~
In file included from /bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf.h:32,
from ./test_progs.h:37:
/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/libbpf_legacy.h:113:17: note: by argument 1 of type ‘const void *’ to ‘libbpf_get_error’ declared here
113 | LIBBPF_API long libbpf_get_error(const void *ptr);
| ^~~~~~~~~~~~~~~~--- tools/testing/selftests/bpf/prog_tests/sha256.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/sha256.c +2 -2
@@ -25,10 +25,10 @@ void test_sha256(void)size_t i; data =malloc (MAX_LEN ); -if (!ASSERT_OK_PTR (data,"malloc" )) +if (!ASSERT_NEQ (data,NULL ,"malloc" )) goto out; digests =malloc ((MAX_LEN +1 ) *SHA256_DIGEST_LENGTH ); -if (!ASSERT_OK_PTR (digests,"malloc" )) +if (!ASSERT_NEQ (digests,NULL ,"malloc" )) goto out;/* Generate MAX_LEN bytes of "random" data deterministically. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 550/1815 selftests/bpf: Silence array bounds warning in global_map_resize
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viktor Malik <[email protected]>
[ Upstream commit dcd164ec67f89e0db5ee025ee9e91280052eb737 ]
When compiling BPF selftests with -O2, GCC reports an array bounds violation warning in global_map_resize test:
In function ‘global_map_resize_bss_subtest’,
inlined from ‘test_global_map_resize’ at /bpf-next/tools/testing/selftests/bpf/prog_tests/global_map_resize.c:228:3:
/bpf-next/tools/testing/selftests/bpf/prog_tests/global_map_resize.c:64:33: error: array subscript 1 is above array bounds of ‘int[1]’ [-Werror=array-bounds=]
64 | skel->bss->array[i] = 1;
| ~~~~~~~~~~~~~~~~^~~
In file included from /bpf-next/tools/testing/selftests/bpf/prog_tests/global_map_resize.c:6:
./test_global_map_resize.skel.h: In function ‘test_global_map_resize’:
./test_global_map_resize.skel.h:44:21: note: while referencing ‘array’
44 | int array[1];
| ^~~~~
This is a false positive because array (a BPF map) has been resized from within the BPF program. GCC doesn't know that so let us silence the warning by accessing the array via a plain pointer.
--- .../testing/selftests/bpf/prog_tests/global_map_resize.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/global_map_resize.c +6 -2
@@ -23,6 +23,7 @@ static void global_map_resize_bss_subtest(void)struct bpf_map *map;const __u32 desired_sz =sizeof (skel->bss->sum) +sysconf (_SC_PAGE_SIZE) *2 ;size_t array_len, actual_sz, new_sz; +int *array; skel =test_global_map_resize__open ();if (!ASSERT_OK_PTR (skel,"test_global_map_resize__open" ))
@@ -58,10 +59,13 @@ static void global_map_resize_bss_subtest(void) goto teardown;/* fill the newly resized array with ones, -* skipping the first element which was previously set +* skipping the first element which was previously set; +* access through a plain pointer to avoid -Warray-bounds +* since the array was resized beyond its declared length. */ + array = skel->bss->array;for (int i =1 ; i < array_len; i++) - skel->bss->array[i] =1 ; + array[i] =1 ;/* set global const values before loading */ skel->rodata->pid =getpid ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 551/1815 selftests/bpf: Silence maybe-uninitialized compiler warning in libarena
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viktor Malik <[email protected]>
[ Upstream commit 5763790965eb3414148720f030b20fd5ccc438ca ]
When compiling BPF selftests with -O2, GCC reports a maybe-uninitialized warning in libarena code:
In file included from /bpf-next/tools/testing/selftests/bpf/prog_tests/libarena_asan.c:11:
In function ‘libarena_asan_init’,
inlined from ‘run_test’ at /bpf-next/tools/testing/selftests/bpf/prog_tests/libarena_asan.c:59:8,
inlined from ‘test_libarena_asan’ at /bpf-next/tools/testing/selftests/bpf/prog_tests/libarena_asan.c:91:2:
/bpf-next/tools/testing/selftests/bpf/libarena/include/libarena/userspace.h:126:14: error: ‘globals_pages’ may be used uninitialized [-Werror=maybe-uninitialized]
126 | args = (struct asan_init_args){
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
127 | .arena_all_pages = arena_all_pages,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128 | .arena_globals_pages = globals_pages,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129 | };
| ~
/bpf-next/tools/testing/selftests/bpf/libarena/include/libarena/userspace.h: In function ‘test_libarena_asan’:
/bpf-next/tools/testing/selftests/bpf/libarena/include/libarena/userspace.h:118:13: note: ‘globals_pages’ was declared here
118 | u64 globals_pages;
| ^~~~~~~~~~~~~
Silence the warning by initializing globals_pages to 0.
--- .../testing/selftests/bpf/libarena/include/libarena/userspace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h +1 -1
@@ -115,7 +115,7 @@ static inline int libarena_asan_init(int arena_asan_init_fd, {LIBBPF_OPTS (bpf_test_run_opts, opts);struct asan_init_args args; -u64 globals_pages; +u64 globals_pages =0 ;int ret; ret = libarena_get_globals_pages(arena_asan_init_fd,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 552/1815 rust: device: make lifetime on `Core` and `CoreInternal` invariant
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit f7acb19abcd867e5d2e1feb6197dcc65aa3b8e45 ]
Currently the lifetime on Core and CoreInternal is covariant. This means that they can be coerced into shorter living lifetimes. On probe function, signature has &'bound Device<Core<'a>>; the type's wellformness would imply 'a: 'bound and thus the type can be coerced &'bound Device<Core<'bound>>, defeating the purpose of having the lifetime bound to prevent users of the Core type to escape the function.
Fix this by making the lifetime invariant, so the coercion is impossible. The lifetime here only needs to be "branded" so it does not coerce or unify with other lifetimes, so we do not need to ensure 'bound: 'a.
This requires modifying nova-core which relies on this implied bound due to pre-2024 capture rule. The "use" bound can be removed if built with edition 2024.
[ Fixup the debugfs sample to use an explicit lifetime instead of
Core<'_>. - Danilo ]
--- drivers/gpu/nova-core/gpu.rs | 6 +++--- rust/kernel/device.rs | 10 ++++++++-- samples/rust/rust_debugfs.rs | 4 +++- 3 files changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/nova-core/gpu.rs +3 -3
@@ -285,10 +285,10 @@ pub(crate) struct Gpu<'gpu> { } impl<'gpu> Gpu<'gpu> { - pub(crate) fn new( - pdev: &'gpu pci::Device<device::Core<'_>>, + pub(crate) fn new<'a>( + pdev: &'gpu pci::Device<device::Core<'a>>, bar: Bar0<'gpu>, - ) -> impl PinInit<Self, Error> + 'gpu { + ) -> impl PinInit<Self, Error> + use<'gpu, 'a> { try_pin_init!(Self { device: pdev.as_ref(), spec: Spec::new(pdev.as_ref(), bar).inspect(|spec| {
rust/kernel/device.rs +8 -2
@@ -511,7 +511,11 @@ pub struct Normal;/// callback it appears in. It is intended to be used for synchronization purposes. Bus device /// implementations can implement methods for [`Device<Core>`], such that they can only be called /// from bus callbacks. -pub struct Core <'a>(PhantomData <&'a ()>); +/// +/// The lifetime `'a` is for "lifetime branding" purpose. Callbacks need to polymorphic over this +/// lifetime so the `&'bound Device<Core<'_>>` provided to them cannot outlive the scope of the +/// function. For this reason, it needs to be invariant. +pub struct Core <'a>(PhantomData <fn (&'a ()) -> &'a ()>);/// Semantically the same as [`Core`], but reserved for internal usage of the corresponding bus /// abstraction.
@@ -522,7 +526,9 @@ pub struct Core<'a>(PhantomData<&'a ()>);/// /// This context mainly exists to share generic [`Device`] infrastructure that should only be called /// from bus callbacks with bus abstractions, but without making them accessible for drivers. -pub struct CoreInternal <'a>(PhantomData <&'a ()>); +/// +/// Lifetime `'a` is invariant for the same reason as [`Core`]. +pub struct CoreInternal <'a>(PhantomData <fn (&'a ()) -> &'a ()>);/// The [`Bound`] context is the [`DeviceContext`] of a bus specific device when it is guaranteed to /// be bound to a driver.
samples/rust/rust_debugfs.rs +3 -1
@@ -147,7 +147,9 @@ impl RustDebugFs { dir.read_write_file (c"pair" ,new_mutex! (Inner { x:3 , y:10 })) } -fn new <'a>(pdev: &'a platform::Device <Core <'_>>) ->impl PinInit <Self ,Error > + 'a { +fn new <'a, 'b>( + pdev: &'a platform::Device <Core <'b>>, + ) ->impl PinInit <Self ,Error > +use <'a, 'b> {let debugfs =Dir ::new (c"sample_debugfs" );let dev = pdev.as_ref ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 553/1815 samples: rust: debugfs: fix excessive stack use
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit f5256ad60651fc010e2cf6dc7fe195415f496fc9 ]
The current implementation creates a 4K array and move it into the box. Klint reports that this causes excesssive stack usage:
warning: stack size of create_file_write is 4472 bytes, exceeds the 2048-byte limit
--> samples/rust/rust_debugfs_scoped.rs:54:1
|
54 | / fn create_file_write(
55 | | mod_data: &ModuleData,
56 | | reader: &mut kernel::uaccess::UserSliceReader,
57 | | ) -> Result {
| |___________^
| = note: the stack size is inferred from instruction sub $0x1178,%rsp at .text+2205
Use pin-init to create the array in-place instead.
--- samples/rust/rust_debugfs_scoped.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
samples/rust/rust_debugfs_scoped.rs +4 -1
@@ -75,7 +75,10 @@ fn create_file_write( GFP_KERNEL, )?; } -let blob =KBox ::pin_init (new_mutex! ([0x42 ;SZ_4K ]),GFP_KERNEL )?; +let blob =KBox ::pin_init ( +new_mutex! (pin_init::init_array_from_fn (|_|0x42 )), +GFP_KERNEL , + )?;let scope =KBox ::pin_init ( mod_data.device_dir.scope(
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 554/1815 irqchip/gic-v3-its: Prevent leak in its_vpe_irq_domain_alloc()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
[ Upstream commit 325ff3e78c64cd619d52b99f7c8b09a3f31e1495 ]
When its_irq_gic_domain_alloc() fails, the following its_vpe_irq_domain_free() fails to invoke its_vep_teardown() for the corresponding interrupt, which leaks the resource.
Invoke its_vpe_teardown() in the error handling path to avoid the leak.
[ tglx: Massaged change log ]
--- drivers/irqchip/irq-gic-v3-its.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +10 -1
@@ -4592,6 +4592,13 @@ static int its_vpe_init(struct its_vpe *vpe)static void its_vpe_teardown (struct its_vpe *vpe) { +/* +* If vpt_page is NULL, then its_vpe_init() has failed, and +* there is nothing to do as no resource has been allocated. +*/ +if (vpe->vpt_page ==NULL ) +return ; +its_vpe_db_proxy_unmap (vpe);its_vpe_id_free (vpe->vpe_id);its_free_pending_table (vpe->vpt_page);
@@ -4672,8 +4679,10 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virqirqd_set_resend_when_in_progress (irq_get_irq_data (virq + i)); } -if (err) +if (err) { +its_vpe_teardown (vm->vpes[i]);its_vpe_irq_domain_free (domain, virq, i); + }return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 555/1815 RDMA/nldev: validate dynamic counter attribute length
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 74f49255492a62658f36bf2578d7916f1c6ffad1 ]
RDMA_NLDEV_ATTR_STAT_HWCOUNTERS is a nested attribute whose children are consumed directly with nla_get_u32(). The top-level policy validates only the container, so it does not establish the fixed shape of each child.
Require every child payload to be exactly one u32 before reading it.
--- drivers/infiniband/core/nldev.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/core/nldev.c +5 -0
@@ -2133,6 +2133,11 @@ static int nldev_stat_set_counter_dynamic_doit(struct nlattr *tb[],nla_for_each_nested (entry_attr, tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS ], rem) { +if (nla_len (entry_attr) !=sizeof (u32)) { + ret = -EINVAL ; + goto out; + } + index =nla_get_u32 (entry_attr);if ((index >= stats->num_counters) || !(stats->descs[index].flags &IB_STAT_FLAG_OPTIONAL )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 556/1815 ACPI: EC: Avoid _REG disconnect on GPIO IRQ defer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Ling <[email protected]>
[ Upstream commit e71bdbce27dcaa7f467a3a198cbe723924f05569 ]
EC event delivery uses either a GPE or, on ACPI reduced hardware platforms, a GpioInt resource. The GPE path does not have a provider lookup that can defer, but acpi_dev_gpio_irq_get() can return -EPROBE_DEFER for the GpioInt path.
ec_install_handlers() currently installs the EC address space handler and executes _REG before looking up the GPIO IRQ. If the GPIO lookup then defers, acpi_ec_setup() tears the handlers down again. Removing the EC address space handler causes ACPICA to execute _REG for disconnect, so firmware may observe an EC OpRegion connected -> disconnected transition during one failed probe attempt.
This is observable when the namespace EC reuses a boot EC that has already installed the EC address space handler. A deferred namespace EC probe can disconnect the already usable boot EC OpRegion until a later reprobe connects it again. AML that gates EC field accesses on _REG state can then return fallback values to other drivers during that window.
Prepare the GPIOInt IRQ before publishing EC OpRegion availability to AML. This leaves the GPE path unchanged, keeps non-deferred GPIO lookup errors non-fatal as before, and still lets the existing acpi_ec_setup() error path clean up real handler installation failures.
--- drivers/acpi/ec.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-)
drivers/acpi/ec.c +26 -14
@@ -1510,6 +1510,24 @@ static bool install_gpio_irq_event_handler(struct acpi_ec *ec) IRQF_SHARED | IRQF_ONESHOT, "ACPI EC", ec) >= 0; } +static int ec_prepare_gpio_irq (struct acpi_ec *ec,struct acpi_device *device) +{ +int irq; + +if (!device || ec->gpe >=0 || ec->irq >=0 ) +return 0 ; + +/* ACPI reduced hardware platforms use a GpioInt from _CRS. */ + irq =acpi_dev_gpio_irq_get (device,0 ); +if (irq == -EPROBE_DEFER ) +return irq; + +if (irq >=0 ) + ec->irq = irq; + +return 0 ; +} +/** * ec_install_handlers - Install service callbacks and register query methods. * @ec: Target EC.
@@ -1524,7 +1542,6 @@ static bool install_gpio_irq_event_handler(struct acpi_ec *ec)* Return: * -ENODEV if the address space handler cannot be installed, which means * "unable to handle transactions", -* -EPROBE_DEFER if GPIO IRQ acquisition needs to be deferred, * or 0 (success) otherwise. */ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,
@@ -1557,19 +1574,6 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,if (!device)return 0 ; -if (ec->gpe <0 ) { -/* ACPI reduced hardware platforms use a GpioInt from _CRS. */ -int irq =acpi_dev_gpio_irq_get (device,0 ); -/* -* Bail out right away for deferred probing or complete the -* initialization regardless of any other errors. -*/ -if (irq == -EPROBE_DEFER ) -return -EPROBE_DEFER ; -else if (irq >=0 ) - ec->irq = irq; - } -if (!test_bit (EC_FLAGS_QUERY_METHODS_INSTALLED , &ec->flags)) {/* Find and register all query methods */ acpi_walk_namespace(ACPI_TYPE_METHOD, ec->handle, 1,
@@ -1647,6 +1651,14 @@ static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device, bool ca {int ret; +/* +* GPIO IRQ lookup can defer. Do it before publishing the EC +* OpRegion to AML to avoid a spurious _REG(disconnect). +*/ + ret =ec_prepare_gpio_irq (ec, device); +if (ret) +return ret; +/* First EC capable of handling transactions */ if (!first_ec) first_ec = ec;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 557/1815 ACPI: processor: validate MADT IOAPIC entry bounds
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 2c50ffdc73f3a70d745d249f509fc290754121e6 ]
The IOAPIC hotplug lookup parses both MADT and _MAT records directly. The MADT walk previously used a subtable's declared length to advance the cursor after only locating a generic header. The _MAT path likewise passed a generic header to the IOAPIC helper.
Validate that a current record has a complete generic header, that its declared length is contained in the available record range, and that a typed IOAPIC record contains the full fixed IOAPIC body before reading its fields. Use the same relation for both MADT and _MAT provider paths.
--- drivers/acpi/processor_core.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)
drivers/acpi/processor_core.c +25 -6
@@ -336,11 +336,26 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)EXPORT_SYMBOL_GPL (acpi_get_cpuid);#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC -static int get_ioapic_id (struct acpi_subtable_header *entry,u32 gsi_base, +static bool madt_entry_is_valid (struct acpi_subtable_header *entry, +unsigned long end) +{ +unsigned long start = (unsigned long )entry; + +if (start >= end || end - start <sizeof (*entry)) +return false; + +return entry->length >=sizeof (*entry) && entry->length <= end - start; +} + +static int get_ioapic_id (struct acpi_subtable_header *entry, +const unsigned long end,u32 gsi_base,u64 *phys_addr,int *ioapic_id) {struct acpi_madt_io_apic *ioapic = (struct acpi_madt_io_apic *)entry; +if (!madt_entry_is_valid (entry, end) ||BAD_MADT_ENTRY (ioapic, end)) +return 0 ; +if (ioapic->global_irq_base != gsi_base)return 0 ;
@@ -361,17 +376,19 @@ static int parse_madt_ioapic_entry(u32 gsi_base, u64 *phys_addr)return apic_id; entry = (unsigned long )madt; +if (madt->header.length <sizeof (*madt)) +return apic_id; madt_end = entry + madt->header.length;/* Parse all entries looking for a match. */ entry +=sizeof (struct acpi_table_madt ); -while (entry +sizeof (struct acpi_subtable_header ) < madt_end) { +while (madt_entry_is_valid ((struct acpi_subtable_header *)entry, + madt_end)) { hdr = (struct acpi_subtable_header *)entry;if (hdr->type ==ACPI_MADT_TYPE_IO_APIC && -get_ioapic_id (hdr, gsi_base, phys_addr, &apic_id)) +get_ioapic_id (hdr, madt_end, gsi_base, phys_addr, &apic_id))break ; -else - entry += hdr->length; + entry += hdr->length; }return apic_id;
@@ -398,7 +415,9 @@ static int parse_mat_ioapic_entry(acpi_handle handle, u32 gsi_base, header = (struct acpi_subtable_header *)obj->buffer.pointer;if (header->type ==ACPI_MADT_TYPE_IO_APIC ) -get_ioapic_id (header, gsi_base, phys_addr, &apic_id); +get_ioapic_id (header, + (unsigned long )header + obj->buffer.length, + gsi_base, phys_addr, &apic_id); exit:kfree (buffer.pointer);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 558/1815 ACPI: PCI: Clear driver_data on all paths that free the acpi_pci_root
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Pei <[email protected]>
[ Upstream commit 8a742141f7ab84975aa758b775567ef4740ef0cf ]
acpi_pci_root_add() assigns the freshly allocated root to device->driver_data before dmar_device_add() and pci_acpi_scan_root(). Both failure paths reach the end: label where root is kfree()'d, but only the pci_acpi_scan_root() path clears driver_data first.
When dmar_device_add() fails during a hot-add, root is freed while device->driver_data still points at it. The ACPI core does not clear driver_data on attach failure, so a later acpi_pci_find_root() call may dereference this dangling pointer.
acpi_pci_root_remove() has the same problem: it frees root without clearing device->driver_data, leaving a dangling pointer behind after the root bridge is removed.
Move the NULL assignment to the shared end: label so every error path in acpi_pci_root_add() clears driver_data before freeing root, and clear it in acpi_pci_root_remove() as well, so the object is never left reachable through driver_data after being freed.
--- drivers/acpi/pci_root.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/pci_root.c +2 -1
@@ -725,7 +725,6 @@ static int acpi_pci_root_add(struct acpi_device *device,dev_err (&device->dev,"Bus %04x:%02x not present in PCI namespace\n" , root->segment, (unsigned int )root->secondary.start); - device->driver_data =NULL ; result = -ENODEV ; goto remove_dmar; }
@@ -765,6 +764,7 @@ static int acpi_pci_root_add(struct acpi_device *device,if (hotadd)dmar_device_remove (handle); end: + device->driver_data =NULL ;kfree (root);return result; }
@@ -788,6 +788,7 @@ static void acpi_pci_root_remove(struct acpi_device *device)pci_unlock_rescan_remove (); + device->driver_data =NULL ;kfree (root); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 559/1815 ext4: fix circular lock dependency in ext4_ext_migrate
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Zhou <[email protected]>
[ Upstream commit a897682793eba5de51ee6f3152760374afa629cf ]
Move iput(tmp_inode) after ext4_writepages_up_write() to avoid a circular lock dependency between s_writepages_rwsem and sb_internal (freeze protection).
The deadlock scenario:
CPU0 (EXT4_IOC_MIGRATE) CPU1 (orphan cleanup during mount)
---- ----
ext4_ext_migrate()
ext4_writepages_down_write()
s_writepages_rwsem (write)
ext4_evict_inode()
sb_start_intwrite() [sb_internal]
...
ext4_writepages()
s_writepages_rwsem (read) [BLOCKED]
iput(tmp_inode)
ext4_evict_inode()
sb_start_intwrite() [BLOCKED]The tmp_inode is a temporary inode with nlink=0 created solely for building the extent tree. Its eviction does not require s_writepages_rwsem protection, so deferring iput() until after releasing the rwsem is safe.
--- fs/ext4/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/migrate.c +2 -1
@@ -464,6 +464,7 @@ int ext4_ext_migrate(struct inode *inode)if (IS_ERR (tmp_inode)) { retval =PTR_ERR (tmp_inode);ext4_journal_stop (handle); + tmp_inode =NULL ; goto out_unlock; }/*
@@ -591,9 +592,9 @@ int ext4_ext_migrate(struct inode *inode)ext4_journal_stop (handle); out_tmp_inode:unlock_new_inode (tmp_inode); -iput (tmp_inode); out_unlock:ext4_writepages_up_write (inode->i_sb, alloc_ctx); +iput (tmp_inode);return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 560/1815 ext4: fix out-of-bounds read in ext4_read_inline_dir()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 9333cc809f0a89e001b814155a6cb8903a6274df ]
ext4_read_inline_dir() can read a dirent header past the end of its inline buffer, triggering a slab-out-of-bounds read during getdents64():
BUG: KASAN: slab-out-of-bounds in __ext4_check_dir_entry Read of size 2 at addr ffff88800f3dd23c by task exploit/148 ... __ext4_check_dir_entry ext4_read_inline_dir iterate_dir
The dirent payload lives in a buffer of exactly inline_size bytes:
dir_buf = kmalloc(inline_size, GFP_NOFS);
but iteration runs in a position space extra_offset bytes larger (extra_size = extra_offset + inline_size) so the synthetic "." and ".." land at their block-dir offsets. A dirent is formed at "dir_buf + pos - extra_offset", yet the ext4_check_dir_entry() length argument uses the larger extra_size. A position whose dirent header would extend past extra_size is therefore accepted, and the rescan loop's rec_len probe and ext4_check_dir_entry() dereference de->rec_len before the entry is rejected.
Reject a position whose minimum-size dirent header would not fit within extra_size before forming de, in both the rescan and main loops, and pass inline_size rather than extra_size to ext4_check_dir_entry() so the length check matches the physical buffer.
--- fs/ext4/inline.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/ext4/inline.c +10 -1
@@ -1454,6 +1454,8 @@ int ext4_read_inline_dir(struct file *file,/* for other entry, the real offset in * the buf has to be tuned accordingly. */ +if (i +ext4_dir_rec_len (1 ,NULL ) > extra_size) +break ; de = (struct ext4_dir_entry_2 *) (dir_buf + i - extra_offset);/* It's too expensive to do a full
@@ -1488,10 +1490,17 @@ int ext4_read_inline_dir(struct file *file,continue ; } +/* +* de lives at dir_buf + ctx->pos - extra_offset, within the +* kmalloc(inline_size) buffer. Make sure its header fits before +* ext4_check_dir_entry() dereferences de->rec_len. +*/ +if (ctx->pos +ext4_dir_rec_len (1 ,NULL ) > extra_size) + goto out; de = (struct ext4_dir_entry_2 *) (dir_buf + ctx->pos - extra_offset);if (ext4_check_dir_entry (inode, file, de, iloc.bh, dir_buf, - extra_size, ctx->pos)) + inline_size, ctx->pos)) goto out; if (le32_to_cpu(de->inode)) { if (!dir_emit(ctx, de->name, de->name_len,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 561/1815 ext4: skip extra isize expansion during mount to prevent deadlock
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Zhou <[email protected]>
[ Upstream commit 7461c60b9c6a839b13ad4c3490681a0cf5aa0637 ]
ext4_try_to_expand_extra_isize() is called from __ext4_mark_inode_dirty() while holding an active jbd2 handle. During mount (!SB_ACTIVE), the expand path may move xattrs to external blocks and release ea_inodes via iput(). When !SB_ACTIVE, iput() calls write_inode_now() which acquires s_writepages_rwsem, creating a circular lock dependency:
s_writepages_rwsem --> jbd2_handle --> xattr_sem --> s_writepages_rwsem
This can be triggered via:
ext4_process_orphan() -> ext4_truncate() -> ext4_mark_inode_dirty()
-> ext4_try_to_expand_extra_isize()
or:
ext4_evict_inode() -> ext4_mark_inode_dirty()
-> ext4_try_to_expand_extra_isize()
Skip expansion when !SB_ACTIVE. This is a minor loss of functionality (extra isize won't grow for these inodes during mount), which e2fsck can resolve later if needed.
--- fs/ext4/inode.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ext4/inode.c +10 -0
@@ -6511,6 +6511,16 @@ static int ext4_try_to_expand_extra_isize(struct inode *inode,if (ext4_test_inode_state (inode,EXT4_STATE_NO_EXPAND ))return -EOVERFLOW ; +/* +* Skip expansion during mount (!SB_ACTIVE). Expanding extra isize +* may move xattrs to external blocks and release ea_inodes via iput. +* When !SB_ACTIVE, iput triggers write_inode_now() which acquires +* s_writepages_rwsem, causing a deadlock with the caller's active +* jbd2 handle (lock order: s_writepages_rwsem -> jbd2_handle). +*/ +if (unlikely (!(inode->i_sb->s_flags &SB_ACTIVE ))) +return -EBUSY ; +/* * In nojournal mode, we can immediately attempt to expand * the inode. When journaled, we first need to obtain extra
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 562/1815 platform/x86: acer-wmi: reject missing gaming WMI results
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yousef Alhouseen <[email protected]>
[ Upstream commit caf8342512c3056005f475d350eeca089c3c6623 ]
WMI_gaming_execute_u32_u64() returns success when firmware supplies no output object, leaving the caller output untouched. Gaming getters then inspect an uninitialized result value.
When the caller requests an output value, return -ENOMSG if firmware supplies no object. Preserve a NULL output pointer as the supported way for callers to ignore the result.
--- drivers/platform/x86/acer-wmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/acer-wmi.c +3 -1
@@ -1581,7 +1581,9 @@ static int WMI_gaming_execute_u32_u64(u32 method_id, u32 in, u64 *out)return -EIO ; obj = result.pointer; -if (obj && out) { +if (!obj && out) { + ret = -ENOMSG ; + }else if (obj && out) {switch (obj->type) {case ACPI_TYPE_INTEGER : *out = obj->integer.value;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 563/1815 bpf: Zero queue and stack outputs on lock failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit 7ac6e1ae41a09f1dd4baeeff1d028ae49ee01232 ]
Queue and stack pop/peek helpers accept an uninitialized output buffer because the verifier expects the helper to initialize it. The empty-map error path clears the buffer, but a failed lock acquisition returns -EBUSY without writing it.
Clear the output before returning -EBUSY so BPF programs cannot observe uninitialized stack contents after a failed helper call.
--- kernel/bpf/queue_stack_maps.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/bpf/queue_stack_maps.c +6 -2
@@ -99,8 +99,10 @@ static long __queue_map_get(struct bpf_map *map, void *value, bool delete)int err =0 ;void *ptr; -if (raw_res_spin_lock_irqsave (&qs->lock, flags)) +if (raw_res_spin_lock_irqsave (&qs->lock, flags)) { +memset (value,0 , qs->map.value_size);return -EBUSY ; + }if (queue_stack_map_is_empty (qs)) {memset (value,0 , qs->map.value_size);
@@ -130,8 +132,10 @@ static long __stack_map_get(struct bpf_map *map, void *value, bool delete)void *ptr;u32 index; -if (raw_res_spin_lock_irqsave (&qs->lock, flags)) +if (raw_res_spin_lock_irqsave (&qs->lock, flags)) { +memset (value,0 , qs->map.value_size);return -EBUSY ; + }if (queue_stack_map_is_empty (qs)) {memset (value,0 , qs->map.value_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 564/1815 selftests/bpf: Fix make install target
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo B. Marlière <[email protected]>
[ Upstream commit 0b236ac75d04a235f3574a2208941b22c1e7a965 ]
After "make install", test_progs fails because two files end up in the wrong place:
- bpftool: TEST_GEN_PROGS_EXTENDED flattens it into $(INSTALL_PATH), losing the tools/sbin/ prefix that detect_bpftool_path() expects. Remove it from TEST_GEN_PROGS_EXTENDED and install it explicitly under tools/sbin/ instead.
- *.BTF: resolve_btfids writes resolve_btfids.test.o.BTF as a side-effect of the build but INSTALL_RULE never copies it over. Install all *.BTF files alongside the rest of the per-flavor output.
--- tools/testing/selftests/bpf/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/Makefile +4 -3
@@ -324,8 +324,6 @@ TRUNNER_BPFTOOL := $(DEFAULT_BPFTOOL) USE_BOOTSTRAP := "bootstrap/" endif -TEST_GEN_PROGS_EXTENDED += $(TRUNNER_BPFTOOL) - $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(BPFOBJ) TESTING_HELPERS := $(OUTPUT)/testing_helpers.o
@@ -1055,10 +1053,13 @@ endif DEFAULT_INSTALL_RULE := $(INSTALL_RULE) override define INSTALL_RULE $(DEFAULT_INSTALL_RULE) + @mkdir -p $(INSTALL_PATH)/tools/sbin + @rsync -a $(if $(PERMISSIVE),--ignore-missing-args) $(TRUNNER_BPFTOOL) $(INSTALL_PATH)/tools/sbin/ + @rsync -a $(if $(PERMISSIVE),--ignore-missing-args) $(OUTPUT)/*.BTF $(INSTALL_PATH)/ @for DIR in $(TEST_INST_SUBDIRS); do \ mkdir -p $(INSTALL_PATH)/$$DIR; \ rsync -a $(if $(PERMISSIVE),--ignore-missing-args) \ - $(OUTPUT)/$$DIR/*.bpf.o \ + $(OUTPUT)/$$DIR/*.bpf.o $(OUTPUT)/$$DIR/*.BTF \ $(INSTALL_PATH)/$$DIR; \ done endef
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 565/1815 selftests/bpf: Fix lsm_bdev dev_t encoding mismatch
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo B. Marlière <[email protected]>
[ Upstream commit 71cf3f3275e5f4d7f31bd540608c80535343b427 ]
progs/lsm_bdev.c keys its verity_devices hashmap with the raw kernel dev_t read straight off bdev->bd_dev, i.e. MKDEV(major, minor) = (major << 20) | minor. prog_tests/lsm_bdev.c instead builds its lookup key with dev_key = (__u32)st.st_rdev from stat(2), but the stat(2) syscall fills st_rdev via the kernel's new_encode_dev(), a different bit layout: (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12).
For any device with a non-trivial major these two values differ, so the lookup can never find what the BPF program stored, and test_lsm_bdev() always fails with:
test_lsm_bdev:FAIL:map lookup unexpected error: -2 (errno 2)
Reconstruct the raw kernel dev_t from the decoded major/minor instead of casting st_rdev directly, restoring the layout the BPF program actually reads.
--- tools/testing/selftests/bpf/prog_tests/lsm_bdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/lsm_bdev.c +2 -1
@@ -17,6 +17,7 @@#include <stdlib.h> #include <string.h> #include <sys/stat.h> +#include <sys/sysmacros.h> #include <sys/types.h> #include <unistd.h> #include "lsm_bdev.skel.h"
@@ -172,7 +173,7 @@ void test_lsm_bdev(void)if (!ASSERT_OK (stat (DM_DEV_PATH , &st),"stat dm dev" )) goto remove_dm; - dev_key = (__u32 )st.st_rdev; + dev_key = (major (st.st_rdev) <<20 ) |minor (st.st_rdev);/* Look up the device in the BPF map and verify. */ err = bpf_map__lookup_elem(skel->maps.verity_devices,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 566/1815 libbpf: Search /lib64 and /lib in resolve_full_path()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo B. Marlière <[email protected]>
[ Upstream commit 7b5ae0481efdac040cea72b4fabd1398109f975b ]
attach_probe/uprobe-lib and uprobe_autoattach selftests fail with "failed to resolve full path for libc.so.6" on older non-usrmerged distros, where libc.so.6 lives under a top-level /lib64 or /lib rather than /usr/lib64 or /usr/lib. Add /lib64:/lib to the search paths, alongside the existing /usr/lib64:/usr/lib and Debian multiarch entries.
--- tools/lib/bpf/libbpf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +2 -1
@@ -12973,13 +12973,14 @@ static const char *arch_specific_lib_paths(void)/* Get full path to program/shared library. */ static int resolve_full_path (const char *file,char *result,size_t result_sz) { -const char *search_paths[3 ] = {}; +const char *search_paths[4 ] = {};int i, perm;if (str_has_sfx (file,".so" ) ||strstr (file,".so." )) { search_paths[0 ] =getenv ("LD_LIBRARY_PATH" ); search_paths[1 ] ="/usr/lib64:/usr/lib" ; search_paths[2 ] =arch_specific_lib_paths (); + search_paths[3 ] ="/lib64:/lib" ; perm =R_OK ; }else { search_paths[0 ] =getenv ("PATH" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 567/1815 riscv, bpf: Fix memory leak in bpf_jit_free
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 369e4635d04801f394d5bd42556f21029e95ff93 ]
When bpf_int_jit_compile() is called for subprograms, it returns early during the first pass (!prog->is_func || extra_pass is false), keeping ctx->offset alive for the subsequent extra pass.
If JIT compilation fails for a later subprogram, the BPF core aborts and calls bpf_jit_free() to clean up the first subprogram. However, bpf_jit_free() fails to free jit_data->ctx.offset, which causes a memory leak of the JIT context offsets array.
Fix this by adding the missing kfree(jit_data->ctx.offset) in bpf_jit_free().
--- arch/riscv/net/bpf_jit_core.c | 1 + 1 file changed, 1 insertion(+)
arch/riscv/net/bpf_jit_core.c +1 -0
@@ -234,6 +234,7 @@ void bpf_jit_free(struct bpf_prog *prog)*/ if (jit_data) {bpf_jit_binary_pack_finalize (jit_data->ro_header, jit_data->header); +kfree (jit_data->ctx.offset);kfree (jit_data); } hdr =bpf_jit_binary_pack_hdr (prog);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 568/1815 riscv, bpf: Fix kernel stack corruption in tailcall with CFI
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 52fb1756ea1d2759dfef2d86245be00b05dac3a2 ]
When CONFIG_CFI_CLANG is enabled, prog->bpf_func already skips the kcfi instruction during setup. Including it again in the tailcall jump offset causes it to jump over an extra 4 bytes, skipping the stack pointer adjustment, which will result in kernel stack corruption.
--- arch/riscv/net/bpf_jit_comp64.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/riscv/net/bpf_jit_comp64.c +4 -3
@@ -18,7 +18,6 @@#define RV_MAX_REG_ARGS 8#define RV_FENTRY_NINSNS 2#define RV_FENTRY_NBYTES (RV_FENTRY_NINSNS * 4) -#define RV_KCFI_NINSNS (IS_ENABLED(CONFIG_CFI) ? 1 : 0)/* imm that allows emit_imm to emit max count insns */ #define RV_MAX_COUNT_IMM 0x7FFF7FF7FF7FF7FF
@@ -272,8 +271,8 @@ static void __build_epilogue(bool is_tail_call, struct rv_jit_context *ctx)if (!is_tail_call)emit_addiw (RV_REG_A0 ,RV_REG_A5 ,0 , ctx);emit_jalr (RV_REG_ZERO , is_tail_call ?RV_REG_T3 :RV_REG_RA , -/* kcfi, fentry and TCC init insns will be skipped on tailcall */ - is_tail_call ? (RV_KCFI_NINSNS +RV_FENTRY_NINSNS +1 ) *4 :0 , +/* fentry and TCC init insns will be skipped on tailcall */ + is_tail_call ? (RV_FENTRY_NINSNS +1 ) *4 :0 , ctx); }
@@ -2033,6 +2032,8 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog)/* emit kcfi type preamble immediately before the first insn */ emit_kcfi (is_subprog ? cfi_bpf_subprog_hash : cfi_bpf_hash, ctx); +/* bpf prog starts here as kcfi skipped during prog->bpf_func setup */ +/* nops reserved for auipc+jalr pair */ for (i =0 ; i <RV_FENTRY_NINSNS ; i++)emit (rv_nop (), ctx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 569/1815 bpf, riscv: Fix extable handling for arena load_acquire
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Jiang <[email protected]>
[ Upstream commit 5eb8921371c6fd117d4a328b6053dfda38707df8 ]
emit_atomic_ld_st() returns 1 to have build_body() skip the zext after a sub-word load_acquire. The caller does "ret = ret ?:add_exception_handler(...)", which skips add_exception_handler() on any non-zero ret, so the extable entry is missing and a faulting PROBE_ATOMIC load_acquire oopses.
REG_DONT_CLEAR_MARKER leaves rd stale on fault, and the verifier still thinks the load overwrote it, so a program can leak it through a map.
Check ret >= 0 before calling add_exception_handler(), and pass rd for LOAD_ACQ so the fault zeroes rd like a PROBE_MEM load. Return ret unchanged for the zext skip.
--- arch/riscv/net/bpf_jit_comp64.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/riscv/net/bpf_jit_comp64.c +6 -1
@@ -1985,7 +1985,12 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,else ret =emit_atomic_rmw (rd, rs, insn, ctx); - ret = ret ?:add_exception_handler (insn,REG_DONT_CLEAR_MARKER , ctx); +/* ret can be 1 (skip-zext); extable entry still needs to be added */ +if (ret >=0 ) + ret =add_exception_handler (insn, + insn->imm ==BPF_LOAD_ACQ ? rd :REG_DONT_CLEAR_MARKER , + ctx) ?: ret; +if (ret)return ret;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 570/1815 ACPI: battery: Adjust charging status validation check
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 77ce4be0d8d53c528d1663ab62a14d93d5853f11 ]
Commit bb1256e0ddc7 ("ACPI: battery: fix incorrect charging status when current is zero") added a charge rate check to validate the "charging" status of the battery, but that check is reported to cause some systems to misbehave [1]. Namely, it causes the "not charging" status to be reported on them while the battery is in fact charging (and they were correctly reporting the "charging" status in that case previously).
To address that, check if the battery is full in addition to checking the charge rate when the "charging" status is reported by the platform firmware and only change it to "not charging" if the battery is full and its charge rate is zero or it is unknown.
--- drivers/acpi/battery.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)
drivers/acpi/battery.c +19 -17
@@ -153,27 +153,28 @@ static int acpi_battery_technology(struct acpi_battery *battery)static int acpi_battery_get_state (struct acpi_battery *battery); -static int acpi_battery_is_charged (struct acpi_battery *battery) +static bool acpi_battery_is_full (struct acpi_battery *battery) { -/* charging, discharging, critical low or charge limited */ -if (battery->state !=0 ) -return 0 ; -/* battery not reporting charge */ if (battery->capacity_now ==ACPI_BATTERY_VALUE_UNKNOWN || battery->capacity_now ==0 ) -return 0 ; +return false;/* good batteries update full_charge as the batteries degrade */ if (battery->full_charge_capacity == battery->capacity_now) -return 1 ; +return true;/* fallback to using design values for broken batteries */ -if (battery->design_capacity <= battery->capacity_now) -return 1 ; +return battery->design_capacity <= battery->capacity_now; +} -/* we don't do any sort of metric based on percentages */ -return 0 ; +static int acpi_battery_is_charged (struct acpi_battery *battery) +{ +/* charging, discharging, critical low or charge limited */ +if (battery->state !=0 ) +return 0 ; + +return acpi_battery_is_full (battery); }static bool acpi_battery_is_degraded (struct acpi_battery *battery)
@@ -226,13 +227,14 @@ static int acpi_battery_get_property(struct power_supply *psy,return 0 ; }else if (battery->state &ACPI_BATTERY_STATE_CHARGING ) -/* Validate the status by checking the current. */ -if (battery->rate_now !=ACPI_BATTERY_VALUE_UNKNOWN && - battery->rate_now ==0 ) { -/* On charge but no current (0W/0mA). */ - val->intval =POWER_SUPPLY_STATUS_NOT_CHARGING ; - }else { +/* Check the rate and capacity to validate the status. */ +if (!acpi_battery_is_full (battery) || + (battery->rate_now !=ACPI_BATTERY_VALUE_UNKNOWN && + battery->rate_now >0 )) { val->intval =POWER_SUPPLY_STATUS_CHARGING ; + }else { +/* Full and zero rate. */ + val->intval =POWER_SUPPLY_STATUS_NOT_CHARGING ; }else if (battery->state &ACPI_BATTERY_STATE_CHARGE_LIMITING ) val->intval =POWER_SUPPLY_STATUS_NOT_CHARGING ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 571/1815 virt: arm-cca-guest: use migrate_disable() for attestation token requests
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kohei Enju <[email protected]>
[ Upstream commit 24f55f511b9e1c19dc48d11bfe0dc60c86bdb376 ]
The RSI attestation token init and continue calls must be issued from the same CPU. arm_cca_report_new() currently snapshots the CPU number and uses smp_call_function_single() to issue those calls on that CPU.
With CONFIG_DEBUG_PREEMPT=y, the smp_processor_id() call used for the snapshot triggers a debug splat [0] because it runs in preemptible context. The snapshot does not pin the task to that CPU; it is only used to choose the target CPU for smp_call_function_single(), which can fail if that CPU is no longer available.
Use migrate_disable() and issue the token init and continue operations directly, without the smp_call_function_single() callbacks. This keeps the token request sequence on the same CPU while preserving a sleepable context for the GFP_KERNEL allocations needed after the init call.
[0]
BUG: using smp_processor_id() in preemptible [00000000] code: cca-workload-at/264 caller is debug_smp_processor_id+0x20/0x30 CPU: 0 UID: 0 PID: 264 Comm: cca-workload-at Not tainted 7.1.0-rc1-00044-g55542ab273f2 #80 PREEMPT(lazy) Hardware name: linux,dummy-virt (DT) Call trace: [...] check_preemption_disabled+0xd8/0xf8 debug_smp_processor_id+0x20/0x30 arm_cca_report_new+0x48/0x278 tsm_report_read+0x154/0x1f8 tsm_report_outblob_read+0x20/0x38 configfs_bin_read_iter+0x118/0x208 vfs_read+0x220/0x318 [...]
--- .../virt/coco/arm-cca-guest/arm-cca-guest.c | 97 +++++++------------ 1 file changed, 36 insertions(+), 61 deletions(-)
drivers/virt/coco/arm-cca-guest/arm-cca-guest.c +36 -61
@@ -16,54 +16,38 @@/** * struct arm_cca_token_info - a descriptor for the token buffer. -* @challenge: Pointer to the challenge data -* @challenge_size: Size of the challenge data * @granule: PA of the granule to which the token will be written * @offset: Offset within granule to start of buffer in bytes -* @result: result of rsi_attestation_token_continue operation */ struct arm_cca_token_info { -void *challenge; -unsigned long challenge_size;phys_addr_t granule;unsigned long offset; -unsigned long result; }; -static void arm_cca_attestation_init (void *param) -{ -struct arm_cca_token_info *info; - - info = (struct arm_cca_token_info *)param; - - info->result =rsi_attestation_token_init (info->challenge, - info->challenge_size); -} -/** * arm_cca_attestation_continue - Retrieve the attestation token data. * -* @param: pointer to the arm_cca_token_info +* @info: pointer to the arm_cca_token_info * * Attestation token generation is a long running operation and therefore * the token data may not be retrieved in a single call. Moreover, the * token retrieval operation must be requested on the same CPU on which the * attestation token generation was initialised. -* This helper function is therefore scheduled on the same CPU multiple +* This helper function must therefore be executed on the same CPU multiple * times until the entire token data is retrieved. */ -static void arm_cca_attestation_continue (void *param) +static unsigned long +arm_cca_attestation_continue (struct arm_cca_token_info *info) { +unsigned long ret;unsigned long len;unsigned long size; -struct arm_cca_token_info *info; - - info = (struct arm_cca_token_info *)param; size =RSI_GRANULE_SIZE - info->offset; - info->result =rsi_attestation_token_continue (info->granule, - info->offset, size, &len); + ret =rsi_attestation_token_continue (info->granule, info->offset, size, + &len); info->offset += len; +return ret; }/**
@@ -74,8 +58,8 @@ static void arm_cca_attestation_continue(void *param)* * Initialise the attestation token generation using the challenge data * passed in the TSM descriptor. Allocate memory for the attestation token -* and schedule calls to retrieve the attestation token on the same CPU -* on which the attestation token generation was initialised. +* and retrieve the attestation token on the same CPU on which the +* attestation token generation was initialised. * * The challenge data must be at least 32 bytes and no more than 64 bytes. If * less than 64 bytes are provided it will be zero padded to 64 bytes.
@@ -85,12 +69,11 @@ static void arm_cca_attestation_continue(void *param)* * %-EINVAL - A parameter was not valid. * * %-ENOMEM - Out of memory. * * %-EFAULT - Failed to get IPA for memory page(s). -* * A negative status code as returned by smp_call_function_single(). */ static int arm_cca_report_new (struct tsm_report *report,void *data) { -int ret; -int cpu; +int ret =0 ; +unsigned long rsi_result;long max_size;unsigned long token_size =0 ;struct arm_cca_token_info info;
@@ -103,37 +86,33 @@ static int arm_cca_report_new(struct tsm_report *report, void *data)/* * The attestation token 'init' and 'continue' calls must be -* performed on the same CPU. smp_call_function_single() is used -* instead of simply calling get_cpu() because of the need to -* allocate outblob based on the returned value from the 'init' -* call and that cannot be done in an atomic context. +* performed on the same CPU, so disable CPU migration around +* those operations. */ - cpu =smp_processor_id (); +migrate_disable (); - info.challenge = desc->inblob; - info.challenge_size = desc->inblob_len; - - ret =smp_call_function_single (cpu, arm_cca_attestation_init, - &info, true); -if (ret) -return ret; - max_size = info.result; - -if (max_size <=0 ) -return -EINVAL ; + max_size =rsi_attestation_token_init (desc->inblob, desc->inblob_len); +if (max_size <=0 ) { + ret = -EINVAL ; + goto exit_migrate_enable; + }/* Allocate outblob */ token =kvzalloc (max_size,GFP_KERNEL ); -if (!token) -return -ENOMEM ; +if (!token) { + ret = -ENOMEM ; + goto exit_migrate_enable; + }/* * Since the outblob may not be physically contiguous, use a page * to bounce the buffer from RMM. */ buf =alloc_pages_exact (RSI_GRANULE_SIZE ,GFP_KERNEL ); -if (!buf) -return -ENOMEM ; +if (!buf) { + ret = -ENOMEM ; + goto exit_migrate_enable; + }/* Get the PA of the memory page(s) that were allocated */ info.granule = (unsigned long )virt_to_phys (buf);
@@ -144,21 +123,15 @@ static int arm_cca_report_new(struct tsm_report *report, void *data) info.offset =0 ;do {/* -* Schedule a call to retrieve a sub-granule chunk -* of data per loop iteration. +* Retrieve a sub-granule chunk of data per loop +* iteration. */ - ret =smp_call_function_single (cpu, - arm_cca_attestation_continue, - (void *)&info, true); -if (ret !=0 ) { - token_size =0 ; - goto exit_free_granule_page; - } - }while (info.result ==RSI_INCOMPLETE && + rsi_result =arm_cca_attestation_continue (&info); + }while (rsi_result ==RSI_INCOMPLETE && info.offset <RSI_GRANULE_SIZE );/* Break out in case of failure */ -if (info.result !=RSI_SUCCESS && info.result !=RSI_INCOMPLETE ) { +if (rsi_result !=RSI_SUCCESS && rsi_result !=RSI_INCOMPLETE ) { ret = -ENXIO ; token_size =0 ; goto exit_free_granule_page;
@@ -173,12 +146,14 @@ static int arm_cca_report_new(struct tsm_report *report, void *data)break ;memcpy (&token[token_size], buf, info.offset); token_size += info.offset; - }while (info.result ==RSI_INCOMPLETE ); + }while (rsi_result ==RSI_INCOMPLETE ); report->outblob =no_free_ptr (token); exit_free_granule_page: report->outblob_len = token_size;free_pages_exact (buf,RSI_GRANULE_SIZE ); +exit_migrate_enable: +migrate_enable ();return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 572/1815 bpf: Fix offset warn check for bpf_res_spin_lock
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit 04e19012efaec2bfd8c3b37fd8a6c3f1fe731ffc ]
Sashiko pointed out correctly that the case statement for BPF_RES_SPIN_LOCK incorrectly checks offset for BPF_SPIN_LOCK. Fix it by checking res_spin_lock_off instead.
--- kernel/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/btf.c +1 -1
@@ -4168,7 +4168,7 @@ struct btf_record *btf_parse_fields(const struct btf *btf, const struct btf_type rec->spin_lock_off = rec->fields[i].offset;break ;case BPF_RES_SPIN_LOCK : -WARN_ON_ONCE (rec->spin_lock_off >=0 ); +WARN_ON_ONCE (rec->res_spin_lock_off >=0 );/* Cache offset for faster lookup at runtime */ rec->res_spin_lock_off = rec->fields[i].offset;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 573/1815 bpf: Preserve unique-field state across nested structs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit f08619f060468076e4acbdc10e0713af20d60e65 ]
btf_find_struct_field() initializes a fresh seen mask for every recursive descent. Unique special fields in different levels of the same aggregate therefore do not see one another. The duplicate fields can reach btf_parse_fields(), where they trigger an invariant WARN_ON_ONCE(). A crafted user BTF can consequently trigger the warning before map creation checks capabilities.
Initialize the seen mask once in btf_find_field() and pass the same pointer through struct, datasec, and nested-struct walks. This gives the entire field traversal one shared uniqueness state.
--- kernel/bpf/btf.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
kernel/bpf/btf.c +14 -12
@@ -3751,7 +3751,7 @@ static int btf_repeat_fields(struct btf_field_info *info, int info_cnt,static int btf_find_struct_field (const struct btf *btf,const struct btf_type *t,u32 field_mask,struct btf_field_info *info,int info_cnt, -u32 level); +u32 level,u32 *seen_mask);/* Find special fields in the struct type of a field. *
@@ -3762,7 +3762,7 @@ static int btf_find_struct_field(const struct btf *btf,static int btf_find_nested_struct (const struct btf *btf,const struct btf_type *t,u32 off,u32 nelems,u32 field_mask,struct btf_field_info *info, -int info_cnt,u32 level) +int info_cnt,u32 level,u32 *seen_mask) {int ret, err, i;
@@ -3770,7 +3770,7 @@ static int btf_find_nested_struct(const struct btf *btf, const struct btf_type *if (level >=MAX_RESOLVE_DEPTH )return -E2BIG ; - ret =btf_find_struct_field (btf, t, field_mask, info, info_cnt, level); + ret =btf_find_struct_field (btf, t, field_mask, info, info_cnt, level, seen_mask);if (ret <=0 )return ret;
@@ -3827,7 +3827,7 @@ static int btf_find_field_one(const struct btf *btf,if (expected_size && expected_size != sz * nelems)return 0 ; ret =btf_find_nested_struct (btf, var_type, off, nelems, field_mask, - &info[0 ], info_cnt, level); + &info[0 ], info_cnt, level, seen_mask);return ret; }
@@ -3892,11 +3892,11 @@ static int btf_find_field_one(const struct btf *btf,static int btf_find_struct_field (const struct btf *btf,const struct btf_type *t,u32 field_mask,struct btf_field_info *info,int info_cnt, -u32 level) +u32 level,u32 *seen_mask) {int ret, idx =0 ;const struct btf_member *member; -u32 i, off, seen_mask =0 ; +u32 i, off;for_each_member (i, t, member) { const struct btf_type *member_type = btf_type_by_id(btf,
@@ -3910,7 +3910,7 @@ static int btf_find_struct_field(const struct btf *btf, ret =btf_find_field_one (btf, t, member_type, i, off,0 , - field_mask, &seen_mask, + field_mask, seen_mask, &info[idx], info_cnt - idx, level);if (ret <0 )return ret;
@@ -3921,11 +3921,11 @@ static int btf_find_struct_field(const struct btf *btf,static int btf_find_datasec_var (const struct btf *btf,const struct btf_type *t,u32 field_mask,struct btf_field_info *info, -int info_cnt,u32 level) +int info_cnt,u32 level,u32 *seen_mask) {int ret, idx =0 ;const struct btf_var_secinfo *vsi; -u32 i, off, seen_mask =0 ; +u32 i, off;for_each_vsi (i, t, vsi) {const struct btf_type *var =btf_type_by_id (btf, vsi->type);
@@ -3933,7 +3933,7 @@ static int btf_find_datasec_var(const struct btf *btf, const struct btf_type *t, off = vsi->offset; ret =btf_find_field_one (btf, var, var_type,-1 , off, vsi->size, - field_mask, &seen_mask, + field_mask, seen_mask, &info[idx], info_cnt - idx, level);if (ret <0 )
@@ -3947,10 +3947,12 @@ static int btf_find_field(const struct btf *btf, const struct btf_type *t, u32 field_mask, struct btf_field_info *info, int info_cnt) { + u32 seen_mask = 0; +if (__btf_type_is_struct (t)) - return btf_find_struct_field(btf, t, field_mask, info, info_cnt, 0); +return btf_find_struct_field (btf, t, field_mask, info, info_cnt,0 , &seen_mask);else if (btf_type_is_datasec (t)) - return btf_find_datasec_var(btf, t, field_mask, info, info_cnt, 0); +return btf_find_datasec_var (btf, t, field_mask, info, info_cnt,0 , &seen_mask);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 574/1815 bpf: Mark bpf_refcount field as unique
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit 61e655391cb19c31f94ecd4354f624c81ce4cf75 ]
BPF_REFCOUNT is not marked as a unique field, while it should be. Fix this oversight.
--- kernel/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/btf.c +1 -1
@@ -3669,7 +3669,7 @@ static int btf_get_field_type(const struct btf *btf, const struct btf_type *var_ { BPF_LIST_NODE, "bpf_list_node", false }, { BPF_RB_ROOT, "bpf_rb_root", false }, { BPF_RB_NODE, "bpf_rb_node", false }, - { BPF_REFCOUNT, "bpf_refcount", false }, + { BPF_REFCOUNT, "bpf_refcount", true }, };int type =0 , i;const char *name =__btf_name_by_offset (btf, var_type->name_off);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 575/1815 RDMA/srpt: Pass the mapped task attribute to target_init_cmd()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit ef63cc441703412628a517dda354f3e51fe2dc92 ]
srpt_handle_cmd() maps the initiator-supplied srp_cmd->task_attr into cmd->sam_task_attr, but then hands a hardcoded TCM_SIMPLE_TAG to target_init_cmd().
Pass the already mapped cmd->sam_task_attr instead, so target core sees the attribute the initiator requested.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +1 -1
@@ -1603,7 +1603,7 @@ static void srpt_handle_cmd(struct srpt_rdma_ch *ch, rc =target_init_cmd (cmd, ch->sess, &send_ioctx->sense_data[0 ],scsilun_to_int (&srp_cmd->lun), data_len, -TCM_SIMPLE_TAG , dir,TARGET_SCF_ACK_KREF ); + cmd->sam_task_attr, dir,TARGET_SCF_ACK_KREF );if (rc !=0 ) {pr_debug ("target_submit_cmd() returned %d for tag %#llx\n" , rc, srp_cmd->tag);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 576/1815 PCI: j721e: Fix incorrect max_lanes for J7200
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takuma Fujiwara <[email protected]>
[ Upstream commit 7147a7bfce47acd48c3738130bf0bd692bfd80de ]
The PCIe Controller in the J7200 SoC supports a 4-lane configuration. However, j7200_pcie_rc_data and j7200_pcie_ep_data incorrectly set .max_lanes = 2, limiting operation to fewer lanes than the hardware supports.
Set .max_lanes = 4 for both j7200_pcie_rc_data and j7200_pcie_ep_data to match the hardware capability.
See J7200 Technical Reference Manual (SPRUIU1D), section 12.2.3.1.1 for further details: https://www.ti.com/lit/pdf/spruiu1d
--- drivers/pci/controller/cadence/pci-j721e.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/cadence/pci-j721e.c +2 -2
@@ -383,7 +383,7 @@ static const struct j721e_pcie_data j7200_pcie_rc_data = { .quirk_detect_quiet_flag = true, .linkdown_irq_regfield = J7200_LINK_DOWN, .byte_access_allowed = true, - .max_lanes = 2, + .max_lanes = 4, };static const struct j721e_pcie_data j7200_pcie_ep_data = {
@@ -391,7 +391,7 @@ static const struct j721e_pcie_data j7200_pcie_ep_data = { .quirk_detect_quiet_flag = true, .linkdown_irq_regfield = J7200_LINK_DOWN, .quirk_disable_flr = true, - .max_lanes = 2, + .max_lanes = 4, };static const struct j721e_pcie_data am64_pcie_rc_data = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 577/1815 RDMA/erdma: Fix CEQ tasklet use-after-free on removal
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 0ca79979384f031d710c4b3bae065dcb5d95aca3 ]
Each CEQ interrupt handler only schedules eqc->tasklet. The tasklet calls erdma_ceq_completion_handler(), which reads the DMA-coherent EQ ring through get_next_valid_eqe() and updates eq->dbrec through notify_eq().
erdma_ceqs_uninit() frees each CEQ IRQ and then destroys its EQ. free_irq() prevents another hard IRQ and waits for an in-flight handler, but it does not drain a tasklet that the handler already scheduled. The tasklet can therefore access eq->qbuf or eq->dbrec after erdma_eq_destroy() frees them.
Clearing ceq_cb->ready does not synchronize with a tasklet that already passed the check at the start of erdma_ceq_completion_handler().
Kill the tasklet after free_irq(), when no handler can schedule it again, and before erdma_ceq_uninit_one() releases the EQ buffers.
--- drivers/infiniband/hw/erdma/erdma_eq.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/erdma/erdma_eq.c +1 -0
@@ -220,6 +220,7 @@ static void erdma_free_ceq_irq(struct erdma_dev *dev, u16 ceqn)irq_set_affinity_hint (eqc->irq.msix_vector,NULL );free_irq (eqc->irq.msix_vector, eqc); +tasklet_kill (&eqc->tasklet); }static int create_eq_cmd (struct erdma_dev *dev,u32 eqn,struct erdma_eq *eq)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 578/1815 RDMA/mana_ib: drain QP references after partial table insertion
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 97f7c2262c28ebcae64fc957ee978646684a5ed9 ]
mana_table_store_ud_qp() publishes a QP at its send-queue id before inserting the receive-queue id, dropping the XArray lock between the two xa_insert_irq() calls. A concurrent completion handler can look up the QP and take a transient reference. When the second insertion fails, the rollback erased only the send-queue entry and returned, leaving both the initial table reference and the transient reference outstanding while RDMA core frees the QP, causing a use-after-free.
Drain the reference as normal destruction does: drop the initial reference and wait for qp->free, releasing the QP only after every concurrent lookup returns its reference.
--- drivers/infiniband/hw/mana/qp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mana/qp.c +8 -2
@@ -472,6 +472,12 @@ static void mana_table_remove_rc_qp(struct mana_ib_dev *mdev, struct mana_ib_qpxa_erase_irq (&mdev->qp_table_wq, qp->ibqp.qp_num); } +static void mana_table_drain_qp_ref (struct mana_ib_qp *qp) +{ +mana_put_qp_ref (qp); +wait_for_completion (&qp->free); +} +static int mana_table_store_ud_qp (struct mana_ib_dev *mdev,struct mana_ib_qp *qp) {u32 qids = qp->ud_qp.queues[MANA_UD_SEND_QUEUE ].id |MANA_SENDQ_MASK ;
@@ -490,6 +496,7 @@ static int mana_table_store_ud_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *q remove_sq:xa_erase_irq (&mdev->qp_table_wq, qids); +mana_table_drain_qp_ref (qp);return err; }
@@ -537,8 +544,7 @@ static void mana_table_remove_qp(struct mana_ib_dev *mdev, qp->ibqp.qp_type);return ; } -mana_put_qp_ref (qp); -wait_for_completion (&qp->free); +mana_table_drain_qp_ref (qp); } static int mana_ib_create_rc_qp(struct ib_qp *ibqp, struct ib_pd *ibpd,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 579/1815 RDMA/core: Add rdma_restrack_begin/abort/commit_del() operations
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 8d186210677c0322db886973bcec9aa4d21b51cd ]
Add rdma_restrack_abort_del(), rdma_restrack_begin_del() and rdma_restrack_commit_del() functions to allow deleting a resource from the xarray to effectively prevent future access to it and wait for all current users to finish while preserving its index in the xarray to allow to re-insert it if needed with guaranteed success.
This is a preparatory change for subsequent patches in the series which will use these functions to fix the cleanup flow.
Stable-dep-of: 709ba0e5311b ("RDMA/core: Fix use after free in ib_query_qp()")
--- drivers/infiniband/core/restrack.c | 165 +++++++++++++++++++++++------ drivers/infiniband/core/restrack.h | 3 + 2 files changed, 135 insertions(+), 33 deletions(-)
drivers/infiniband/core/restrack.c +132 -33
@@ -129,6 +129,46 @@ static void rdma_restrack_attach_task(struct rdma_restrack_entry *res, res->user = true; } +static struct rdma_restrack_root *res_to_rt (struct rdma_restrack_entry *res) +{ +struct ib_device *dev =res_to_dev (res); + +if (WARN_ON (!dev)) +return NULL ; + +return &dev->res[res->type]; +} + +static void restrack_drain_res (struct rdma_restrack_root *rt, +struct rdma_restrack_entry *res) +{ +if (rt) { +struct rdma_restrack_entry *old; + + old =xa_cmpxchg (&rt->xa, res->id, res,XA_ZERO_ENTRY , +GFP_KERNEL ); +WARN_ON (old != res); + } + +rdma_restrack_put (res); +wait_for_completion (&res->comp); +} + +static void restrack_restore_res (struct rdma_restrack_root *rt, +struct rdma_restrack_entry *res) +{ +reinit_completion (&res->comp); +kref_init (&res->kref); + +if (rt) { +struct rdma_restrack_entry *old; + + old =xa_cmpxchg (&rt->xa, res->id,XA_ZERO_ENTRY , res, +GFP_KERNEL ); +WARN_ON (old); + } +} +/** * rdma_restrack_set_name() - set the task for this resource * @res: resource entry
@@ -177,22 +217,23 @@ void rdma_restrack_new(struct rdma_restrack_entry *res,EXPORT_SYMBOL (rdma_restrack_new);/** -* rdma_restrack_add() - add object to the resource tracking database +* rdma_restrack_add() - add object to the resource tracking database. +* If this resource reuses an ID of a resource that was already destroyed +* after calling rdma_restrack_begin() but didn't yet call +* rdma_restrack_commit_del() it can result in an untracked QP. * @res: resource entry */ void rdma_restrack_add (struct rdma_restrack_entry *res) { -struct ib_device *dev =res_to_dev (res);struct rdma_restrack_root *rt;int ret =0 ; -if (!dev) -return ; -if (res->no_track) goto out; - rt = &dev->res[res->type]; + rt =res_to_rt (res); +if (!rt) +return ;if (res->type ==RDMA_RESTRACK_QP ) {/* Special case to ensure that LQPN points to right QP */
@@ -229,6 +270,28 @@ void rdma_restrack_add(struct rdma_restrack_entry *res) }EXPORT_SYMBOL (rdma_restrack_add); +/** +* rdma_restrack_abort_del() - re-add object to the resource tracking database +* it can only be used after rdma_restrack_begin_del(). +* @res: resource entry +*/ +void rdma_restrack_abort_del (struct rdma_restrack_entry *res) +{ +struct rdma_restrack_root *rt =NULL ; + +if (!res->valid) +return ; + +if (!res->no_track) { + rt =res_to_rt (res); +if (!rt) +return ; + } + +restrack_restore_res (rt, res); +} +EXPORT_SYMBOL (rdma_restrack_abort_del); +int __must_check rdma_restrack_get (struct rdma_restrack_entry *res) {return kref_get_unless_zero (&res->kref);
@@ -265,7 +328,7 @@ static void restrack_release(struct kref *kref)struct rdma_restrack_entry *res; res = container_of(kref, struct rdma_restrack_entry, kref); -if (res->task) { +if (res->task && !res->valid) {put_task_struct (res->task); res->task =NULL ; }
@@ -291,37 +354,20 @@ EXPORT_SYMBOL(rdma_restrack_put);*/ void rdma_restrack_sync (struct rdma_restrack_entry *res) { -struct rdma_restrack_entry *old;struct rdma_restrack_root *rt; -struct task_struct *task; -struct ib_device *dev;if (!res->valid || res->no_track)return ; - dev =res_to_dev (res); -if (WARN_ON (!dev)) + rt =res_to_rt (res); +if (!rt)return ; - rt = &dev->res[res->type];if (WARN_ON (xa_get_mark (&rt->xa, res->id,RESTRACK_DD )))return ; - old =xa_cmpxchg (&rt->xa, res->id, res,XA_ZERO_ENTRY ,GFP_KERNEL ); -if (WARN_ON (old != res)) -return ; - - task = res->task; -if (task) -get_task_struct (task); -rdma_restrack_put (res); -wait_for_completion (&res->comp); -reinit_completion (&res->comp); -if (task) - res->task = task; -kref_init (&res->kref); - -xa_cmpxchg (&rt->xa, res->id,XA_ZERO_ENTRY , res,GFP_KERNEL ); +restrack_drain_res (rt, res); +restrack_restore_res (rt, res); }EXPORT_SYMBOL (rdma_restrack_sync);
@@ -333,7 +379,6 @@ void rdma_restrack_del(struct rdma_restrack_entry *res) {struct rdma_restrack_entry *old;struct rdma_restrack_root *rt; -struct ib_device *dev;if (!res->valid) {if (res->task) {
@@ -346,12 +391,10 @@ void rdma_restrack_del(struct rdma_restrack_entry *res)if (res->no_track) goto out; - dev =res_to_dev (res); -if (WARN_ON (!dev)) + rt =res_to_rt (res); +if (!rt)return ; - rt = &dev->res[res->type]; - old =xa_erase (&rt->xa, res->id);WARN_ON (old != res);
@@ -359,5 +402,61 @@ void rdma_restrack_del(struct rdma_restrack_entry *res) res->valid = false;rdma_restrack_put (res);wait_for_completion (&res->comp); +if (res->task) { +put_task_struct (res->task); + res->task =NULL ; + } }EXPORT_SYMBOL (rdma_restrack_del); + +/** +* rdma_restrack_begin_del() - invalidate the object from the resource tracking +* database but preserve its index in the array. +* Since this preserves the index in the array until rdma_restrack_commit_del() +* is called, if rdma_restrack_add() is called in between with an old QP ID it +* can result in an untracked QP. +* @res: resource entry +*/ +void rdma_restrack_begin_del (struct rdma_restrack_entry *res) +{ +struct rdma_restrack_root *rt =NULL ; + +if (!res->valid) +return ; + +if (!res->no_track) { + rt =res_to_rt (res); +if (!rt) +return ; + } + +restrack_drain_res (rt, res); +} +EXPORT_SYMBOL (rdma_restrack_begin_del); + +/** +* rdma_restrack_commit_del() - delete object from the resource tracking +* database and free the task. +* @res: resource entry +*/ +void rdma_restrack_commit_del (struct rdma_restrack_entry *res) +{ +struct rdma_restrack_root *rt; + +if (!res->valid || res->no_track) + goto out; + + rt =res_to_rt (res); +if (!rt) +return ; + +xa_erase (&rt->xa, res->id); + +out: + res->valid = false; +if (res->task) { +put_task_struct (res->task); + res->task =NULL ; + } +} +EXPORT_SYMBOL (rdma_restrack_commit_del);
drivers/infiniband/core/restrack.h +3 -0
@@ -26,8 +26,11 @@ struct rdma_restrack_root {int rdma_restrack_init (struct ib_device *dev);void rdma_restrack_clean (struct ib_device *dev);void rdma_restrack_add (struct rdma_restrack_entry *res); +void rdma_restrack_abort_del (struct rdma_restrack_entry *res);void rdma_restrack_del (struct rdma_restrack_entry *res);void rdma_restrack_sync (struct rdma_restrack_entry *res); +void rdma_restrack_begin_del (struct rdma_restrack_entry *res); +void rdma_restrack_commit_del (struct rdma_restrack_entry *res);void rdma_restrack_new (struct rdma_restrack_entry *res,enum rdma_restrack_type type); void rdma_restrack_set_name(struct rdma_restrack_entry *res,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 580/1815 RDMA/core: Fix use after free in ib_query_qp()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 709ba0e5311bd034eb4d9c1c00cc4e1109d6dc3e ]
When querying a QP via the netlink flow the only synchronization mechanism for the said QP is rdma_restrack_get(), meanwhile during the QP destroy path rdma_restrack_del() is called at the end of the ib_destroy_qp_user() function which is too late, since by then the vendor specific resources for said QP would already be destroyed, and till the rdma_restrack_del() is called this QP can still be accessed, which could cause the use after free below.
Fix this by moving the rdma_restrack_begin_del() to the start of the ib_destroy_qp_user(), which in turn waits for all usages of the QP to be done then removes it from the database to prevent access to it while it is being destroyed.
RIP: 0010:ib_query_qp+0x15/0x50 [ib_core] Code: 48 83 05 5d 8e b9 ff 01 eb b5 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 c7 46 40 00 00 00 00 48 c7 46 78 00 00 00 00 <48> 8b 07 48 8b 80 88 01 00 00 48 85 c0 74 1a 48 83 05 54 91 b9 ff RSP: 0018:ff11000108a8f2f0 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ff11000108a8f370 RCX: ff11000108a8f370 RDX: 0000000000000000 RSI: ff11000108a8f3d8 RDI: 0000000000000000 RBP: ff1100010de5a000 R08: 0000000000000e80 R09: 0000000000000004 R10: ff110001057a604c R11: 0000000000000000 R12: ff11000108a8f370 R13: ff110001090e8000 R14: 0000000000000000 R15: ff110001057a602c FS: 00007f2ffd8db6c0(0000) GS:ff110008dc90b000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000010b9a7004 CR4: 0000000000373eb0 Call Trace: <TASK> mlx5_ib_gsi_query_qp+0x21/0x50 [mlx5_ib] mlx5_ib_query_qp+0x689/0x9d0 [mlx5_ib] ib_query_qp+0x35/0x50 [ib_core] fill_res_qp_entry_query.isra.0+0x47/0x280 [ib_core] ? __wake_up+0x40/0x50 ? netlink_broadcast_filtered+0x15a/0x550 ? kobject_uevent_env+0x562/0x710 ? ep_poll_callback+0x242/0x270 ? __nla_put+0xc/0x20 ? nla_put+0x28/0x40 ? nla_put_string+0x2e/0x40 [ib_core] fill_res_qp_entry+0x138/0x190 [ib_core] res_get_common_dumpit+0x4a5/0x800 [ib_core] ? fill_res_qp_entry_query.isra.0+0x280/0x280 [ib_core] nldev_res_get_qp_dumpit+0x1e/0x30 [ib_core] netlink_dump+0x16f/0x450 __netlink_dump_start+0x1ce/0x2e0 rdma_nl_rcv_msg+0x1d3/0x330 [ib_core] ? nldev_res_get_qp_raw_dumpit+0x30/0x30 [ib_core] rdma_nl_rcv_skb.constprop.0.isra.0+0x108/0x180 [ib_core] rdma_nl_rcv+0x12/0x20 [ib_core] netlink_unicast+0x255/0x380 ? __alloc_skb+0xfa/0x1e0 netlink_sendmsg+0x1f3/0x420 __sock_sendmsg+0x38/0x60 ____sys_sendmsg+0x1e8/0x230 ? copy_msghdr_from_user+0xea/0x170 ___sys_sendmsg+0x7c/0xb0 ? __futex_wait+0x95/0xf0 ? __futex_wake_mark+0x40/0x40 ? futex_wait+0x67/0x100 ? futex_wake+0xac/0x1b0 __sys_sendmsg+0x5f/0xb0 do_syscall_64+0x55/0xb90 entry_SYSCALL_64_after_hwframe+0x4b/0x53
--- drivers/infiniband/core/verbs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +4 -1
@@ -2154,6 +2154,8 @@ int ib_destroy_qp_user(struct ib_qp *qp, struct ib_udata *udata)if (qp->real_qp != qp)return __ib_destroy_shared_qp (qp); +rdma_restrack_begin_del (&qp->res); + sec = qp->qp_sec;if (sec)ib_destroy_qp_security_begin (sec);
@@ -2166,6 +2168,7 @@ int ib_destroy_qp_user(struct ib_qp *qp, struct ib_udata *udata)if (ret) {if (sec)ib_destroy_qp_security_abort (sec); +rdma_restrack_abort_del (&qp->res);return ret; }
@@ -2178,7 +2181,7 @@ int ib_destroy_qp_user(struct ib_qp *qp, struct ib_udata *udata)if (sec)ib_destroy_qp_security_end (sec); -rdma_restrack_del (&qp->res); +rdma_restrack_commit_del (&qp->res);kfree (qp);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 581/1815 RDMA/core: Fix potential use after free in ib_destroy_cq_user()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 3481bec4dfc4aee24ffea5a547ee95b70b67d9d5 ]
When accessing a CQ via the netlink path the only synchronization mechanism for the said CQ is rdma_restrack_get(). Currently, rdma_restrack_del() is invoked at the end of ib_destroy_cq_user(), which is too late, since by that point vendor-specific resources associated with the CQ might already be freed. This can leave a short window where the CQ remains accessible through restrack, leading to a potential use-after-free.
Fix this by moving the rdma_restrack_begin_del() call to the start of ib_destroy_cq_user(), ensuring that the CQ is removed from restrack before its internal resources are released. This guarantees that no new users hold references to a CQ that is in the process of destruction.
In addition, this change preserves the intended inverted order between create and destroy routines: resources are added to restrack at the end of successful creation, and hence shall be removed from the restrack first thing during the destruction flow, which keeps the lifecycle management consistent and predictable.
--- drivers/infiniband/core/verbs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/infiniband/core/verbs.c +6 -2
@@ -2247,11 +2247,15 @@ int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata)if (atomic_read (&cq->usecnt))return -EBUSY ; +rdma_restrack_begin_del (&cq->res); + ret = cq->device->ops.destroy_cq (cq, udata); -if (ret) +if (ret) { +rdma_restrack_abort_del (&cq->res);return ret; + } -rdma_restrack_del (&cq->res); +rdma_restrack_commit_del (&cq->res);kfree (cq);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 582/1815 RDMA/core: Fix potential use after free in ib_destroy_srq_user()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 88244ecc71cc0b3ed200f5ef7ddea6686adfd730 ]
When accessing a SRQ via the netlink path the only synchronization mechanism for the said SRQ is rdma_restrack_get(). Currently, rdma_restrack_del() is invoked at the end of ib_destroy_srq_user(), which is too late, since by that point vendor-specific resources associated with the SRQ might already be freed. This can leave a short window where the SRQ remains accessible through restrack, leading to a potential use-after-free.
Fix this by moving the rdma_restrack_begin_del() call to the start of ib_destroy_srq_user(), ensuring that the SRQ is removed from restrack before its internal resources are released. This guarantees that no new users hold references to a SRQ that is in the process of destruction.
In addition, this change preserves the intended inverted order between create and destroy routines: resources are added to restrack at the end of successful creation, and hence shall be removed from the restrack first thing during the destruction flow, which keeps the lifecycle management consistent and predictable.
--- drivers/infiniband/core/verbs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/infiniband/core/verbs.c +6 -2
@@ -1140,16 +1140,20 @@ int ib_destroy_srq_user(struct ib_srq *srq, struct ib_udata *udata)if (atomic_read (&srq->usecnt))return -EBUSY ; +rdma_restrack_begin_del (&srq->res); + ret = srq->device->ops.destroy_srq (srq, udata); -if (ret) +if (ret) { +rdma_restrack_abort_del (&srq->res);return ret; + }atomic_dec (&srq->pd->usecnt);if (srq->srq_type ==IB_SRQT_XRC && srq->ext.xrc.xrcd)atomic_dec (&srq->ext.xrc.xrcd->usecnt);if (ib_srq_has_cq (srq->srq_type))atomic_dec (&srq->ext.cq->usecnt); -rdma_restrack_del (&srq->res); +rdma_restrack_commit_del (&srq->res);kfree (srq);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 583/1815 RDMA/core: Fix potential use after free in counter_release()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 235ef2d0e750885c29340b0fc40620a7a4f52e12 ]
When accessing a counter via the netlink path the only synchronization mechanism for the said counter is rdma_restrack_get(). Currently, rdma_restrack_del() is invoked at the end of counter_release(), which is too late, since by that point vendor-specific resources associated with the counter might already be freed. This can leave a short window where the counter remains accessible through restrack, leading to a potential use-after-free.
Fix this by moving the rdma_restrack_del() call to be before the freeing of the vendor-specific resources, ensuring that the counter is removed from restrack before its internal resources are released. This guarantees that no new users hold references to a counter that is in the process of destruction.
--- drivers/infiniband/core/counters.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/core/counters.c +3 -2
@@ -234,7 +234,6 @@ static void rdma_counter_free(struct rdma_counter *counter)mutex_unlock (&port_counter->lock); -rdma_restrack_del (&counter->res);rdma_free_hw_stats_struct (counter->stats);kfree (counter); }
@@ -329,6 +328,7 @@ static void counter_release(struct kref *kref) counter = container_of(kref, struct rdma_counter, kref);counter_history_stat_update (counter); +rdma_restrack_del (&counter->res); counter->device->ops.counter_dealloc (counter);rdma_counter_free (counter); }
@@ -490,7 +490,8 @@ static struct rdma_counter *rdma_get_counter_by_id(struct ib_device *dev,return NULL ; counter = container_of(res, struct rdma_counter, res); -kref_get (&counter->kref); +if (!kref_get_unless_zero (&counter->kref)) + counter =NULL ;rdma_restrack_put (res);return counter;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 584/1815 RDMA/core: Fix potential use after free in ib_free_cq()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 29dc2f8e1c97372c2871a70088707933515fbd5b ]
When accessing a CQ via the netlink path the only synchronization mechanism for the said CQ is rdma_restrack_get(). Currently, rdma_restrack_del() is invoked at the end of ib_free_cq(), which is too late, since by that point vendor-specific resources associated with the CQ might already be freed. This can leave a short window where the CQ remains accessible through restrack, leading to a potential use-after-free.
Fix this by moving the rdma_restrack_del() call to be before the freeing of the vendor-specific resources ensuring that the CQ is removed from restrack before its internal resources are released.
This guarantees that no new users hold references to a CQ that is in the process of destruction.
--- drivers/infiniband/core/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/cq.c +1 -1
@@ -327,6 +327,7 @@ void ib_free_cq(struct ib_cq *cq)if (WARN_ON_ONCE (cq->cqe_used))return ; +rdma_restrack_del (&cq->res);if (cq->device->ops.pre_destroy_cq) { ret = cq->device->ops.pre_destroy_cq (cq);WARN_ONCE (ret,"Disable of kernel CQ shouldn't fail" );
@@ -353,7 +354,6 @@ void ib_free_cq(struct ib_cq *cq)else ret = cq->device->ops.destroy_cq (cq,NULL );WARN_ONCE (ret,"Destroy of kernel CQ shouldn't fail" ); -rdma_restrack_del (&cq->res);kfree (cq->wc);kfree (cq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 585/1815 RDMA/core: Fix potential use after free in uverbs_free_dmah()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 2696626a0be5877f445fb647c25ef43930c777e6 ]
When accessing a dmah via the netlink path the only synchronization mechanism for the said dmah is rdma_restrack_get(). Currently, rdma_restrack_del() is invoked at the end of uverbs_free_dmah(), which is too late, since by that point vendor-specific resources associated with the dmah might already be freed. This can leave a short window where the dmah remains accessible through restrack, leading to a potential use-after-free.
Fix this by moving the rdma_restrack_begin_del() call to the start of uverbs_free_dmah(), ensuring that the dmah is removed from restrack before its internal resources are released. This guarantees that no new users hold references to a dmah that is in the process of destruction.
In addition, this change preserves the intended inverted order between create and destroy routines: resources are added to restrack at the end of successful creation, and hence shall be removed from the restrack first thing during the destruction flow, which keeps the lifecycle management consistent and predictable.
--- drivers/infiniband/core/uverbs_std_types_dmah.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/infiniband/core/uverbs_std_types_dmah.c +5 -2
@@ -18,11 +18,14 @@ static int uverbs_free_dmah(struct ib_uobject *uobject,if (atomic_read (&dmah->usecnt))return -EBUSY ; +rdma_restrack_begin_del (&dmah->res); ret = dmah->device->ops.dealloc_dmah (dmah, attrs); -if (ret) +if (ret) { +rdma_restrack_abort_del (&dmah->res);return ret; + } -rdma_restrack_del (&dmah->res); +rdma_restrack_commit_del (&dmah->res);kfree (dmah);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 586/1815 RDMA/core: Fix potential use after free in ib_dealloc_pd_user()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 8b90e701342275f414e36e7421c502237df241ad ]
When accessing a PD via the netlink path the only synchronization mechanism for the said PD is rdma_restrack_get(). Currently, rdma_restrack_del() is invoked at the end of ib_dealloc_pd_user(), which is too late, since by that point vendor-specific resources associated with the PD might already be freed. This can leave a short window where the PD remains accessible through restrack, leading to a potential use-after-free.
Fix this by moving the rdma_restrack_begin_del() call to the start of ib_dealloc_pd_user(), ensuring that the PD is removed from restrack before its internal resources are released. This guarantees that no new users hold references to a PD that is in the process of destruction.
In addition, this change preserves the intended inverted order between create and destroy routines: resources are added to restrack at the end of successful creation, and hence shall be removed from the restrack first thing during the destruction flow, which keeps the lifecycle management consistent and predictable.
--- drivers/infiniband/core/verbs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/infiniband/core/verbs.c +5 -2
@@ -392,6 +392,7 @@ int ib_dealloc_pd_user(struct ib_pd *pd, struct ib_udata *udata) {int ret; +rdma_restrack_begin_del (&pd->res);if (pd->__internal_mr) { ret = pd->device->ops.dereg_mr (pd->__internal_mr,NULL );WARN_ON (ret);
@@ -399,10 +400,12 @@ int ib_dealloc_pd_user(struct ib_pd *pd, struct ib_udata *udata) } ret = pd->device->ops.dealloc_pd (pd, udata); -if (ret) +if (ret) { +rdma_restrack_abort_del (&pd->res);return ret; + } -rdma_restrack_del (&pd->res); +rdma_restrack_commit_del (&pd->res);kfree (pd);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 587/1815 firmware: arm_scmi: Fix requested device removal race
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 2c4097e6c4aed276c5e9ec2ab331ab397ea780bf ]
scmi_protocol_device_unrequest() drops scmi_requested_devices_mtx while notifying listeners but continues to retain the per-protocol list head. When two SCMI drivers for the same protocol unregister concurrently, one thread can remove the final request and free the list head while the other is running its notifier. The latter then dereferences the freed list head after reacquiring the mutex and can free it a second time.
Complete the list and IDR updates, including freeing an empty list head, before dropping the mutex. Keep the blocking notifier outside the critical section and retain only the detached request across the callback.
--- drivers/firmware/arm_scmi/bus.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/firmware/arm_scmi/bus.c +13 -13
@@ -158,6 +158,7 @@ static int scmi_protocol_table_register(const struct scmi_device_id *id_table)*/ static void scmi_protocol_device_unrequest (const struct scmi_device_id *id_table) { +struct scmi_requested_dev *rdev, *victim =NULL ;struct list_head *phead; pr_debug("Unrequesting SCMI device (%s) for protocol %x\n",
@@ -166,29 +167,28 @@ static void scmi_protocol_device_unrequest(const struct scmi_device_id *id_tablemutex_lock (&scmi_requested_devices_mtx); phead =idr_find (&scmi_requested_devices, id_table->protocol_id);if (phead) { -struct scmi_requested_dev *victim, *tmp; - -list_for_each_entry_safe (victim, tmp, phead, node) { -if (!strcmp (victim->id_table->name, id_table->name)) { -list_del (&victim->node); - -mutex_unlock (&scmi_requested_devices_mtx); -blocking_notifier_call_chain (&scmi_requested_devices_nh, -SCMI_BUS_NOTIFY_DEVICE_UNREQUEST , - (void *)victim->id_table); -kfree (victim); -mutex_lock (&scmi_requested_devices_mtx); +list_for_each_entry (rdev, phead, node) { +if (!strcmp (rdev->id_table->name, id_table->name)) { + victim = rdev; +list_del (&rdev->node);break ; } } -if (list_empty (phead)) { +if (victim &&list_empty (phead)) {idr_remove (&scmi_requested_devices, id_table->protocol_id);kfree (phead); } }mutex_unlock (&scmi_requested_devices_mtx); + +if (victim) { +blocking_notifier_call_chain (&scmi_requested_devices_nh, +SCMI_BUS_NOTIFY_DEVICE_UNREQUEST , + (void *)victim->id_table); +kfree (victim); + } } static void
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 588/1815 iommu/amd: Fix undefined behavior in devid_write debugfs function
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 843e149989665f8309ad2efe6048dc76591e1f94 ]
When for_each_pci_segment() loop completes without finding a matching segment, the pci_seg pointer is not NULL but points to an invalid memory location (the list head). Accessing pci_seg->id after the loop causes undefined behavior.
Fix this by handling the successful case inside the loop and returning -EINVAL after the loop if no matching segment is found.
--- drivers/iommu/amd/debugfs.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/iommu/amd/debugfs.c +3 -9
@@ -176,19 +176,13 @@ static ssize_t devid_write(struct file *filp, const char __user *ubuf,kfree (srcid_ptr);return -ENODEV ; } -break ; - } - -if (pci_seg->id != seg) { + sbdf =PCI_SEG_DEVID_TO_SBDF (seg, devid);kfree (srcid_ptr); -return -EINVAL ; +return cnt; } - sbdf =PCI_SEG_DEVID_TO_SBDF (seg, devid); -kfree (srcid_ptr); - -return cnt; +return -EINVAL ; }static int devid_show (struct seq_file *m,void *unused)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 589/1815 iommu/qcom: Remove sysfs device on probe failure path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
[ Upstream commit c579f18e79599c16168925cb149e1db3f29eea5f ]
In qcom_iommu_device_probe(), if iommu_device_register() fails, the sysfs device created by iommu_device_sysfs_add() is not released. Add a goto label to do the cleanup.
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +3 -1
@@ -855,7 +855,7 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) ret =iommu_device_register (&qcom_iommu->iommu, &qcom_iommu_ops, dev);if (ret) {dev_err (dev,"Failed to register iommu\n" ); - goto err_pm_disable; + goto err_sysfs_remove; }if (qcom_iommu->local_base) {
@@ -866,6 +866,8 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)return 0 ; +err_sysfs_remove: +iommu_device_sysfs_remove (&qcom_iommu->iommu); err_pm_disable:pm_runtime_disable (dev);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 590/1815 iommu/qcom: Fix inverted fault report check in qcom_iommu_fault()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 1f33b8208a1978b0c0d6ad60a47fe4bb7a235e58 ]
report_iommu_fault() returns 0 when a fault handler successfully handles the fault, and -ENOSYS when no handler is installed. The condition '!report_iommu_fault()' evaluates to true (printing "Unhandled context fault") precisely when the fault *was* handled, and stays silent when no handler is present — the opposite of what is intended.
Remove the '!' so the driver logs unhandled faults correctly.
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +1 -1
@@ -200,7 +200,7 @@ static irqreturn_t qcom_iommu_fault(int irq, void *dev) fsynr =iommu_readl (ctx,ARM_SMMU_CB_FSYNR0 ); iova =iommu_readq (ctx,ARM_SMMU_CB_FAR ); -if (!report_iommu_fault (ctx->domain, ctx->dev, iova,0 )) { +if (report_iommu_fault (ctx->domain, ctx->dev, iova,0 )) { dev_err_ratelimited(ctx->dev, "Unhandled context fault: fsr=0x%x, " "iova=0x%016llx, fsynr=0x%x, cb=%d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 591/1815 iommu/arm-smmu-v3: Declare eats_s1chk and eats_trans as host-endian u64
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit 4455286274474e95f223c68c215d32c864404889 ]
arm_smmu_get_ste_update_safe() declares the eats_s1chk and eats_trans locals as __le64, but initializes them from FIELD_PREP(), which returns a host-endian value, and passes them through cpu_to_le64() at the use sites.
Sparse reports the following warnings:
Quoted 1 line
Quoted 1 line
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:1122:38: sparse: sparse: cast from restricted__le64
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:1124:33: sparse: sparse: cast from restricted __le64
Declare both locals as u64 so the type matches FIELD_PREP() and the existing cpu_to_le64() at the use sites performs the host-to-little-endian conversion. No functional change.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +2 -2
@@ -1240,9 +1240,9 @@ VISIBLE_IF_KUNITvoid arm_smmu_get_ste_update_safe (const __le64 *cur,const __le64 *target,__le64 *safe_bits) { -const __le64 eats_s1chk = +const u64 eats_s1chk =FIELD_PREP (STRTAB_STE_1_EATS ,STRTAB_STE_1_EATS_S1CHK ); -const __le64 eats_trans = +const u64 eats_trans =FIELD_PREP (STRTAB_STE_1_EATS ,STRTAB_STE_1_EATS_TRANS );/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 592/1815 thermal: intel: int3400: clean up ODVP on probe failures
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit d83dc9ce57a746a6dca28439bcc0575d26fa6986 ]
evaluate_odvp() creates per-ODVP sysfs files before the thermal zone and later probe resources are registered. The current unwind path only calls cleanup_odvp() from the late sysfs failure path, so failures after evaluate_odvp() but before that label, including thermal_tripless_zone_device_register() failures, leave the ODVP files and storage behind.
Move the ODVP cleanup to the common ART/TRT unwind path so every failure after evaluate_odvp() releases the ODVP state. Also clear the cached ODVP pointers in cleanup_odvp(), because evaluate_odvp() can already call it for partial setup failures while probe continues.
--- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3 -1
@@ -356,8 +356,10 @@ static void cleanup_odvp(struct int3400_thermal_priv *priv)kfree (priv->odvp_attrs[i].attr.attr.name); }kfree (priv->odvp_attrs); + priv->odvp_attrs =NULL ; }kfree (priv->odvp); + priv->odvp =NULL ; priv->odvp_count =0 ; }
@@ -635,7 +637,6 @@ static int int3400_thermal_probe(struct platform_device *pdev)acpi_remove_notify_handler (priv->adev->handle,ACPI_DEVICE_NOTIFY , int3400_notify); free_sysfs: -cleanup_odvp (priv);if (!ZERO_OR_NULL_PTR (priv->data_vault)) {device_remove_bin_file (&pdev->dev, &bin_attr_data_vault);kfree (priv->data_vault);
@@ -649,6 +650,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)acpi_thermal_rel_misc_device_remove (priv->adev->handle);thermal_zone_device_unregister (priv->thermal); free_art_trt: +cleanup_odvp (priv);kfree (priv->trts);kfree (priv->arts); free_priv:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 593/1815 ext4: fix ABBA deadlock in ext4_xattr_inode_cache_find()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Prakash Srivastava <[email protected]>
[ Upstream commit 03438084a7b8621fb5c762dd3d04cff5f2630fb2 ]
Syzbot/stress-ng reported an ABBA deadlock in ext4 when exercising concurrent xattr workloads (using the ea_inode mount/format option).
The deadlock occurs between the running transaction and the eviction thread:
- Task 1 (stress-ng): Holds a reference to a shared mbcache_entry (ce) and calls ext4_xattr_inode_cache_find() -> ext4_iget() to retrieve the corresponding EA inode. Since the EA inode is currently being evicted, ext4_iget() blocks in __wait_on_freeing_inode() waiting for eviction to complete.
- Task 2 (eviction thread): Currently evicting the same EA inode in ext4_evict_ea_inode(). It calls mb_cache_entry_wait_unused(oe) which blocks waiting for Task 1 to release the reference to the mbcache_entry.
To break this deadlock, implement a new ext4_iget() configuration flag named EXT4_IGET_NOWAIT. When set, perform a non-blocking lookup of the inode via VFS's find_inode_nowait() API.
If the inode is currently being evicted (marked with I_FREEING or I_WILL_FREE) or created (I_CREATING), or if it is not present in the VFS inode cache (cache miss), simply skip it (returning -ENOENT) rather than waiting for eviction/creation to complete, breaking the ABBA cycle.
Since we return -ENOENT immediately on a cache miss, we never attempt to allocate a new inode or call iget_locked(), completely eliminating any TOCTOU race window.
If the returned inode is I_NEW, wait for its initialization to clear via wait_on_new_inode(). If initialization fails and the inode is unhashed during wait_on_new_inode() waking up (e.g., due to an I/O read error in another thread), safely drop the reference and return -ENOENT. This unhashed check is executed unconditionally on all cache-hit pathways to properly handle concurrent initialization failures.
Finally, standard validation checks (including is_bad_inode, EXT4_EA_INODE_FL, file_acl, and xattr flags) are executed as normal inside check_igot_inode() to fully guarantee VFS-layer safety.
In ext4_xattr_inode_cache_find(), invoke ext4_iget() with the new EXT4_IGET_NOWAIT flag to perform the non-blocking cache search.
--- fs/ext4/ext4.h | 3 ++- fs/ext4/inode.c | 35 ++++++++++++++++++++++++++++++++--- fs/ext4/xattr.c | 2 +- 3 files changed, 35 insertions(+), 5 deletions(-)
fs/ext4/ext4.h +2 -1
@@ -3144,7 +3144,8 @@ typedef enum {EXT4_IGET_SPECIAL =0x0001 ,/* OK to iget a system inode */ EXT4_IGET_HANDLE =0x0002 ,/* Inode # is from a handle */ EXT4_IGET_BAD =0x0004 ,/* Allow to iget a bad inode */ - EXT4_IGET_EA_INODE = 0x0008 /* Inode should contain an EA value */ +EXT4_IGET_EA_INODE =0x0008 ,/* Inode should contain an EA value */ + EXT4_IGET_NOWAIT = 0x0010 /* Non-blocking lookup (skip if freeing) */ } ext4_iget_flags; extern struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
fs/ext4/inode.c +32 -3
@@ -5271,6 +5271,20 @@ void ext4_set_inode_mapping_order(struct inode *inode)mapping_set_folio_order_range (inode->i_mapping, min_order, max_order); } +static int ext4_iget_match (struct inode *inode,u64 ino,void *data) +{ +if (inode->i_ino != ino) +return 0 ; +spin_lock (&inode->i_lock); +if (inode_state_read (inode) & (I_FREEING |I_WILL_FREE |I_CREATING )) { +spin_unlock (&inode->i_lock); +return -1 ; + } +__iget (inode); +spin_unlock (&inode->i_lock); +return 1 ; +} +struct inode *__ext4_iget (struct super_block *sb,unsigned long ino,ext4_iget_flags flags,const char *function,unsigned int line)
@@ -5299,9 +5313,24 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,return ERR_PTR (-EFSCORRUPTED ); } - inode =iget_locked (sb, ino); -if (!inode) -return ERR_PTR (-ENOMEM ); +if (flags &EXT4_IGET_NOWAIT ) { + inode =find_inode_nowait (sb, ino, ext4_iget_match,NULL ); +if (!inode) +return ERR_PTR (-ENOENT ); + +if (inode_state_read_once (inode) &I_NEW ) +wait_on_new_inode (inode); + +if (unlikely (inode_unhashed (inode))) { +iput (inode); +return ERR_PTR (-ENOENT ); + } + }else { + inode =iget_locked (sb, ino); +if (!inode) +return ERR_PTR (-ENOMEM ); + } +if (!(inode_state_read_once (inode) &I_NEW )) { ret =check_igot_inode (inode, flags, function, line);if (ret) {
fs/ext4/xattr.c +1 -1
@@ -1550,7 +1550,7 @@ ext4_xattr_inode_cache_find(struct inode *inode, const void *value,while (ce) { ea_inode =ext4_iget (inode->i_sb, ce->e_value, -EXT4_IGET_EA_INODE ); +EXT4_IGET_EA_INODE |EXT4_IGET_NOWAIT );if (IS_ERR (ea_inode)) goto next_entry;ext4_xattr_inode_set_class (ea_inode);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 594/1815 ext4: clear stale xarray tags on folios skipped during writeback
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gerald Yang <[email protected]>
[ Upstream commit ec524aae479b4b2078c47492b90ec21200bce434 ]
In data=journal mode, the writeback thread can hit the WARN_ON_ONCE(sb_rdonly(sb)) in ext4_journal_check_start() while the superblock is being remounted read-only during reboot:
Workqueue: writeback wb_workfn (flush-253:0) RIP: 0010:ext4_journal_check_start+0x8b/0xd0 Call Trace: __ext4_journal_start_sb+0x3c/0x1e0 mpage_prepare_extent_to_map+0x4af/0x580 ext4_do_writepages+0x3c0/0x1080 ext4_writepages+0xc8/0x1a0 do_writepages+0xc4/0x180 __writeback_single_inode+0x45/0x2f0 writeback_sb_inodes+0x26b/0x5d0 __writeback_inodes_wb+0x54/0x100 wb_writeback+0x1ac/0x320 wb_workfn+0x394/0x470
And followed by the warning:
EXT4-fs warning (device vda1): ext4_evict_inode:195: inode #6263:
comm (sd-umount): data will be lost
This issue is not reproduced every time, but frequently.
The reproduction step is to create a VM with 8 CPUs, 16G memory and setup data=journal:
sudo tune2fs -o journal_data /dev/vda1
Run fio:
rm -f fiotest
fio --name=fiotest --rw=randwrite --bs=4k --runtime=6 --ioengine=libaio --iodepth=256 --numjobs=8 --filename=fiotest --filesize=30G --group_reporting
Reboot the VM, and check the console output from:
virsh console testvm
But there is no dirty inode, folio_clear_dirty_for_io clears PG_dirty but leaves tags PAGECACHE_TAG_DIRTY and PAGECACHE_TAG_TOWRITE set which are only cleared by __folio_start_writeback.
In data=journal mode, jbd2 checkpoints the journalled data to its final location and clears its own dirty flag without touching folio PG_dirty or xarray dirty flags.
The commit f4a2b42e7891 ("ext4: fix stale xarray tags after writeback") fixes when PG_dirty is still set but there is no dirty page. Another case is PG_dirty is cleared, but PAGECACHE_TAG_DIRTY and PAGECACHE_TAG_TOWRITE is still set. In this case, writeback thread checks clean folio and skips it in mpage_prepare_extent_to_map:
if (!folio_test_dirty(folio) ||
...
folio_unlcok(folio);
continueAnd never reaches ext4_bio_write_folio where the commit f4a2b42e7891 clears the stale xarray tags. Print debug logs after the filesystem is remounted read-only:
writepages RDONLY nrpages=2048 dirtytag=1 wbtag=0 towrite=1 sync=0 And all folios are actually clean:
folio idx=3 dirty=0 wb=0 checked=0 dirtybuf=0 jbddirty=0 mapped=1
...
We need to clear the xarray stale tags for such clean folios by cycling them through writeback in the skip path, the same way f4a2b42e7891 does in ext4_bio_write_folio.
--- fs/ext4/inode.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
fs/ext4/inode.c +15 -3
@@ -2695,13 +2695,25 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)* page is already under writeback and we are not doing * a data integrity writeback, skip the page */ -if (!folio_test_dirty (folio) || - (folio_test_writeback (folio) && - (mpd->wbc->sync_mode ==WB_SYNC_NONE )) || +if ((folio_test_writeback (folio) && + mpd->wbc->sync_mode ==WB_SYNC_NONE ) ||unlikely (folio->mapping != mapping)) {folio_unlock (folio);continue ; } +/* +* If the folio is clean, skip writing it back. +* Cycle the folio through the writeback state +* though, to clear stale xarray tags. +*/ +if (!folio_test_dirty (folio)) { +if (!folio_test_writeback (folio)) { +__folio_start_writeback (folio, false); +folio_end_writeback (folio); + } +folio_unlock (folio); +continue ; + }folio_wait_writeback (folio);BUG_ON (folio_test_writeback (folio));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 595/1815 ext4: drain in-flight DIO before buffered write fallback
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 15cdefd0c0522f9d5e12d947fa04f4c11649b699 ]
generic/746 started failing intermittently on ext3 (no-extent inodes). The test triggers 'Page cache invalidation failure on direct I/O' warnings and subsequent fsync returns -EIO. Adding a 50ms delay between ext4_buffered_write_iter() and filemap_write_and_wait_range() in ext4_dio_write_iter() makes the race almost always reproducible.
On no-extent inodes, DIO writes to holes cannot use unwritten extents, so ext4_iomap_alloc() leaves m_flags=0 and ext4_map_blocks() returns 0. The iomap layer then returns -ENOTBLK, causing fallback to buffered I/O.
The fallback path in ext4_dio_write_iter() calls ext4_buffered_write_iter() which dirties pages, then does flush and invalidate. However, there's an unprotected window between ext4_buffered_write_iter() returning (with inode lock released) and the subsequent flush+invalidate.
Concurrent async DIO completions from other threads can run kiocb_invalidate_post_direct_write() during this window. If pages have been re-dirtied, post-invalidation finds dirty pages and triggers the warning, setting -EIO in the error sequence.
Consider a file with two 4k extents: [hole][written]. Thread A does DIO to the written extent, while thread B does DIO spanning both:
kworker A (4k DIO, allocated block) kworker B (8k DIO, fallback)
----------------------------------- ----------------------------
inode_lock_shared() inode_lock_shared()
iomap_dio_rw(): iomap_dio_rw():
kiocb_invalidate_pages -> clean iomap_begin -> -ENOTBLK
submit_bio (async) dio->size = 0 inode_unlock_shared() inode_unlock_shared()
[bio pending in block layer] /* fallback: lock released */
ext4_buffered_write_iter()
inode_lock(exclusive)
generic_perform_write()
-> dirty pages [0, 8k]
inode_unlock(exclusive)
/* pages dirty, no lock */
[bio completes] filemap_write_and_wait_range()
iomap_dio_complete() -> flush dirty pages
kiocb_invalidate_post_direct_write() invalidate_mapping_pages()
invalidate_inode_pages2_range()
-> finds dirty page!
-> dio_warn_stale_pagecache()
-> errseq_set(-EIO)This issue can be triggered through normal I/O paths, not just intentionally overlapping DIO writes from userspace. For example, generic/746 uses a loop device where multiple kworkers issue concurrent I/O to the backing file. Additionally, when block_size < folio_size, non-overlapping DIO writes that share a large folio can also trigger the race.
Add inode_dio_wait() in ext4_buffered_write_iter() before ext4_write_checks() to drain all in-flight DIO. This ensures that all DIO clears existing pages before submitting IO (via kiocb_invalidate_pages()), all BIO waits for all DIO to complete (via inode_dio_wait()), and ext4_write_checks() observes the inode size after all completed DIO so that ext4_block_zero_eof() does not race with in-flight DIO, thus eliminating the race.
--- fs/ext4/file.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/ext4/file.c +7 -0
@@ -309,6 +309,13 @@ static ssize_t ext4_buffered_write_iter(struct kiocb *iocb,return -EOPNOTSUPP ;inode_lock (inode); + +/* +* Prevent concurrent direct I/O and buffered I/O to the same file +* range. Wait for in-flight DIO to finish before dirtying pages. +*/ +inode_dio_wait (inode); + ret =ext4_write_checks (iocb, from);if (ret <=0 ) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 596/1815 ext4: use fsdata to track inline data write state and fix race
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Prakash Srivastava <[email protected]>
[ Upstream commit 7edbb323bab2b2a609016014caafdb651c898249 ]
Instead of checking the live inode state (ext4_has_inline_data(inode) and ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) in the write_end handlers, use the fsdata parameter of the address space operations to explicitly pass down the state in which write_begin prepared the write.
A concurrent thread (such as ext4_page_mkwrite()) can convert the inline data to an extent between write_begin and write_end. If this happens, the write_end handlers would previously miss the inline write_end path and fall through to extent-based write_end logic. However, since block buffers were never allocated in write_begin, this resulted in NULL pointer dereferences or data loss because folio_buffers(folio) was NULL.
Define EXT4_WRITE_DATA_INLINE (4) as a bit flag (Bit 2), treating fsdata as bitwise flags rather than mutually exclusive enums to keep states of the write path independent. Communicate this state via fsdata:
1) ext4_write_begin() and ext4_da_write_begin() set the EXT4_WRITE_DATA_INLINE bit in *fsdata via bitwise OR when an inline write is successfully prepared.
2) On entry, ext4_write_begin() clears the EXT4_WRITE_DATA_INLINE bit to safely handle VFS retries (where generic_perform_write() bypasses the fsdata initialization on its retry jump).
3) The write_end handlers perform a bitwise AND to check if the EXT4_WRITE_DATA_INLINE bit is set and invoke the inline write_end helper accordingly.
Furthermore, during a buffered write, ext4_write_inline_data_end() acquires the xattr lock after preparing the write. If a concurrent page fault (ext4_page_mkwrite()) converts the inline data to an extent after the write_end handlers check the state but before ext4_write_inline_data_end() acquires the xattr write lock, the subsequent check will trigger a kernel panic via BUG_ON(!ext4_has_inline_data(inode)).
To keep git history working and bisectability clean, replace the BUG_ON check in ext4_write_inline_data_end() with a graceful error- handling retry path in this same commit. If the inline data is cleared after locking the xattr, we safely release all resources (releasing iloc.bh, unlocking/putting the folio, stopping the active journal transaction handle) and return 0 (VFS retry) to let the generic write path retry the operation safely.
--- fs/ext4/ext4.h | 1 + fs/ext4/inline.c | 14 +++++++++++++- fs/ext4/inode.c | 24 +++++++++++++----------- 3 files changed, 27 insertions(+), 12 deletions(-)
fs/ext4/ext4.h +1 -0
@@ -3138,6 +3138,7 @@ int do_journal_get_write_access(handle_t *handle, struct inode *inode,void ext4_set_inode_mapping_order (struct inode *inode);#define FALL_BACK_TO_NONDELALLOC 1#define CONVERT_INLINE_DATA 2 +#define EXT4_WRITE_DATA_INLINE 4 typedef enum { EXT4_IGET_NORMAL = 0,
fs/ext4/inline.c +13 -1
@@ -812,7 +812,19 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len, goto out; }ext4_write_lock_xattr (inode, &no_expand); -BUG_ON (!ext4_has_inline_data (inode)); +/* +* We could have raced with ext4_page_mkwrite() converting +* the inode and clearing the inline data flag, so we just +* release resources and retry the whole write. +*/ +if (unlikely (!ext4_has_inline_data (inode))) { +ext4_write_unlock_xattr (inode, &no_expand); +brelse (iloc.bh); +folio_unlock (folio); +folio_put (folio); +ext4_journal_stop (handle); +return 0 ; + }/* * ei->i_inline_off may have changed since
fs/ext4/inode.c +13 -11
@@ -1303,6 +1303,8 @@ static int ext4_write_begin(const struct kiocb *iocb,if (unlikely (ret))return ret; + *fsdata = (void *)((unsigned long )*fsdata & ~EXT4_WRITE_DATA_INLINE ); +trace_ext4_write_begin (inode, pos, len);/* * Reserve one block more for addition to orphan list in case
@@ -1317,8 +1319,10 @@ static int ext4_write_begin(const struct kiocb *iocb, foliop);if (ret <0 )return ret; -if (ret ==1 ) +if (ret ==1 ) { + *fsdata = (void *)((unsigned long )*fsdata |EXT4_WRITE_DATA_INLINE );return 0 ; + } }/*
@@ -1451,8 +1455,7 @@ static int ext4_write_end(const struct kiocb *iocb,trace_ext4_write_end (inode, pos, len, copied); -if (ext4_has_inline_data (inode) && -ext4_test_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA )) +if ((unsigned long )fsdata &EXT4_WRITE_DATA_INLINE )return ext4_write_inline_data_end (inode, pos, len, copied, folio);
@@ -1561,8 +1564,7 @@ static int ext4_journalled_write_end(const struct kiocb *iocb,BUG_ON (!ext4_handle_valid (handle)); -if (ext4_has_inline_data (inode) && -ext4_test_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA )) +if ((unsigned long )fsdata &EXT4_WRITE_DATA_INLINE )return ext4_write_inline_data_end (inode, pos, len, copied, folio);
@@ -3174,8 +3176,10 @@ static int ext4_da_write_begin(const struct kiocb *iocb, foliop, fsdata, true);if (ret <0 )return ret; -if (ret ==1 ) +if (ret ==1 ) { + *fsdata = (void *)((unsigned long )*fsdata |EXT4_WRITE_DATA_INLINE );return 0 ; + } } retry:
@@ -3304,17 +3308,15 @@ static int ext4_da_write_end(const struct kiocb *iocb, struct folio *folio, void *fsdata) { struct inode *inode = mapping->host; -int write_mode = (int )(unsigned long )fsdata; +unsigned long write_mode = (unsigned long )fsdata; -if (write_mode ==FALL_BACK_TO_NONDELALLOC ) +if (write_mode &FALL_BACK_TO_NONDELALLOC )return ext4_write_end (iocb, mapping, pos, len, copied, folio, fsdata);trace_ext4_da_write_end (inode, pos, len, copied); -if (write_mode !=CONVERT_INLINE_DATA && -ext4_test_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA ) && -ext4_has_inline_data (inode)) +if (write_mode &EXT4_WRITE_DATA_INLINE )return ext4_write_inline_data_end (inode, pos, len, copied, folio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 597/1815 ext4: validate readdir offset before accessing dirent
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yao Kai <[email protected]>
[ Upstream commit bc4b7b0414c33b2c8898eb04386df0d21a13dad8 ]
A corrupted directory can trigger the following KASAN report when ext4_readdir() resumes from an invalid position:
BUG: KASAN: use-after-free in __ext4_check_dir_entry+0x5ef/0x820 Read of size 2 at addr ffff88810a646000 by task repro_linear/509 Call Trace: <TASK> dump_stack_lvl+0x53/0x70 print_report+0xd0/0x630 kasan_report+0xce/0x100 __ext4_check_dir_entry+0x5ef/0x820 ext4_readdir+0xcde/0x2b70 iterate_dir+0x1a1/0x520 __x64_sys_getdents64+0x12b/0x220 do_syscall_64+0xf9/0x540 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
KASAN reports use-after-free because the out-of-bounds access lands in an adjacent freed page. The directory buffer itself is still referenced.
ext4_dir_llseek() invalidates the directory cookie so that ext4_readdir() rescans directory entries from the start of the block. The rescan checks only the lower bound of rec_len before advancing. A corrupted rec_len can therefore place the offset where the block has insufficient space for a complete directory entry. The rescan itself may dereference that truncated entry, or the main loop may pass it to __ext4_check_dir_entry(). The latter reads de->rec_len before validating the range. For example:
block offset 0 4092 4096
|---- de1.rec_len = 4092 -----|----|
de2.inode
| de2.rec_len
^ OOB, reported as UAFde2 starts at offset 4092 in this 4 KiB block. Its four-byte inode fits in the block, but its rec_len starts at offset 4096 and crosses the boundary.
The minimum safe length is inode-dependent. Encrypted and casefolded directory entries need eight additional hash bytes, while a valid metadata checksum tail is only 12 bytes.
Cache the metadata checksum feature state and derive the minimum directory entry length from the on-disk format. Use it to bound both the rescan and the offset passed to the main loop. Report an offset in a truncated block tail and skip the remainder of the block, while continuing to accept an offset exactly at the block boundary.
--- fs/ext4/dir.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
fs/ext4/dir.c +18 -2
@@ -138,6 +138,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)struct buffer_head *bh =NULL ;struct fscrypt_str fstr =FSTR_INIT (NULL ,0 );struct dir_private_info *info = file->private_data; +bool has_csum =ext4_has_feature_metadata_csum (sb); err =fscrypt_prepare_readdir (inode);if (err)
@@ -149,7 +150,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)return err;/* Can we just clear INDEX flag to ignore htree information? */ -if (!ext4_has_feature_metadata_csum (sb)) { +if (!has_csum) {/* * We don't set the inode dirty flag since it's not * critical that it gets flushed back to the disk.
@@ -235,7 +236,10 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)* dirent right now. Scan from the start of the block * to make sure. */ if (!inode_eq_iversion (inode, info->cookie)) { -for (i =0 ; i < sb->s_blocksize && i < offset; ) { +for (i =0 ; + i <= sb->s_blocksize - +ext4_dir_rec_len (1 , has_csum ?NULL : inode) && + i < offset;) { de = (struct ext4_dir_entry_2 *) (bh->b_data + i);/* It's too expensive to do a full
@@ -257,6 +261,17 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx) info->cookie =inode_query_iversion (inode); } +if (unlikely (offset < sb->s_blocksize && + offset > sb->s_blocksize - +ext4_dir_rec_len (1 , has_csum ?NULL : inode))) { +EXT4_ERROR_FILE (file, bh->b_blocknr, +"bad entry in directory: %s - offset=%u, size=%lu" , +"directory entry too close to block end" , + offset, sb->s_blocksize); + ctx->pos =round_up (ctx->pos, sb->s_blocksize); + goto next_block; + } +while (ctx->pos < inode->i_size && offset < sb->s_blocksize) { de = (struct ext4_dir_entry_2 *) (bh->b_data + offset);
@@ -312,6 +327,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx) ctx->pos +=ext4_rec_len_from_disk (de->rec_len, sb->s_blocksize); } +next_block:if ((ctx->pos < inode->i_size) && !dir_relax_shared (inode)) goto done;brelse (bh);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 598/1815 wifi: ath12k: Advertise multicast Ethernet encapsulation offload support
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tamizh Chelvam Raja <[email protected]>
[ Upstream commit e47d6c9bb4165721f61356f5fccae8f7dd78876b ]
Advertise IEEE80211_OFFLOAD_ENCAP_MCAST to inform mac80211 that multicast frame encapsulation is handled in hardware. This allows mac80211 to pass Ethernet-formatted multicast frames directly to the driver.
In ath12k_wifi7_mac_op_tx(), refine the logic that selects the MLO multicast replication path. Add a sta pointer check so that only unicast Hardware-encap frames use the direct transmit path, while multicast Hardware-encap frames fall through to the MLO replication loop and are transmitted on each active link.
In the MLO replication loop, use skb_clone() for Hardware-encap frames. These frames are already in Ethernet format and do not require 802.11 link address rewriting by ath12k_mlo_mcast_update_tx_link_address().
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
Stable-dep-of: be72d6aecea4 ("wifi: ath12k: Set IEEE80211_OFFLOAD_ENCAP_4ADDR after tx_encap_type vdev param")
--- drivers/net/wireless/ath/ath12k/mac.c | 6 ++- drivers/net/wireless/ath/ath12k/wifi7/hw.c | 61 +++++++++++++++++----- 2 files changed, 53 insertions(+), 14 deletions(-)
drivers/net/wireless/ath/ath12k/mac.c +5 -1
@@ -10169,7 +10169,8 @@ static void ath12k_mac_update_vif_offload(struct ath12k_link_vif *arvif)if (vif->type !=NL80211_IFTYPE_STATION && vif->type !=NL80211_IFTYPE_AP ) vif->offload_flags &= ~(IEEE80211_OFFLOAD_ENCAP_ENABLED | -IEEE80211_OFFLOAD_DECAP_ENABLED ); +IEEE80211_OFFLOAD_DECAP_ENABLED | +IEEE80211_OFFLOAD_ENCAP_MCAST );if (vif->offload_flags &IEEE80211_OFFLOAD_ENCAP_ENABLED ) { ahvif->dp_vif.tx_encap_type =ATH12K_HW_TXRX_ETHERNET ;
@@ -10188,6 +10189,9 @@ static void ath12k_mac_update_vif_offload(struct ath12k_link_vif *arvif) vif->offload_flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED ; } +if (vif->offload_flags &IEEE80211_OFFLOAD_ENCAP_ENABLED ) + vif->offload_flags |=IEEE80211_OFFLOAD_ENCAP_MCAST ; + param_id =WMI_VDEV_PARAM_RX_DECAP_TYPE ;if (vif->offload_flags &IEEE80211_OFFLOAD_DECAP_ENABLED ) param_value =ATH12K_HW_TXRX_ETHERNET ;
drivers/net/wireless/ath/ath12k/wifi7/hw.c +48 -13
107 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 599/1815 wifi: ath12k: Set IEEE80211_OFFLOAD_ENCAP_4ADDR after tx_encap_type vdev param
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tamizh Chelvam Raja <[email protected]>
[ Upstream commit be72d6aecea491ee202de81fc3a71c7ea9d34d2b ]
Currently, IEEE80211_OFFLOAD_ENCAP_4ADDR is set when IEEE80211_OFFLOAD_ENCAP_ENABLED is present in vif->offload_flags at the beginning of ath12k_mac_update_vif_offload().
However, if the WMI vdev set_param for tx_encap_type fails, IEEE80211_OFFLOAD_ENCAP_ENABLED is cleared but IEEE80211_OFFLOAD_ENCAP_4ADDR remains set, leaving the flags in an inconsistent state.
Fix this by setting IEEE80211_OFFLOAD_ENCAP_4ADDR only after the tx_encap_type has been configured via the WMI vdev set parameter.
Compile tested only.
--- drivers/net/wireless/ath/ath12k/mac.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath12k/mac.c +7 -7
@@ -10170,16 +10170,15 @@ static void ath12k_mac_update_vif_offload(struct ath12k_link_vif *arvif) vif->type != NL80211_IFTYPE_AP) vif->offload_flags &= ~(IEEE80211_OFFLOAD_ENCAP_ENABLED |IEEE80211_OFFLOAD_DECAP_ENABLED | -IEEE80211_OFFLOAD_ENCAP_MCAST ); +IEEE80211_OFFLOAD_ENCAP_MCAST | +IEEE80211_OFFLOAD_ENCAP_4ADDR ); -if (vif->offload_flags &IEEE80211_OFFLOAD_ENCAP_ENABLED ) { +if (vif->offload_flags &IEEE80211_OFFLOAD_ENCAP_ENABLED ) ahvif->dp_vif.tx_encap_type =ATH12K_HW_TXRX_ETHERNET ; - vif->offload_flags |=IEEE80211_OFFLOAD_ENCAP_4ADDR ; - }else if (test_bit (ATH12K_FLAG_RAW_MODE , &ab->dev_flags)) { +else if (test_bit (ATH12K_FLAG_RAW_MODE , &ab->dev_flags)) ahvif->dp_vif.tx_encap_type =ATH12K_HW_TXRX_RAW ; - }else { +else ahvif->dp_vif.tx_encap_type =ATH12K_HW_TXRX_NATIVE_WIFI ; - } ret =ath12k_wmi_vdev_set_param_cmd (ar, arvif->vdev_id, param_id, ahvif->dp_vif.tx_encap_type);
@@ -10190,7 +10189,8 @@ static void ath12k_mac_update_vif_offload(struct ath12k_link_vif *arvif) }if (vif->offload_flags &IEEE80211_OFFLOAD_ENCAP_ENABLED ) - vif->offload_flags |=IEEE80211_OFFLOAD_ENCAP_MCAST ; + vif->offload_flags |= (IEEE80211_OFFLOAD_ENCAP_MCAST | +IEEE80211_OFFLOAD_ENCAP_4ADDR ); param_id =WMI_VDEV_PARAM_RX_DECAP_TYPE ;if (vif->offload_flags &IEEE80211_OFFLOAD_DECAP_ENABLED )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 600/1815 wifi: ath12k: advertise ieee_link_id in vdev start MLO params
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manish Dharanenthiran <[email protected]>
[ Upstream commit 784f7dabf5d3bce23c69c48a0441ff2b1536f069 ]
Firmware builds the AP MLD partner profile from the hw_link_id passed in the vdev start parameters. However, hw_link_id is not always the same as the logical per-MLD ieee_link_id, since ieee_link_id is assigned per MLD and not per pdev.
This matters in mixed MLO and SLO setups. For example:
MLD 1 - 5 GHz + 6 GHz (2-link MLO): ieee_link_id 0 and 1
MLD 2 - 6 GHz only (1-link SLO): ieee_link_id 0
MLD 3 - 5 GHz only (1-link SLO): ieee_link_id 0
The same physical 6 GHz radio can use ieee_link_id 1 for one MLD and ieee_link_id 0 for another. Pass the correct ieee_link_id to firmware so it can build accurate per-STA profile elements.
Add ieee_link_id to wmi_vdev_start_mlo_params for the self link and to wmi_partner_link_info for each partner link. Populate these fields in ath12k_mac_mlo_get_vdev_args() from the corresponding vdev link_id before encoding the WMI command.
Introduce two new flags in ML params to indicate to firmware when the new fields are valid:
ATH12K_WMI_FLAG_MLO_IEEE_LINK_IDX_VALID BIT(18) for the self link
ATH12K_WMI_FLAG_MLO_IEEE_LINK_IDX_VALID_PARTNER BIT(19) for partner links
Firmware parses ieee_link_id only when the matching flag is set.
Also fix the debug message by using correct format specifiers and host-endian values instead of __le32 values.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
Stable-dep-of: ff651212f2e2 ("wifi: ath12k: fix ML-STA authentication timeout on QCC2072")
--- drivers/net/wireless/ath/ath12k/mac.c | 3 +++ drivers/net/wireless/ath/ath12k/wmi.c | 32 +++++++++++++++++---------- drivers/net/wireless/ath/ath12k/wmi.h | 7 ++++++ 3 files changed, 30 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath12k/mac.c +3 -0
@@ -11295,6 +11295,8 @@ ath12k_mac_mlo_get_vdev_args(struct ath12k_link_vif *arvif, ml_arg->assoc_link = arvif->is_sta_assoc_link; + ml_arg->ieee_link_id = arvif->link_id; + partner_info = ml_arg->partner_info; links = ahvif->links_map;
@@ -11318,6 +11320,7 @@ ath12k_mac_mlo_get_vdev_args(struct ath12k_link_vif *arvif, partner_info->vdev_id = arvif_p->vdev_id; partner_info->hw_link_id = arvif_p->ar->pdev->hw_link_id; + partner_info->ieee_link_id = arvif_p->link_id;ether_addr_copy (partner_info->addr, link_conf->addr); ml_arg->num_partner_links++; partner_info++;
drivers/net/wireless/ath/ath12k/wmi.c +20 -12
@@ -1228,10 +1228,14 @@ int ath12k_wmi_vdev_start(struct ath12k *ar, struct wmi_vdev_start_req_arg *arg,le32_encode_bits (arg->ml.mcast_link,ATH12K_WMI_FLAG_MLO_MCAST_VDEV ) |le32_encode_bits (arg->ml.link_add, -ATH12K_WMI_FLAG_MLO_LINK_ADD ); +ATH12K_WMI_FLAG_MLO_LINK_ADD ) | +cpu_to_le32 (ATH12K_WMI_FLAG_MLO_IEEE_LINK_IDX_VALID ); -ath12k_dbg (ar->ab,ATH12K_DBG_WMI ,"vdev %d start ml flags 0x%x\n" , - arg->vdev_id, ml_params->flags); + ml_params->ieee_link_id =cpu_to_le32 (arg->ml.ieee_link_id); + +ath12k_dbg (ar->ab,ATH12K_DBG_WMI ,"vdev %u start link_id %u ml flags 0x%x\n" , + arg->vdev_id, arg->ml.ieee_link_id, +le32_to_cpu (ml_params->flags)); ptr +=sizeof (*ml_params);
@@ -1244,19 +1248,23 @@ int ath12k_wmi_vdev_start(struct ath12k *ar, struct wmi_vdev_start_req_arg *arg, partner_info = ptr;for (i =0 ; i < arg->ml.num_partner_links; i++) { +struct wmi_ml_partner_info *pinfo = &arg->ml.partner_info[i]; + partner_info->tlv_header =ath12k_wmi_tlv_cmd_hdr (WMI_TAG_MLO_PARTNER_LINK_PARAMS ,sizeof (*partner_info)); - partner_info->vdev_id = -cpu_to_le32 (arg->ml.partner_info[i].vdev_id); - partner_info->hw_link_id = -cpu_to_le32 (arg->ml.partner_info[i].hw_link_id); + partner_info->vdev_id =cpu_to_le32 (pinfo->vdev_id); + partner_info->hw_link_id =cpu_to_le32 (pinfo->hw_link_id);ether_addr_copy (partner_info->vdev_addr.addr, - arg->ml.partner_info[i].addr); - -ath12k_dbg (ar->ab,ATH12K_DBG_WMI ,"partner vdev %d hw_link_id %d macaddr%pM\n" , - partner_info->vdev_id, partner_info->hw_link_id, - partner_info->vdev_addr.addr); + pinfo->addr); + partner_info->flags = +cpu_to_le32 (ATH12K_WMI_FLAG_MLO_IEEE_LINK_IDX_VALID_PARTNER ); + partner_info->ieee_link_id =cpu_to_le32 (pinfo->ieee_link_id); + +ath12k_dbg (ar->ab,ATH12K_DBG_WMI ,"partner vdev %u hw_link_id %u macaddr %pM link_id %u ml flags 0x%x\n" , + pinfo->vdev_id, pinfo->hw_link_id, + pinfo->addr, pinfo->ieee_link_id, +le32_to_cpu (partner_info->flags)); partner_info++; }
drivers/net/wireless/ath/ath12k/wmi.h +7 -0
@@ -2954,10 +2954,13 @@ struct wmi_vdev_create_mlo_params {#define ATH12K_WMI_FLAG_MLO_EMLSR_SUPPORT BIT(6)#define ATH12K_WMI_FLAG_MLO_FORCED_INACTIVE BIT(7)#define ATH12K_WMI_FLAG_MLO_LINK_ADD BIT(8) +#define ATH12K_WMI_FLAG_MLO_IEEE_LINK_IDX_VALID BIT(18) +#define ATH12K_WMI_FLAG_MLO_IEEE_LINK_IDX_VALID_PARTNER BIT(19)struct wmi_vdev_start_mlo_params {__le32 tlv_header;__le32 flags; +__le32 ieee_link_id; } __packed;struct wmi_partner_link_info {
@@ -2965,6 +2968,8 @@ struct wmi_partner_link_info {__le32 vdev_id;__le32 hw_link_id;struct ath12k_wmi_mac_addr_params vdev_addr; +__le32 flags; +__le32 ieee_link_id; } __packed;struct wmi_vdev_delete_cmd {
@@ -3120,6 +3125,7 @@ struct wmi_ml_partner_info {bool primary_umac;bool logical_link_idx_valid;u32 logical_link_idx; +u32 ieee_link_id; };struct wmi_ml_arg {
@@ -3127,6 +3133,7 @@ struct wmi_ml_arg {bool assoc_link;bool mcast_link;bool link_add; +u32 ieee_link_id;u8 num_partner_links;struct wmi_ml_partner_info partner_info[ATH12K_WMI_MLO_MAX_LINKS ]; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 601/1815 wifi: ath12k: fix ML-STA authentication timeout on QCC2072
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaoqing Pan <[email protected]>
[ Upstream commit ff651212f2e237d790a5b36deef9d332360dc272 ]
QCC2072 firmware interprets the MLO_LINK_ADD and MLO_START_AS_ACTIVE flags to control the link state during MLO vdev start. MLO_LINK_ADD indicates that a link is being added, while MLO_START_AS_ACTIVE specifies that the link should become active during the start.
When an association link is added without setting MLO_START_AS_ACTIVE, the firmware may transition the link into a suspended state. In this case, authentication frames transmitted by the host can be dropped, leading to repeated authentication retries and eventual timeout, for example:
wlp1s0: send auth to <AP> (try 1/3)
wlp1s0: send auth to <AP> (try 2/3)
wlp1s0: send auth to <AP> (try 3/3)
wlp1s0: authentication with <AP> timed out
Avoid triggering this behavior by setting the MLO_START_AS_ACTIVE flag when MLO_ASSOC_LINK is set, which tells the firmware that the current vdev must not enter suspend mode
Note that this change relies on firmware behavior observed on the QCC2072 platform. The firmware on WCN7850 and QCN9274 does not use the MLO_START_AS_ACTIVE flag, so this change is effectively a no-op on those platforms
Tested-on: QCC2072 hw1.0 PCI WLAN.COL.1.0.c2-00068-QCACOLSWPL_V1_TO_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3
--- drivers/net/wireless/ath/ath12k/wmi.c | 2 ++ drivers/net/wireless/ath/ath12k/wmi.h | 1 + 2 files changed, 3 insertions(+)
drivers/net/wireless/ath/ath12k/wmi.c +2 -0
@@ -1229,6 +1229,8 @@ int ath12k_wmi_vdev_start(struct ath12k *ar, struct wmi_vdev_start_req_arg *arg, ATH12K_WMI_FLAG_MLO_MCAST_VDEV) |le32_encode_bits (arg->ml.link_add,ATH12K_WMI_FLAG_MLO_LINK_ADD ) | +le32_encode_bits (arg->ml.assoc_link, +ATH12K_WMI_FLAG_MLO_START_AS_ACTIVE ) |cpu_to_le32 (ATH12K_WMI_FLAG_MLO_IEEE_LINK_IDX_VALID ); ml_params->ieee_link_id =cpu_to_le32 (arg->ml.ieee_link_id);
drivers/net/wireless/ath/ath12k/wmi.h +1 -0
@@ -2954,6 +2954,7 @@ struct wmi_vdev_create_mlo_params {#define ATH12K_WMI_FLAG_MLO_EMLSR_SUPPORT BIT(6)#define ATH12K_WMI_FLAG_MLO_FORCED_INACTIVE BIT(7)#define ATH12K_WMI_FLAG_MLO_LINK_ADD BIT(8) +#define ATH12K_WMI_FLAG_MLO_START_AS_ACTIVE BIT(17)#define ATH12K_WMI_FLAG_MLO_IEEE_LINK_IDX_VALID BIT(18)#define ATH12K_WMI_FLAG_MLO_IEEE_LINK_IDX_VALID_PARTNER BIT(19)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 602/1815 wifi: ath6kl: avoid buffer overreads in WMI event handlers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit f57314aade9d74d30f3360ec5ef85a83654748be ]
The following WMI event handlers currently read from the event buffer without first verifying that the message was large enough to hold the expected event:ath6kl_wmi_scan_complete_rx() ath6kl_wmi_addba_req_event_rx() ath6kl_wmi_delba_req_event_rx()
Add length checks to prevent overread.
--- drivers/net/wireless/ath/ath6kl/wmi.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/wmi.c +15 -2
@@ -1296,6 +1296,9 @@ static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len, {struct wmi_scan_complete_event *ev; +if (len <sizeof (*ev)) +return -EINVAL ; + ev = (struct wmi_scan_complete_event *) datap;ath6kl_scan_complete_evt (vif,a_sle32_to_cpu (ev->status));
@@ -3372,7 +3375,12 @@ static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,static int ath6kl_wmi_addba_req_event_rx (struct wmi *wmi,u8 *datap,int len,struct ath6kl_vif *vif) { -struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; +struct wmi_addba_req_event *cmd; + +if (len <sizeof (*cmd)) +return -EINVAL ; + + cmd = (struct wmi_addba_req_event *)datap;aggr_recv_addba_req_evt (vif, cmd->tid,le16_to_cpu (cmd->st_seq_no), cmd->win_sz);
@@ -3383,7 +3391,12 @@ static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len,static int ath6kl_wmi_delba_req_event_rx (struct wmi *wmi,u8 *datap,int len,struct ath6kl_vif *vif) { -struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; +struct wmi_delba_event *cmd; + +if (len <sizeof (*cmd)) +return -EINVAL ; + + cmd = (struct wmi_delba_event *)datap;aggr_recv_delba_req_evt (vif, cmd->tid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 603/1815 wifi: ath12k: switch to name-based reserved memory lookup
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaradhana Sahu <[email protected]>
[ Upstream commit 3fe59edd1901c040e5b8e9d2428bf9ec6b4ce630 ]
The driver currently retrieves reserved memory regions using index-based lookup, which depends on the ordering of reserved-memory nodes in the device tree. Since different platforms define these regions in varying orders and combinations, this approach is not compatible and can result in incorrect memory region access.
Switch to looking up memory regions by name instead of index so it does not depend on node order.
Use names already defined in qcom,ipq5332-wifi.yaml, so there are no backward compatibility issues.
Tested-on: IPQ5332 hw1.0 AHB WLAN.WBE.1.6-01275-QCAHKSWPL_SILICONZ-1
Stable-dep-of: 42399be44b13 ("wifi: ath12k: allocate HOST_DDR and BDF regions after Q6 RO region")
--- drivers/net/wireless/ath/ath12k/ahb.c | 18 ++++++------ drivers/net/wireless/ath/ath12k/core.c | 25 ----------------- drivers/net/wireless/ath/ath12k/core.h | 2 -- drivers/net/wireless/ath/ath12k/qmi.c | 38 +++++++++++++------------- 4 files changed, 29 insertions(+), 54 deletions(-)
drivers/net/wireless/ath/ath12k/ahb.c +10 -8
@@ -12,6 +12,7 @@#include <linux/remoteproc.h> #include <linux/soc/qcom/mdt_loader.h> #include <linux/soc/qcom/smem_state.h> +#include <linux/of_reserved_mem.h> #include "ahb.h" #include "debug.h" #include "hif.h"
@@ -338,24 +339,25 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)char fw2_name[ATH12K_USERPD_FW_NAME_LEN ];struct device *dev = ab->dev;const struct firmware *fw, *fw2; -struct reserved_mem *rmem =NULL ;unsigned long time_left;phys_addr_t mem_phys; +struct resource res;void *mem_region;size_t mem_size;u32 pasid;int ret; - rmem =ath12k_core_get_reserved_mem (ab,0 ); -if (!rmem) -return -ENODEV ; + ret =of_reserved_mem_region_to_resource_byname (dev->of_node,"q6-region" , + &res); +if (ret) +return ret; - mem_phys = rmem->base; - mem_size = rmem->size; + mem_phys = res.start; + mem_size =resource_size (&res); mem_region =devm_memremap (dev, mem_phys, mem_size,MEMREMAP_WC );if (IS_ERR (mem_region)) { -ath12k_err (ab,"unable to map memory region: %pa+%pa\n" , - &rmem->base, &rmem->size); +ath12k_err (ab,"unable to map memory region: %pa+%zx\n" , + &res.start, mem_size);return PTR_ERR (mem_region); }
drivers/net/wireless/ath/ath12k/core.c +0 -25
@@ -637,31 +637,6 @@ u32 ath12k_core_get_max_peers_per_radio(struct ath12k_base *ab) }EXPORT_SYMBOL (ath12k_core_get_max_peers_per_radio); -struct reserved_mem *ath12k_core_get_reserved_mem (struct ath12k_base *ab, -int index) -{ -struct device *dev = ab->dev; -struct reserved_mem *rmem; -struct device_node *node; - - node =of_parse_phandle (dev->of_node,"memory-region" , index); -if (!node) { -ath12k_dbg (ab,ATH12K_DBG_BOOT , -"failed to parse memory-region for index %d\n" , index); -return NULL ; - } - - rmem =of_reserved_mem_lookup (node); -of_node_put (node); -if (!rmem) { -ath12k_dbg (ab,ATH12K_DBG_BOOT , -"unable to get memory-region for index %d\n" , index); -return NULL ; - } - -return rmem; -} -static inline void ath12k_core_to_group_ref_get (struct ath12k_base *ab) {
drivers/net/wireless/ath/ath12k/core.h +0 -2
@@ -1298,8 +1298,6 @@ void ath12k_fw_stats_init(struct ath12k *ar);void ath12k_fw_stats_bcn_free (struct list_head *head);void ath12k_fw_stats_free (struct ath12k_fw_stats *stats);void ath12k_fw_stats_reset (struct ath12k *ar); -struct reserved_mem *ath12k_core_get_reserved_mem (struct ath12k_base *ab, -int index);enum ath12k_qmi_mem_mode ath12k_core_get_memory_mode (struct ath12k_base *ab);static inline const char *ath12k_scan_state_str (enum ath12k_scan_state state)
drivers/net/wireless/ath/ath12k/qmi.c +19 -19
@@ -13,6 +13,7 @@#include <linux/firmware.h> #include <linux/of_address.h> #include <linux/ioport.h> +#include <linux/of_reserved_mem.h> #define SLEEP_CLOCK_SELECT_INTERNAL_BIT 0x02#define HOST_CSTATE_BIT 0x04
@@ -2727,20 +2728,20 @@ static int ath12k_qmi_alloc_target_mem_chunk(struct ath12k_base *ab)static int ath12k_qmi_assign_target_mem_chunk (struct ath12k_base *ab) { -struct reserved_mem *rmem; +struct device_node *np = ab->dev->of_node;size_t avail_rmem_size; +struct resource res;int i, idx, ret;for (i =0 , idx =0 ; i < ab->qmi.mem_seg_count; i++) {switch (ab->qmi.target_mem[i].type) {case HOST_DDR_REGION_TYPE : - rmem =ath12k_core_get_reserved_mem (ab,0 ); -if (!rmem) { - ret = -ENODEV ; + ret =of_reserved_mem_region_to_resource_byname (np,"q6-region" , + &res); +if (ret) goto out; - } - avail_rmem_size = rmem->size; + avail_rmem_size =resource_size (&res);if (avail_rmem_size < ab->qmi.target_mem[i].size) { ath12k_dbg(ab, ATH12K_DBG_QMI, "failed to assign mem type %u req size %u avail size %zu\n",
@@ -2751,7 +2752,7 @@ static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab) goto out; } - ab->qmi.target_mem[idx].paddr = rmem->base; + ab->qmi.target_mem[idx].paddr = res.start; ab->qmi.target_mem[idx].v.ioaddr =ioremap (ab->qmi.target_mem[idx].paddr, ab->qmi.target_mem[i].size);
@@ -2764,13 +2765,13 @@ static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab) idx++;break ;case BDF_MEM_REGION_TYPE : - rmem =ath12k_core_get_reserved_mem (ab,0 ); -if (!rmem) { - ret = -ENODEV ; + ret =of_reserved_mem_region_to_resource_byname (np,"q6-region" , + &res); +if (ret) goto out; - } - avail_rmem_size = rmem->size - ab->hw_params->bdf_addr_offset; + avail_rmem_size =resource_size (&res) - + ab->hw_params->bdf_addr_offset;if (avail_rmem_size < ab->qmi.target_mem[i].size) { ath12k_dbg(ab, ATH12K_DBG_QMI, "failed to assign mem type %u req size %u avail size %zu\n",
@@ -2781,7 +2782,7 @@ static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab) goto out; } ab->qmi.target_mem[idx].paddr = - rmem->base + ab->hw_params->bdf_addr_offset; + res.start + ab->hw_params->bdf_addr_offset; ab->qmi.target_mem[idx].v.ioaddr =ioremap (ab->qmi.target_mem[idx].paddr, ab->qmi.target_mem[i].size);
@@ -2806,13 +2807,12 @@ static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab) idx++;break ;case M3_DUMP_REGION_TYPE : - rmem =ath12k_core_get_reserved_mem (ab,1 ); -if (!rmem) { - ret = -EINVAL ; + ret =of_reserved_mem_region_to_resource_byname (np,"m3-dump" , + &res); +if (ret) goto out; - } - avail_rmem_size = rmem->size; + avail_rmem_size =resource_size (&res);if (avail_rmem_size < ab->qmi.target_mem[i].size) { ath12k_dbg(ab, ATH12K_DBG_QMI, "failed to assign mem type %u req size %u avail size %zu\n",
@@ -2823,7 +2823,7 @@ static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab) goto out; } - ab->qmi.target_mem[idx].paddr = rmem->base; + ab->qmi.target_mem[idx].paddr = res.start; ab->qmi.target_mem[idx].v.ioaddr =ioremap (ab->qmi.target_mem[idx].paddr, ab->qmi.target_mem[i].size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 604/1815 wifi: ath12k: refactor QMI memory assignment
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaradhana Sahu <[email protected]>
[ Upstream commit ecb517f97e629d3b8c360cbb5db3fed4d599ea2e ]
ath12k_qmi_assign_target_mem_chunk() uses a large switch-case to handle both memory region identification and allocation for each memory request type, leading to redundant allocation logic.
Refactor this by introducing ath12k_qmi_get_mem_reg_name() to map memory request types to their corresponding reserved memory region names.
Tested-on: IPQ5332 hw1.0 AHB WLAN.WBE.1.6-01275-QCAHKSWPL_SILICONZ-1
Stable-dep-of: 42399be44b13 ("wifi: ath12k: allocate HOST_DDR and BDF regions after Q6 RO region")
--- drivers/net/wireless/ath/ath12k/qmi.c | 157 ++++++++++---------------- 1 file changed, 61 insertions(+), 96 deletions(-)
drivers/net/wireless/ath/ath12k/qmi.c +61 -96
@@ -2726,120 +2726,85 @@ static int ath12k_qmi_alloc_target_mem_chunk(struct ath12k_base *ab)return ret; } +static const char *ath12k_qmi_get_mem_reg_name (int mem_type) +{ +switch (mem_type) { +case HOST_DDR_REGION_TYPE : +case BDF_MEM_REGION_TYPE : +return "q6-region" ; +case M3_DUMP_REGION_TYPE : +return "m3-dump" ; +case CALDB_MEM_REGION_TYPE : +return "q6-caldb" ; +case MLO_GLOBAL_MEM_REGION_TYPE : +return "mlo-global-mem" ; +default : +return NULL ; + } +} +static int ath12k_qmi_assign_target_mem_chunk (struct ath12k_base *ab) {struct device_node *np = ab->dev->of_node; +struct target_mem_chunk *chunk;size_t avail_rmem_size;struct resource res; +const char *rname;int i, idx, ret;for (i =0 , idx =0 ; i < ab->qmi.mem_seg_count; i++) { -switch (ab->qmi.target_mem[i].type) { -case HOST_DDR_REGION_TYPE : - ret =of_reserved_mem_region_to_resource_byname (np,"q6-region" , - &res); -if (ret) - goto out; - - avail_rmem_size =resource_size (&res); -if (avail_rmem_size < ab->qmi.target_mem[i].size) { -ath12k_dbg (ab,ATH12K_DBG_QMI , -"failed to assign mem type %u req size %u avail size %zu\n" , - ab->qmi.target_mem[i].type, - ab->qmi.target_mem[i].size, - avail_rmem_size); - ret = -EINVAL ; - goto out; - } - - ab->qmi.target_mem[idx].paddr = res.start; - ab->qmi.target_mem[idx].v.ioaddr = -ioremap (ab->qmi.target_mem[idx].paddr, - ab->qmi.target_mem[i].size); -if (!ab->qmi.target_mem[idx].v.ioaddr) { - ret = -EIO ; - goto out; - } - ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; - ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; - idx++; -break ; -case BDF_MEM_REGION_TYPE : - ret =of_reserved_mem_region_to_resource_byname (np,"q6-region" , - &res); -if (ret) - goto out; - - avail_rmem_size =resource_size (&res) - - ab->hw_params->bdf_addr_offset; -if (avail_rmem_size < ab->qmi.target_mem[i].size) { -ath12k_dbg (ab,ATH12K_DBG_QMI , -"failed to assign mem type %u req size %u avail size %zu\n" , - ab->qmi.target_mem[i].type, - ab->qmi.target_mem[i].size, - avail_rmem_size); - ret = -EINVAL ; - goto out; - } - ab->qmi.target_mem[idx].paddr = - res.start + ab->hw_params->bdf_addr_offset; - ab->qmi.target_mem[idx].v.ioaddr = -ioremap (ab->qmi.target_mem[idx].paddr, - ab->qmi.target_mem[i].size); -if (!ab->qmi.target_mem[idx].v.ioaddr) { - ret = -EIO ; - goto out; - } - ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; - ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; - idx++; -break ; -case CALDB_MEM_REGION_TYPE : -/* Cold boot calibration is not enabled in Ath12k. Hence, + chunk = &ab->qmi.target_mem[i]; +if (chunk->type ==CALDB_MEM_REGION_TYPE ) { +/* +* Cold boot calibration is not enabled in Ath12k. Hence, * assign paddr = 0. * Once cold boot calibration is enabled add support to * assign reserved memory from DT. */ ab->qmi.target_mem[idx].paddr =0 ; ab->qmi.target_mem[idx].v.ioaddr =NULL ; - ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; - ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; + ab->qmi.target_mem[idx].size = chunk->size; + ab->qmi.target_mem[idx].type = chunk->type; idx++; -break ; -case M3_DUMP_REGION_TYPE : - ret =of_reserved_mem_region_to_resource_byname (np,"m3-dump" , - &res); -if (ret) - goto out; - - avail_rmem_size =resource_size (&res); -if (avail_rmem_size < ab->qmi.target_mem[i].size) { -ath12k_dbg (ab,ATH12K_DBG_QMI , -"failed to assign mem type %u req size %u avail size %zu\n" , - ab->qmi.target_mem[i].type, - ab->qmi.target_mem[i].size, - avail_rmem_size); - ret = -EINVAL ; - goto out; - } +continue ; + } - ab->qmi.target_mem[idx].paddr = res.start; - ab->qmi.target_mem[idx].v.ioaddr = -ioremap (ab->qmi.target_mem[idx].paddr, - ab->qmi.target_mem[i].size); -if (!ab->qmi.target_mem[idx].v.ioaddr) { - ret = -EIO ; - goto out; - } - ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; - ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; - idx++; -break ; -default : + rname =ath12k_qmi_get_mem_reg_name (chunk->type); +if (!rname) {ath12k_warn (ab,"qmi ignore invalid mem req type %u\n" , - ab->qmi.target_mem[i].type); -break ; + chunk->type); +continue ; + } + + ret =of_reserved_mem_region_to_resource_byname (np, rname, &res); +if (ret) + goto out; + + avail_rmem_size =resource_size (&res); +if (chunk->type ==BDF_MEM_REGION_TYPE ) { + avail_rmem_size -= ab->hw_params->bdf_addr_offset; + res.start += ab->hw_params->bdf_addr_offset; } + +if (avail_rmem_size < chunk->size) { +ath12k_dbg (ab,ATH12K_DBG_QMI , +"failed to assign mem type %u req size %u avail size %zu\n" , + chunk->type, chunk->size, avail_rmem_size); + ret = -EINVAL ; + goto out; + } + + ab->qmi.target_mem[idx].paddr = res.start; + ab->qmi.target_mem[idx].v.ioaddr =ioremap (ab->qmi.target_mem[idx].paddr, + chunk->size); +if (!ab->qmi.target_mem[idx].v.ioaddr) { + ret = -EIO ; + goto out; + } + + ab->qmi.target_mem[idx].size = chunk->size; + ab->qmi.target_mem[idx].type = chunk->type; + idx++; } ab->qmi.mem_seg_count = idx;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 605/1815 wifi: ath12k: allocate HOST_DDR and BDF regions after Q6 RO region
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaradhana Sahu <[email protected]>
[ Upstream commit 42399be44b13eafb45c56b1c7d7c92107e50c289 ]
Currently, the Q6 region contains a read-only firmware region along with the BDF_MEM_REGION_TYPE and HOST_DDR_REGION_TYPE memory areas. The firmware expects these writable memory regions to be assigned after the Q6 read-only section.
However, the ath12k driver currently allocates the HOST_DDR_REGION_TYPE starting from the base of the Q6 region, which includes the read-only firmware area. As a result, the allocated memory regions overlap with the read-only section, causing the firmware to assert during QMI memory allocation. The Q6 memory region layout is as follows:
Q6 Reserved Memory
+--------------------------------------+
| |
| Read-only Firmware Region |
| (Q6 RO Region) |
| |
+--------------------------------------+ <--- bdf_addr_offset
| Writable Memory Region |
| (BDF + HOST_DDR allocations) |
| |
+--------------------------------------+
Fix this by allocating the required memory regions only after the end of the read-only region in the Q6 address space. The bdf_addr_offset parameter indicates where the writable region starts. Both HOST_DDR and BDF regions are allocated sequentially after this offset, with each region placed immediately after the previous one to avoid gaps and overlaps.
Tested-on: IPQ5332 hw1.0 AHB WLAN.WBE.1.6-01275-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/qmi.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath12k/qmi.c +15 -4
@@ -2746,8 +2746,8 @@ static const char *ath12k_qmi_get_mem_reg_name(int mem_type)static int ath12k_qmi_assign_target_mem_chunk (struct ath12k_base *ab) {struct device_node *np = ab->dev->of_node; +size_t avail_rmem_size, offset =0 ;struct target_mem_chunk *chunk; -size_t avail_rmem_size;struct resource res;const char *rname;int i, idx, ret;
@@ -2781,9 +2781,20 @@ static int ath12k_qmi_assign_target_mem_chunk(struct ath12k_base *ab) goto out; avail_rmem_size =resource_size (&res); -if (chunk->type ==BDF_MEM_REGION_TYPE ) { - avail_rmem_size -= ab->hw_params->bdf_addr_offset; - res.start += ab->hw_params->bdf_addr_offset; +if (chunk->type ==BDF_MEM_REGION_TYPE || + chunk->type ==HOST_DDR_REGION_TYPE ) { +if (ab->hw_params->bdf_addr_offset > avail_rmem_size || + offset > avail_rmem_size - ab->hw_params->bdf_addr_offset) { +ath12k_err (ab,"qmi mem offset overflow: bdf_offset=%u offset=%zu size=%zu\n" , + ab->hw_params->bdf_addr_offset, offset, + avail_rmem_size); + ret = -EINVAL ; + goto out; + } + + avail_rmem_size -= ab->hw_params->bdf_addr_offset + offset; + res.start += ab->hw_params->bdf_addr_offset + offset; + offset += chunk->size; }if (avail_rmem_size < chunk->size) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 606/1815 wifi: ath12k: Correctly copy the hint BSSID in WMI scan request
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 7b0bd40e97a00991122122d5888ae455fb2bfc7a ]
Currently, in ath12k_wmi_send_scan_start_cmd(), the logic to populate the hint_bssid copies the BSSID in the wrong direction, from the firmware message to the argument buffer. Swap the parameters so that the BSSID is correctly populated in the firmware message from the argument buffer.
Compile tested only.
--- drivers/net/wireless/ath/ath12k/wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath12k/wmi.c +2 -2
@@ -2798,8 +2798,8 @@ int ath12k_wmi_send_scan_start_cmd(struct ath12k *ar,for (i =0 ; i < arg->num_hint_bssid; ++i) { hint_bssid->freq_flags = arg->hint_bssid[i].freq_flags; -ether_addr_copy (&arg->hint_bssid[i].bssid.addr[0 ], - &hint_bssid->bssid.addr[0 ]); +ether_addr_copy (&hint_bssid->bssid.addr[0 ], + &arg->hint_bssid[i].bssid.addr[0 ]); hint_bssid++; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 607/1815 wifi: ath11k: Correctly copy the hint BSSID in WMI scan request
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 6fe2dddf59bbb2a96be0fcf23a205807b25ac173 ]
Currently, in ath11k_wmi_send_scan_start_cmd(), the logic to populate the hint_bssid copies the BSSID in the wrong direction, from the firmware message to the argument buffer. Swap the parameters so that the BSSID is correctly populated in the firmware message from the argument buffer.
This issue was reported on ath12k, but exists in ath11k as well.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.c +2 -2
@@ -2423,8 +2423,8 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,for (i =0 ; i < params->num_hint_bssid; ++i) { hint_bssid->freq_flags = params->hint_bssid[i].freq_flags; -ether_addr_copy (¶ms->hint_bssid[i].bssid.addr[0 ], - &hint_bssid->bssid.addr[0 ]); +ether_addr_copy (&hint_bssid->bssid.addr[0 ], + ¶ms->hint_bssid[i].bssid.addr[0 ]); hint_bssid++; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 608/1815 wifi: ath12k: fix survey indexing across bands
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Leach <[email protected]>
[ Upstream commit c42b27336eeffd7926a77604cdefcc8918bed926 ]
When running 'iw dev wlan0 survey dump' the values for the channel busy time have the same sequence across bands. This is caused by indexing into the ath12k survey array using a band-local index rather than the global index passed by mac80211. This results in surveys for 5 GHz and 6 GHz channels returning values from 2.4 GHz slots, making the survey unusable on those bands. Further, there are redundant survey slots for multi-radio/single-phy instances.
Fix by moving the survey data into ath12k_hw so multiple radios under a single wiphy share one table, and index into it using the global mac80211 index. A new spinlock in ath12k_hw serialises access to the survey array, which is now shared across all radios under a single hw.
Band busy-times Before this fix:
2.4 GHz: 9, 2, 2, 2, 4, 2, 10, 16, 4, 12, 5
5 GHz: 9, 2, 2, 2, 4, 2, 10, 16, 4, 12, 5
6 GHz: 9, 2, 2, 2, 4, 2, 10, 16, 4, 12, 5
After this fix, times are independent:
2.4 GHz: 23, 5, 5, 12, 2, 12, 26, 5, 3, 1, 27
5 GHz: 30, 40, 29, 27, 118, 118, 112, 120, 11, 11, 11
6 GHz: 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
Tested-on: wcn7850 hw2.0 PCI WLAN.IOE_HMT.1.1-00018-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/core.h | 8 ++- drivers/net/wireless/ath/ath12k/mac.c | 33 +++++++------ drivers/net/wireless/ath/ath12k/wmi.c | 68 ++++++++++++++------------ 3 files changed, 62 insertions(+), 47 deletions(-)
drivers/net/wireless/ath/ath12k/core.h +6 -2
@@ -666,7 +666,7 @@ struct ath12k {/* protects the radio specific data like debug stats, ppdu_stats_info stats, * vdev_stop_status info, scan data, ath12k_sta info, ath12k_link_vif info, -* channel context data, survey info, test mode data, regd_channel_update_queue, +* channel context data, test mode data, regd_channel_update_queue, * peer_delete_waits. */ spinlock_t data_lock;
@@ -723,7 +723,6 @@ struct ath12k {* avoid reporting garbage data. */ bool ch_info_can_report_survey; -struct survey_info survey[ATH12K_NUM_CHANS ];struct completion bss_survey_done;struct work_struct regd_update_work;
@@ -793,6 +792,11 @@ struct ath12k_hw {*/ struct mutex hw_mutex;enum ath12k_hw_state state; + +/* protects survey[] shared across radios of this hw. */ +spinlock_t survey_lock; +struct survey_info survey[ATH12K_NUM_CHANS ]; +bool regd_updated;bool use_6ghz_regd;bool host_alloc_ml_id;
drivers/net/wireless/ath/ath12k/mac.c +18 -15
@@ -13626,52 +13626,54 @@ ath12k_mac_update_bss_chan_survey(struct ath12k *ar,int ath12k_mac_op_get_survey (struct ieee80211_hw *hw,int idx,struct survey_info *survey) { +struct ath12k_hw *ah = hw->priv;struct ath12k *ar;struct ieee80211_supported_band *sband; -struct survey_info *ar_survey; +struct survey_info *ah_survey; +int sband_idx = idx;lockdep_assert_wiphy (hw->wiphy); -if (idx >=ATH12K_NUM_CHANS ) +if (sband_idx >=ATH12K_NUM_CHANS )return -ENOENT ; sband = hw->wiphy->bands[NL80211_BAND_2GHZ ]; -if (sband && idx >= sband->n_channels) { - idx -= sband->n_channels; +if (sband && sband_idx >= sband->n_channels) { + sband_idx -= sband->n_channels; sband =NULL ; }if (!sband) sband = hw->wiphy->bands[NL80211_BAND_5GHZ ]; -if (sband && idx >= sband->n_channels) { - idx -= sband->n_channels; +if (sband && sband_idx >= sband->n_channels) { + sband_idx -= sband->n_channels; sband =NULL ; }if (!sband) sband = hw->wiphy->bands[NL80211_BAND_6GHZ ]; -if (!sband || idx >= sband->n_channels) +if (!sband || sband_idx >= sband->n_channels)return -ENOENT ; - ar =ath12k_mac_get_ar_by_chan (hw, &sband->channels[idx]); + ar =ath12k_mac_get_ar_by_chan (hw, &sband->channels[sband_idx]);if (!ar) { -if (sband->channels[idx].flags &IEEE80211_CHAN_DISABLED ) { +if (sband->channels[sband_idx].flags &IEEE80211_CHAN_DISABLED ) {memset (survey,0 ,sizeof (*survey));return 0 ; }return -ENOENT ; } - ar_survey = &ar->survey[idx]; + ah_survey = &ah->survey[idx]; -ath12k_mac_update_bss_chan_survey (ar, &sband->channels[idx]); +ath12k_mac_update_bss_chan_survey (ar, &sband->channels[sband_idx]); -spin_lock_bh (&ar->data_lock); -memcpy (survey, ar_survey,sizeof (*survey)); -spin_unlock_bh (&ar->data_lock); + scoped_guard(spinlock_bh, &ah->survey_lock) { +memcpy (survey, ah_survey,sizeof (*survey)); + } - survey->channel = &sband->channels[idx]; + survey->channel = &sband->channels[sband_idx];if (ar->rx_channel == survey->channel) survey->filled |=SURVEY_INFO_IN_USE ;
@@ -15353,6 +15355,7 @@ static struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_hw_group *ag,mutex_init (&ah->hw_mutex);init_completion (&ah->peer_ml_id_done); +spin_lock_init (&ah->survey_lock);spin_lock_init (&ah->dp_hw.peer_lock);INIT_LIST_HEAD (&ah->dp_hw.dp_peers_list);
drivers/net/wireless/ath/ath12k/wmi.c +38 -30
122 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 609/1815 wifi: ath12k: Avoid buffer overread in ath12k_wmi_op_rx()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 7698656a2f7b045af5a6859766238cefea1b1945 ]
Currently, in ath12k_wmi_op_rx(), the firmware buffer is read without first verifying that the buffer has enough data to hold a header. This could result in a buffer overread.
Update the logic to verify the buffer contains at least enough data to hold a wmi_cmd_hdr before reading from the buffer.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
--- drivers/net/wireless/ath/ath12k/wmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath12k/wmi.c +4 -4
@@ -10279,12 +10279,12 @@ static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb)struct wmi_cmd_hdr *cmd_hdr;enum wmi_tlv_event_id id; - cmd_hdr = (struct wmi_cmd_hdr *)skb->data; - id =le32_get_bits (cmd_hdr->cmd_id,WMI_CMD_HDR_CMD_ID ); - -if (!skb_pull (skb,sizeof (struct wmi_cmd_hdr ))) + cmd_hdr =skb_pull_data (skb,sizeof (*cmd_hdr)); +if (!cmd_hdr) goto out; + id =le32_get_bits (cmd_hdr->cmd_id,WMI_CMD_HDR_CMD_ID ); +switch (id) {/* Process all the WMI events here */ case WMI_SERVICE_READY_EVENTID :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 610/1815 wifi: ath11k: Avoid buffer overread in ath11k_wmi_tlv_op_rx()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 9ef9dd30058cc9223c72f711dca1a28a5947d0c5 ]
Currently, in ath11k_wmi_tlv_op_rx(), the firmware buffer is read without first verifying that the buffer has enough data to hold a header. This could result in a buffer overread.
Add an upfront length check before dereferencing skb->data as a wmi_cmd_hdr. The check is placed before the trace_ath11k_wmi_event() call to preserve the existing trace semantics (tracing the full raw WMI event including the header), unlike the analogous ath12k fix which could use skb_pull_data() directly.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.c +4 -2
@@ -8895,13 +8895,15 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb)struct wmi_cmd_hdr *cmd_hdr;enum wmi_tlv_event_id id; +if (skb->len <sizeof (*cmd_hdr)) + goto out; + cmd_hdr = (struct wmi_cmd_hdr *)skb->data; id =FIELD_GET (WMI_CMD_HDR_CMD_ID , (cmd_hdr->cmd_id));trace_ath11k_wmi_event (ab, id, skb->data, skb->len); -if (skb_pull (skb,sizeof (struct wmi_cmd_hdr )) ==NULL ) - goto out; +skb_pull (skb,sizeof (*cmd_hdr));switch (id) {/* Process all the WMI events here */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 611/1815 RDMA/bnxt_re: Clear VM_MAYWRITE on DBR/toggle page mmap
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit 9b66c9af7172ffcf727214fa0ebe9a5e1ed6eb16 ]
bnxt_re_mmap() rejects VM_WRITE for the DBR_PAGE and TOGGLE_PAGE mmap flags, but a read-only mapping can still retain VM_MAYWRITE. nd later be upgraded with mprotect(PROT_WRITE). This can bypass the write check that only runs at mmap time.
Clear VM_MAYWRITE before vm_insert_page() in the shared DBR/toggle-page branch, matching the existing policy that userspace writes are not expected for these pages.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +4 -2
@@ -4986,11 +4986,13 @@ int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma)case BNXT_RE_MMAP_DBR_PAGE :case BNXT_RE_MMAP_TOGGLE_PAGE :/* Driver doesn't expect write access for user space */ -if (vma->vm_flags &VM_WRITE ) +if (vma->vm_flags &VM_WRITE ) { ret = -EFAULT ; -else + }else { +vm_flags_clear (vma,VM_MAYWRITE ); ret =vm_insert_page (vma, vma->vm_start,virt_to_page ((void *)bnxt_entry->mem_offset)); + }break ;default : ret = -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 612/1815 ext4: fix buffer_head leak in ext4_init_orphan_info
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanghui Yang <[email protected]>
[ Upstream commit 05704335803b69c1bfa8637b7ada942bf2ee8a41 ]
ext4_init_orphan_info() reads orphan file blocks with ext4_bread() and stores the returned buffer_head in oi->of_binfo[i].ob_bh.
If ext4_bread() succeeds but the orphan block magic or checksum validation fails, the function jumps to out_free. However, the old out_free loop starts releasing buffers from i - 1, so the current buffer_head at index i is skipped.
This leaks the buffer_head reference obtained by ext4_bread() on the bad magic and bad checksum error paths.
Fix this by tracking the number of successfully read buffer_heads and releasing exactly those buffer_heads on the error path.
--- fs/ext4/orphan.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ext4/orphan.c +6 -2
@@ -572,6 +572,7 @@ int ext4_init_orphan_info(struct super_block *sb)int i, j;int ret;int free; +int loaded =0 ;__le32 *bdata;int inodes_per_ob =ext4_inodes_per_orphan_block (sb);struct ext4_orphan_block_tail *ot;
@@ -613,6 +614,7 @@ int ext4_init_orphan_info(struct super_block *sb) ret = -EIO ; goto out_free; } + loaded++; ot =ext4_orphan_block_tail (sb, oi->of_binfo[i].ob_bh);if (le32_to_cpu (ot->ob_magic) !=EXT4_ORPHAN_BLOCK_MAGIC ) {ext4_error (sb,"orphan file block %d: bad magic" , i);
@@ -635,8 +637,10 @@ int ext4_init_orphan_info(struct super_block *sb)iput (inode);return 0 ; out_free: -for (i--; i >=0 ; i--) -brelse (oi->of_binfo[i].ob_bh); +while (loaded >0 ) { + loaded--; +brelse (oi->of_binfo[loaded].ob_bh); + }kvfree (oi->of_binfo); out_put:iput (inode);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 613/1815 ext4: check dir entry fits before reading the hash trailer in ext4_search_dir()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit c7e6b863d298f56522d0d08554bbea7f142e6588 ]
For casefolded encrypted directories ext4 stores an 8-byte hash trailer after the name (EXT4_DIRENT_HASHES()), at an offset derived from de->name_len. On the sb_no_casefold_compat_fallback() path ext4_match() reads that trailer, but ext4_search_dir()'s by-hand pre-check only tests de->name + de->name_len <= dlimit, which proves the name fits, not the rounded trailer. A crafted entry whose name ends at the block boundary passes the check while EXT4_DIRENT_HASHES(de) lands past the block end, so ext4_match() reads out of bounds on an ordinary lookup. KASAN reports it as a use-after-free when the page after the directory block holds a freed object:
BUG: KASAN: use-after-free in ext4_match (fs/ext4/namei.c:1435) Read of size 4 at addr ffff888010458000 by task exploit Call Trace: ext4_match (fs/ext4/namei.c:1435) ext4_search_dir (fs/ext4/namei.c:1470) __ext4_find_entry (fs/ext4/namei.c:1268 fs/ext4/namei.c:1632) ext4_lookup (fs/ext4/namei.c:1703 fs/ext4/namei.c:1769) ... filename_lookup (fs/namei.c:2842) vfs_statx (fs/stat.c:353) __do_sys_newfstatat (fs/stat.c:538) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
Require, for hash-in-dirent directories, that the whole entry including the rounded trailer fits before calling ext4_match(). This is the same bound ext4_check_dir_entry() already enforces via ext4_dir_rec_len(), so no well-formed entry is rejected. The other caller, ext4_find_dest_de(), runs ext4_check_dir_entry() first and is unaffected.
--- fs/ext4/namei.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ext4/namei.c +2 -0
@@ -1467,6 +1467,8 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,/* this code is executed quadratically often */ /* do minimal checking `by hand' */ if (de->name + de->name_len <= dlimit && + (!ext4_hash_in_dirent (dir) || + (char *)de +ext4_dir_rec_len (de->name_len, dir) <= dlimit) &&ext4_match (dir, fname, de)) {/* found a match - just to be sure, do * a full check */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 614/1815 ext4: skip tail block zeroing for inline data files
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit 2fff82f081401a61a47e8171f6392d2b0cde5a30 ]
ext4_block_zero_eof() is called from ext4_write_checks() on every append write beyond EOF. For inline data files, ext4_get_block() returns -ERANGE when ext4_load_tail_bh() looks up the tail block. However, this error is currently ignored because the return value of ext4_get_block() in ext4_load_tail_bh() is discarded.
Before we fix ext4_load_tail_bh() to properly propagate the error, skip the zeroing for inline data inodes to avoid unnecessary failures or confusion.
--- fs/ext4/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ext4/inode.c +8 -0
@@ -4234,6 +4234,14 @@ int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end) offset = from & (blocksize -1 );if (!offset || from >= end)return 0 ; +/* +* Inline data has no tail block to zero out. Note that a race with +* ext4_page_mkwrite() converting inline data to an extent without +* holding i_rwsem is safe, as that path zeroes the full block before +* copying in the inline data. +*/ +if (ext4_has_inline_data (inode)) +return 0 ;/* If we are processing an encrypted inode during orphan list handling */ if (IS_ENCRYPTED (inode) && !fscrypt_has_encryption_key (inode))return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 615/1815 ARM: dts: allwinner: a10: Fix PMU interrupt
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Przywara <[email protected]>
[ Upstream commit eb7051f756460d7b951e94d9656e31ebb631ba28 ]
The Performance Monitoring Unit of the Cortex-A8 cores in the Allwinner A10 SoC is connected to interrupt line 66, not 3. This is shown in the manual (where interrupt 3 is assigned to UART2, also in our .dtsi), but has also been confirmed by triggering an PMU overflow interrupt and inspecting the IRQ controller status registers (from U-Boot). Please note that "perf stat" does not use interrupts, this might explain why this evaded the initial testing.
--- arch/arm/boot/dts/allwinner/sun4i-a10.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/allwinner/sun4i-a10.dtsi +1 -1
@@ -185,7 +185,7 @@ de: display-engine { pmu { compatible = "arm,cortex-a8-pmu"; - interrupts = <3>; + interrupts = <66>; }; reserved-memory {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 616/1815 cpufreq: amd-pstate-ut: Skip tests when amd-pstate driver is not active
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianheng Peng <[email protected]>
[ Upstream commit 8d31bb1451643f328db0cea0e21e63ef54b4faf2 ]
The crash issue may occur when modprobe amd_pstate_ut on intel platform.
amd_pstate_ut: 1 amd_pstate_ut_acpi_cpc_valid success!
amd_pstate_ut: 2 amd_pstate_ut_check_enabled success!
BUG: kernel NULL pointer dereference, address: 0000000000000080
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1] SMP NOPTI
CPU: 0 PID: 20300 Comm: modprobe
Kdump: loaded Tainted: G O 6.6.0-0010.rc1.ctl4.x86_64 #1
Hardware name: FiberHome R2200 V5/Xeon Boards, BIOS 3.1a 02/24/2020
RIP: 0010:amd_pstate_ut_check_perf+0x141/0x280 [amd_pstate_ut]
Call Trace:
<TASK>
amd_pstate_ut_init+0x1b/0xff0 [amd_pstate_ut]
? __pfx_amd_pstate_ut_init+0x10/0x10 [amd_pstate_ut]
do_one_initcall+0x42/0x2e0
? kmalloc_trace+0x26/0x90
do_init_module+0x60/0x240
__se_sys_init_module+0x185/0x1c0
do_syscall_64+0x62/0x190
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>Add state detection to amd pstate driver to prevent amd_pstate_ut driver from testing on non-AMD platforms.
(ML: adjust title)
--- drivers/cpufreq/amd-pstate-ut.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/cpufreq/amd-pstate-ut.c +5 -0
@@ -560,6 +560,11 @@ static int amd_pstate_ut_check_freq_attrs(u32 index)static int __init amd_pstate_ut_init (void ) {u32 i =0 , arr_size =ARRAY_SIZE (amd_pstate_ut_cases); +enum amd_pstate_mode mode =amd_pstate_get_status (); + +/* don't test if no running amd-pstate driver */ +if (mode ==AMD_PSTATE_UNDEFINED || mode ==AMD_PSTATE_DISABLE ) +return -EOPNOTSUPP ;for (i =0 ; i < arr_size; i++) {int ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 617/1815 cpufreq/amd-pstate: Fix EPP return type and handle errors during initialization
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Scardovi <[email protected]>
[ Upstream commit 57476909c3000a04e84a1d6018d63ba1b2aa20ab ]
Currently, the EPP getter helper functions (msr_get_epp, shmem_get_epp, and the static call wrapper amd_pstate_get_epp) return u8 or s16. This makes it difficult to correctly propagate negative error values returned by the underlying MSR read or CPPC helpers (such as rdmsrq_on_cpu or cppc_get_epp_perf).
Modify the return type of these functions to int, allowing them to return negative error codes properly.
Additionally, in amd_pstate_epp_cpu_init(), fetch the firmware-programmed default EPP value and validate it before assigning it to the EPP variables. If amd_pstate_get_epp() returns an error code, propagate the error and abort the CPU initialization to prevent subsequent configuration failures.
--- drivers/cpufreq/amd-pstate.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/cpufreq/amd-pstate.c +12 -4
@@ -199,7 +199,7 @@ static inline int get_mode_idx_from_str(const char *str, size_t size)static DEFINE_MUTEX (amd_pstate_driver_lock); -static u8 msr_get_epp (struct amd_cpudata *cpudata) +static int msr_get_epp (struct amd_cpudata *cpudata) {u64 value;int ret;
@@ -215,12 +215,12 @@ static u8 msr_get_epp(struct amd_cpudata *cpudata)DEFINE_STATIC_CALL (amd_pstate_get_epp, msr_get_epp); -static inline s16 amd_pstate_get_epp (struct amd_cpudata *cpudata) +static inline int amd_pstate_get_epp (struct amd_cpudata *cpudata) {return static_call (amd_pstate_get_epp)(cpudata); } -static u8 shmem_get_epp (struct amd_cpudata *cpudata) +static int shmem_get_epp (struct amd_cpudata *cpudata) {u64 epp;int ret;
@@ -1876,6 +1876,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)struct amd_cpudata *cpudata;union perf_cached perf;struct device *dev; +int default_epp;int ret;/*
@@ -1924,6 +1925,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) policy->boost_supported =READ_ONCE (cpudata->boost_supported); +/* Fetch the firmware programmed default EPP value */ + default_epp =amd_pstate_get_epp (cpudata); +if (default_epp <0 ) { + ret = default_epp; + goto free_cpudata1; + } +/* * Set the policy to provide a valid fallback value in case * the default cpufreq governor is neither powersave nor performance.
@@ -1931,7 +1939,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)if (amd_pstate_acpi_pm_profile_server () ||amd_pstate_acpi_pm_profile_undefined ()) { policy->policy =CPUFREQ_POLICY_PERFORMANCE ; - cpudata->epp_default_ac = cpudata->epp_default_dc =amd_pstate_get_epp (cpudata); + cpudata->epp_default_ac = cpudata->epp_default_dc = default_epp; cpudata->current_profile =PLATFORM_PROFILE_PERFORMANCE ; }else { policy->policy =CPUFREQ_POLICY_POWERSAVE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 618/1815 cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Scardovi <[email protected]>
[ Upstream commit 9dfd13f80c856eab79130403a13fa3b83199346b ]
On shared memory systems, the EPP configuration path (handled via cppc_set_epp_perf()) is responsible for toggling on the CPPC autonomous selection register (auto_sel).
Currently, shmem_init_perf() returns early without doing any of the auto_sel configuration steps if cppc_state is AMD_PSTATE_ACTIVE. This skips enabling auto_sel, leaving the CPU in non-autonomous mode.
Remove the early return check in shmem_init_perf() when cppc_state is AMD_PSTATE_ACTIVE. Toggling auto_sel is necessary for the active mode on shared memory systems to function based on the ACPI spec for CPPC v2 and below.
--- drivers/cpufreq/amd-pstate.c | 3 --- 1 file changed, 3 deletions(-)
drivers/cpufreq/amd-pstate.c +0 -3
@@ -526,9 +526,6 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)WRITE_ONCE (cpudata->perf, perf);WRITE_ONCE (cpudata->prefcore_ranking, cppc_perf.highest_perf); -if (cppc_state ==AMD_PSTATE_ACTIVE ) -return 0 ; - ret =cppc_get_auto_sel (cpudata->cpu, &auto_sel);if (ret) {pr_warn ("failed to get auto_sel, ret: %d\n" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 619/1815 cpufreq/amd-pstate: handle missing policy in dynamic EPP callbacks
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: EDAMAMEX <[email protected]>
[ Upstream commit 39c0cf62fc7851a17782e7efe8dfb2948739c681 ]
cpufreq_cpu_get() returns NULL when no cpufreq policy is associated with the requested CPU, for example because the CPU is offline or the policy has already been torn down. Both amd_pstate_power_supply_notifier() and amd_pstate_profile_set() acquire a policy via cpufreq_cpu_get() and then pass that pointer to amd_pstate_get_balanced_epp() and amd_pstate_set_epp(), which dereference it unconditionally. A racing CPU hotplug or driver teardown can therefore lead to a NULL pointer dereference on either of these dynamic EPP paths.
The third cpufreq_cpu_get() caller in this file, amd_pstate_verify(), already handles the NULL case. Bring the two new callers in line with that pattern: return NOTIFY_OK from the power-supply notifier (matching the other "nothing to do" exits) and -ENODEV from amd_pstate_profile_set() (the usual cpufreq error for a missing CPU policy).
Found by code inspection; not tested on hardware.
--- drivers/cpufreq/amd-pstate.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/cpufreq/amd-pstate.c +6 -0
@@ -1170,6 +1170,9 @@ static int amd_pstate_power_supply_notifier(struct notifier_block *nb,if (cpudata->current_profile !=PLATFORM_PROFILE_BALANCED )return 0 ; +if (!policy) +return NOTIFY_OK ; + epp =amd_pstate_get_balanced_epp (policy); ret =amd_pstate_set_epp (policy, epp);
@@ -1205,6 +1208,9 @@ static int amd_pstate_profile_set(struct device *dev, struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpudata->cpu);int ret; +if (!policy) +return -ENODEV ; +switch (profile) {case PLATFORM_PROFILE_LOW_POWER : ret =amd_pstate_set_epp (policy,AMD_CPPC_EPP_POWERSAVE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 620/1815 firmware: arm_scmi: Roll back partial protocol table registration
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 2224b622260ba590ab56ea1585d6bf7610be25b2 ]
scmi_protocol_table_register() can leave earlier requests registered when a later entry in the same ID table fails. Each request retains a pointer to the driver's ID table, so a failed module load can leave a dangling pointer after the module storage is released.
Unrequest only the successfully registered prefix, in reverse order, before returning the failure. Leave the failed entry and the remaining entries untouched because matching requests can be owned by another driver.
--- drivers/firmware/arm_scmi/bus.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/firmware/arm_scmi/bus.c +20 -11
@@ -135,17 +135,6 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table)return ret; } -static int scmi_protocol_table_register (const struct scmi_device_id *id_table) -{ -int ret =0 ; -const struct scmi_device_id *entry; - -for (entry = id_table; entry->name && ret ==0 ; entry++) - ret =scmi_protocol_device_request (entry); - -return ret; -} -/** * scmi_protocol_device_unrequest - Helper to unrequest a device *
@@ -191,6 +180,26 @@ static void scmi_protocol_device_unrequest(const struct scmi_device_id *id_table } } +static int scmi_protocol_table_register (const struct scmi_device_id *id_table) +{ +const struct scmi_device_id *entry; +int ret; + +for (entry = id_table; entry->name; entry++) { + ret =scmi_protocol_device_request (entry); +if (ret) + goto err_unrequest; + } + +return 0 ; + +err_unrequest: +while (entry != id_table) +scmi_protocol_device_unrequest (--entry); + +return ret; +} +static void scmi_protocol_table_unregister (const struct scmi_device_id *id_table) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 621/1815 firmware: arm_scmi: Unrequest devices if driver registration fails
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
[ Upstream commit 9f7cd6a62aa754ed6b48cbd5d50de40add1bcc86 ]
scmi_driver_register() requests protocol devices before registering the driver. If driver_register() fails, those requests remain in the global IDR and retain pointers to the module's ID table. Once the failed module load releases that storage, later request matching or SCMI device creation can dereference the stale pointers.
Unrequest the complete protocol table before returning the registration failure. At this point table registration succeeded, so every entry is owned by the current registration attempt.
--- drivers/firmware/arm_scmi/bus.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/firmware/arm_scmi/bus.c +7 -3
@@ -395,10 +395,14 @@ int scmi_driver_register(struct scmi_driver *driver, struct module *owner, driver->driver.mod_name = mod_name; retval =driver_register (&driver->driver); -if (!retval) -pr_debug ("Registered new scmi driver %s\n" , driver->name); +if (retval) { +scmi_protocol_table_unregister (driver->id_table); +return retval; + } -return retval; +pr_debug ("Registered new scmi driver %s\n" , driver->name); + +return 0 ; }EXPORT_SYMBOL_GPL (scmi_driver_register);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 622/1815 bitmap: Properly initialise destination bitmap for scatter & gather test
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy (CS GROUP) <[email protected]>
[ Upstream commit 36f78b0dfa7df4892ba067ccf00d95a4513b4935 ]
Erhard reports failure of bitmap tests on powerpc:
test_bitmap: loaded.
test_bitmap: [lib/test_bitmap.c:397] bitmaps contents differ: expected "1,3-4,9", got "1,3-4,9,65-71,73-79,81-87,89-95,97-99"
test_bitmap: parselist('0-2047:128/256'): 912
test_bitmap: scnprintf("%*pbl", '0-32767'): 5977
test_bitmap: test_bitmap_read_perf: 1191082
test_bitmap: test_bitmap_write_perf: 1270153
test_bitmap: failed 1 out of 208655 tests
It happens mainly when CONFIG_INIT_STACK_ALL_PATTERN is set.
Commit 6b5a4b687367 ("bitmap: Add test for out-of-boundary modifications for scatter & gather") extended the test to out-of-boundary bits, but those bits were left uninitialised.
Properly initialise the entire result bitmap before the test.
[Yury: minor commit message tweaks]
--- lib/test_bitmap.c | 1 + 1 file changed, 1 insertion(+)
lib/test_bitmap.c +1 -0
@@ -392,6 +392,7 @@ static void __init test_bitmap_sg(void)/* Scatter/gather relationship */ bitmap_zero (bmap_tmp,100 ); +bitmap_zero (bmap_res,100 );bitmap_gather (bmap_tmp, bmap_scatter, sg_mask, nbits);bitmap_scatter (bmap_res, bmap_tmp, sg_mask, nbits);expect_eq_bitmap (bmap_scatter, bmap_res,100 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 623/1815 riscv: dts: spacemit: set console baud rate on K3 Pico-ITX board
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aurelien Jarno <[email protected]>
[ Upstream commit 788ed93b3b85baa3b5817655ce621ff1f6c300e9 ]
Because the default console's baud rate is not set, defconfig kernels do not have any serial output on this platform. Set the baud rate to 115200, matching what is used by U-Boot etc on this platform.
--- arch/riscv/boot/dts/spacemit/k3-pico-itx.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +1 -1
@@ -18,7 +18,7 @@ aliases { }; chosen { - stdout-path = "serial0"; + stdout-path = "serial0:115200n8"; }; memory@100000000 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 624/1815 riscv: dts: spacemit: k1: Split gmac_clk_ref into independent pinctrl groups
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junhui Liu <[email protected]>
[ Upstream commit 8270311d70fdf36bc8aab1e52b554e654a8839ff ]
The gmac_clk_ref signal is optional for the GMAC controller and is not strictly required for all hardware designs. The pins for gmac0_clk_ref (GPIO 45) and gmac1_clk_ref (GPIO 46) may also be used as GPIOs for other functions even when the Ethernet controller is active.
Split the refclk pins into independent pinctrl groups so boards can request them only when the reference clock path is actually needed.
Among the already mainlined boards, BPI-F3, Jupiter and MusePi Pro have optional hardware paths for the GMAC refclk pins. BPI-F3 and Jupiter route both GMAC refclk pins to the PHYs through NC/0R option resistors, while MusePi Pro only does so for GMAC0. Keep referencing the new clk-ref pinctrl groups on these boards so the optional hardware paths remain usable if the option resistors are populated.
OrangePi R2S has no publicly available schematic, so also keep the clk-ref groups there to preserve the previous pinmux behavior.
--- .../boot/dts/spacemit/k1-bananapi-f3.dts | 4 ++-- .../boot/dts/spacemit/k1-milkv-jupiter.dts | 4 ++-- .../riscv/boot/dts/spacemit/k1-musepi-pro.dts | 2 +- .../boot/dts/spacemit/k1-orangepi-r2s.dts | 4 ++-- arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 24 +++++++++++++++---- 5 files changed, 27 insertions(+), 11 deletions(-)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +2 -2
@@ -101,7 +101,7 @@ ð0 { phy-handle = <&rgmii0>; phy-mode = "rgmii-id"; pinctrl-names = "default"; - pinctrl-0 = <&gmac0_cfg>; + pinctrl-0 = <&gmac0_cfg>, <&gmac0_clk_ref_cfg>; rx-internal-delay-ps = <0>; tx-internal-delay-ps = <0>; status = "okay";
@@ -124,7 +124,7 @@ ð1 { phy-handle = <&rgmii1>; phy-mode = "rgmii-id"; pinctrl-names = "default"; - pinctrl-0 = <&gmac1_cfg>; + pinctrl-0 = <&gmac1_cfg>, <&gmac1_clk_ref_cfg>; rx-internal-delay-ps = <0>; tx-internal-delay-ps = <250>; status = "okay";
arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts +2 -2
@@ -121,7 +121,7 @@ ð0 { phy-handle = <&rgmii0>; phy-mode = "rgmii-id"; pinctrl-names = "default"; - pinctrl-0 = <&gmac0_cfg>; + pinctrl-0 = <&gmac0_cfg>, <&gmac0_clk_ref_cfg>; rx-internal-delay-ps = <0>; tx-internal-delay-ps = <0>; status = "okay";
@@ -144,7 +144,7 @@ ð1 { phy-handle = <&rgmii1>; phy-mode = "rgmii-id"; pinctrl-names = "default"; - pinctrl-0 = <&gmac1_cfg>; + pinctrl-0 = <&gmac1_cfg>, <&gmac1_clk_ref_cfg>; rx-internal-delay-ps = <0>; tx-internal-delay-ps = <250>; status = "okay";
arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts +1 -1
@@ -102,7 +102,7 @@ &combo_phy { ð0 { phy-handle = <&rgmii0>; phy-mode = "rgmii-id"; - pinctrl-0 = <&gmac0_cfg>; + pinctrl-0 = <&gmac0_cfg>, <&gmac0_clk_ref_cfg>; pinctrl-names = "default"; rx-internal-delay-ps = <0>; tx-internal-delay-ps = <0>;
arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts +2 -2
@@ -60,7 +60,7 @@ ð0 { phy-handle = <&rgmii0>; phy-mode = "rgmii-id"; pinctrl-names = "default"; - pinctrl-0 = <&gmac0_cfg>; + pinctrl-0 = <&gmac0_cfg>, <&gmac0_clk_ref_cfg>; rx-internal-delay-ps = <0>; tx-internal-delay-ps = <0>; status = "okay";
@@ -84,7 +84,7 @@ ð1 { phy-handle = <&rgmii1>; phy-mode = "rgmii-id"; pinctrl-names = "default"; - pinctrl-0 = <&gmac1_cfg>; + pinctrl-0 = <&gmac1_cfg>, <&gmac1_clk_ref_cfg>; rx-internal-delay-ps = <0>; tx-internal-delay-ps = <250>; status = "okay";
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi +20 -4
@@ -27,8 +27,16 @@ gmac0-pins { <K1_PADCONF(11, 1)>, /* gmac0_tx_en */ <K1_PADCONF(12, 1)>, /* gmac0_mdc */ <K1_PADCONF(13, 1)>, /* gmac0_mdio */ - <K1_PADCONF(14, 1)>, /* gmac0_int_n */ - <K1_PADCONF(45, 1)>; /* gmac0_clk_ref */ + <K1_PADCONF(14, 1)>; /* gmac0_int_n */ + + bias-pull-up = <0>; + drive-strength = <21>; + }; + }; + + gmac0_clk_ref_cfg: gmac0-clk-ref-cfg { + gmac0-clk-ref-pins { + pinmux = <K1_PADCONF(45, 1)>; /* gmac0_clk_ref */ bias-pull-up = <0>; drive-strength = <21>;
@@ -51,8 +59,16 @@ gmac1-pins { <K1_PADCONF(40, 1)>, /* gmac1_tx_en */ <K1_PADCONF(41, 1)>, /* gmac1_mdc */ <K1_PADCONF(42, 1)>, /* gmac1_mdio */ - <K1_PADCONF(43, 1)>, /* gmac1_int_n */ - <K1_PADCONF(46, 1)>; /* gmac1_clk_ref */ + <K1_PADCONF(43, 1)>; /* gmac1_int_n */ + + bias-pull-up = <0>; + drive-strength = <21>; + }; + }; + + gmac1_clk_ref_cfg: gmac1-clk-ref-cfg { + gmac1-clk-ref-pins { + pinmux = <K1_PADCONF(46, 1)>; /* gmac1_clk_ref */ bias-pull-up = <0>; drive-strength = <21>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 625/1815 riscv: dts: thead: th1520: remove pclk for I2C1
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Icenowy Zheng <[email protected]>
[ Upstream commit 5ed8cdb56cd90859e0c7f269b4a7c2b1571419b2 ]
The I2C1 node added previously to the th1520.dtsi file has two clocks set -- one "ref" clock (CLK_I2C1) and one "pclk" (CLK_PERI_APB_PCLK).
However, the CLK_I2C1 clock is just a clock gate with the CLK_PERI_APB_PCLK clock as its input. In addition, when it's gated, reading registers from the I2C controller returns fixed value (the last read value) for all registers. These facts indicate that the CLK_I2C1 clock is the true APB clock fed into the I2C controller instead of a dedicated reference clock.
Leave only the CLK_I2C1 clock as the clocks property of the I2C1 device node and remove clock-names property, which represents the I2C controller only takes a single clock both as the APB clock and the reference clock.
--- arch/riscv/boot/dts/thead/th1520.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/riscv/boot/dts/thead/th1520.dtsi +1 -2
@@ -415,8 +415,7 @@ i2c1: i2c@ffe7f24000 { compatible = "thead,th1520-i2c", "snps,designware-i2c"; reg = <0xff 0xe7f24000 0x0 0x4000>; interrupts = <45 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk CLK_I2C1>, <&clk CLK_PERI_APB_PCLK>; - clock-names = "ref", "pclk"; + clocks = <&clk CLK_I2C1>; #address-cells = <1>; #size-cells = <0>; status = "disabled";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 626/1815 gpu: nova-core: correct RISC-V HALTED field
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eliot Courtney <[email protected]>
[ Upstream commit 5557c238eb0f97169edda1d0776207e3d61f4f16 ]
This uses the incorrect value, so update it.
--- drivers/gpu/nova-core/regs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/nova-core/regs.rs +1 -1
@@ -570,7 +570,7 @@ register! {/// GA102 and later. pub(crate) NV_PRISCV_RISCV_CPUCTL(u32) @ PFalcon2Base + 0x00000388 { 7:7 active_stat => bool; - 0:0 halted => bool; + 4:4 halted => bool; }/// GA102 and later.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 627/1815 perf cs-etm: Flush thread stacks after decoder reset
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit ea5075e3776846d4941dddf1549426ebd3feb81f ]
Perf resets the CoreSight decoder when moving to a new AUX trace buffer, this causes trace discontinunity globally.
For callchain synthesis, keeping thread-stack state after decoder reset can leave stale call/return history attached to threads that are decoded later, producing incorrect synthesized callchains.
Flush all host thread stacks after a decoder reset. When virtualization is present, flush the guest thread stacks as well.
Stable-dep-of: ec99be8a31db ("perf cs-etm: Avoid truncating AUX buffer sizes to int")
--- tools/perf/util/cs-etm.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
tools/perf/util/cs-etm.c +45 -0
@@ -2089,6 +2089,45 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq,return 0 ; } + +static int cs_etm__flush_stack_cb (struct thread *thread, +void *data__maybe_unused ) +{ +thread_stack__flush (thread); +return 0 ; +} + +static void cs_etm__flush_machine_stack (struct cs_etm_queue *etmq,pid_t pid) +{ +struct machine *machine; + + machine =machines__find (&etmq->etm->session->machines, pid); +if (machine) +machine__for_each_thread (machine, cs_etm__flush_stack_cb,NULL ); +} + +static void cs_etm__flush_all_stack (struct cs_etm_queue *etmq) +{ +enum cs_etm_pid_fmt pid_fmt =cs_etm__get_pid_fmt (etmq); + +if (!etmq->etm->synth_opts.last_branch) +return ; + +switch (pid_fmt) { +case CS_ETM_PIDFMT_CTXTID2 : +/* Clear the guest stack if virtualization is supported */ +cs_etm__flush_machine_stack (etmq,DEFAULT_GUEST_KERNEL_ID ); + fallthrough; +case CS_ETM_PIDFMT_CTXTID : +cs_etm__flush_machine_stack (etmq,HOST_KERNEL_ID ); +break ; +case CS_ETM_PIDFMT_NONE : +default : +break ; + + } +} +/* * cs_etm__get_data_block: Fetch a block from the auxtrace_buffer queue * if need be.
@@ -2111,6 +2150,12 @@ static int cs_etm__get_data_block(struct cs_etm_queue *etmq) ret =cs_etm_decoder__reset (etmq->decoder);if (ret)return ret; + +/* +* Since the decoder is reset, this causes a global trace +* discontinuity. Flush all thread stacks. +*/ +cs_etm__flush_all_stack (etmq); }return etmq->buf_len;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 628/1815 perf cs-etm: Avoid truncating AUX buffer sizes to int
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit ec99be8a31db999a4f866be74ea7db61dbb19f24 ]
cs_etm__get_trace() returns an int, but it used to return etmq->buf_len on success. That value comes from auxtrace_buffer::size, which is a size_t. For a large AUX trace block, returning the byte count through an int can overflow and make a valid buffer look like a negative error.
The callers do not need the actual byte count from cs_etm__get_trace(). The buffer length is already stored in the etmq->buf_len. The callers only need to distinguish three states:
< 0: error
= 0: no more AUX buffers
Quoted 1 line
0: data is available
Make cs_etm__get_trace() return 0 for all non-error cases and use etmq->buf_len to indicate whether a new buffer was found. Then make cs_etm__get_data_block() return 1 whenever data is available, instead of returning the buffer length.
Also refactor cs_etm__get_data_block() to make its return value semantics clearer.
--- tools/perf/util/cs-etm.c | 46 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-)
tools/perf/util/cs-etm.c +26 -20
@@ -1528,8 +1528,7 @@ cs_etm__get_trace(struct cs_etm_queue *etmq) etmq->buf_used =0 ; etmq->buf_len = aux_buffer->size; etmq->buf = aux_buffer->data; - -return etmq->buf_len; +return 0 ; }/*
@@ -2139,26 +2138,33 @@ static int cs_etm__get_data_block(struct cs_etm_queue *etmq) {int ret; -if (!etmq->buf_len) { - ret =cs_etm__get_trace (etmq); -if (ret <=0 ) -return ret; -/* -* We cannot assume consecutive blocks in the data file -* are contiguous, reset the decoder to force re-sync. -*/ - ret =cs_etm_decoder__reset (etmq->decoder); -if (ret) -return ret; +/* The current block is not finished */ +if (etmq->buf_len) +return 1 ; -/* -* Since the decoder is reset, this causes a global trace -* discontinuity. Flush all thread stacks. -*/ -cs_etm__flush_all_stack (etmq); - } + ret =cs_etm__get_trace (etmq); +if (ret <0 ) +return ret; + +/* No more buffer to read */ +if (!etmq->buf_len) +return 0 ; + +/* +* We cannot assume consecutive blocks in the data file +* are contiguous, reset the decoder to force re-sync. +*/ + ret =cs_etm_decoder__reset (etmq->decoder); +if (ret) +return ret; + +/* +* Since the decoder is reset, this causes a global trace +* discontinuity. Flush all thread stacks. +*/ +cs_etm__flush_all_stack (etmq); -return etmq->buf_len; +return 1 ; } static bool cs_etm__is_svc_instr(struct cs_etm_queue *etmq,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 629/1815 xfrm: Fix skb double-free in xfrm_dev_direct_output()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit 2aed51fc58d9ce450e2c116efb956160fd06fa02 ]
A return value other than 1 from local_out() means that the skb has been consumed or its ownership was transferred. xfrm_dev_direct_output() nevertheless frees the skb on this path, causing a double-free when netfilter drops the packet and invalidating any other owner.
Return the local_out() result directly, matching the ownership handling in xfrm_output_resume().
--- net/xfrm/xfrm_output.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/xfrm/xfrm_output.c +1 -3
@@ -636,10 +636,8 @@ static int xfrm_dev_direct_output(struct sock *sk, struct xfrm_state *x,nf_reset_ct (skb); err =skb_dst (skb)->ops->local_out (net, sk, skb); -if (unlikely (err !=1 )) { -kfree_skb (skb); +if (unlikely (err !=1 ))return err; - }/* In transport mode, network destination is * directly reachable, while in tunnel mode,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 630/1815 RDMA/erdma: complete object teardown when the destroy command fails
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 652befcba956ef357f480525ccbe25c59bc81d4d ]
erdma_destroy_qp(), erdma_destroy_cq(), erdma_dereg_mr(), and erdma_destroy_ah() returned early when erdma_post_cmd_wait() failed, leaking the queue buffers, MTTs, doorbells and the STAG, QPN, CQN and AHN identifiers. A command timeout clears ERDMA_CMDQ_STATE_OK_BIT and permanently disables the command queue, so no retry can succeed; the RDMA core keeps the object after a failed destructor and forced uverbs cleanup then nulls the pointers, making the resources unreachable.
Warn on failure but release every software-owned resource and return success, since during terminal destruction the hardware command result is only diagnostic.
--- drivers/infiniband/hw/erdma/erdma_verbs.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/infiniband/hw/erdma/erdma_verbs.c +17 -4
@@ -1304,8 +1304,15 @@ int erdma_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) ret =erdma_post_cmd_wait (&dev->cmdq, &req,sizeof (req),NULL ,NULL , true); +/* +* A timeout disables the command queue, so retry cannot succeed. Treat +* terminal command failures as diagnostic; propagating them can make +* forced uverbs cleanup discard the last software resource pointers. +*/ if (ret) -return ret; +ibdev_warn_ratelimited (&dev->ibdev, +"failed to deregister MR 0x%x: %d\n" , + ibmr->lkey, ret);erdma_free_idx (&dev->res_cb[ERDMA_RES_TYPE_STAG_IDX ], ibmr->lkey >>8 );
@@ -1331,7 +1338,9 @@ int erdma_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) err =erdma_post_cmd_wait (&dev->cmdq, &req,sizeof (req),NULL ,NULL , true);if (err) -return err; +ibdev_warn_ratelimited (&dev->ibdev, +"failed to destroy CQ %u: %d\n" , + cq->cqn, err);if (rdma_is_kernel_res (&cq->ibcq.res)) { dma_free_coherent(&dev->pdev->dev, cq->depth << CQE_SHIFT,
@@ -1379,7 +1388,9 @@ int erdma_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) err =erdma_post_cmd_wait (&dev->cmdq, &req,sizeof (req),NULL ,NULL , true);if (err) -return err; +ibdev_warn_ratelimited (&dev->ibdev, +"failed to destroy QP %u: %d\n" , +QP_ID (qp), err);erdma_qp_put (qp);wait_for_completion (&qp->safe_free);
@@ -2281,7 +2292,9 @@ int erdma_destroy_ah(struct ib_ah *ibah, u32 flags) ret =erdma_post_cmd_wait (&dev->cmdq, &req,sizeof (req),NULL ,NULL , flags &RDMA_DESTROY_AH_SLEEPABLE );if (ret) -return ret; +ibdev_warn_ratelimited (&dev->ibdev, +"failed to destroy AH %u: %d\n" , + ah->ahn, ret);erdma_free_idx (&dev->res_cb[ERDMA_RES_TYPE_AH ], ah->ahn);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 631/1815 PM: hibernate: Fix memory leak in snapshot_write_next() error path
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Malaya Kumar Rout <[email protected]>
[ Upstream commit 21d5c4cee31c5ce78f6decc7fafc7e7759af391f ]
When memory_bm_create() succeeds for copy_bm but fails for zero_bm, the function returns without freeing the resources allocated for copy_bm. This results in a memory leak that includes radix tree nodes, zone structures, and page lists.
Fix this by calling memory_bm_free() to release copy_bm's resources before returning the error code when zero_bm allocation fails.
--- kernel/power/snapshot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/power/snapshot.c +3 -2
@@ -2797,9 +2797,10 @@ int snapshot_write_next(struct snapshot_handle *handle)return error; error =memory_bm_create (&zero_bm,GFP_ATOMIC ,PG_ANY ); -if (error) +if (error) { +memory_bm_free (©_bm,PG_UNSAFE_CLEAR );return error; - + } nr_zero_pages =0 ;hibernate_restore_protection_begin ();
Signature · 1 line
2.53.0