5.15.209-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 116/776 tty: n_gsm: fix deadlock and link starvation in outgoing data path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Starke <[email protected]>
[ Upstream commit 0af021678d5d30c31f5a6b631f404ead3575212a ]
The current implementation queues up new control and user packets as needed and processes this queue down to the ldisc in the same code path. That means that the upper and the lower layer are hard coupled in the code. Due to this deadlocks can happen as seen below while transmitting data, especially during ldisc congestion. Furthermore, the data channels starve the control channel on high transmission load on the ldisc.
Introduce an additional control channel data queue to prevent timeouts and link hangups during ldisc congestion. This is being processed before the user channel data queue in gsm_data_kick(), i.e. with the highest priority. Put the queue to ldisc data path into a workqueue and trigger it whenever new data has been put into the transmission queue. Change gsm_dlci_data_sweep() accordingly to fill up the transmission queue until TX_THRESH_HI. This solves the locking issue, keeps latency low and provides good performance on high data load.
Note that now all packets from a DLCI are removed from the internal queue if the associated DLCI was closed. This ensures that no data is sent by the introduced write task to an already closed DLCI.
BUG: spinlock recursion on CPU#0, test_v24_loop/124 lock: serial8250_ports+0x3a8/0x7500, .magic: dead4ead, .owner: test_v24_loop/124, .owner_cpu: 0 CPU: 0 PID: 124 Comm: test_v24_loop Tainted: G O 5.18.0-rc2 #3 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 Call Trace: <IRQ> dump_stack_lvl+0x34/0x44 do_raw_spin_lock+0x76/0xa0 _raw_spin_lock_irqsave+0x72/0x80 uart_write_room+0x3b/0xc0 gsm_data_kick+0x14b/0x240 [n_gsm] gsmld_write_wakeup+0x35/0x70 [n_gsm] tty_wakeup+0x53/0x60 tty_port_default_wakeup+0x1b/0x30 serial8250_tx_chars+0x12f/0x220 serial8250_handle_irq.part.0+0xfe/0x150 serial8250_default_handle_irq+0x48/0x80 serial8250_interrupt+0x56/0xa0 __handle_irq_event_percpu+0x78/0x1f0 handle_irq_event+0x34/0x70 handle_fasteoi_irq+0x90/0x1e0 __common_interrupt+0x69/0x100 common_interrupt+0x48/0xc0 asm_common_interrupt+0x1e/0x40 RIP: 0010:__do_softirq+0x83/0x34e Code: 2a 0a ff 0f b7 ed c7 44 24 10 0a 00 00 00 48 c7 c7 51 2a 64 82 e8 2d
e2 d5 ff 65 66 c7 05 83 af 1e 7e 00 00 fb b8 ff ff ff ff <49> c7 c2 40 61 80 82 0f bc c5 41 89 c4 41 83 c4 01 0f 84 e6 00 00
RSP: 0018:ffffc90000003f98 EFLAGS: 00000286
RAX: 00000000ffffffff RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff82642a51 RDI: ffffffff825bb5e7
RBP: 0000000000000200 R08: 00000008de3271a8 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000030 R14: 0000000000000000 R15: 0000000000000000
? __do_softirq+0x73/0x34e irq_exit_rcu+0xb5/0x100 common_interrupt+0xa4/0xc0 </IRQ> <TASK> asm_common_interrupt+0x1e/0x40 RIP: 0010:_raw_spin_unlock_irqrestore+0x2e/0x50 Code: 00 55 48 89 fd 48 83 c7 18 53 48 89 f3 48 8b 74 24 10 e8 85 28 36 ff
48 89 ef e8 cd 58 36 ff 80 e7 02 74 01 fb bf 01 00 00 00 <e8> 3d 97 33 ff 65 8b 05 96 23 2b 7e 85 c0 74 03 5b 5d c3 0f 1f 44
RSP: 0018:ffffc9000020fd08 EFLAGS: 00000202
RAX: 0000000000000000 RBX: 0000000000000246 RCX: 0000000000000000
RDX: 0000000000000004 RSI: ffffffff8257fd74 RDI: 0000000000000001
RBP: ffff8880057de3a0 R08: 00000008de233000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000100 R14: 0000000000000202 R15: ffff8880057df0b8
? _raw_spin_unlock_irqrestore+0x23/0x50 gsmtty_write+0x65/0x80 [n_gsm] n_tty_write+0x33f/0x530 ? swake_up_all+0xe0/0xe0 file_tty_write.constprop.0+0x1b1/0x320 ? n_tty_flush_buffer+0xb0/0xb0 new_sync_write+0x10c/0x190 vfs_write+0x282/0x310 ksys_write+0x68/0xe0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f3e5e35c15c Code: 8b 7c 24 08 89 c5 e8 c5 ff ff ff 89 ef 89 44 24 08 e8 58 bc 02 00 8b
44 24 08 48 83 c4 10 5d c3 48 63 ff b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 76 10 48 8b 15 fd fc 05 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffcee77cd18 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007ffcee77cd70 RCX: 00007f3e5e35c15c
RDX: 0000000000000100 RSI: 00007ffcee77cd90 RDI: 0000000000000003
RBP: 0000000000000100 R08: 0000000000000000 R09: 7efefefefefefeff
R10: 00007f3e5e3bddeb R11: 0000000000000246 R12: 00007ffcee77ce8f
R13: 0000000000000001 R14: 000056214404e010 R15: 00007ffcee77cd90
</TASK>
[ The context change is due to the commit a8c5b8255f8a ("tty: n_gsm: fix broken virtual tty handling") in v5.18 which is irrelevant to the logic of this patch. ]
--- drivers/tty/n_gsm.c | 403 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 279 insertions(+), 124 deletions(-)
drivers/tty/n_gsm.c +279 -124
@@ -5,6 +5,14 @@* * * THIS IS A DEVELOPMENT SNAPSHOT IT IS NOT A FINAL RELEASE * * +* Outgoing path: +* tty -> DLCI fifo -> scheduler -> GSM MUX data queue ---o-> ldisc +* control message -> GSM MUX control queue --´ +* +* Incoming path: +* ldisc -> gsm_queue() -o--> tty +* `-> gsm_control_response() +* * TO DO: * Mostly done: ioctls for setting modes/timing * Partly done: hooks so you can pull off frames to non tty devs
@@ -212,6 +220,9 @@ struct gsm_mux {/* Events on the GSM channel */ wait_queue_head_t event; +/* ldisc send work */ +struct work_struct tx_work; +/* Bits for GSM mode decoding */ /* Framing Layer */
@@ -243,7 +254,8 @@ struct gsm_mux {unsigned int tx_bytes;/* TX data outstanding */ #define TX_THRESH_HI 8192#define TX_THRESH_LO 2048 -struct list_head tx_list;/* Pending data packets */ +struct list_head tx_ctrl_list;/* Pending control packets */ +struct list_head tx_data_list;/* Pending data packets */ /* Control messages */ struct timer_list kick_timer;/* Kick TX queuing on timeout */
@@ -377,6 +389,11 @@ static const u8 gsm_fcs8[256] = {static int gsmld_output (struct gsm_mux *gsm,u8 *data,int len);static int gsm_modem_update (struct gsm_dlci *dlci,u8 brk); +static struct gsm_msg *gsm_data_alloc (struct gsm_mux *gsm,u8 addr,int len, +u8 ctrl); +static int gsm_send_packet (struct gsm_mux *gsm,struct gsm_msg *msg); +static void gsmld_write_trigger (struct gsm_mux *gsm); +static void gsmld_write_task (struct work_struct *work);/** * gsm_fcs_add - update FCS
@@ -661,53 +678,73 @@ static int gsm_stuff_frame(const u8 *inp* @cr: command/response bit seen as initiator * @control: control byte including PF bit * -* Format up and transmit a control frame. These do not go via the -* queueing logic as they should be transmitted ahead of data when -* they are needed. -* -* FIXME: Lock versus data TX path +* Format up and transmit a control frame. These should be transmitted +* ahead of data when they are needed. */ - -static void gsm_send (struct gsm_mux *gsm,int addr,int cr,int control) +static int gsm_send (struct gsm_mux *gsm,int addr,int cr,int control) { -int len; -u8 cbuf[10 ]; -u8 ibuf[3 ]; +struct gsm_msg *msg; +u8 *dp;int ocr; +unsigned long flags; + + msg =gsm_data_alloc (gsm, addr,0 , control); +if (!msg) +return -ENOMEM ;/* toggle C/R coding if not initiator */ ocr = cr ^ (gsm->initiator ?0 :1 ); -switch (gsm->encoding) { -case 0 : - cbuf[0 ] =GSM0_SOF ; - cbuf[1 ] = (addr <<2 ) | (ocr <<1 ) |EA ; - cbuf[2 ] = control; - cbuf[3 ] =EA ;/* Length of data = 0 */ - cbuf[4 ] =0xFF -gsm_fcs_add_block (INIT_FCS , cbuf +1 ,3 ); - cbuf[5 ] =GSM0_SOF ; - len =6 ; -break ; -case 1 : -case 2 : -/* Control frame + packing (but not frame stuffing) in mode 1 */ - ibuf[0 ] = (addr <<2 ) | (ocr <<1 ) |EA ; - ibuf[1 ] = control; - ibuf[2 ] =0xFF -gsm_fcs_add_block (INIT_FCS , ibuf,2 ); -/* Stuffing may double the size worst case */ - len =gsm_stuff_frame (ibuf, cbuf +1 ,3 ); -/* Now add the SOF markers */ - cbuf[0 ] =GSM1_SOF ; - cbuf[len +1 ] =GSM1_SOF ; -/* FIXME: we can omit the lead one in many cases */ - len +=2 ; -break ; -default : -WARN_ON (1 ); -return ; + msg->data -=3 ; + dp = msg->data; + *dp++ = (addr <<2 ) | (ocr <<1 ) |EA ; + *dp++ = control; + +if (gsm->encoding ==0 ) + *dp++ =EA ;/* Length of data = 0 */ + + *dp =0xFF -gsm_fcs_add_block (INIT_FCS , msg->data, dp - msg->data); + msg->len = (dp - msg->data) +1 ; + +gsm_print_packet ("Q->" , addr, cr, control,NULL ,0 ); + +spin_lock_irqsave (&gsm->tx_lock, flags); +list_add_tail (&msg->list, &gsm->tx_ctrl_list); + gsm->tx_bytes += msg->len; +spin_unlock_irqrestore (&gsm->tx_lock, flags); +gsmld_write_trigger (gsm); + +return 0 ; +} + +/** +* gsm_dlci_clear_queues - remove outstanding data for a DLCI +* @gsm: mux +* @dlci: clear for this DLCI +* +* Clears the data queues for a given DLCI. +*/ +static void gsm_dlci_clear_queues (struct gsm_mux *gsm,struct gsm_dlci *dlci) +{ +struct gsm_msg *msg, *nmsg; +int addr = dlci->addr; +unsigned long flags; + +/* Clear DLCI write fifo first */ +spin_lock_irqsave (&dlci->lock, flags); +kfifo_reset (&dlci->fifo); +spin_unlock_irqrestore (&dlci->lock, flags); + +/* Clear data packets in MUX write queue */ +spin_lock_irqsave (&gsm->tx_lock, flags); +list_for_each_entry_safe (msg, nmsg, &gsm->tx_data_list, list) { +if (msg->addr != addr) +continue ; + gsm->tx_bytes -= msg->len; +list_del (&msg->list); +kfree (msg); } -gsmld_output (gsm, cbuf, len); -gsm_print_packet ("-->" , addr, cr, control,NULL ,0 ); +spin_unlock_irqrestore (&gsm->tx_lock, flags); }/**
@@ -770,6 +807,45 @@ static struct gsm_msg *gsm_data_alloc(st }/** +* gsm_send_packet - sends a single packet +* @gsm: GSM Mux +* @msg: packet to send +* +* The given packet is encoded and sent out. No memory is freed. +* The caller must hold the gsm tx lock. +*/ +static int gsm_send_packet (struct gsm_mux *gsm,struct gsm_msg *msg) +{ +int len, ret; + + +if (gsm->encoding ==0 ) { + gsm->txframe[0 ] =GSM0_SOF ; +memcpy (gsm->txframe +1 , msg->data, msg->len); + gsm->txframe[msg->len +1 ] =GSM0_SOF ; + len = msg->len +2 ; + }else { + gsm->txframe[0 ] =GSM1_SOF ; + len =gsm_stuff_frame (msg->data, gsm->txframe +1 , msg->len); + gsm->txframe[len +1 ] =GSM1_SOF ; + len +=2 ; + } + +if (debug &4 ) +gsm_hex_dump_bytes (__func__, gsm->txframe, len); +gsm_print_packet ("-->" , msg->addr, gsm->initiator, msg->ctrl, msg->data, + msg->len); + + ret =gsmld_output (gsm, gsm->txframe, len); +if (ret <=0 ) +return ret; +/* FIXME: Can eliminate one SOF in many more cases */ + gsm->tx_bytes -= msg->len; + +return 0 ; +} + +/** * gsm_is_flow_ctrl_msg - checks if flow control message * @msg: message to check *
@@ -801,59 +877,81 @@ static bool gsm_is_flow_ctrl_msg(struct }/** -* gsm_data_kick - poke the queue +* gsm_data_kick - poke the queue * @gsm: GSM Mux -* @dlci: DLCI sending the data * * The tty device has called us to indicate that room has appeared in -* the transmit queue. Ram more data into the pipe if we have any +* the transmit queue. Ram more data into the pipe if we have any. * If we have been flow-stopped by a CMD_FCOFF, then we can only -* send messages on DLCI0 until CMD_FCON -* -* FIXME: lock against link layer control transmissions +* send messages on DLCI0 until CMD_FCON. The caller must hold +* the gsm tx lock. */ - -static void gsm_data_kick (struct gsm_mux *gsm,struct gsm_dlci *dlci) +static int gsm_data_kick (struct gsm_mux *gsm) {struct gsm_msg *msg, *nmsg; -int len; +struct gsm_dlci *dlci; +int ret; -list_for_each_entry_safe (msg, nmsg, &gsm->tx_list, list) { +clear_bit (TTY_DO_WRITE_WAKEUP , &gsm->tty->flags); + +/* Serialize control messages and control channel messages first */ +list_for_each_entry_safe (msg, nmsg, &gsm->tx_ctrl_list, list) {if (gsm->constipated && !gsm_is_flow_ctrl_msg (msg)) +return -EAGAIN ; + ret =gsm_send_packet (gsm, msg); +switch (ret) { +case -ENOSPC : +return -ENOSPC ; +case -ENODEV : +/* ldisc not open */ + gsm->tx_bytes -= msg->len; +list_del (&msg->list); +kfree (msg);continue ; -if (gsm->encoding !=0 ) { - gsm->txframe[0 ] =GSM1_SOF ; - len =gsm_stuff_frame (msg->data, - gsm->txframe +1 , msg->len); - gsm->txframe[len +1 ] =GSM1_SOF ; - len +=2 ; - }else { - gsm->txframe[0 ] =GSM0_SOF ; -memcpy (gsm->txframe +1 , msg->data, msg->len); - gsm->txframe[msg->len +1 ] =GSM0_SOF ; - len = msg->len +2 ; - } - -if (debug &4 ) -gsm_hex_dump_bytes (__func__, gsm->txframe, len); -if (gsmld_output (gsm, gsm->txframe, len) <=0 ) +default : +if (ret >=0 ) { +list_del (&msg->list); +kfree (msg); + }break ; -/* FIXME: Can eliminate one SOF in many more cases */ - gsm->tx_bytes -= msg->len; - -list_del (&msg->list); -kfree (msg); + } + } -if (dlci) { -tty_port_tty_wakeup (&dlci->port); - }else { -int i =0 ; +if (gsm->constipated) +return -EAGAIN ; -for (i =0 ; i <NUM_DLCI ; i++) -if (gsm->dlci[i]) -tty_port_tty_wakeup (&gsm->dlci[i]->port); +/* Serialize other channels */ +if (list_empty (&gsm->tx_data_list)) +return 0 ; +list_for_each_entry_safe (msg, nmsg, &gsm->tx_data_list, list) { + dlci = gsm->dlci[msg->addr]; +/* Send only messages for DLCIs with valid state */ +if (dlci->state !=DLCI_OPEN ) { + gsm->tx_bytes -= msg->len; +list_del (&msg->list); +kfree (msg); +continue ; + } + ret =gsm_send_packet (gsm, msg); +switch (ret) { +case -ENOSPC : +return -ENOSPC ; +case -ENODEV : +/* ldisc not open */ + gsm->tx_bytes -= msg->len; +list_del (&msg->list); +kfree (msg); +continue ; +default : +if (ret >=0 ) { +list_del (&msg->list); +kfree (msg); + } +break ; } } + +return 1 ; }/**
@@ -902,9 +1000,21 @@ static void __gsm_data_queue(struct gsm_ msg->data = dp;/* Add to the actual output queue */ -list_add_tail (&msg->list, &gsm->tx_list); +switch (msg->ctrl & ~PF ) { +case UI : +case UIH : +if (msg->addr >0 ) { +list_add_tail (&msg->list, &gsm->tx_data_list); +break ; + } + fallthrough; +default : +list_add_tail (&msg->list, &gsm->tx_ctrl_list); +break ; + } gsm->tx_bytes += msg->len; -gsm_data_kick (gsm, dlci); + +gsmld_write_trigger (gsm);mod_timer (&gsm->kick_timer, jiffies +10 * gsm->t1 *HZ /100 ); }
@@ -1131,32 +1241,39 @@ static int gsm_dlci_modem_output(structstatic int gsm_dlci_data_sweep (struct gsm_mux *gsm) { -int len, ret =0 ;/* Priority ordering: We should do priority with RR of the groups */ -int i =1 ; - -while (i <NUM_DLCI ) { -struct gsm_dlci *dlci; +int i, len, ret =0 ; +bool sent; +struct gsm_dlci *dlci; -if (gsm->tx_bytes >TX_THRESH_HI ) -break ; - dlci = gsm->dlci[i]; -if (dlci ==NULL || dlci->constipated) { - i++; -continue ; +while (gsm->tx_bytes <TX_THRESH_HI ) { +for (sent = false, i =1 ; i <NUM_DLCI ; i++) { + dlci = gsm->dlci[i]; +/* skip unused or blocked channel */ +if (!dlci || dlci->constipated) +continue ; +/* skip channels with invalid state */ +if (dlci->state !=DLCI_OPEN ) +continue ; +/* count the sent data per adaption */ +if (dlci->adaption <3 && !dlci->net) + len =gsm_dlci_data_output (gsm, dlci); +else + len =gsm_dlci_data_output_framed (gsm, dlci); +/* on error exit */ +if (len <0 ) +return ret; +if (len >0 ) { + ret++; + sent = true; +/* The lower DLCs can starve the higher DLCs! */ +break ; + } +/* try next */ } -if (dlci->adaption <3 && !dlci->net) - len =gsm_dlci_data_output (gsm, dlci); -else - len =gsm_dlci_data_output_framed (gsm, dlci); -if (len <0 ) +if (!sent)break ; -/* DLCI empty - try the next */ -if (len ==0 ) - i++; -else - ret++; - } + };return ret; }
@@ -1405,7 +1522,6 @@ static void gsm_control_message(struct g const u8 *data, int clen) {u8 buf[1 ]; -unsigned long flags;struct gsm_dlci *dlci;int i;int address;
@@ -1440,9 +1556,7 @@ static void gsm_control_message(struct g gsm->constipated = false;gsm_control_reply (gsm,CMD_FCON ,NULL ,0 );/* Kick the link in case it is idling */ -spin_lock_irqsave (&gsm->tx_lock, flags); -gsm_data_kick (gsm,NULL ); -spin_unlock_irqrestore (&gsm->tx_lock, flags); +gsmld_write_trigger (gsm);break ;case CMD_FCOFF :/* Modem wants us to STFU */
@@ -1645,8 +1759,6 @@ static int gsm_control_wait(struct gsm_mstatic void gsm_dlci_close (struct gsm_dlci *dlci) { -unsigned long flags; -del_timer (&dlci->t1);if (debug &8 )pr_debug ("DLCI %d goes closed.\n" , dlci->addr);
@@ -1655,17 +1767,16 @@ static void gsm_dlci_close(struct gsm_dl dlci->constipated = true;if (dlci->addr !=0 ) {tty_port_tty_hangup (&dlci->port, false); -spin_lock_irqsave (&dlci->lock, flags); -kfifo_reset (&dlci->fifo); -spin_unlock_irqrestore (&dlci->lock, flags); +gsm_dlci_clear_queues (dlci->gsm, dlci);/* Ensure that gsmtty_open() can return. */ tty_port_set_initialized (&dlci->port,0 );wake_up_interruptible (&dlci->port.open_wait); }else dlci->gsm->dead = true; -wake_up (&dlci->gsm->event);/* A DLCI 0 close is a MUX termination so we need to kick that back to userspace somehow */ +gsm_dlci_data_kick (dlci); +wake_up (&dlci->gsm->event); }/**
@@ -1688,6 +1799,7 @@ static void gsm_dlci_open(struct gsm_dlc/* Send current modem state */ if (dlci->addr)gsm_modem_update (dlci,0 ); +gsm_dlci_data_kick (dlci);wake_up (&dlci->gsm->event); }
@@ -2325,7 +2437,7 @@ static void gsm1_receive(struct gsm_mux }else if ((c &ISO_IEC_646_MASK ) ==XOFF ) { gsm->constipated = false;/* Kick the link in case it is idling */ -gsm_data_kick (gsm,NULL ); +gsmld_write_trigger (gsm);return ; }if (c ==GSM1_SOF ) {
@@ -2460,6 +2572,9 @@ static void gsm_cleanup_mux(struct gsm_mdel_timer_sync (&gsm->kick_timer);del_timer_sync (&gsm->t2_timer); +/* Finish writing to ldisc */ +flush_work (&gsm->tx_work); +/* Free up any link layer users and finally the control channel */ if (gsm->has_devices) {gsm_unregister_devices (gsm_tty_driver, gsm->num);
@@ -2471,9 +2586,12 @@ static void gsm_cleanup_mux(struct gsm_mmutex_unlock (&gsm->mutex);/* Now wipe the queues */ tty_ldisc_flush (gsm->tty); -list_for_each_entry_safe (txq, ntxq, &gsm->tx_list, list) +list_for_each_entry_safe (txq, ntxq, &gsm->tx_ctrl_list, list) +kfree (txq); +INIT_LIST_HEAD (&gsm->tx_ctrl_list); +list_for_each_entry_safe (txq, ntxq, &gsm->tx_data_list, list)kfree (txq); -INIT_LIST_HEAD (&gsm->tx_list); +INIT_LIST_HEAD (&gsm->tx_data_list); }/**
@@ -2496,6 +2614,7 @@ static int gsm_activate_mux(struct gsm_mtimer_setup (&gsm->kick_timer, gsm_kick_timer,0 );timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 ); +INIT_WORK (&gsm->tx_work, gsmld_write_task);init_waitqueue_head (&gsm->event);spin_lock_init (&gsm->control_lock);spin_lock_init (&gsm->tx_lock);
@@ -2602,7 +2721,8 @@ static struct gsm_mux *gsm_alloc_mux(voispin_lock_init (&gsm->lock);mutex_init (&gsm->mutex);kref_init (&gsm->ref); -INIT_LIST_HEAD (&gsm->tx_list); +INIT_LIST_HEAD (&gsm->tx_ctrl_list); +INIT_LIST_HEAD (&gsm->tx_data_list); gsm->t1 =T1 ; gsm->t2 =T2 ;
@@ -2759,6 +2879,47 @@ static int gsmld_output(struct gsm_mux *return gsm->tty->ops->write (gsm->tty, data, len); } + +/** +* gsmld_write_trigger - schedule ldisc write task +* @gsm: our mux +*/ +static void gsmld_write_trigger (struct gsm_mux *gsm) +{ +if (!gsm || !gsm->dlci[0 ] || gsm->dlci[0 ]->dead) +return ; +schedule_work (&gsm->tx_work); +} + + +/** +* gsmld_write_task - ldisc write task +* @work: our tx write work +* +* Writes out data to the ldisc if possible. We are doing this here to +* avoid dead-locking. This returns if no space or data is left for output. +*/ +static void gsmld_write_task (struct work_struct *work) +{ + struct gsm_mux *gsm = container_of(work, struct gsm_mux, tx_work); +unsigned long flags; +int i, ret; + +/* All outstanding control channel and control messages and one data +* frame is sent. +*/ + ret = -ENODEV ; +spin_lock_irqsave (&gsm->tx_lock, flags); +if (gsm->tty) + ret =gsm_data_kick (gsm); +spin_unlock_irqrestore (&gsm->tx_lock, flags); + +if (ret >=0 ) +for (i =0 ; i <NUM_DLCI ; i++) +if (gsm->dlci[i]) +tty_port_tty_wakeup (&gsm->dlci[i]->port); +} +/** * gsmld_attach_gsm - mode set up * @tty: our tty structure
@@ -2902,6 +3063,7 @@ static int gsmld_open(struct tty_structtimer_setup (&gsm->kick_timer, gsm_kick_timer,0 );timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 ); +INIT_WORK (&gsm->tx_work, gsmld_write_task);return 0 ; }
@@ -2918,16 +3080,9 @@ static int gsmld_open(struct tty_structstatic void gsmld_write_wakeup (struct tty_struct *tty) {struct gsm_mux *gsm = tty->disc_data; -unsigned long flags;/* Queue poll */ -clear_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); -spin_lock_irqsave (&gsm->tx_lock, flags); -gsm_data_kick (gsm,NULL ); -if (gsm->tx_bytes <TX_THRESH_LO ) { -gsm_dlci_data_sweep (gsm); - } -spin_unlock_irqrestore (&gsm->tx_lock, flags); +gsmld_write_trigger (gsm); }/**
Greg Kroah-Hartman
maintainerPATCH 117/776 netdevsim: Fix memory leak of nsim_dev->fa_cookie
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Yufen <[email protected]>
[ Upstream commit 064bc7312bd09a48798418663090be0c776183db ]
kmemleak reports this issue:
unreferenced object 0xffff8881bac872d0 (size 8):
comm "sh", pid 58603, jiffies 4481524462 (age 68.065s) hex dump (first 8 bytes):
04 00 00 00 de ad be ef ........
backtrace:
[<00000000c80b8577>] __kmalloc+0x49/0x150
[<000000005292b8c6>] nsim_dev_trap_fa_cookie_write+0xc1/0x210 [netdevsim]
[<0000000093d78e77>] full_proxy_write+0xf3/0x180
[<000000005a662c16>] vfs_write+0x1c5/0xaf0
[<000000007aabf84a>] ksys_write+0xed/0x1c0
[<000000005f1d2e47>] do_syscall_64+0x3b/0x90
[<000000006001c6ec>] entry_SYSCALL_64_after_hwframe+0x63/0xcdThe issue occurs in the following scenarios:
nsim_dev_trap_fa_cookie_write()
kmalloc() fa_cookie
nsim_dev->fa_cookie = fa_cookie
..nsim_drv_remove()
The fa_cookie allocked in nsim_dev_trap_fa_cookie_write() is not freed. To fix, add kfree(nsim_dev->fa_cookie) to nsim_drv_remove().
[ The context change is due to the commit 5e388f3dc38c ("netdevsim: move vfconfig to nsim_dev") in v5.16 which is irrelevant to the logic of this patch. ]
--- drivers/net/netdevsim/dev.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/netdevsim/dev.c +1 -0
@@ -1582,6 +1582,7 @@ void nsim_dev_remove(struct nsim_bus_dev ARRAY_SIZE(nsim_devlink_params));devlink_unregister (devlink);devlink_resources_unregister (devlink,NULL ); +kfree (nsim_dev->fa_cookie);devlink_free (devlink); }
Greg Kroah-Hartman
maintainerPATCH 118/776 Revert "nvme: nvme-fc: Ensure ->ioerr_work is cancelled in nvme_fc_delete_ctrl()"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaskaran Singh <[email protected]>
This reverts commit 60ba31330faf5677e2eebef7eac62ea9e42a200d.
The backport of upstream commit 0a2c5495b6d1 was incorrectly applied. The cancel_work_sync() call for ->ioerr_work was added to nvme_fc_reset_ctrl_work() instead of nvme_fc_delete_ctrl().
Revert this commit so the correct fix can be applied.
--- drivers/nvme/host/fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/fc.c +1 -1
@@ -3263,6 +3263,7 @@ nvme_fc_delete_ctrl(struct nvme_ctrl *nc {struct nvme_fc_ctrl *ctrl =to_fc_ctrl (nctrl); +cancel_work_sync (&ctrl->ioerr_work);cancel_delayed_work_sync (&ctrl->connect_work);/* * kill the association on the link side. this will block
@@ -3333,7 +3334,6 @@ nvme_fc_reset_ctrl_work(struct work_stru/* will block will waiting for io to terminate */ nvme_fc_delete_association (ctrl); -cancel_work_sync (&ctrl->ioerr_work);if (!nvme_change_ctrl_state (&ctrl->ctrl,NVME_CTRL_CONNECTING )) dev_err(ctrl->ctrl.device,
Greg Kroah-Hartman
maintainerPATCH 119/776 nvme: nvme-fc: Ensure ->ioerr_work is cancelled in nvme_fc_delete_ctrl()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaskaran Singh <[email protected]>
commit 0a2c5495b6d1ecb0fa18ef6631450f391a888256 upstream.
nvme_fc_delete_assocation() waits for pending I/O to complete before returning, and an error can cause ->ioerr_work to be queued after cancel_work_sync() had been called. Move the call to cancel_work_sync() to be after nvme_fc_delete_association() to ensure ->ioerr_work is not running when the nvme_fc_ctrl object is freed. Otherwise the following can occur:
[ 1135.911754] list_del corruption, ff2d24c8093f31f8->next is NULL [ 1135.917705] ------------[ cut here ]------------ [ 1135.922336] kernel BUG at lib/list_debug.c:52! [ 1135.926784] Oops: invalid opcode: 0000 [#1] SMP NOPTI [ 1135.931851] CPU: 48 UID: 0 PID: 726 Comm: kworker/u449:23 Kdump: loaded Not tainted 6.12.0 #1 PREEMPT(voluntary) [ 1135.943490] Hardware name: Dell Inc. PowerEdge R660/0HGTK9, BIOS 2.5.4 01/16/2025 [ 1135.950969] Workqueue: 0x0 (nvme-wq) [ 1135.954673] RIP: 0010:__list_del_entry_valid_or_report.cold+0xf/0x6f [ 1135.961041] Code: c7 c7 98 68 72 94 e8 26 45 fe ff 0f 0b 48 c7 c7 70 68 72 94 e8 18 45 fe ff 0f 0b 48 89 fe 48 c7 c7 80 69 72 94 e8 07 45 fe ff <0f> 0b 48 89 d1 48 c7 c7 a0 6a 72 94 48 89 c2 e8 f3 44 fe ff 0f 0b [ 1135.979788] RSP: 0018:ff579b19482d3e50 EFLAGS: 00010046 [ 1135.985015] RAX: 0000000000000033 RBX: ff2d24c8093f31f0 RCX: 0000000000000000 [ 1135.992148] RDX: 0000000000000000 RSI: ff2d24d6bfa1d0c0 RDI: ff2d24d6bfa1d0c0 [ 1135.999278] RBP: ff2d24c8093f31f8 R08: 0000000000000000 R09: ffffffff951e2b08 [ 1136.006413] R10: ffffffff95122ac8 R11: 0000000000000003 R12: ff2d24c78697c100 [ 1136.013546] R13: fffffffffffffff8 R14: 0000000000000000 R15: ff2d24c78697c0c0 [ 1136.020677] FS: 0000000000000000(0000) GS:ff2d24d6bfa00000(0000) knlGS:0000000000000000 [ 1136.028765] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1136.034510] CR2: 00007fd207f90b80 CR3: 000000163ea22003 CR4: 0000000000f73ef0 [ 1136.041641] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1136.048776] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400 [ 1136.055910] PKRU: 55555554 [ 1136.058623] Call Trace: [ 1136.061074] <TASK> [ 1136.063179] ? show_trace_log_lvl+0x1b0/0x2f0 [ 1136.067540] ? show_trace_log_lvl+0x1b0/0x2f0 [ 1136.071898] ? move_linked_works+0x4a/0xa0 [ 1136.075998] ? __list_del_entry_valid_or_report.cold+0xf/0x6f [ 1136.081744] ? __die_body.cold+0x8/0x12 [ 1136.085584] ? die+0x2e/0x50 [ 1136.088469] ? do_trap+0xca/0x110 [ 1136.091789] ? do_error_trap+0x65/0x80 [ 1136.095543] ? __list_del_entry_valid_or_report.cold+0xf/0x6f [ 1136.101289] ? exc_invalid_op+0x50/0x70 [ 1136.105127] ? __list_del_entry_valid_or_report.cold+0xf/0x6f [ 1136.110874] ? asm_exc_invalid_op+0x1a/0x20 [ 1136.115059] ? __list_del_entry_valid_or_report.cold+0xf/0x6f [ 1136.120806] move_linked_works+0x4a/0xa0 [ 1136.124733] worker_thread+0x216/0x3a0 [ 1136.128485] ? __pfx_worker_thread+0x10/0x10 [ 1136.132758] kthread+0xfa/0x240 [ 1136.135904] ? __pfx_kthread+0x10/0x10 [ 1136.139657] ret_from_fork+0x31/0x50 [ 1136.143236] ? __pfx_kthread+0x10/0x10 [ 1136.146988] ret_from_fork_asm+0x1a/0x30 [ 1136.150915] </TASK>
--- drivers/nvme/host/fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/fc.c +1 -1
@@ -3263,13 +3263,13 @@ nvme_fc_delete_ctrl(struct nvme_ctrl *nc {struct nvme_fc_ctrl *ctrl =to_fc_ctrl (nctrl); -cancel_work_sync (&ctrl->ioerr_work);cancel_delayed_work_sync (&ctrl->connect_work);/* * kill the association on the link side. this will block * waiting for io to terminate */ nvme_fc_delete_association (ctrl); +cancel_work_sync (&ctrl->ioerr_work); } static void
Greg Kroah-Hartman
maintainerPATCH 120/776 ALSA: control: Avoid WARN() for symlink errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit b2e538a9827dd04ab5273bf4be8eb2edb84357b0 upstream.
Using WARN() for showing the error of symlink creations don't give more information than telling that something goes wrong, since the usual code path is a lregister callback from each control element creation. More badly, the use of WARN() rather confuses fuzzer as if it were serious issues.
This patch downgrades the warning messages to use the normal dev_err() instead of WARN(). For making it clearer, add the function name to the prefix, too.
--- sound/core/control_led.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
sound/core/control_led.c +10 -4
@@ -693,10 +693,16 @@ static void snd_ctl_led_sysfs_add(struct goto cerr; led->cards[card->number] = led_card;snprintf (link_name,sizeof (link_name),"led-%s" , led->name); -WARN (sysfs_create_link (&card->ctl_dev.kobj, &led_card->dev.kobj, link_name), -"can't create symlink to controlC%i device\n" , card->number); -WARN (sysfs_create_link (&led_card->dev.kobj, &card->card_dev.kobj,"card" ), -"can't create symlink to card%i\n" , card->number); +if (sysfs_create_link (&card->ctl_dev.kobj, &led_card->dev.kobj, + link_name)) +dev_err (card->dev, +"%s: can't create symlink to controlC%i device\n" , + __func__, card->number); +if (sysfs_create_link (&led_card->dev.kobj, &card->card_dev.kobj, +"card" )) +dev_err (card->dev, +"%s: can't create symlink to card%i\n" , + __func__, card->number);continue ; cerr:
Greg Kroah-Hartman
maintainerPATCH 121/776 s390/xor: Fix xor_xc_2() inline assembly constraints
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit f775276edc0c505dc0f782773796c189f31a1123 upstream.
The inline assembly constraints for xor_xc_2() are incorrect. "bytes", "p1", and "p2" are input operands, while all three of them are modified within the inline assembly. Given that the function consists only of this inline assembly it seems unlikely that this may cause any problems, however fix this in any case.
--- arch/s390/lib/xor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/lib/xor.c +2 -2
@@ -28,8 +28,8 @@ static void xor_xc_2(unsigned long bytes" j 3f\n" "2: xc 0(1,%1),0(%2)\n" "3:\n" - : : "d" (bytes), "a" (p1), "a" (p2) - : "0", "1", "cc", "memory"); + : "+d" (bytes), "+a" (p1), "+a" (p2) + : : "0", "1", "cc", "memory"); } static void xor_xc_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
Greg Kroah-Hartman
maintainerPATCH 122/776 f2fs: fix null-ptr-deref in f2fs_submit_page_bio()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
commit b7d0a97b28083084ebdd8e5c6bccd12e6ec18faa upstream.
There's issue as follows when concurrently installing the f2fs.ko module and mounting the f2fs file system:
KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027] RIP: 0010:__bio_alloc+0x2fb/0x6c0 [f2fs] Call Trace: <TASK> f2fs_submit_page_bio+0x126/0x8b0 [f2fs] __get_meta_page+0x1d4/0x920 [f2fs] get_checkpoint_version.constprop.0+0x2b/0x3c0 [f2fs] validate_checkpoint+0xac/0x290 [f2fs] f2fs_get_valid_checkpoint+0x207/0x950 [f2fs] f2fs_fill_super+0x1007/0x39b0 [f2fs] mount_bdev+0x183/0x250 legacy_get_tree+0xf4/0x1e0 vfs_get_tree+0x88/0x340 do_new_mount+0x283/0x5e0 path_mount+0x2b2/0x15b0 __x64_sys_mount+0x1fe/0x270 do_syscall_64+0x5f/0x170 entry_SYSCALL_64_after_hwframe+0x76/0x7e
Above issue happens as the biset of the f2fs file system is not initialized before register "f2fs_fs_type".
To address above issue just register "f2fs_fs_type" at the last in init_f2fs_fs(). Ensure that all f2fs file system resources are initialized.
--- fs/f2fs/super.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
fs/f2fs/super.c +2 -6
@@ -4634,9 +4634,6 @@ static int __init init_f2fs_fs(void) err =register_shrinker (&f2fs_shrinker_info);if (err) goto free_sysfs; - err =register_filesystem (&f2fs_fs_type); -if (err) - goto free_shrinker;f2fs_create_root_stats (); err =f2fs_init_post_read_processing ();if (err)
@@ -4660,6 +4657,7 @@ static int __init init_f2fs_fs(void)if (err) goto free_compress_cache; err =f2fs_init_xattr_cache (); + err =register_filesystem (&f2fs_fs_type);if (err) goto free_casefold_cache;return 0 ;
@@ -4679,8 +4677,6 @@ free_post_read:f2fs_destroy_post_read_processing (); free_root_stats:f2fs_destroy_root_stats (); -unregister_filesystem (&f2fs_fs_type); -free_shrinker:unregister_shrinker (&f2fs_shrinker_info); free_sysfs:f2fs_exit_sysfs ();
@@ -4704,6 +4700,7 @@ fail: static void __exit exit_f2fs_fs(void) { +unregister_filesystem (&f2fs_fs_type);f2fs_destroy_xattr_cache ();f2fs_destroy_casefold_cache ();f2fs_destroy_compress_cache ();
@@ -4713,7 +4710,6 @@ static void __exit exit_f2fs_fs(void)f2fs_destroy_iostat_processing ();f2fs_destroy_post_read_processing ();f2fs_destroy_root_stats (); -unregister_filesystem (&f2fs_fs_type);unregister_shrinker (&f2fs_shrinker_info);f2fs_exit_sysfs ();f2fs_destroy_garbage_collection_cache ();
Greg Kroah-Hartman
maintainerPATCH 123/776 wifi: iwlwifi: read txq->read_ptr under lock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit c2ace6300600c634553657785dfe5ea0ed688ac2 upstream.
If we read txq->read_ptr without lock, we can read the same value twice, then obtain the lock, and reclaim from there to two different places, but crucially reclaim the same entry twice, resulting in the WARN_ONCE() a little later. Fix that by reading txq->read_ptr under lock.
[ Change read_ptr definition according to commit
413be839bfca9("wifi: iwlwifi: add a validity check of queue_id in iwl_txq_reclaim"). ]
--- drivers/net/wireless/intel/iwlwifi/queue/tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/queue/tx.c +2 -1
@@ -1524,7 +1524,7 @@ void iwl_txq_reclaim(struct iwl_trans *t {struct iwl_txq *txq = trans->txqs.txq[txq_id];int tfd_num =iwl_txq_get_cmd_index (txq, ssn); -int read_ptr =iwl_txq_get_cmd_index (txq, txq->read_ptr); +int read_ptr;int last_to_free;/* This function is not meant to release cmd queue*/
@@ -1532,6 +1532,7 @@ void iwl_txq_reclaim(struct iwl_trans *treturn ;spin_lock_bh (&txq->lock); + read_ptr =iwl_txq_get_cmd_index (txq, txq->read_ptr);if (!test_bit (txq_id, trans->txqs.queue_used)) { IWL_DEBUG_TX_QUEUES(trans, "Q %d inactive - ignoring idx %d\n",
Greg Kroah-Hartman
maintainerPATCH 124/776 blk-mq: use quiesced elevator switch when reinitializing queues
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 8237c01f1696bc53c470493bf1fe092a107648a6 ]
The hctx's run_work may be racing with the elevator switch when reinitializing hardware queues. The queue is merely frozen in this context, but that only prevents requests from allocating and doesn't stop the hctx work from running. The work may get an elevator pointer that's being torn down, and can result in use-after-free errors and kernel panics (example below). Use the quiesced elevator switch instead, and make the previous one static since it is now only used locally.
nvme nvme0: resetting controller
nvme nvme0: 32/0/0 default/read/poll queues
BUG: kernel NULL pointer dereference, address: 0000000000000008 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 80000020c8861067 P4D 80000020c8861067 PUD 250f8c8067 PMD 0 Oops: 0000 [#1] SMP PTI Workqueue: kblockd blk_mq_run_work_fn RIP: 0010:kyber_has_work+0x29/0x70
...
Call Trace: __blk_mq_do_dispatch_sched+0x83/0x2b0 __blk_mq_sched_dispatch_requests+0x12e/0x170 blk_mq_sched_dispatch_requests+0x30/0x60 __blk_mq_run_hw_queue+0x2b/0x50 process_one_work+0x1ef/0x380 worker_thread+0x2d/0x3e0
--- block/blk-mq.c | 6 +++--- block/blk.h | 3 +-- block/elevator.c | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-)
block/blk-mq.c +3 -3
@@ -3732,14 +3732,14 @@ static bool blk_mq_elv_switch_none(strucmutex_lock (&q->sysfs_lock);/* -* After elevator_switch_mq, the previous elevator_queue will be +* After elevator_switch, the previous elevator_queue will be * released by elevator_release. The reference of the io scheduler * module get by elevator_get will also be put. So we need to get * a reference of the io scheduler module here to prevent it to be * removed. */ __module_get (qe->type->elevator_owner); -elevator_switch_mq (q,NULL ); +elevator_switch (q,NULL );mutex_unlock (&q->sysfs_lock);return true;
@@ -3764,7 +3764,7 @@ static void blk_mq_elv_switch_back(struckfree (qe);mutex_lock (&q->sysfs_lock); -elevator_switch_mq (q, t); +elevator_switch (q, t);mutex_unlock (&q->sysfs_lock); }
block/blk.h +1 -2
@@ -189,8 +189,7 @@ void blk_account_io_done(struct requestvoid blk_insert_flush (struct request *rq); -int elevator_switch_mq (struct request_queue *q, -struct elevator_type *new_e); +int elevator_switch (struct request_queue *q,struct elevator_type *new_e);void __elevator_exit (struct request_queue *,struct elevator_queue *);int elv_register_queue (struct request_queue *q,bool uevent);void elv_unregister_queue (struct request_queue *q);
block/elevator.c +2 -2
@@ -581,7 +581,7 @@ void elv_unregister(struct elevator_type }EXPORT_SYMBOL_GPL (elv_unregister); -int elevator_switch_mq (struct request_queue *q, +static int elevator_switch_mq (struct request_queue *q,struct elevator_type *new_e) {int ret;
@@ -719,7 +719,7 @@ void elevator_init_mq(struct request_que* need for the new one. this way we have a chance of going back to the old * one, if the new one fails init for some reason. */ -static int elevator_switch (struct request_queue *q,struct elevator_type *new_e) +int elevator_switch (struct request_queue *q,struct elevator_type *new_e) {int err;
Greg Kroah-Hartman
maintainerPATCH 125/776 dm-verity: disable recursive forward error correction
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit d9f3e47d3fae0c101d9094bc956ed24e7a0ee801 ]
There are two problems with the recursive correction:
1. It may cause denial-of-service. In fec_read_bufs, there is a loop that has 253 iterations. For each iteration, we may call verity_hash_for_block recursively. There is a limit of 4 nested recursions - that means that there may be at most 253^4 (4 billion) iterations. Red Hat QE team actually created an image that pushes dm-verity to this limit - and this image just makes the udev-worker process get stuck in the 'D' state.
2. It doesn't work. In fec_read_bufs we store data into the variable "fio->bufs", but fio bufs is shared between recursive invocations, if "verity_hash_for_block" invoked correction recursively, it would overwrite partially filled fio->bufs.
[ The context change is due to the commit bdf253d580d7 ("dm-verity: remove support for asynchronous hashes") in v6.18 and the commit 9356fcfe0ac4
("dm verity: set DM_TARGET_SINGLETON feature flag") in v6.9 which are irrelevant to the logic of this patch. ]
--- drivers/md/dm-verity-fec.c | 4 +--- drivers/md/dm-verity-fec.h | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/md/dm-verity-fec.c +1 -3
@@ -423,10 +423,8 @@ int verity_fec_decode(struct dm_verity *if (!verity_fec_is_enabled (v))return -EOPNOTSUPP ; -if (fio->level >=DM_VERITY_FEC_MAX_RECURSION ) { -DMWARN_LIMIT ("%s: FEC: recursion too deep" , v->data_dev->name); +if (fio->level)return -EIO ; - } fio->level++;
drivers/md/dm-verity-fec.h +0 -3
@@ -23,9 +23,6 @@#define DM_VERITY_FEC_BUF_MAX \ (1 << (PAGE_SHIFT - DM_VERITY_FEC_BUF_RS_BITS)) -/* maximum recursion level for verity_fec_decode */ -#define DM_VERITY_FEC_MAX_RECURSION 4 -#define DM_VERITY_OPT_FEC_DEV "use_fec_from_device"#define DM_VERITY_OPT_FEC_BLOCKS "fec_blocks"#define DM_VERITY_OPT_FEC_START "fec_start"
Greg Kroah-Hartman
maintainerPATCH 126/776 net: add skb_header_pointer_careful() helper
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 13e00fdc9236bd4d0bff4109d2983171fbcb74c4 ]
This variant of skb_header_pointer() should be used in contexts where @offset argument is user-controlled and could be negative.
Negative offsets are supported, as long as the zone starts between skb->head and skb->data.
--- include/linux/skbuff.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/linux/skbuff.h +12 -0
@@ -3869,6 +3869,18 @@ skb_header_pointer(const struct sk_buff skb_headlen(skb), buffer); } +/* Variant of skb_header_pointer() where @offset is user-controlled +* and potentially negative. +*/ +static inline void *__must_check +skb_header_pointer_careful (const struct sk_buff *skb,int offset, +int len,void *buffer) +{ +if (unlikely (offset <0 && -offset >skb_headroom (skb))) +return NULL ; +return skb_header_pointer (skb, offset, len, buffer); +} +/** * skb_needs_linearize - check if we need to linearize a given skb * depending on the given device features.
Greg Kroah-Hartman
maintainerPATCH 127/776 net/sched: cls_u32: use skb_header_pointer_careful()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit cabd1a976375780dabab888784e356f574bbaed8 ]
skb_header_pointer() does not fully validate negative @offset values.
Use skb_header_pointer_careful() instead.
GangMin Kim provided a report and a repro fooling u32_classify():
BUG: KASAN: slab-out-of-bounds in u32_classify+0x1180/0x11b0
net/sched/cls_u32.c:221
--- net/sched/cls_u32.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
net/sched/cls_u32.c +6 -7
@@ -149,10 +149,8 @@ next_knode:int toff = off + key->off + (off2 & key->offmask);__be32 *data, hdata; -if (skb_headroom (skb) + toff >INT_MAX ) - goto out; - - data =skb_header_pointer (skb, toff,4 , &hdata); + data =skb_header_pointer_careful (skb, toff,4 , + &hdata);if (!data) goto out;if ((*data ^ key->val) & key->mask) {
@@ -202,8 +200,9 @@ check_terminal:if (ht->divisor) {__be32 *data, hdata; - data =skb_header_pointer (skb, off + n->sel.hoff,4 , - &hdata); + data =skb_header_pointer_careful (skb, + off + n->sel.hoff, +4 , &hdata);if (!data) goto out; sel = ht->divisor & u32_hash_fold(*data, &n->sel,
@@ -217,7 +216,7 @@ check_terminal:if (n->sel.flags &TC_U32_VAROFFSET ) {__be16 *data, hdata; - data =skb_header_pointer (skb, + data =skb_header_pointer_careful (skb, off + n->sel.offoff,2 , &hdata);if (!data)
Greg Kroah-Hartman
maintainerPATCH 128/776 dmaengine: mmp_pdma: Fix race condition in mmp_pdma_residue()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guodong Xu <[email protected]>
[ Upstream commit a143545855bc2c6e1330f6f57ae375ac44af00a7 ]
Add proper locking in mmp_pdma_residue() to prevent use-after-free when accessing descriptor list and descriptor contents.
The race occurs when multiple threads call tx_status() while the tasklet on another CPU is freeing completed descriptors:
CPU 0 CPU 1
----- -----mmp_pdma_tx_status()mmp_pdma_residue()
-> NO LOCK held
list_for_each_entry(sw, ..)
DMA interrupt
dma_do_tasklet()
-> spin_lock(&desc_lock)
list_move(sw->node, ...)
spin_unlock(&desc_lock) | dma_pool_free(sw) <- FREED!
-> access sw->desc <- UAF!
This issue can be reproduced when running dmatest on the same channel with multiple threads (threads_per_chan > 1).
Fix by protecting the chain_running list iteration and descriptor access with the chan->desc_lock spinlock.
--- drivers/dma/mmp_pdma.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/dma/mmp_pdma.c +6 -0
@@ -764,6 +764,7 @@ static unsigned int mmp_pdma_residue(str {struct mmp_pdma_desc_sw *sw;u32 curr, residue =0 ; +unsigned long flags;bool passed = false;bool cyclic = chan->cyclic_first !=NULL ;
@@ -779,6 +780,8 @@ static unsigned int mmp_pdma_residue(strelse curr =readl (chan->phy->base +DSADR (chan->phy->idx)); +spin_lock_irqsave (&chan->desc_lock, flags); +list_for_each_entry (sw, &chan->chain_running, node) {u32 start, end, len;
@@ -822,6 +825,7 @@ static unsigned int mmp_pdma_residue(strcontinue ;if (sw->async_tx.cookie == cookie) { +spin_unlock_irqrestore (&chan->desc_lock, flags);return residue; }else { residue =0 ;
@@ -829,6 +833,8 @@ static unsigned int mmp_pdma_residue(str } } +spin_unlock_irqrestore (&chan->desc_lock, flags); +/* We should only get here in case of cyclic transactions */ return residue; }
Greg Kroah-Hartman
maintainerPATCH 129/776 fs: dlm: fix use after free in midcomms commit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Aring <[email protected]>
[ Upstream commit 724b6bab0d75f1dc01fdfbf7fe8d4217a5cb90ba ]
While working on processing dlm message in softirq context I experienced the following KASAN use-after-free warning:
[ 151.760477] ================================================================== [ 151.761803] BUG: KASAN: use-after-free in dlm_midcomms_commit_mhandle+0x19d/0x4b0 [ 151.763414] Read of size 4 at addr ffff88811a980c60 by task lock_torture/1347
[ 151.765284] CPU: 7 PID: 1347 Comm: lock_torture Not tainted 6.1.0-rc4+ #2828 [ 151.766778] Hardware name: Red Hat KVM/RHEL-AV, BIOS 1.16.0-3.module+el8.7.0+16134+e5908aa2 04/01/2014 [ 151.768726] Call Trace: [ 151.769277] <TASK> [ 151.769748] dump_stack_lvl+0x5b/0x86 [ 151.770556] print_report+0x180/0x4c8 [ 151.771378] ? kasan_complete_mode_report_info+0x7c/0x1e0 [ 151.772241] ? dlm_midcomms_commit_mhandle+0x19d/0x4b0 [ 151.773069] kasan_report+0x93/0x1a0 [ 151.773668] ? dlm_midcomms_commit_mhandle+0x19d/0x4b0 [ 151.774514] __asan_load4+0x7e/0xa0 [ 151.775089] dlm_midcomms_commit_mhandle+0x19d/0x4b0 [ 151.775890] ? create_message.isra.29.constprop.64+0x57/0xc0 [ 151.776770] send_common+0x19f/0x1b0 [ 151.777342] ? remove_from_waiters+0x60/0x60 [ 151.778017] ? lock_downgrade+0x410/0x410 [ 151.778648] ? __this_cpu_preempt_check+0x13/0x20 [ 151.779421] ? rcu_lockdep_current_cpu_online+0x88/0xc0 [ 151.780292] _convert_lock+0x46/0x150 [ 151.780893] convert_lock+0x7b/0xc0 [ 151.781459] dlm_lock+0x3ac/0x580 [ 151.781993] ? 0xffffffffc0540000 [ 151.782522] ? torture_stop+0x120/0x120 [dlm_locktorture] [ 151.783379] ? dlm_scan_rsbs+0xa70/0xa70 [ 151.784003] ? preempt_count_sub+0xd6/0x130 [ 151.784661] ? is_module_address+0x47/0x70 [ 151.785309] ? torture_stop+0x120/0x120 [dlm_locktorture] [ 151.786166] ? 0xffffffffc0540000 [ 151.786693] ? lockdep_init_map_type+0xc3/0x360 [ 151.787414] ? 0xffffffffc0540000 [ 151.787947] torture_dlm_lock_sync.isra.3+0xe9/0x150 [dlm_locktorture] [ 151.789004] ? torture_stop+0x120/0x120 [dlm_locktorture] [ 151.789858] ? 0xffffffffc0540000 [ 151.790392] ? lock_torture_cleanup+0x20/0x20 [dlm_locktorture] [ 151.791347] ? delay_tsc+0x94/0xc0 [ 151.791898] torture_ex_iter+0xc3/0xea [dlm_locktorture] [ 151.792735] ? torture_start+0x30/0x30 [dlm_locktorture] [ 151.793606] lock_torture+0x177/0x270 [dlm_locktorture] [ 151.794448] ? torture_dlm_lock_sync.isra.3+0x150/0x150 [dlm_locktorture] [ 151.795539] ? lock_torture_stats+0x80/0x80 [dlm_locktorture] [ 151.796476] ? do_raw_spin_lock+0x11e/0x1e0 [ 151.797152] ? mark_held_locks+0x34/0xb0 [ 151.797784] ? _raw_spin_unlock_irqrestore+0x30/0x70 [ 151.798581] ? __kthread_parkme+0x79/0x110 [ 151.799246] ? trace_preempt_on+0x2a/0xf0 [ 151.799902] ? __kthread_parkme+0x79/0x110 [ 151.800579] ? preempt_count_sub+0xd6/0x130 [ 151.801271] ? __kasan_check_read+0x11/0x20 [ 151.801963] ? __kthread_parkme+0xec/0x110 [ 151.802630] ? lock_torture_stats+0x80/0x80 [dlm_locktorture] [ 151.803569] kthread+0x192/0x1d0 [ 151.804104] ? kthread_complete_and_exit+0x30/0x30 [ 151.804881] ret_from_fork+0x1f/0x30 [ 151.805480] </TASK>
[ 151.806111] Allocated by task 1347: [ 151.806681] kasan_save_stack+0x26/0x50 [ 151.807308] kasan_set_track+0x25/0x30 [ 151.807920] kasan_save_alloc_info+0x1e/0x30 [ 151.808609] __kasan_slab_alloc+0x63/0x80 [ 151.809263] kmem_cache_alloc+0x1ad/0x830 [ 151.809916] dlm_allocate_mhandle+0x17/0x20 [ 151.810590] dlm_midcomms_get_mhandle+0x96/0x260 [ 151.811344] _create_message+0x95/0x180 [ 151.811994] create_message.isra.29.constprop.64+0x57/0xc0 [ 151.812880] send_common+0x129/0x1b0 [ 151.813467] _convert_lock+0x46/0x150 [ 151.814074] convert_lock+0x7b/0xc0 [ 151.814648] dlm_lock+0x3ac/0x580 [ 151.815199] torture_dlm_lock_sync.isra.3+0xe9/0x150 [dlm_locktorture] [ 151.816258] torture_ex_iter+0xc3/0xea [dlm_locktorture] [ 151.817129] lock_torture+0x177/0x270 [dlm_locktorture] [ 151.817986] kthread+0x192/0x1d0 [ 151.818518] ret_from_fork+0x1f/0x30
[ 151.819369] Freed by task 1336: [ 151.819890] kasan_save_stack+0x26/0x50 [ 151.820514] kasan_set_track+0x25/0x30 [ 151.821128] kasan_save_free_info+0x2e/0x50 [ 151.821812] __kasan_slab_free+0x107/0x1a0 [ 151.822483] kmem_cache_free+0x204/0x5e0 [ 151.823152] dlm_free_mhandle+0x18/0x20 [ 151.823781] dlm_mhandle_release+0x2e/0x40 [ 151.824454] rcu_core+0x583/0x1330 [ 151.825047] rcu_core_si+0xe/0x20 [ 151.825594] __do_softirq+0xf4/0x5c2
[ 151.826450] Last potentially related work creation: [ 151.827238] kasan_save_stack+0x26/0x50 [ 151.827870] __kasan_record_aux_stack+0xa2/0xc0 [ 151.828609] kasan_record_aux_stack_noalloc+0xb/0x20 [ 151.829415] call_rcu+0x4c/0x760 [ 151.829954] dlm_mhandle_delete+0x97/0xb0 [ 151.830718] dlm_process_incoming_buffer+0x2fc/0xb30 [ 151.831524] process_dlm_messages+0x16e/0x470 [ 151.832245] process_one_work+0x505/0xa10 [ 151.832905] worker_thread+0x67/0x650 [ 151.833507] kthread+0x192/0x1d0 [ 151.834046] ret_from_fork+0x1f/0x30
[ 151.834900] The buggy address belongs to the object at ffff88811a980c30
which belongs to the cache dlm_mhandle of size 88
[ 151.836894] The buggy address is located 48 bytes inside of
88-byte region [ffff88811a980c30, ffff88811a980c88)[ 151.839007] The buggy address belongs to the physical page: [ 151.839904] page:0000000076cf5d62 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11a980 [ 151.841378] flags: 0x8000000000000200(slab|zone=2) [ 151.842141] raw: 8000000000000200 0000000000000000 dead000000000122 ffff8881089b43c0 [ 151.843401] raw: 0000000000000000 0000000000220022 00000001ffffffff 0000000000000000 [ 151.844640] page dumped because: kasan: bad access detected
[ 151.845822] Memory state around the buggy address: [ 151.846602] ffff88811a980b00: fb fb fb fb fc fc fc fc fa fb fb fb fb fb fb fb [ 151.847761] ffff88811a980b80: fb fb fb fc fc fc fc fa fb fb fb fb fb fb fb fb [ 151.848921] >ffff88811a980c00: fb fb fc fc fc fc fa fb fb fb fb fb fb fb fb fb [ 151.850076] ^ [ 151.851085] ffff88811a980c80: fb fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb [ 151.852269] ffff88811a980d00: fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb fc [ 151.853428] ================================================================== [ 151.855618] Disabling lock debugging due to kernel taint
It is accessing a mhandle in dlm_midcomms_commit_mhandle() and the mhandle was freed by a call_rcu() call in dlm_process_incoming_buffer(), dlm_mhandle_delete(). It looks like it was freed because an ack of this message was received. There is a short race between committing the dlm message to be transmitted and getting an ack back. If the ack is faster than returning from dlm_midcomms_commit_msg_3_2(), then we run into a use-after free because we still need to reference the mhandle when calling srcu_read_unlock().
To avoid that, we don't allow that mhandle to be freed between dlm_midcomms_commit_msg_3_2() and srcu_read_unlock() by using rcu read lock. We can do that because mhandle is protected by rcu handling.
--- fs/dlm/midcomms.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/dlm/midcomms.c +7 -0
@@ -1131,8 +1131,15 @@ void dlm_midcomms_commit_mhandle(structkfree (mh);break ;case DLM_VERSION_3_2 : +/* held rcu read lock here, because we sending the +* dlm message out, when we do that we could receive +* an ack back which releases the mhandle and we +* get a use after free. +*/ +rcu_read_lock ();dlm_midcomms_commit_msg_3_2 (mh);srcu_read_unlock (&nodes_srcu, mh->idx); +rcu_read_unlock ();break ;default :srcu_read_unlock (&nodes_srcu, mh->idx);
Greg Kroah-Hartman
maintainerPATCH 130/776 spi: cadence-quadspi: Implement refcount to handle unbind during busy
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Khairul Anuar Romli <[email protected]>
[ Upstream commit 7446284023e8ef694fb392348185349c773eefb3 ]
driver support indirect read and indirect write operation with assumption no force device removal(unbind) operation. However force device removal(removal) is still available to root superuser.
Unbinding driver during operation causes kernel crash. This changes ensure driver able to handle such operation for indirect read and indirect write by implementing refcount to track attached devices to the controller and gracefully wait and until attached devices remove operation completed before proceed with removal operation.
--- drivers/spi/spi-cadence-quadspi.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/spi/spi-cadence-quadspi.c +34 -0
@@ -85,6 +85,8 @@ struct cqspi_st {bool use_direct_mode;struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT ];bool wr_completion; +refcount_t refcount; +refcount_t inflight_ops; };struct cqspi_driver_platdata {
@@ -684,6 +686,9 @@ static int cqspi_indirect_read_execute(su8 *rxbuf_end = rxbuf + n_rx;int ret =0 ; +if (!refcount_read (&cqspi->refcount)) +return -ENODEV ; +writel (from_addr, reg_base +CQSPI_REG_INDIRECTRDSTARTADDR );writel (remaining, reg_base +CQSPI_REG_INDIRECTRDBYTES );
@@ -826,6 +831,9 @@ static int cqspi_indirect_write_execute(unsigned int write_bytes;int ret; +if (!refcount_read (&cqspi->refcount)) +return -ENODEV ; +writel (to_addr, reg_base +CQSPI_REG_INDIRECTWRSTARTADDR );writel (remaining, reg_base +CQSPI_REG_INDIRECTWRBYTES );
@@ -1210,11 +1218,29 @@ static int cqspi_mem_process(struct spi_static int cqspi_exec_mem_op (struct spi_mem *mem,const struct spi_mem_op *op) {int ret; +struct cqspi_st *cqspi =spi_controller_get_devdata (mem->spi->controller); + +if (refcount_read (&cqspi->inflight_ops) ==0 ) +return -ENODEV ; + +if (!refcount_read (&cqspi->refcount)) +return -EBUSY ; + +refcount_inc (&cqspi->inflight_ops); + +if (!refcount_read (&cqspi->refcount)) { +if (refcount_read (&cqspi->inflight_ops)) +refcount_dec (&cqspi->inflight_ops); +return -EBUSY ; + } ret =cqspi_mem_process (mem, op);if (ret)dev_err (&mem->spi->dev,"operation failed with %d\n" , ret); +if (refcount_read (&cqspi->inflight_ops) >1 ) +refcount_dec (&cqspi->inflight_ops); +return ret; }
@@ -1564,6 +1590,9 @@ static int cqspi_probe(struct platform_d cqspi->wr_completion = false; } +refcount_set (&cqspi->refcount,1 ); +refcount_set (&cqspi->inflight_ops,1 ); + ret =devm_request_irq (dev, irq, cqspi_irq_handler,0 , pdev->name, cqspi);if (ret) {
@@ -1613,6 +1642,11 @@ static int cqspi_remove(struct platform_ {struct cqspi_st *cqspi =platform_get_drvdata (pdev); +refcount_set (&cqspi->refcount,0 ); + +if (!refcount_dec_and_test (&cqspi->inflight_ops)) +cqspi_wait_idle (cqspi); +cqspi_controller_enable (cqspi,0 );if (cqspi->rx_chan)
Greg Kroah-Hartman
maintainerPATCH 131/776 x86/uprobes: Fix XOL allocation failure for 32-bit tasks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Nesterov <[email protected]>
[ Upstream commit d55c571e4333fac71826e8db3b9753fadfbead6a ]
This script
#!/usr/bin/bash
echo 0 > /proc/sys/kernel/randomize_va_space
echo 'void main(void) {}' > TEST.c
# -fcf-protection to ensure that the 1st endbr32 insn can't be emulated gcc -m32 -fcf-protection=branch TEST.c -o test
bpftrace -e 'uprobe:./test:main {}' -c ./test
"hangs", the probed ./test task enters an endless loop.
The problem is that with randomize_va_space == 0 get_unmapped_area(TASK_SIZE - PAGE_SIZE) called by xol_add_vma() can not just return the "addr == TASK_SIZE - PAGE_SIZE" hint, this addr is used by the stack vma.
arch_get_unmapped_area_topdown() doesn't take TIF_ADDR32 into account and in_32bit_syscall() is false, this leads to info.high_limit > TASK_SIZE. vm_unmapped_area() happily returns the high address > TASK_SIZE and then get_unmapped_area() returns -ENOMEM after the "if (addr > TASK_SIZE - len)" check.
handle_swbp() doesn't report this failure (probably it should) and silently restarts the probed insn. Endless loop.
I think that the right fix should change the x86 get_unmapped_area() paths to rely on TIF_ADDR32 rather than in_32bit_syscall(). Note also that if CONFIG_X86_X32_ABI=y, in_x32_syscall() falsely returns true in this case because ->orig_ax = -1.
But we need a simple fix for -stable, so this patch just sets TS_COMPAT if the probed task is 32-bit to make in_ia32_syscall() true.
--- arch/x86/kernel/uprobes.c | 24 ++++++++++++++++++++++++ include/linux/uprobes.h | 1 + kernel/events/uprobes.c | 10 +++++++--- 3 files changed, 32 insertions(+), 3 deletions(-)
arch/x86/kernel/uprobes.c +24 -0
@@ -1097,3 +1097,27 @@ bool arch_uretprobe_is_alive(struct retuelse return regs->sp <= ret->stack; } + +#ifdef CONFIG_IA32_EMULATION +unsigned long arch_uprobe_get_xol_area (void ) +{ +struct thread_info *ti =current_thread_info (); +unsigned long vaddr; + +/* +* HACK: we are not in a syscall, but x86 get_unmapped_area() paths +* ignore TIF_ADDR32 and rely on in_32bit_syscall() to calculate +* vm_unmapped_area_info.high_limit. +* +* The #ifdef above doesn't cover the CONFIG_X86_X32_ABI=y case, +* but in this case in_32bit_syscall() -> in_x32_syscall() always +* (falsely) returns true because ->orig_ax == -1. +*/ +if (test_thread_flag (TIF_ADDR32 )) + ti->status |=TS_COMPAT ; + vaddr =get_unmapped_area (NULL ,TASK_SIZE -PAGE_SIZE ,PAGE_SIZE ,0 ,0 ); + ti->status &= ~TS_COMPAT ; + +return vaddr; +} +#endif
include/linux/uprobes.h +1 -0
@@ -138,6 +138,7 @@ extern bool arch_uretprobe_is_alive(struextern bool arch_uprobe_ignore (struct arch_uprobe *aup,struct pt_regs *regs);extern void arch_uprobe_copy_ixol (struct page *page,unsigned long vaddr,void *src,unsigned long len); +extern unsigned long arch_uprobe_get_xol_area (void );#else /* !CONFIG_UPROBES */ struct uprobes_state { };
kernel/events/uprobes.c +7 -3
@@ -1437,6 +1437,12 @@ void uprobe_munmap(struct vm_area_structset_bit (MMF_RECALC_UPROBES , &vma->vm_mm->flags); } +unsigned long __weak arch_uprobe_get_xol_area (void ) +{ +/* Try to map as high as possible, this is only a hint. */ +return get_unmapped_area (NULL ,TASK_SIZE -PAGE_SIZE ,PAGE_SIZE ,0 ,0 ); +} +/* Slot allocation for XOL */ static int xol_add_vma (struct mm_struct *mm,struct xol_area *area) {
@@ -1452,9 +1458,7 @@ static int xol_add_vma(struct mm_struct }if (!area->vaddr) { -/* Try to map as high as possible, this is only a hint. */ - area->vaddr =get_unmapped_area (NULL ,TASK_SIZE -PAGE_SIZE , -PAGE_SIZE ,0 ,0 ); + area->vaddr =arch_uprobe_get_xol_area ();if (IS_ERR_VALUE (area->vaddr)) { ret = area->vaddr; goto fail;
Greg Kroah-Hartman
maintainerPATCH 132/776 btrfs: send: check for inline extents in range_is_hole_in_parent()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 08b096c1372cd69627f4f559fb47c9fb67a52b39 ]
Before accessing the disk_bytenr field of a file extent item we need to check if we are dealing with an inline extent.
This is because for inline extents their data starts at the offset of the disk_bytenr field. So accessing the disk_bytenr
means we are accessing inline data or in case the inline data is less than 8 bytes we can actually cause an invalid
memory access if this inline extent item is the first item in the leaf or access metadata from other items.
[ Avoid leaking the path by using { ret = 0; goto out; } instead of returning directly. ]
--- fs/btrfs/send.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/btrfs/send.c +4 -0
@@ -5892,6 +5892,10 @@ static int range_is_hole_in_parent(struc extent_end =btrfs_file_extent_end (path);if (extent_end <= start) goto next; +if (btrfs_file_extent_type (leaf, fi) ==BTRFS_FILE_EXTENT_INLINE ) { + ret =0 ; + goto out; + }if (btrfs_file_extent_disk_bytenr (leaf, fi) ==0 ) { search_start = extent_end; goto next;
Greg Kroah-Hartman
maintainerPATCH 133/776 btrfs: do not strictly require dirty metadata threshold for metadata writepages
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 4e159150a9a56d66d247f4b5510bed46fe58aa1c ]
[BUG]
There is an internal report that over 1000 processes are waiting at the io_schedule_timeout() of balance_dirty_pages(), causing a system hang and trigger a kernel coredump.
The kernel is v6.4 kernel based, but the root problem still applies to any upstream kernel before v6.18.
[CAUSE]
Quoted 1 line
From Jan Kara for his wisdom on the dirty page balance behavior first.
This cgroup dirty limit was what was actually playing the role here because the cgroup had only a small amount of memory and so the dirty limit for it was something like 16MB.
Dirty throttling is responsible for enforcing that nobody can dirty (significantly) more dirty memory than there's dirty limit. Thus when a task is dirtying pages it periodically enters into balance_dirty_pages() and we let it sleep there to slow down the dirtying.
When the system is over dirty limit already (either globally or within a cgroup of the running task), we will not let the task exit from balance_dirty_pages() until the number of dirty pages drops below the limit.
So in this particular case, as I already mentioned, there was a cgroup with relatively small amount of memory and as a result with dirty limit set at 16MB. A task from that cgroup has dirtied about 28MB worth of pages in btrfs btree inode and these were practically the only dirty pages in that cgroup.
So that means the only way to reduce the dirty pages of that cgroup is to writeback the dirty pages of btrfs btree inode, and only after that those processes can exit balance_dirty_pages().
Now back to the btrfs part, btree_writepages() is responsible for writing back dirty btree inode pages.
The problem here is, there is a btrfs internal threshold that if the btree inode's dirty bytes are below the 32M threshold, it will not do any writeback.
This behavior is to batch as much metadata as possible so we won't write back those tree blocks and then later re-COW them again for another modification.
This internal 32MiB is higher than the existing dirty page size (28MiB), meaning no writeback will happen, causing a deadlock between btrfs and cgroup:
- Btrfs doesn't want to write back btree inode until more dirty pages
- Cgroup/MM doesn't want more dirty pages for btrfs btree inode Thus any process touching that btree inode is put into sleep until the number of dirty pages is reduced.
Thanks Jan Kara a lot for the analysis of the root cause.
[ENHANCEMENT]
Since kernel commit b55102826d7d ("btrfs: set AS_KERNEL_FILE on the btree_inode"), btrfs btree inode pages will only be charged to the root cgroup which should have a much larger limit than btrfs' 32MiB threshold.
So it should not affect newer kernels.
But for all current LTS kernels, they are all affected by this problem, and backporting the whole AS_KERNEL_FILE may not be a good idea.
Even for newer kernels I still think it's a good idea to get rid of the internal threshold at btree_writepages(), since for most cases cgroup/MM has a better view of full system memory usage than btrfs' fixed threshold.
For internal callers using btrfs_btree_balance_dirty() since that function is already doing internal threshold check, we don't need to bother them.
But for external callers of btree_writepages(), just respect their requests and write back whatever they want, ignoring the internal btrfs threshold to avoid such deadlock on btree inode dirty page balancing.
[ The context change is due to the commit 41044b41ad2c ("btrfs: add helper to get fs_info from struct inode pointer") in v6.9 and the commit c66f2afc7148
("btrfs: remove pointless writepages callback wrapper") in v6.10 which are irrelevant to the logic of this patch. ]
--- fs/btrfs/disk-io.c | 23 ----------------------- fs/btrfs/extent_io.c | 3 +-- fs/btrfs/extent_io.h | 3 +-- 3 files changed, 2 insertions(+), 27 deletions(-)
fs/btrfs/disk-io.c +0 -23
@@ -912,29 +912,6 @@ static int btree_migratepage(struct addr }#endif - -static int btree_writepages (struct address_space *mapping, -struct writeback_control *wbc) -{ -struct btrfs_fs_info *fs_info; -int ret; - -if (wbc->sync_mode ==WB_SYNC_NONE ) { - -if (wbc->for_kupdate) -return 0 ; - - fs_info =BTRFS_I (mapping->host)->root->fs_info; -/* this is a bit racy, but that's ok */ - ret =__percpu_counter_compare (&fs_info->dirty_metadata_bytes, -BTRFS_DIRTY_METADATA_THRESH , - fs_info->dirty_metadata_batch); -if (ret <0 ) -return 0 ; - } -return btree_write_cache_pages (mapping, wbc); -} -static int btree_releasepage (struct page *page,gfp_t gfp_flags) {if (PageWriteback (page) ||PageDirty (page))
fs/btrfs/extent_io.c +1 -2
@@ -4792,8 +4792,7 @@ static int submit_eb_page(struct page *preturn 1 ; } -int btree_write_cache_pages (struct address_space *mapping, -struct writeback_control *wbc) +int btree_writepages (struct address_space *mapping,struct writeback_control *wbc) {struct extent_buffer *eb_context =NULL ;struct extent_page_data epd = {
fs/btrfs/extent_io.h +1 -2
@@ -187,8 +187,7 @@ int extent_write_locked_range(struct ino int mode);int extent_writepages (struct address_space *mapping,struct writeback_control *wbc); -int btree_write_cache_pages (struct address_space *mapping, -struct writeback_control *wbc); +int btree_writepages (struct address_space *mapping,struct writeback_control *wbc);void extent_readahead (struct readahead_control *rac);int extent_fiemap (struct btrfs_inode *inode,struct fiemap_extent_info *fieinfo,u64 start,u64 len);
Greg Kroah-Hartman
maintainerPATCH 134/776 mailbox: Prevent out-of-bounds access in of_mbox_index_xlate()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joonwon Kang <[email protected]>
[ Upstream commit fcd7f96c783626c07ee3ed75fa3739a8a2052310 ]
Although it is guided that #mbox-cells must be at least 1, there are many instances of #mbox-cells = <0>; in the device tree. If that is the case and the corresponding mailbox controller does not provide fw_xlate and of_xlate function pointers, of_mbox_index_xlate()` will be used by default and out-of-bounds accesses could occur due to lack of bounds check in that function.
[ changed sp->nargs to sp->args_count in the code and fw_mbox_index_xlate() to of_mbox_index_xlate() in the commit message. ]
--- drivers/mailbox/mailbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mailbox/mailbox.c +2 -4
@@ -468,12 +468,10 @@ static struct mbox_chan * of_mbox_index_xlate(struct mbox_controller *mbox, const struct of_phandle_args *sp) { - int ind = sp->args[0]; - -if (ind >= mbox->num_chans) +if (sp->args_count <1 || sp->args[0 ] >= mbox->num_chans)return ERR_PTR (-EINVAL ); -return &mbox->chans[ind]; +return &mbox->chans[sp->args[0 ]]; }/**
Greg Kroah-Hartman
maintainerPATCH 135/776 Bluetooth: hci_core: Fix use-after-free in vhci_flush()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 1d6123102e9fbedc8d25bf4731da6d513173e49e ]
syzbot reported use-after-free in vhci_flush() without repro. [0]
Quoted 1 line
From the splat, a thread close()d a vhci file descriptor while
its device was being used by iotcl() on another thread.
Once the last fd refcnt is released, vhci_release() calls hci_unregister_dev(), hci_free_dev(), and kfree() for struct vhci_data, which is set to hci_dev->dev->driver_data.
The problem is that there is no synchronisation after unlinking hdev from hci_dev_list in hci_unregister_dev(). There might be another thread still accessing the hdev which was fetched before the unlink operation.
We can use SRCU for such synchronisation.
Let's run hci_dev_reset() under SRCU and wait for its completion in hci_unregister_dev().
Another option would be to restore hci_dev->destruct(), which was removed in commit 587ae086f6e4 ("Bluetooth: Remove unused hci-destruct cb"). However, this would not be a good solution, as we should not run hci_unregister_dev() while there are in-flight ioctl() requests, which could lead to another data-race KCSAN splat.
Note that other drivers seem to have the same problem, for exmaple, virtbt_remove().
[0]:
BUG: KASAN: slab-use-after-free in skb_queue_empty_lockless include/linux/skbuff.h:1891 [inline] BUG: KASAN: slab-use-after-free in skb_queue_purge_reason+0x99/0x360 net/core/skbuff.c:3937 Read of size 8 at addr ffff88807cb8d858 by task syz.1.219/6718 CPU: 1 UID: 0 PID: 6718 Comm: syz.1.219 Not tainted 6.16.0-rc1-syzkaller-00196-g08207f42d3ff #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: <TASK> dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xd2/0x2b0 mm/kasan/report.c:521 kasan_report+0x118/0x150 mm/kasan/report.c:634 skb_queue_empty_lockless include/linux/skbuff.h:1891 [inline] skb_queue_purge_reason+0x99/0x360 net/core/skbuff.c:3937 skb_queue_purge include/linux/skbuff.h:3368 [inline] vhci_flush+0x44/0x50 drivers/bluetooth/hci_vhci.c:69 hci_dev_do_reset net/bluetooth/hci_core.c:552 [inline] hci_dev_reset+0x420/0x5c0 net/bluetooth/hci_core.c:592 sock_do_ioctl+0xd9/0x300 net/socket.c:1190 sock_ioctl+0x576/0x790 net/socket.c:1311 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0xf9/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fcf5b98e929 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fcf5c7b9038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fcf5bbb6160 RCX: 00007fcf5b98e929 RDX: 0000000000000000 RSI: 00000000400448cb RDI: 0000000000000009 RBP: 00007fcf5ba10b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fcf5bbb6160 R15: 00007ffd6353d528 </TASK> Allocated by task 6535: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:394 kasan_kmalloc include/linux/kasan.h:260 [inline] __kmalloc_cache_noprof+0x230/0x3d0 mm/slub.c:4359 kmalloc_noprof include/linux/slab.h:905 [inline] kzalloc_noprof include/linux/slab.h:1039 [inline] vhci_open+0x57/0x360 drivers/bluetooth/hci_vhci.c:635 misc_open+0x2bc/0x330 drivers/char/misc.c:161 chrdev_open+0x4c9/0x5e0 fs/char_dev.c:414 do_dentry_open+0xdf0/0x1970 fs/open.c:964 vfs_open+0x3b/0x340 fs/open.c:1094 do_open fs/namei.c:3887 [inline] path_openat+0x2ee5/0x3830 fs/namei.c:4046 do_filp_open+0x1fa/0x410 fs/namei.c:4073 do_sys_openat2+0x121/0x1c0 fs/open.c:1437 do_sys_open fs/open.c:1452 [inline] __do_sys_openat fs/open.c:1468 [inline] __se_sys_openat fs/open.c:1463 [inline] __x64_sys_openat+0x138/0x170 fs/open.c:1463 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 6535: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:576 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x62/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2381 [inline] slab_free mm/slub.c:4643 [inline] kfree+0x18e/0x440 mm/slub.c:4842 vhci_release+0xbc/0xd0 drivers/bluetooth/hci_vhci.c:671 __fput+0x44c/0xa70 fs/file_table.c:465 task_work_run+0x1d1/0x260 kernel/task_work.c:227 exit_task_work include/linux/task_work.h:40 [inline] do_exit+0x6ad/0x22e0 kernel/exit.c:955 do_group_exit+0x21c/0x2d0 kernel/exit.c:1104 __do_sys_exit_group kernel/exit.c:1115 [inline] __se_sys_exit_group kernel/exit.c:1113 [inline] __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1113 x64_sys_call+0x21ba/0x21c0 arch/x86/include/generated/asm/syscalls_64.h:232 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88807cb8d800 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 88 bytes inside of
freed 1024-byte region [ffff88807cb8d800, ffff88807cb8dc00)
--- include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_core.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-)
include/net/bluetooth/hci_core.h +2 -0
@@ -28,6 +28,7 @@#include <linux/idr.h> #include <linux/leds.h> #include <linux/rculist.h> +#include <linux/srcu.h> #include <net/bluetooth/hci.h> #include <net/bluetooth/hci_sock.h>
@@ -308,6 +309,7 @@ struct amp_assoc {struct hci_dev {struct list_head list; +struct srcu_struct srcu;struct mutex lock;const char *name;
net/bluetooth/hci_core.c +30 -4
@@ -1048,7 +1048,7 @@ static int hci_linkpol_req(struct hci_re/* Get HCI device by index. * Device is held on return. */ -struct hci_dev *hci_dev_get (int index) +static struct hci_dev *__hci_dev_get (int index,int *srcu_index) {struct hci_dev *hdev =NULL , *d;
@@ -1061,6 +1061,8 @@ struct hci_dev *hci_dev_get(int index)list_for_each_entry (d, &hci_dev_list, list) {if (d->id == index) { hdev =hci_dev_hold (d); +if (srcu_index) + *srcu_index =srcu_read_lock (&d->srcu);break ; } }
@@ -1068,6 +1070,22 @@ struct hci_dev *hci_dev_get(int index)return hdev; } +struct hci_dev *hci_dev_get (int index) +{ +return __hci_dev_get (index,NULL ); +} + +static struct hci_dev *hci_dev_get_srcu (int index,int *srcu_index) +{ +return __hci_dev_get (index, srcu_index); +} + +static void hci_dev_put_srcu (struct hci_dev *hdev,int srcu_index) +{ +srcu_read_unlock (&hdev->srcu, srcu_index); +hci_dev_put (hdev); +} +/* ---- Inquiry support ---- */ bool hci_discovery_active (struct hci_dev *hdev)
@@ -1918,9 +1936,9 @@ static int hci_dev_do_reset(struct hci_dint hci_dev_reset (__u16 dev) {struct hci_dev *hdev; -int err; +int err, srcu_index; - hdev =hci_dev_get (dev); + hdev =hci_dev_get_srcu (dev, &srcu_index);if (!hdev)return -ENODEV ;
@@ -1942,7 +1960,7 @@ int hci_dev_reset(__u16 dev) err =hci_dev_do_reset (hdev); done: -hci_dev_put (hdev); +hci_dev_put_srcu (hdev, srcu_index);return err; }
@@ -3780,6 +3798,11 @@ struct hci_dev *hci_alloc_dev_priv(int sif (!hdev)return NULL ; +if (init_srcu_struct (&hdev->srcu)) { +kfree (hdev); +return NULL ; + } + hdev->pkt_type = (HCI_DM1 |HCI_DH1 |HCI_HV1 ); hdev->esco_type = (ESCO_HV1 ); hdev->link_mode = (HCI_LM_ACCEPT );
@@ -4029,6 +4052,9 @@ void hci_unregister_dev(struct hci_dev *list_del (&hdev->list);write_unlock (&hci_dev_list_lock); +synchronize_srcu (&hdev->srcu); +cleanup_srcu_struct (&hdev->srcu); +cancel_work_sync (&hdev->rx_work);cancel_work_sync (&hdev->cmd_work);cancel_work_sync (&hdev->tx_work);
Greg Kroah-Hartman
maintainerPATCH 136/776 dlm: fix possible lkb_resource null dereference
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Aring <[email protected]>
[ Upstream commit b98333c67daf887c724cd692e88e2db9418c0861 ]
This patch fixes a possible null pointer dereference when this function is called from request_lock() as lkb->lkb_resource is not assigned yet, only after validate_lock_args() by calling attach_lkb(). Another issue is that a resource name could be a non printable bytearray and we cannot assume to be ASCII coded.
The log functionality is probably never being hit when DLM is used in normal way and no debug logging is enabled. The null pointer dereference can only occur on a new created lkb that does not have the resource assigned yet, it probably never hits the null pointer dereference but we should be sure that other changes might not change this behaviour and we actually can hit the mentioned null pointer dereference.
In this patch we just drop the printout of the resource name, the lkb id is enough to make a possible connection to a resource name if this exists.
[ The context change is due to the commit 9ac8ba46a701 ("fs: dlm: handle -EINVAL as log_error()") in v6.1 which is irrelevant to the logic of this patch. ]
--- fs/dlm/lock.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/dlm/lock.c +2 -3
@@ -2923,10 +2923,9 @@ static int validate_lock_args(struct dlm rv =0 ; out:if (rv) -log_debug (ls,"validate_lock_args %d %x %x %x %d %d %s" , +log_debug (ls,"validate_lock_args %d %x %x %x %d %d" , rv, lkb->lkb_id, lkb->lkb_flags, args->flags, - lkb->lkb_status, lkb->lkb_wait_type, - lkb->lkb_resource->res_name); + lkb->lkb_status, lkb->lkb_wait_type);return rv; }
Greg Kroah-Hartman
maintainerPATCH 137/776 bpf: Do mark_chain_precision for ARG_CONST_ALLOC_SIZE_OR_ZERO
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit 2fc31465c5373b5ca4edf2e5238558cb62902311 ]
Precision markers need to be propagated whenever we have an ARG_CONST_* style argument, as the verifier cannot consider imprecise scalars to be equivalent for the purposes of states_equal check when such arguments refine the return value (in this case, set mem_size for PTR_TO_MEM). The resultant mem_size for the R0 is derived from the constant value, and if the verifier incorrectly prunes states considering them equivalent where such arguments exist (by seeing that both registers have reg->precise as false in regsafe), we can end up with invalid programs passing the verifier which can do access beyond what should have been the correct mem_size in that explored state.
To show a concrete example of the problem:
0000000000000000 <prog>:
0: r2 = *(u32 *)(r1 + 80)
1: r1 = *(u32 *)(r1 + 76)
2: r3 = r1
3: r3 += 4
4: if r3 > r2 goto +18 <LBB5_5>
5: w2 = 0
6: *(u32 *)(r1 + 0) = r2
7: r1 = *(u32 *)(r1 + 0)
8: r2 = 1
9: if w1 == 0 goto +1 <LBB5_3>
10: r2 = -10000000000000058 <LBB5_3>:
11: r1 = 0 ll
13: r3 = 0
14: call bpf_ringbuf_reserve
15: if r0 == 0 goto +7 <LBB5_5>
16: r1 = r0
17: r1 += 16777215
18: w2 = 0
19: *(u8 *)(r1 + 0) = r2
20: r1 = r0
21: r2 = 0
22: call bpf_ringbuf_submit00000000000000b8 <LBB5_5>:
23: w0 = 0
24: exitFor the first case, the single line execution's exploration will prune the search at insn 14 for the branch insn 9's second leg as it will be verified first using r2 = -1 (UINT_MAX), while as w1 at insn 9 will always be 0 so at runtime we don't get error for being greater than UINT_MAX/4 from bpf_ringbuf_reserve. The verifier during regsafe just sees reg->precise as false for both r2 registers in both states, hence considers them equal for purposes of states_equal.
If we propagated precise markers using the backtracking support, we would use the precise marking to then ensure that old r2 (UINT_MAX) was within the new r2 (1) and this would never be true, so the verification would rightfully fail.
The end result is that the out of bounds access at instruction 19 would be permitted without this fix.
Note that reg->precise is always set to true when user does not have CAP_BPF (or when subprog count is greater than 1 (i.e. use of any static or global functions)), hence this is only a problem when precision marks need to be explicitly propagated (i.e. privileged users with CAP_BPF).
A simplified test case has been included in the next patch to prevent future regressions.
[ The context change is due to the commit 8ab4cdcf03d0 ("bpf: Tidy up verifier check_func_arg()") in v6.0 which is irrelevant to the logic of this patch. ]
--- kernel/bpf/verifier.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/bpf/verifier.c +3 -0
@@ -5540,6 +5540,9 @@ skip_type_check:return -EACCES ; } meta->mem_size = reg->var_off.value; + err =mark_chain_precision (env, regno); +if (err) +return err; }else if (arg_type_is_int_ptr (arg_type)) {int size =int_ptr_type_to_size (arg_type);
Greg Kroah-Hartman
maintainerPATCH 138/776 gfs2: No more self recovery
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
[ Upstream commit deb016c1669002e48c431d6fd32ea1c20ef41756 ]
When a node withdraws and it turns out that it is the only node that has the filesystem mounted, gfs2 currently tries to replay the local journal to bring the filesystem back into a consistent state. Not only is that a very bad idea, it has also never worked because gfs2_recover_func() will refuse to do anything during a withdraw.
However, before even getting to this point, gfs2_recover_func() dereferences sdp->sd_jdesc->jd_inode. This was a use-after-free before commit 04133b607a78 ("gfs2: Prevent double iput for journal on error") and is a NULL pointer dereference since then.
Simply get rid of self recovery to fix that.
[ The context change is due to the commit f80d882edcf2 ("gfs2: Get rid of gfs2_glock_queue_put in signal_our_withdraw") in v6.10 which is irrelevant to the logic of this patch. ]
--- fs/gfs2/util.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-)
fs/gfs2/util.c +11 -19
@@ -234,31 +234,23 @@ static void signal_our_withdraw(struct g*/ ret =gfs2_glock_nq (&sdp->sd_live_gh); +gfs2_glock_put (live_gl);/* drop extra reference we acquired */ +clear_bit (SDF_WITHDRAW_RECOVERY , &sdp->sd_flags); +/* * If we actually got the "live" lock in EX mode, there are no other -* nodes available to replay our journal. So we try to replay it -* ourselves. We hold the "live" glock to prevent other mounters -* during recovery, then just dequeue it and reacquire it in our -* normal SH mode. Just in case the problem that caused us to -* withdraw prevents us from recovering our journal (e.g. io errors -* and such) we still check if the journal is clean before proceeding -* but we may wait forever until another mounter does the recovery. +* nodes available to replay our journal. */ if (ret ==0 ) { -fs_warn (sdp,"No other mounters found. Trying to recover our " -"own journal jid %d.\n" , sdp->sd_lockstruct.ls_jid); -if (gfs2_recover_journal (sdp->sd_jdesc,1 )) -fs_warn (sdp,"Unable to recover our journal jid %d.\n" , - sdp->sd_lockstruct.ls_jid); -gfs2_glock_dq_wait (&sdp->sd_live_gh); -gfs2_holder_reinit (LM_ST_SHARED ,LM_FLAG_NOEXP |GL_EXACT , - &sdp->sd_live_gh); -gfs2_glock_nq (&sdp->sd_live_gh); +fs_warn (sdp,"No other mounters found.\n" ); +/* +* We are about to release the lockspace. By keeping live_gl +* locked here, we ensure that the next mounter coming along +* will be a "first" mounter which will perform recovery. +*/ + goto skip_recovery; } -gfs2_glock_queue_put (live_gl);/* drop extra reference we acquired */ -clear_bit (SDF_WITHDRAW_RECOVERY , &sdp->sd_flags); -/* * At this point our journal is evicted, so we need to get a new inode * for it. Once done, we need to call gfs2_find_jhead which
Greg Kroah-Hartman
maintainerPATCH 139/776 binfmt_misc: restore write access before closing files opened by open_exec()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zilin Guan <[email protected]>
[ Upstream commit 90f601b497d76f40fa66795c3ecf625b6aced9fd ]
bm_register_write() opens an executable file using open_exec(), which internally calls do_open_execat() and denies write access on the file to avoid modification while it is being executed.
However, when an error occurs, bm_register_write() closes the file using filp_close() directly. This does not restore the write permission, which may cause subsequent write operations on the same file to fail.
Fix this by calling exe_file_allow_write_access() before filp_close() to restore the write permission properly.
[ Use allow_write_access() instead of exe_file_allow_write_access() according to commit 0357ef03c94ef
("fs: don't block write during exec on pre-content watched files"). ]
--- fs/binfmt_misc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/binfmt_misc.c +3 -1
@@ -816,8 +816,10 @@ out:inode_unlock (d_inode (root));if (err) { -if (f) +if (f) { +allow_write_access (f);filp_close (f,NULL ); + }kfree (e);return err; }
Greg Kroah-Hartman
maintainerPATCH 140/776 drm/amdgpu: unmap and remove csa_va properly
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lang Yu <[email protected]>
[ Upstream commit 5daff15cd013422bc6d1efcfe82b586800025384 ]
Root PD BO should be reserved before unmap and remove a bo_va from VM otherwise lockdep will complain.
v2: check fpriv->csa_va is not NULL instead of amdgpu_mcbp (christian)
[14616.936827] WARNING: CPU: 6 PID: 1711 at drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1762 amdgpu_vm_bo_del+0x399/0x3f0 [amdgpu] [14616.937096] Call Trace: [14616.937097] <TASK> [14616.937102] amdgpu_driver_postclose_kms+0x249/0x2f0 [amdgpu] [14616.937187] drm_file_free+0x1d6/0x300 [drm] [14616.937207] drm_close_helper.isra.0+0x62/0x70 [drm] [14616.937220] drm_release+0x5e/0x100 [drm] [14616.937234] __fput+0x9f/0x280 [14616.937239] ____fput+0xe/0x20 [14616.937241] task_work_run+0x61/0x90 [14616.937246] exit_to_user_mode_prepare+0x215/0x220 [14616.937251] syscall_exit_to_user_mode+0x2a/0x60 [14616.937254] do_syscall_64+0x48/0x90 [14616.937257] entry_SYSCALL_64_after_hwframe+0x63/0xcd
[ The context change is due to the commit e56694f718f0 ("drm/amdgpu: rename amdgpu_vm_bo_rmv to _del") in v5.18 and the proper adoption is done which is irrelevant to the logic of this patch. ]
--- drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 38 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_csa.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 10 +++----- 3 files changed, 45 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c +38 -0
@@ -106,3 +106,41 @@ int amdgpu_map_static_csa(struct amdgpu_ttm_eu_backoff_reservation (&ticket, &list);return 0 ; } + +int amdgpu_unmap_static_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amdgpu_bo *bo,struct amdgpu_bo_va *bo_va, +uint64_t csa_addr) +{ +struct ww_acquire_ctx ticket; +struct list_head list; +struct amdgpu_bo_list_entry pd; +struct ttm_validate_buffer csa_tv; +int r; + +INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&csa_tv.head); + csa_tv.bo = &bo->tbo; + csa_tv.num_shared =1 ; + +list_add (&csa_tv.head, &list); +amdgpu_vm_get_pd_bo (vm, &list, &pd); + + r =ttm_eu_reserve_buffers (&ticket, &list, true,NULL ); +if (r) { +DRM_ERROR ("failed to reserve CSA,PD BOs: err=%d\n" , r); +return r; + } + + r =amdgpu_vm_bo_unmap (adev, bo_va, csa_addr); +if (r) { +DRM_ERROR ("failed to do bo_unmap on static CSA, err=%d\n" , r); +ttm_eu_backoff_reservation (&ticket, &list); +return r; + } + +amdgpu_vm_bo_rmv (adev, bo_va); + +ttm_eu_backoff_reservation (&ticket, &list); + +return 0 ; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.h +3 -0
@@ -34,6 +34,9 @@ int amdgpu_allocate_static_csa(struct amint amdgpu_map_static_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct amdgpu_bo *bo,struct amdgpu_bo_va **bo_va,uint64_t csa_addr,uint32_t size); +int amdgpu_unmap_static_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amdgpu_bo *bo,struct amdgpu_bo_va *bo_va, +uint64_t csa_addr);void amdgpu_free_static_csa (struct amdgpu_bo **bo);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -6
@@ -1273,14 +1273,12 @@ void amdgpu_driver_postclose_kms(structif (amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_VCE ) !=NULL )amdgpu_vce_free_handles (adev, file_priv); -amdgpu_vm_bo_rmv (adev, fpriv->prt_va); +if (fpriv->csa_va) { +uint64_t csa_addr =amdgpu_csa_vaddr (adev) &AMDGPU_GMC_HOLE_MASK ; -if (amdgpu_mcbp ||amdgpu_sriov_vf (adev)) { -/* TODO: how to handle reserve failure */ -BUG_ON (amdgpu_bo_reserve (adev->virt.csa_obj, true)); -amdgpu_vm_bo_rmv (adev, fpriv->csa_va); +WARN_ON (amdgpu_unmap_static_csa (adev, &fpriv->vm, adev->virt.csa_obj, + fpriv->csa_va, csa_addr)); fpriv->csa_va =NULL ; -amdgpu_bo_unreserve (adev->virt.csa_obj); } pasid = fpriv->vm.pasid;
Greg Kroah-Hartman
maintainerPATCH 141/776 nvmet: always initialize cqe.result
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit cd0c1b8e045a8d2785342b385cb2684d9b48e426 ]
The spec doesn't mandate that the first two double words (aka results) for the command queue entry need to be set to 0 when they are not used (not specified). Though, the target implemention returns 0 for TCP and FC but not for RDMA.
Let's make RDMA behave the same and thus explicitly initializing the result field. This prevents leaking any data from the stack.
[ Ignored the fabrics-cmd-auth.c, it was introduced in commit:db1312dd9548 ("nvmet: implement basic In-Band Authentication") ]
--- drivers/nvme/target/core.c | 1 + drivers/nvme/target/fabrics-cmd.c | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/nvme/target/core.c +1 -0
@@ -932,6 +932,7 @@ bool nvmet_req_init(struct nvmet_req *re req->metadata_sg_cnt =0 ; req->transfer_len =0 ; req->metadata_len =0 ; + req->cqe->result.u64 =0 ; req->cqe->status =0 ; req->cqe->sq_head =0 ; req->ns =NULL ;
drivers/nvme/target/fabrics-cmd.c +0 -6
@@ -187,9 +187,6 @@ static void nvmet_execute_admin_connect(if (status) goto out; -/* zero out initial completion result, assign values as needed */ - req->cqe->result.u32 =0 ; -if (c->recfmt !=0 ) {pr_warn ("invalid connect version (%d).\n" ,le16_to_cpu (c->recfmt));
@@ -255,9 +252,6 @@ static void nvmet_execute_io_connect(strif (status) goto out; -/* zero out initial completion result, assign values as needed */ - req->cqe->result.u32 =0 ; -if (c->recfmt !=0 ) {pr_warn ("invalid connect version (%d).\n" ,le16_to_cpu (c->recfmt));
Greg Kroah-Hartman
maintainerPATCH 142/776 net: stmmac: fix TSO DMA API usage causing oops
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Russell King (Oracle)" <[email protected]>
[ Upstream commit 4c49f38e20a57f8abaebdf95b369295b153d1f8e ]
Commit 66600fac7a98 ("net: stmmac: TSO: Fix unbalanced DMA map/unmap for non-paged SKB data") moved the assignment of tx_skbuff_dma[]'s members to be later in stmmac_tso_xmit().
The buf (dma cookie) and len stored in this structure are passed to dma_unmap_single() by stmmac_tx_clean(). The DMA API requires that the dma cookie passed to dma_unmap_single() is the same as the value returned from dma_map_single(). However, by moving the assignment later, this is not the case when priv->dma_cap.addr64 > 32 as "des" is offset by proto_hdr_len.
This causes problems such as:
dwc-eth-dwmac 2490000.ethernet eth0: Tx DMA map failed
and with DMA_API_DEBUG enabled:
DMA-API: dwc-eth-dwmac 2490000.ethernet: device driver tries to +free DMA memory it has not allocated [device address=0x000000ffffcf65c0] [size=66 bytes]
Fix this by maintaining "des" as the original DMA cookie, and use tso_des to pass the offset DMA cookie to stmmac_tso_allocator().
Full details of the crashes can be found at:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/klkzp5yn5kq5efgtrow6wbvnc46bcqfxs65nz3qy77ujr5turc@bwwhelz2l4dw/
[ The context change is due to the commit 041cc86b3653 ("net: stmmac: Enable TSO on VLANs") in v6.11 which is irrelevant to the logic of this patch. ]
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -3
@@ -4034,9 +4034,9 @@ static netdev_tx_t stmmac_tso_xmit(strucint tmp_pay_len =0 , first_tx;struct stmmac_tx_queue *tx_q;bool has_vlan, set_ic; +dma_addr_t tso_des, des;u8 proto_hdr_len, hdr;u32 pay_len, mss; -dma_addr_t des;int i; tx_q = &priv->tx_queue[queue];
@@ -4120,14 +4120,15 @@ static netdev_tx_t stmmac_tso_xmit(struc/* If needed take extra descriptors to fill the remaining payload */ tmp_pay_len = pay_len -TSO_MAX_BUFF_SIZE ; + tso_des = des; }else {stmmac_set_desc_addr (priv, first, des); tmp_pay_len = pay_len; - des += proto_hdr_len; + tso_des = des + proto_hdr_len; pay_len =0 ; } -stmmac_tso_allocator (priv, des, tmp_pay_len, (nfrags ==0 ), queue); +stmmac_tso_allocator (priv, tso_des, tmp_pay_len, (nfrags ==0 ), queue);/* In case two or more DMA transmit descriptors are allocated for this * non-paged SKB data, the DMA buffer address should be saved to
Greg Kroah-Hartman
maintainerPATCH 143/776 f2fs: fix to wait on block writeback for post_read case
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 55fdc1c24a1d6229fe0ecf31335fb9a2eceaaa00 ]
If inode is compressed, but not encrypted, it missed to call f2fs_wait_on_block_writeback() to wait for GCed page writeback in IPU write path.
Thread A GC-Thread
- f2fs_gc
- do_garbage_collect
- gc_data_segment
- move_data_block
- f2fs_submit_page_write migrate normal cluster's block via meta_inode's page cache
- f2fs_write_single_data_page
- f2fs_do_write_data_page
- f2fs_inplace_write_data
- f2fs_submit_page_bio
IRQ
- f2fs_read_end_io
IRQ
old data overrides new data due to out-of-order GC and common IO.
- f2fs_read_end_io
--- fs/f2fs/data.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/f2fs/data.c +5 -3
@@ -2537,9 +2537,6 @@ int f2fs_encrypt_one_page(struct f2fs_io page = fio->compressed_page ? fio->compressed_page : fio->page; -/* wait for GCed page writeback via META_MAPPING */ -f2fs_wait_on_block_writeback (inode, fio->old_blkaddr); -if (fscrypt_inode_uses_inline_crypto (inode))return 0 ;
@@ -2718,6 +2715,11 @@ got_it: err = -EFSCORRUPTED ; goto out_writepage; } + +/* wait for GCed page writeback via META_MAPPING */ +if (fio->post_read) +f2fs_wait_on_block_writeback (inode, fio->old_blkaddr); +/* * If current allocation needs SSR, * it had better in-place writes for updated data.
Greg Kroah-Hartman
maintainerPATCH 144/776 pstore: inode: Only d_invalidate() is needed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit a43e0fc5e9134a46515de2f2f8d4100b74e50de3 ]
Unloading a modular pstore backend with records in pstorefs would trigger the dput() double-drop warning:
WARNING: CPU: 0 PID: 2569 at fs/dcache.c:762 dput.part.0+0x3f3/0x410
Using the combo of d_drop()/dput() (as mentioned in Documentation/filesystems/vfs.rst) isn't the right approach here, and leads to the reference counting problem seen above. Use d_invalidate() and update the code to not bother checking for error codes that can never happen.
---
--- fs/pstore/inode.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/pstore/inode.c +3 -7
@@ -312,7 +312,6 @@ int pstore_put_backend_records(struct ps {struct pstore_private *pos, *tmp;struct dentry *root; -int rc =0 ; root =psinfo_lock_root ();if (!root)
@@ -322,11 +321,8 @@ int pstore_put_backend_records(struct pslist_for_each_entry_safe (pos, tmp, &records_list, list) {if (pos->record->psi == psi) {list_del_init (&pos->list); - rc =simple_unlink (d_inode (root), pos->dentry); -if (WARN_ON (rc)) -break ; -d_drop (pos->dentry); -dput (pos->dentry); +d_invalidate (pos->dentry); +simple_unlink (d_inode (root), pos->dentry); pos->dentry =NULL ; } }
@@ -334,7 +330,7 @@ int pstore_put_backend_records(struct psinode_unlock (d_inode (root)); -return rc; +return 0 ; }/*
Greg Kroah-Hartman
maintainerPATCH 145/776 ALSA: usb-audio: Kill timer properly at removal
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 0718a78f6a9f04b88d0dc9616cc216b31c5f3cf1 ]
The USB-audio MIDI code initializes the timer, but in a rare case, the driver might be freed without the disconnect call. This leaves the timer in an active state while the assigned object is released via snd_usbmidi_free(), which ends up with a kernel warning when the debug configuration is enabled, as spotted by fuzzer.
For avoiding the problem, put timer_shutdown_sync() at snd_usbmidi_free(), so that the timer can be killed properly. While we're at it, replace the existing timer_delete_sync() at the disconnect callback with timer_shutdown_sync(), too.
[ The context change is due to the commit 8fa7292fee5c ("treewide: Switch/rename to timer_delete[_sync]()") in v6.15 which is irrelevant to the logic of this patch. ]
--- sound/usb/midi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/usb/midi.c +2 -1
@@ -1530,6 +1530,7 @@ static void snd_usbmidi_free(struct snd_snd_usbmidi_in_endpoint_delete (ep->in); }mutex_destroy (&umidi->mutex); +timer_shutdown_sync (&umidi->error_timer);kfree (umidi); }
@@ -1553,7 +1554,7 @@ void snd_usbmidi_disconnect(struct list_spin_unlock_irq (&umidi->disc_lock);up_write (&umidi->disc_rwsem); -del_timer_sync (&umidi->error_timer); +timer_shutdown_sync (&umidi->error_timer);for (i =0 ; i <MIDI_MAX_ENDPOINTS ; ++i) {struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i];
Greg Kroah-Hartman
maintainerPATCH 146/776 ice: Add netif_device_attach/detach into PF reset flow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dawid Osuchowski <[email protected]>
[ Upstream commit d11a67634227f9f9da51938af085fb41a733848f ]
Ethtool callbacks can be executed while reset is in progress and try to access deleted resources, e.g. getting coalesce settings can result in a NULL pointer dereference seen below.
Reproduction steps:
Once the driver is fully initialized, trigger reset:
# echo 1 > /sys/class/net/<interface>/device/reset when reset is in progress try to get coalesce settings using ethtool: # ethtool -c <interface>
BUG: kernel NULL pointer dereference, address: 0000000000000020 PGD 0 P4D 0 Oops: Oops: 0000 [#1] PREEMPT SMP PTI CPU: 11 PID: 19713 Comm: ethtool Tainted: G S 6.10.0-rc7+ #7 RIP: 0010:ice_get_q_coalesce+0x2e/0xa0 [ice] RSP: 0018:ffffbab1e9bcf6a8 EFLAGS: 00010206 RAX: 000000000000000c RBX: ffff94512305b028 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffff9451c3f2e588 RDI: ffff9451c3f2e588 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: ffff9451c3f2e580 R11: 000000000000001f R12: ffff945121fa9000 R13: ffffbab1e9bcf760 R14: 0000000000000013 R15: ffffffff9e65dd40 FS: 00007faee5fbe740(0000) GS:ffff94546fd80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000020 CR3: 0000000106c2e005 CR4: 00000000001706f0 Call Trace: <TASK> ice_get_coalesce+0x17/0x30 [ice] coalesce_prepare_data+0x61/0x80 ethnl_default_doit+0xde/0x340 genl_family_rcv_msg_doit+0xf2/0x150 genl_rcv_msg+0x1b3/0x2c0 netlink_rcv_skb+0x5b/0x110 genl_rcv+0x28/0x40 netlink_unicast+0x19c/0x290 netlink_sendmsg+0x222/0x490 __sys_sendto+0x1df/0x1f0 __x64_sys_sendto+0x24/0x30 do_syscall_64+0x82/0x160 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7faee60d8e27
Calling netif_device_detach() before reset makes the net core not call the driver when ethtool command is issued, the attempt to execute an ethtool command during reset will result in the following message:
netlink error: No such device
instead of NULL pointer dereference. Once reset is done and ice_rebuild() is executing, the netif_device_attach() is called to allow for ethtool operations to occur again in a safe manner.
[ Minor changed in ice_prepare_for_reset() to make sure vsi available to access ]
--- drivers/net/ethernet/intel/ice/ice_main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/intel/ice/ice_main.c +8 -0
@@ -479,6 +479,7 @@ static void ice_prepare_for_reset(struct ice_pf *pf) {struct ice_hw *hw = &pf->hw; +struct ice_vsi *vsi =ice_get_main_vsi (pf);unsigned int i;/* already prepared for reset */
@@ -495,6 +496,9 @@ ice_prepare_for_reset(struct ice_pf *pf)ice_for_each_vf (pf, i)ice_set_vf_state_qs_dis (&pf->vf[i]); +if (vsi && vsi->netdev) +netif_device_detach (vsi->netdev); +/* clear SW filtering DB */ ice_clear_hw_tbls (hw);/* disable the VSIs and their queues that are not already DOWN */
@@ -6417,6 +6421,7 @@ static void ice_update_pf_netdev_link(st*/ static void ice_rebuild (struct ice_pf *pf,enum ice_reset_req reset_type) { +struct ice_vsi *vsi =ice_get_main_vsi (pf);struct device *dev =ice_pf_to_dev (pf);struct ice_hw *hw = &pf->hw;enum ice_status ret;
@@ -6538,6 +6543,9 @@ static void ice_rebuild(struct ice_pf *pice_rebuild_arfs (pf); } +if (vsi && vsi->netdev) +netif_device_attach (vsi->netdev); +ice_update_pf_netdev_link (pf);/* tell the firmware we are up */
Greg Kroah-Hartman
maintainerPATCH 147/776 iio: imu: inv_icm42600: fix odr switch when turning buffer off
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
[ Upstream commit ffd32db8263d2d785a2c419486a450dc80693235 ]
ODR switch is done in 2 steps when FIFO is on : change the ODR register value and acknowledge change when reading the FIFO ODR change flag. When we are switching odr and turning buffer off just afterward, we are losing the FIFO ODR change flag and ODR switch is blocked.
Fix the issue by force applying any waiting ODR change when turning buffer off.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c +3 -0
@@ -377,6 +377,7 @@ out_unlock:static int inv_icm42600_buffer_postdisable (struct iio_dev *indio_dev) {struct inv_icm42600_state *st =iio_device_get_drvdata (indio_dev); +struct inv_icm42600_timestamp *ts =iio_priv (indio_dev);struct device *dev =regmap_get_device (st->map);unsigned int sensor;unsigned int *watermark;
@@ -398,6 +399,8 @@ static int inv_icm42600_buffer_postdisabmutex_lock (&st->lock); +inv_icm42600_timestamp_apply_odr (ts,0 ,0 ,0 ); + ret =inv_icm42600_buffer_set_fifo_en (st, st->fifo.en & ~sensor);if (ret) goto out_unlock;
Greg Kroah-Hartman
maintainerPATCH 148/776 Bluetooth: af_bluetooth: Fix deadlock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f7b94bdc1ec107c92262716b073b3e816d4784fb ]
Attemting to do sock_lock on .recvmsg may cause a deadlock as shown bellow, so instead of using sock_sock this uses sk_receive_queue.lock on bt_sock_ioctl to avoid the UAF:
INFO: task kworker/u9:1:121 blocked for more than 30 seconds.
Not tainted 6.7.6-lemon #183
Workqueue: hci0 hci_rx_work
Call Trace:
<TASK>
__schedule+0x37d/0xa00
schedule+0x32/0xe0
__lock_sock+0x68/0xa0
? __pfx_autoremove_wake_function+0x10/0x10
lock_sock_nested+0x43/0x50
l2cap_sock_recv_cb+0x21/0xa0
l2cap_recv_frame+0x55b/0x30a0
? psi_task_switch+0xeb/0x270
? finish_task_switch.isra.0+0x93/0x2a0
hci_rx_work+0x33a/0x3f0
process_one_work+0x13a/0x2f0
worker_thread+0x2f0/0x410
? __pfx_worker_thread+0x10/0x10
kthread+0xe0/0x110
? __pfx_kthread+0x10/0x10
ret_from_fork+0x2c/0x50
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1b/0x30
</TASK>[ The context change is due to the commit f4b41f062c42 ("net: remove noblock parameter from skb_recv_datagram()") in v5.19 which is irrelevant to the logic of this patch. ]
--- net/bluetooth/af_bluetooth.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
net/bluetooth/af_bluetooth.c +3 -7
@@ -285,14 +285,11 @@ int bt_sock_recvmsg(struct socket *sock,if (flags &MSG_OOB )return -EOPNOTSUPP ; -lock_sock (sk); - skb =skb_recv_datagram (sk, flags, noblock, &err);if (!skb) {if (sk->sk_shutdown &RCV_SHUTDOWN ) err =0 ; -release_sock (sk);return err; }
@@ -318,8 +315,6 @@ int bt_sock_recvmsg(struct socket *sock,skb_free_datagram (sk, skb); -release_sock (sk); -if (flags &MSG_TRUNC ) copied = skblen;
@@ -542,10 +537,11 @@ int bt_sock_ioctl(struct socket *sock, uif (sk->sk_state ==BT_LISTEN )return -EINVAL ; -lock_sock (sk); +spin_lock (&sk->sk_receive_queue.lock); skb =skb_peek (&sk->sk_receive_queue); amount = skb ? skb->len :0 ; -release_sock (sk); +spin_unlock (&sk->sk_receive_queue.lock); + err =put_user (amount, (int __user *)arg);break ;
Greg Kroah-Hartman
maintainerPATCH 149/776 can: gs_usb: gs_usb_xmit_callback(): fix handling of failed transmitted URBs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit 516a0cd1c03fa266bb67dd87940a209fd4e53ce7 ]
The driver lacks the cleanup of failed transfers of URBs. This reduces the number of available URBs per error by 1. This leads to reduced performance and ultimately to a complete stop of the transmission.
If the sending of a bulk URB fails do proper cleanup:
- increase netdev stats
- mark the echo_sbk as free
- free the driver's context and do accounting
- wake the send queue
--- drivers/net/can/usb/gs_usb.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/net/can/usb/gs_usb.c +15 -2
@@ -467,8 +467,21 @@ static void gs_usb_xmit_callback(structstruct gs_can *dev = txc->dev;struct net_device *netdev = dev->netdev; -if (urb->status) -netdev_info (netdev,"usb xmit fail %d\n" , txc->echo_id); +if (!urb->status) +return ; + +if (urb->status != -ESHUTDOWN &&net_ratelimit ()) +netdev_info (netdev,"failed to xmit URB %u: %pe\n" , + txc->echo_id,ERR_PTR (urb->status)); + + netdev->stats.tx_dropped++; + netdev->stats.tx_errors++; + +can_free_echo_skb (netdev, txc->echo_id,NULL ); +gs_free_tx_context (txc); +atomic_dec (&dev->active_tx_urbs); + +netif_wake_queue (netdev); usb_free_coherent(urb->dev, urb->transfer_buffer_length,
Greg Kroah-Hartman
maintainerPATCH 150/776 vdpa: Add max vqp attr to vdpa_nl_policy for nlattr length check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lin Ma <[email protected]>
[ Upstream commit 5d6ba607d6cb5c58a4ddf33381e18c83dbb4098f ]
The vdpa_nl_policy structure is used to validate the nlattr when parsing the incoming nlmsg. It will ensure the attribute being described produces a valid nlattr pointer in info->attrs before entering into each handler in vdpa_nl_ops.
That is to say, the missing part in vdpa_nl_policy may lead to illegal nlattr after parsing, which could lead to OOB read just like CVE-2023-3773.
This patch adds the missing nla_policy for vdpa max vqp attr to avoid such bugs.
Message-Id: <[email protected]>
--- drivers/vdpa/vdpa.c | 1 + 1 file changed, 1 insertion(+)
drivers/vdpa/vdpa.c +1 -0
@@ -847,6 +847,7 @@ static const struct nla_policy vdpa_nl_p [VDPA_ATTR_MGMTDEV_BUS_NAME] = { .type = NLA_NUL_STRING }, [VDPA_ATTR_MGMTDEV_DEV_NAME] = { .type = NLA_STRING }, [VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING }, + [VDPA_ATTR_DEV_NET_CFG_MAX_VQP] = { .type = NLA_U16 }, };static const struct genl_ops vdpa_nl_ops[] = {
Greg Kroah-Hartman
maintainerPATCH 151/776 f2fs: fix to trigger foreground gc during f2fs_map_blocks() in lfs mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 1005a3ca28e90c7a64fa43023f866b960a60f791 ]
w/ "mode=lfs" mount option, generic/299 will cause system panic as below:
------------[ cut here ]------------ kernel BUG at fs/f2fs/segment.c:2835! Call Trace: <TASK> f2fs_allocate_data_block+0x6f4/0xc50 f2fs_map_blocks+0x970/0x1550 f2fs_iomap_begin+0xb2/0x1e0 iomap_iter+0x1d6/0x430 __iomap_dio_rw+0x208/0x9a0 f2fs_file_write_iter+0x6b3/0xfa0 aio_write+0x15d/0x2e0 io_submit_one+0x55e/0xab0 __x64_sys_io_submit+0xa5/0x230 do_syscall_64+0x84/0x2f0 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0010:new_curseg+0x70f/0x720
The root cause of we run out-of-space is: in f2fs_map_blocks(), f2fs may trigger foreground gc only if it allocates any physical block, it will be a little bit later when there is multiple threads writing data w/ aio/dio/bufio method in parallel, since we always use OPU in lfs mode, so f2fs_map_blocks() does block allocations aggressively.
In order to fix this issue, let's give a chance to trigger foreground gc in prior to block allocation in f2fs_map_blocks().
[ The context change is due to the commit 2f51ade9524c ("f2fs: f2fs_do_map_lock") in v6.3 which is irrelevant to the logic of this patch. ]
--- fs/f2fs/data.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/data.c +4 -1
@@ -1523,8 +1523,11 @@ int f2fs_map_blocks(struct inode *inode, } next_dnode: -if (map->m_may_create) +if (map->m_may_create) { +if (f2fs_lfs_mode (sbi)) +f2fs_balance_fs (sbi, true);f2fs_do_map_lock (sbi, flag, true); + }/* When reading holes, we need its node page */ set_new_dnode (&dn, inode,NULL ,NULL ,0 );
Greg Kroah-Hartman
maintainerPATCH 152/776 SUNRPC: lock against ->sock changing during sysfs read
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
[ Upstream commit b49ea673e119f59c71645e2f65b3ccad857c90ee ]
->sock can be set to NULL asynchronously unless ->recv_mutex is held. So it is important to hold that mutex. Otherwise a sysfs read can trigger an oops.
Commit 17f09d3f619a ("SUNRPC: Check if the xprt is connected before handling sysfs reads") appears to attempt to fix this problem, but it only narrows the race window.
--- net/sunrpc/sysfs.c | 5 ++++- net/sunrpc/xprtsock.c | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-)
net/sunrpc/sysfs.c +4 -1
@@ -113,11 +113,14 @@ static ssize_t rpc_sysfs_xprt_srcaddr_shreturn 0 ; sock = container_of(xprt, struct sock_xprt, xprt); -if (kernel_getsockname (sock->sock, (struct sockaddr *)&saddr) <0 ) +mutex_lock (&sock->recv_mutex); +if (sock->sock ==NULL || +kernel_getsockname (sock->sock, (struct sockaddr *)&saddr) <0 ) goto out; ret =sprintf (buf,"%pISc\n" , &saddr); out: +mutex_unlock (&sock->recv_mutex);xprt_put (xprt);return ret +1 ; }
net/sunrpc/xprtsock.c +6 -1
@@ -1680,7 +1680,12 @@ static int xs_get_srcport(struct sock_xpunsigned short get_srcport (struct rpc_xprt *xprt) { struct sock_xprt *sock = container_of(xprt, struct sock_xprt, xprt); -return xs_sock_getport (sock->sock); +unsigned short ret =0 ; +mutex_lock (&sock->recv_mutex); +if (sock->sock) + ret =xs_sock_getport (sock->sock); +mutex_unlock (&sock->recv_mutex); +return ret; }EXPORT_SYMBOL (get_srcport);
Greg Kroah-Hartman
maintainerPATCH 153/776 net: usb: lan78xx: Fix double free issue with interrupt buffer allocation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit 03819abbeb11117dcbba40bfe322b88c0c88a6b6 ]
In lan78xx_probe(), the buffer buf was being freed twice: once implicitly through usb_free_urb(dev->urb_intr) with the URB_FREE_BUFFER flag and again explicitly by kfree(buf). This caused a double free issue.
To resolve this, reordered kmalloc() and usb_alloc_urb() calls to simplify the initialization sequence and removed the redundant kfree(buf). Now, buf is allocated after usb_alloc_urb(), ensuring it is correctly managed by usb_fill_int_urb() and freed by usb_free_urb() as intended.
[ Adjust context. Make the function usb_alloc_urb() call before kmalloc(). ]
--- drivers/net/usb/lan78xx.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/net/usb/lan78xx.c +14 -15
@@ -4111,29 +4111,30 @@ static int lan78xx_probe(struct usb_inte period = ep_intr->desc.bInterval; maxp =usb_maxpacket (dev->udev, dev->pipe_intr,0 ); - buf =kmalloc (maxp,GFP_KERNEL ); -if (!buf) { + + dev->urb_intr =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!dev->urb_intr) { ret = -ENOMEM ; goto out3; } - dev->urb_intr =usb_alloc_urb (0 ,GFP_KERNEL ); -if (!dev->urb_intr) { + buf =kmalloc (maxp,GFP_KERNEL ); +if (!buf) { ret = -ENOMEM ; - goto out4; - }else { -usb_fill_int_urb (dev->urb_intr, dev->udev, - dev->pipe_intr, buf, maxp, - intr_complete, dev, period); - dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; + goto free_urbs; } +usb_fill_int_urb (dev->urb_intr, dev->udev, + dev->pipe_intr, buf, maxp, + intr_complete, dev, period); + dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; + dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out,1 );/* Reject broken descriptors. */ if (dev->maxpacket ==0 ) { ret = -ENODEV ; - goto out5; + goto free_urbs; }/* driver requires remote-wakeup capability during autosuspend. */
@@ -4141,7 +4142,7 @@ static int lan78xx_probe(struct usb_inte ret =lan78xx_phy_init (dev);if (ret <0 ) - goto out5; + goto free_urbs; ret =register_netdev (netdev);if (ret !=0 ) {
@@ -4163,10 +4164,8 @@ static int lan78xx_probe(struct usb_inte out6:phy_disconnect (netdev->phydev); -out5: +free_urbs:usb_free_urb (dev->urb_intr); -out4: -kfree (buf); out3:lan78xx_unbind (dev, intf); out2:
Greg Kroah-Hartman
maintainerPATCH 154/776 btrfs: lock the inode in shared mode before starting fiemap
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 519b7e13b5ae8dd38da1e52275705343be6bb508 ]
Currently fiemap does not take the inode's lock (VFS lock), it only locks a file range in the inode's io tree. This however can lead to a deadlock if we have a concurrent fsync on the file and fiemap code triggers a fault when accessing the user space buffer with fiemap_fill_next_extent(). The deadlock happens on the inode's i_mmap_lock semaphore, which is taken both by fsync and btrfs_page_mkwrite(). This deadlock was recently reported by syzbot and triggers a trace like the following:
task:syz-executor361 state:D stack:20264 pid:5668 ppid:5119 flags:0x00004004
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5293 [inline]
__schedule+0x995/0xe20 kernel/sched/core.c:6606
schedule+0xcb/0x190 kernel/sched/core.c:6682
wait_on_state fs/btrfs/extent-io-tree.c:707 [inline]
wait_extent_bit+0x577/0x6f0 fs/btrfs/extent-io-tree.c:751
lock_extent+0x1c2/0x280 fs/btrfs/extent-io-tree.c:1742
find_lock_delalloc_range+0x4e6/0x9c0 fs/btrfs/extent_io.c:488
writepage_delalloc+0x1ef/0x540 fs/btrfs/extent_io.c:1863
__extent_writepage+0x736/0x14e0 fs/btrfs/extent_io.c:2174
extent_write_cache_pages+0x983/0x1220 fs/btrfs/extent_io.c:3091
extent_writepages+0x219/0x540 fs/btrfs/extent_io.c:3211
do_writepages+0x3c3/0x680 mm/page-writeback.c:2581
filemap_fdatawrite_wbc+0x11e/0x170 mm/filemap.c:388
__filemap_fdatawrite_range mm/filemap.c:421 [inline]
filemap_fdatawrite_range+0x175/0x200 mm/filemap.c:439
btrfs_fdatawrite_range fs/btrfs/file.c:3850 [inline]
start_ordered_ops fs/btrfs/file.c:1737 [inline]
btrfs_sync_file+0x4ff/0x1190 fs/btrfs/file.c:1839
generic_write_sync include/linux/fs.h:2885 [inline]
btrfs_do_write_iter+0xcd3/0x1280 fs/btrfs/file.c:1684
call_write_iter include/linux/fs.h:2189 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x7dc/0xc50 fs/read_write.c:584
ksys_write+0x177/0x2a0 fs/read_write.c:637
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f7d4054e9b9
RSP: 002b:00007f7d404fa2f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f7d405d87a0 RCX: 00007f7d4054e9b9
RDX: 0000000000000090 RSI: 0000000020000000 RDI: 0000000000000006
RBP: 00007f7d405a51d0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 61635f65646f6e69
R13: 65646f7475616f6e R14: 7261637369646f6e R15: 00007f7d405d87a8
</TASK>
INFO: task syz-executor361:5697 blocked for more than 145 seconds.
Not tainted 6.2.0-rc3-syzkaller-00376-g7c6984405241 #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor361 state:D stack:21216 pid:5697 ppid:5119 flags:0x00004004
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5293 [inline]
__schedule+0x995/0xe20 kernel/sched/core.c:6606
schedule+0xcb/0x190 kernel/sched/core.c:6682
rwsem_down_read_slowpath+0x5f9/0x930 kernel/locking/rwsem.c:1095
__down_read_common+0x54/0x2a0 kernel/locking/rwsem.c:1260
btrfs_page_mkwrite+0x417/0xc80 fs/btrfs/inode.c:8526
do_page_mkwrite+0x19e/0x5e0 mm/memory.c:2947
wp_page_shared+0x15e/0x380 mm/memory.c:3295
handle_pte_fault mm/memory.c:4949 [inline]
__handle_mm_fault mm/memory.c:5073 [inline]
handle_mm_fault+0x1b79/0x26b0 mm/memory.c:5219
do_user_addr_fault+0x69b/0xcb0 arch/x86/mm/fault.c:1428
handle_page_fault arch/x86/mm/fault.c:1519 [inline]
exc_page_fault+0x7a/0x110 arch/x86/mm/fault.c:1575
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0010:copy_user_short_string+0xd/0x40 arch/x86/lib/copy_user_64.S:233
Code: 74 0a 89 (...)
RSP: 0018:ffffc9000570f330 EFLAGS: 00050202
RAX: ffffffff843e6601 RBX: 00007fffffffefc8 RCX: 0000000000000007
RDX: 0000000000000000 RSI: ffffc9000570f3e0 RDI: 0000000020000120
RBP: ffffc9000570f490 R08: 0000000000000000 R09: fffff52000ae1e83
R10: fffff52000ae1e83 R11: 1ffff92000ae1e7c R12: 0000000000000038
R13: ffffc9000570f3e0 R14: 0000000020000120 R15: ffffc9000570f3e0
copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
raw_copy_to_user arch/x86/include/asm/uaccess_64.h:58 [inline]
_copy_to_user+0xe9/0x130 lib/usercopy.c:34
copy_to_user include/linux/uaccess.h:169 [inline]
fiemap_fill_next_extent+0x22e/0x410 fs/ioctl.c:144
emit_fiemap_extent+0x22d/0x3c0 fs/btrfs/extent_io.c:3458
fiemap_process_hole+0xa00/0xad0 fs/btrfs/extent_io.c:3716
extent_fiemap+0xe27/0x2100 fs/btrfs/extent_io.c:3922
btrfs_fiemap+0x172/0x1e0 fs/btrfs/inode.c:8209
ioctl_fiemap fs/ioctl.c:219 [inline]
do_vfs_ioctl+0x185b/0x2980 fs/ioctl.c:810
__do_sys_ioctl fs/ioctl.c:868 [inline]
__se_sys_ioctl+0x83/0x170 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f7d4054e9b9
RSP: 002b:00007f7d390d92f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f7d405d87b0 RCX: 00007f7d4054e9b9
RDX: 0000000020000100 RSI: 00000000c020660b RDI: 0000000000000005
RBP: 00007f7d405a51d0 R08: 00007f7d390d9700 R09: 0000000000000000
R10: 00007f7d390d9700 R11: 0000000000000246 R12: 61635f65646f6e69
R13: 65646f7475616f6e R14: 7261637369646f6e R15: 00007f7d405d87b8
</TASK>What happens is the following:
1) Task A is doing an fsync, enters btrfs_sync_file() and flushes delalloc before locking the inode and the i_mmap_lock semaphore, that is, before calling btrfs_inode_lock();
2) After task A flushes delalloc and before it calls btrfs_inode_lock(), another task dirties a page;
3) Task B starts a fiemap without FIEMAP_FLAG_SYNC, so the page dirtied at step 2 remains dirty and unflushed. Then when it enters extent_fiemap() and it locks a file range that includes the range of the page dirtied in step 2;
4) Task A calls btrfs_inode_lock() and locks the inode (VFS lock) and the inode's i_mmap_lock semaphore in write mode. Then it tries to flush delalloc by calling start_ordered_ops(), which will block, at find_lock_delalloc_range(), when trying to lock the range of the page dirtied at step 2, since this range was locked by the fiemap task (at step 3);
5) Task B generates a page fault when accessing the user space fiemap buffer with a call to fiemap_fill_next_extent().
The fault handler needs to call btrfs_page_mkwrite() for some other page of our inode, and there we deadlock when trying to lock the inode's i_mmap_lock semaphore in read mode, since the fsync task locked it in write mode (step 4) and the fsync task can not progress because it's waiting to lock a file range that is currently locked by us (the fiemap task, step 3).
Fix this by taking the inode's lock (VFS lock) in shared mode when entering fiemap. This effectively serializes fiemap with fsync (except the most expensive part of fsync, the log sync), preventing this deadlock.
--- fs/btrfs/extent_io.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/extent_io.c +2 -0
@@ -5590,6 +5590,7 @@ int extent_fiemap(struct btrfs_inode *in last_for_get_extent = isize; } +btrfs_inode_lock (&inode->vfs_inode,BTRFS_ILOCK_SHARED );lock_extent_bits (&inode->io_tree, start, start + len -1 , &cached_state);
@@ -5705,6 +5706,7 @@ out_free: out:unlock_extent_cached (&inode->io_tree, start, start + len -1 , &cached_state); +btrfs_inode_unlock (&inode->vfs_inode,BTRFS_ILOCK_SHARED ); out_free_ulist:btrfs_free_path (path);
Greg Kroah-Hartman
maintainerPATCH 155/776 fs/ntfs3: Add more attributes checks in mi_enum_attr()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit 013ff63b649475f0ee134e2c8d0c8e65284ede50 ]
--- fs/ntfs3/record.c | 63 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 13 deletions(-)
fs/ntfs3/record.c +50 -13
@@ -193,8 +193,9 @@ struct ATTRIB *mi_enum_attr(struct mft_i {const struct MFT_REC *rec = mi->mrec;u32 used =le32_to_cpu (rec->used); -u32 t32, off, asize; +u32 t32, off, asize, prev_type;u16 t16; +u64 data_size, alloc_size, tot_size;if (!attr) {u32 total =le32_to_cpu (rec->total);
@@ -213,6 +214,7 @@ struct ATTRIB *mi_enum_attr(struct mft_iif (!is_rec_inuse (rec))return NULL ; + prev_type =0 ; attr =Add2Ptr (rec, off); }else {/* Check if input attr inside record. */
@@ -226,6 +228,7 @@ struct ATTRIB *mi_enum_attr(struct mft_ireturn NULL ; } + prev_type =le32_to_cpu (attr->type); attr =Add2Ptr (attr, asize); off += asize; }
@@ -245,7 +248,11 @@ struct ATTRIB *mi_enum_attr(struct mft_i/* 0x100 is last known attribute for now. */ t32 =le32_to_cpu (attr->type); -if ((t32 &0xf ) || (t32 >0x100 )) +if (!t32 || (t32 &0xf ) || (t32 >0x100 )) +return NULL ; + +/* attributes in record must be ordered by type */ +if (t32 < prev_type)return NULL ;/* Check overflow and boundary. */
@@ -254,16 +261,15 @@ struct ATTRIB *mi_enum_attr(struct mft_i/* Check size of attribute. */ if (!attr->non_res) { +/* Check resident fields. */ if (asize <SIZEOF_RESIDENT )return NULL ; t16 =le16_to_cpu (attr->res.data_off); -if (t16 > asize)return NULL ; - t32 =le32_to_cpu (attr->res.data_size); -if (t16 + t32 > asize) +if (t16 +le32_to_cpu (attr->res.data_size) > asize)return NULL ; if (attr->name_len &&
@@ -274,21 +280,52 @@ struct ATTRIB *mi_enum_attr(struct mft_ireturn attr; } -/* Check some nonresident fields. */ -if (attr->name_len && -le16_to_cpu (attr->name_off) +sizeof (short ) * attr->name_len > -le16_to_cpu (attr->nres.run_off)) { +/* Check nonresident fields. */ +if (attr->non_res !=1 ) +return NULL ; + + t16 =le16_to_cpu (attr->nres.run_off); +if (t16 > asize) +return NULL ; + + t32 =sizeof (short ) * attr->name_len; +if (t32 &&le16_to_cpu (attr->name_off) + t32 > t16) +return NULL ; + +/* Check start/end vcn. */ +if (le64_to_cpu (attr->nres.svcn) >le64_to_cpu (attr->nres.evcn) +1 ) +return NULL ; + + data_size =le64_to_cpu (attr->nres.data_size); +if (le64_to_cpu (attr->nres.valid_size) > data_size)return NULL ; - } -if (attr->nres.svcn || !is_attr_ext (attr)) { + alloc_size =le64_to_cpu (attr->nres.alloc_size); +if (data_size > alloc_size) +return NULL ; + + t32 = mi->sbi->cluster_mask; +if (alloc_size & t32) +return NULL ; + +if (!attr->nres.svcn &&is_attr_ext (attr)) { +/* First segment of sparse/compressed attribute */ +if (asize +8 <SIZEOF_NONRESIDENT_EX ) +return NULL ; + + tot_size =le64_to_cpu (attr->nres.total_size); +if (tot_size & t32) +return NULL ; + +if (tot_size > alloc_size) +return NULL ; + }else {if (asize +8 <SIZEOF_NONRESIDENT )return NULL ;if (attr->nres.c_unit)return NULL ; - }else if (asize +8 <SIZEOF_NONRESIDENT_EX ) -return NULL ; + }return attr; }
Greg Kroah-Hartman
maintainerPATCH 156/776 rxrpc: Fix recvmsg() unconditional requeue
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 2c28769a51deb6022d7fbd499987e237a01dd63a ]
If rxrpc_recvmsg() fails because MSG_DONTWAIT was specified but the call at the front of the recvmsg queue already has its mutex locked, it requeues the call - whether or not the call is already queued. The call may be on the queue because MSG_PEEK was also passed and so the call was not dequeued or because the I/O thread requeued it.
The unconditional requeue may then corrupt the recvmsg queue, leading to things like UAFs or refcount underruns.
Fix this by only requeuing the call if it isn't already on the queue - and moving it to the front if it is already queued. If we don't queue it, we have to put the ref we obtained by dequeuing it.
Also, MSG_PEEK doesn't dequeue the call so shouldn't call rxrpc_notify_socket() for the call if we didn't use up all the data on the queue, so fix that also.
[Adapted to 5.15: use write_lock_bh/write_unlock_bh, trace_rxrpc_call
directly for see-call tracing, 5.15 trace enum naming convention, and added entries to both plain enum and EM() macro list.]
--- include/trace/events/rxrpc.h | 8 ++++++++ net/rxrpc/recvmsg.c | 22 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-)
include/trace/events/rxrpc.h +8 -0
@@ -93,9 +93,13 @@ enum rxrpc_call_trace { rxrpc_call_put_notimer, rxrpc_call_put_timer, rxrpc_call_put_userid, + rxrpc_call_put_recvmsg_peek_nowait, rxrpc_call_queued, rxrpc_call_queued_ref, rxrpc_call_release, + rxrpc_call_see_recvmsg_requeue, + rxrpc_call_see_recvmsg_requeue_first, + rxrpc_call_see_recvmsg_requeue_move, rxrpc_call_seen, };
@@ -291,9 +295,13 @@ enum rxrpc_tx_point { EM(rxrpc_call_put_notimer, "PnT") \ EM(rxrpc_call_put_timer, "PTM") \ EM(rxrpc_call_put_userid, "Pus") \ + EM(rxrpc_call_put_recvmsg_peek_nowait, "PpN") \ EM(rxrpc_call_queued, "QUE") \ EM(rxrpc_call_queued_ref, "QUR") \ EM(rxrpc_call_release, "RLS") \ + EM(rxrpc_call_see_recvmsg_requeue, "SrQ") \ + EM(rxrpc_call_see_recvmsg_requeue_first,"SrF") \ + EM(rxrpc_call_see_recvmsg_requeue_move, "SrM") \ E_(rxrpc_call_seen, "SEE")#define rxrpc_transmit_traces \
net/rxrpc/recvmsg.c +18 -4
@@ -607,7 +607,8 @@ try_again:if (after (call->rx_top, call->rx_hard_ack) && call->rxtx_buffer[(call->rx_hard_ack +1 ) &RXRPC_RXTX_BUFF_MASK ]) -rxrpc_notify_socket (call); +if (!(flags &MSG_PEEK )) +rxrpc_notify_socket (call);break ;default : ret =0 ;
@@ -642,11 +643,24 @@ error_unlock_call: error_requeue_call:if (!(flags &MSG_PEEK )) {write_lock_bh (&rx->recvmsg_lock); -list_add (&call->recvmsg_link, &rx->recvmsg_q); -write_unlock_bh (&rx->recvmsg_lock); +if (list_empty (&call->recvmsg_link)) { +list_add (&call->recvmsg_link, &rx->recvmsg_q); +trace_rxrpc_call (call->debug_id, + rxrpc_call_see_recvmsg_requeue, +refcount_read (&call->ref), +__builtin_return_address (0 ),NULL ); +write_unlock_bh (&rx->recvmsg_lock); + }else if (list_is_first (&call->recvmsg_link, &rx->recvmsg_q)) { +write_unlock_bh (&rx->recvmsg_lock); +rxrpc_put_call (call, rxrpc_call_see_recvmsg_requeue_first); + }else { +list_move (&call->recvmsg_link, &rx->recvmsg_q); +write_unlock_bh (&rx->recvmsg_lock); +rxrpc_put_call (call, rxrpc_call_see_recvmsg_requeue_move); + }trace_rxrpc_recvmsg (call, rxrpc_recvmsg_requeue,0 ,0 ,0 ,0 ); }else { -rxrpc_put_call (call, rxrpc_call_put); +rxrpc_put_call (call, rxrpc_call_put_recvmsg_peek_nowait); } error_no_call:release_sock (&rx->sk);
Greg Kroah-Hartman
maintainerPATCH 157/776 cpufreq: governor: Free dbs_data directly when gov->init() fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liao Chang <[email protected]>
[ Upstream commit 916f13884042f615cfbfc0b42cc68dadee826f2a ]
Due to the kobject embedded in the dbs_data doest not has a release() method yet, it needs to use kfree() to free dbs_data directly when governor fails to allocate the tunner field of dbs_data.
Stable-dep-of: 6dcf9d0064ce ("cpufreq: governor: fix double free in cpufreq_dbs_governor_init() error path")
--- drivers/cpufreq/cpufreq_governor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq_governor.c +3 -1
@@ -440,7 +440,7 @@ int cpufreq_dbs_governor_init(struct cpu ret = gov->init (dbs_data);if (ret) - goto free_policy_dbs_info; + goto free_dbs_data;/* * The sampling interval should not be less than the transition latency
@@ -475,6 +475,8 @@ int cpufreq_dbs_governor_init(struct cpuif (!have_governor_per_policy ()) gov->gdbs_data =NULL ; gov->exit (dbs_data); + +free_dbs_data:kfree (dbs_data); free_policy_dbs_info:
Greg Kroah-Hartman
maintainerPATCH 158/776 cpufreq: governor: fix double free in cpufreq_dbs_governor_init() error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 6dcf9d0064ce2f3e3dfe5755f98b93abe6a98e1e ]
When kobject_init_and_add() fails, cpufreq_dbs_governor_init() calls kobject_put(&dbs_data->attr_set.kobj).
The kobject release callback cpufreq_dbs_data_release() calls gov->exit(dbs_data) and kfree(dbs_data), but the current error path then calls gov->exit(dbs_data) and kfree(dbs_data) again, causing a double free.
Keep the direct kfree(dbs_data) for the gov->init() failure path, but after kobject_init_and_add() has been called, let kobject_put() handle the cleanup through cpufreq_dbs_data_release().
--- drivers/cpufreq/cpufreq_governor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/cpufreq/cpufreq_governor.c +3 -3
@@ -468,13 +468,13 @@ int cpufreq_dbs_governor_init(struct cpu/* Failure, so roll back. */ pr_err ("initialization failed (dbs_data kobject init error %d)\n" , ret); -kobject_put (&dbs_data->attr_set.kobj); - policy->governor_data =NULL ;if (!have_governor_per_policy ()) gov->gdbs_data =NULL ; - gov->exit (dbs_data); + +kobject_put (&dbs_data->attr_set.kobj); + goto free_policy_dbs_info; free_dbs_data:kfree (dbs_data);
Greg Kroah-Hartman
maintainerPATCH 159/776 md/md-bitmap: Synchronize bitmap_get_stats() with bitmap lifetime
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
[ Upstream commit 8d28d0ddb986f56920ac97ae704cc3340a699a30 ]
After commit ec6bb299c7c3 ("md/md-bitmap: add 'sync_size' into struct md_bitmap_stats"), following panic is reported:
Oops: general protection fault, probably for non-canonical address RIP: 0010:bitmap_get_stats+0x2b/0xa0 Call Trace: <TASK> md_seq_show+0x2d2/0x5b0 seq_read_iter+0x2b9/0x470 seq_read+0x12f/0x180 proc_reg_read+0x57/0xb0 vfs_read+0xf6/0x380 ksys_read+0x6c/0xf0 do_syscall_64+0x82/0x170 entry_SYSCALL_64_after_hwframe+0x76/0x7e
Root cause is that bitmap_get_stats() can be called at anytime if mddev is still there, even if bitmap is destroyed, or not fully initialized. Deferenceing bitmap in this case can crash the kernel. Meanwhile, the above commit start to deferencing bitmap->storage, make the problem easier to trigger.
Fix the problem by protecting bitmap_get_stats() with bitmap_info.mutex.
[ The context change is due to the commit 38f287d7e495
("md/md-bitmap: replace md_bitmap_status() with a new helper md_bitmap_get_stats()") in v6.12 and the commit f9cfe7e7f96a ("md: Fix md_seq_ops() regressions") in v6.8 which are irrelevant to the logic of this patch. ]
--- drivers/md/md-bitmap.c | 4 ++++ drivers/md/md.c | 4 ++++ 2 files changed, 8 insertions(+)
drivers/md/md-bitmap.c +4 -0
@@ -2033,6 +2033,10 @@ void md_bitmap_status(struct seq_file *sif (!bitmap)return ; +if (bitmap->mddev->bitmap_info.external) +return ; +if (!bitmap->storage.sb_page)/* no superblock */ +return ; counts = &bitmap->counts;
drivers/md/md.c +4 -0
@@ -8300,6 +8300,9 @@ static int md_seq_show(struct seq_file *return 0 ; } +/* prevent bitmap to be freed after checking */ +mutex_lock (&mddev->bitmap_info.mutex); +spin_lock (&mddev->lock);if (mddev->pers || mddev->raid_disks || !list_empty (&mddev->disks)) { seq_printf(seq, "%s : %sactive", mdname(mddev),
@@ -8371,6 +8374,7 @@ static int md_seq_show(struct seq_file *seq_printf (seq,"\n" ); }spin_unlock (&mddev->lock); +mutex_unlock (&mddev->bitmap_info.mutex);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 160/776 fbdev: efifb: Register sysfs groups through driver core
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 95cdd538e0e5677efbdf8aade04ec098ab98f457 ]
The driver core can register and cleanup sysfs groups already. Make use of that functionality to simplify the error handling and cleanup.
Also avoid a UAF race during unregistering where the sysctl attributes were usable after the info struct was freed.
--- drivers/video/fbdev/efifb.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/video/fbdev/efifb.c +2 -9
@@ -581,15 +581,10 @@ static int efifb_probe(struct platform_dbreak ; } - err =sysfs_create_groups (&dev->dev.kobj, efifb_groups); -if (err) { -pr_err ("efifb: cannot add sysfs attrs\n" ); - goto err_unmap; - } err =fb_alloc_cmap (&info->cmap,256 ,0 );if (err <0 ) {pr_err ("efifb: cannot allocate colormap\n" ); - goto err_groups; + goto err_unmap; }if (efifb_pci_dev)
@@ -608,8 +603,6 @@ err_put_rpm_ref:pm_runtime_put (&efifb_pci_dev->dev);fb_dealloc_cmap (&info->cmap); -err_groups: -sysfs_remove_groups (&dev->dev.kobj, efifb_groups); err_unmap:if (mem_flags & (EFI_MEMORY_UC |EFI_MEMORY_WC ))iounmap (info->screen_base);
@@ -629,7 +622,6 @@ static int efifb_remove(struct platform_/* efifb_destroy takes care of info cleanup */ unregister_framebuffer (info); -sysfs_remove_groups (&pdev->dev.kobj, efifb_groups);return 0 ; }
@@ -637,6 +629,7 @@ static int efifb_remove(struct platform_static struct platform_driver efifb_driver = { .driver = { .name ="efi-framebuffer" , + .dev_groups = efifb_groups, }, .probe = efifb_probe, .remove = efifb_remove,
Greg Kroah-Hartman
maintainerPATCH 161/776 net: clear the dst when changing skb protocol
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit ba9db6f907ac02215e30128770f85fbd7db2fcf9 ]
A not-so-careful NAT46 BPF program can crash the kernel if it indiscriminately flips ingress packets from v4 to v6:
BUG: kernel NULL pointer dereference, address: 0000000000000000
ip6_rcv_core (net/ipv6/ip6_input.c:190:20)
ipv6_rcv (net/ipv6/ip6_input.c:306:8)
process_backlog (net/core/dev.c:6186:4)
napi_poll (net/core/dev.c:6906:9)
net_rx_action (net/core/dev.c:7028:13)
do_softirq (kernel/softirq.c:462:3)
netif_rx (net/core/dev.c:5326:3)
dev_loopback_xmit (net/core/dev.c:4015:2)
ip_mc_finish_output (net/ipv4/ip_output.c:363:8)
NF_HOOK (./include/linux/netfilter.h:314:9)
ip_mc_output (net/ipv4/ip_output.c:400:5)
dst_output (./include/net/dst.h:459:9)
ip_local_out (net/ipv4/ip_output.c:130:9)
ip_send_skb (net/ipv4/ip_output.c:1496:8)
udp_send_skb (net/ipv4/udp.c:1040:8)
udp_sendmsg (net/ipv4/udp.c:1328:10)The output interface has a 4->6 program attached at ingress. We try to loop the multicast skb back to the sending socket. Ingress BPF runs as part of netif_rx(), pushes a valid v6 hdr and changes skb->protocol to v6. We enter ip6_rcv_core which tries to use skb_dst(). But the dst is still an IPv4 one left after IPv4 mcast output.
Clear the dst in all BPF helpers which change the protocol. Try to preserve metadata dsts, those may carry non-routing metadata.
[ The context change is due to the commit d219df60a70e ("bpf: Add ipip6 and ip6ip decap support for bpf_skb_adjust_room()") in v6.3 which is irrelevant to the logic of this patch. ]
--- net/core/filter.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
net/core/filter.c +11 -4
@@ -3219,6 +3219,13 @@ static const struct bpf_func_proto bpf_s .arg1_type = ARG_PTR_TO_CTX, }; +static void bpf_skb_change_protocol (struct sk_buff *skb,u16 proto) +{ + skb->protocol =htons (proto); +if (skb_valid_dst (skb)) +skb_dst_drop (skb); +} +static int bpf_skb_generic_push (struct sk_buff *skb,u32 off,u32 len) {/* Caller already did skb_cow() with len as headroom,
@@ -3315,7 +3322,7 @@ static int bpf_skb_proto_4_to_6(struct s } } - skb->protocol =htons (ETH_P_IPV6 ); +bpf_skb_change_protocol (skb,ETH_P_IPV6 );skb_clear_hash (skb);return 0 ;
@@ -3345,7 +3352,7 @@ static int bpf_skb_proto_6_to_4(struct s } } - skb->protocol =htons (ETH_P_IP ); +bpf_skb_change_protocol (skb,ETH_P_IP );skb_clear_hash (skb);return 0 ;
@@ -3532,10 +3539,10 @@ static int bpf_skb_net_grow(struct sk_bu/* Match skb->protocol to new outer l3 protocol */ if (skb->protocol ==htons (ETH_P_IP ) && flags &BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 ) - skb->protocol =htons (ETH_P_IPV6 ); +bpf_skb_change_protocol (skb,ETH_P_IPV6 );else if (skb->protocol ==htons (ETH_P_IPV6 ) && flags &BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 ) - skb->protocol =htons (ETH_P_IP ); +bpf_skb_change_protocol (skb,ETH_P_IP ); }if (skb_is_gso (skb)) {
Greg Kroah-Hartman
maintainerPATCH 162/776 cpufreq: Avoid a bad reference count on CPU node
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Sabaté Solà <[email protected]>
[ Upstream commit c0f02536fffbbec71aced36d52a765f8c4493dc2 ]
In the parse_perf_domain function, if the call to of_parse_phandle_with_args returns an error, then the reference to the CPU device node that was acquired at the start of the function would not be properly decremented.
Address this by declaring the variable with the __free(device_node) cleanup attribute.
--- include/linux/cpufreq.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
include/linux/cpufreq.h +1 -4
@@ -1014,11 +1014,10 @@ static inline int cpufreq_table_count_vastatic inline int parse_perf_domain (int cpu,const char *list_name,const char *cell_name) { -struct device_node *cpu_np;struct of_phandle_args args;int ret; - cpu_np =of_cpu_device_node_get (cpu); + struct device_node *cpu_np __free(device_node) = of_cpu_device_node_get(cpu);if (!cpu_np)return -ENODEV ;
@@ -1027,8 +1026,6 @@ static inline int parse_perf_domain(intif (ret <0 )return ret; -of_node_put (cpu_np); -return args.args[0 ]; }
Greg Kroah-Hartman
maintainerPATCH 163/776 drivers: base: Free devm resources when unregistering a device
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Gow <[email protected]>
[ Upstream commit 699fb50d99039a50e7494de644f96c889279aca3 ]
In the current code, devres_release_all() only gets called if the device has a bus and has been probed.
This leads to issues when using bus-less or driver-less devices where the device might never get freed if a managed resource holds a reference to the device. This is happening in the DRM framework for example.
We should thus call devres_release_all() in the device_del() function to make sure that the device-managed actions are properly executed when the device is unregistered, even if it has neither a bus nor a driver.
This is effectively the same change than commit 2f8d16a996da ("devres:
release resources on device_del()") that got reverted by commit a525a3ddeaca ("driver core: free devres in device_release") over memory leaks concerns.
This patch effectively combines the two commits mentioned above to release the resources both on device_del() and device_release() and get the best of both worlds.
--- drivers/base/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/base/core.c +12 -0
@@ -3604,9 +3604,21 @@ void device_del(struct device *dev)device_remove_properties (dev);device_links_purge (dev); +/* +* If a device does not have a driver attached, we need to clean +* up any managed resources. We do this in device_release(), but +* it's never called (and we leak the device) if a managed +* resource holds a reference to the device. So release all +* managed resources here, like we do in driver_detach(). We +* still need to do so again in device_release() in case someone +* adds a new resource after this point, though. +*/ +devres_release_all (dev); +if (dev->bus)blocking_notifier_call_chain (&dev->bus->p->bus_notifier,BUS_NOTIFY_REMOVED_DEVICE , dev); +kobject_uevent (&dev->kobj,KOBJ_REMOVE ); glue_dir =get_glue_dir (dev);kobject_del (&dev->kobj);
Greg Kroah-Hartman
maintainerPATCH 164/776 Revert "wifi: cfg80211: stop NAN and P2P in cfg80211_leave"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guocai He <[email protected]>
This reverts commit 31344ffecd7a34335ce2b52e8c205bce3cbfca4b which is commit e1696c8bd0056bc1a5f7766f58ac333adc203e8a upstream.
The reverted patch introduced a deadlock. The locking situation in mainline is totally different, so it is incorrect to directly backport the commit from mainline.
--- net/wireless/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/wireless/core.c +1 -3
@@ -1300,10 +1300,8 @@ void __cfg80211_leave(struct cfg80211_re__cfg80211_leave_ocb (rdev, dev);break ;case NL80211_IFTYPE_P2P_DEVICE : -cfg80211_stop_p2p_device (rdev, wdev); -break ;case NL80211_IFTYPE_NAN : -cfg80211_stop_nan (rdev, wdev); +/* cannot happen, has no netdev */ break ;case NL80211_IFTYPE_AP_VLAN :case NL80211_IFTYPE_MONITOR :
Greg Kroah-Hartman
maintainerPATCH 165/776 scripts/dtc: Remove unused dts_version in dtc-lexer.l
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
This patch is for stable only. Commit 5a09df20872c ("scripts/dtc: Update to upstream version v1.7.2-69-g53373d135579") upstream applied it as part of a regular scripts/dtc sync, which may be unsuitable for older versions of stable where the warning it fixes is present.
A recent strengthening of -Wunused-but-set-variable (enabled with -Wall) in clang under a new subwarning, -Wunused-but-set-global, points out an unused static global variable in dtc-lexer.lex.c (compiled from dtc-lexer.l):
scripts/dtc/dtc-lexer.lex.c:641:12: warning: variable 'dts_version' set but not used [-Wunused-but-set-global]
641 | static int dts_version = 1;
| ^Remove it to clear up the warning, as it is truly unused.
---
This should apply cleanly to all supported stable branches.
--- scripts/dtc/dtc-lexer.l | 3 --- 1 file changed, 3 deletions(-)
scripts/dtc/dtc-lexer.l +0 -3
@@ -39,8 +39,6 @@ extern bool treesource_error; #define DPRINT(fmt, ...) do { } while (0) #endif -static int dts_version = 1; - #define BEGIN_DEFAULT() DPRINT("<V1>\n"); \ BEGIN(V1); \
@@ -101,7 +99,6 @@ static void PRINTF(1, 2) lexical_error(c <*>"/dts-v1/" { DPRINT("Keyword: /dts-v1/\n"); - dts_version = 1; BEGIN_DEFAULT(); return DT_V1; }
Greg Kroah-Hartman
maintainerPATCH 166/776 ksmbd: unset conn->binding on failed binding request
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 282343cf8a4a5a3603b1cb0e17a7083e4a593b03 upstream.
When a multichannel SMB2_SESSION_SETUP request with SMB2_SESSION_REQ_FLAG_BINDING fails ksmbd sets conn->binding = true but never clears it on the error path. This leaves the connection in a binding state where all subsequent ksmbd_session_lookup_all() calls fall back to the global sessions table. This fix it by clearing conn->binding = false in the error path.
--- fs/ksmbd/smb2pdu.c | 1 + 1 file changed, 1 insertion(+)
fs/ksmbd/smb2pdu.c +1 -0
@@ -1949,6 +1949,7 @@ out_err: } }smb2_set_err_rsp (work); + conn->binding = false; }else {unsigned int iov_len;
Greg Kroah-Hartman
maintainerPATCH 167/776 rxrpc: only handle RESPONSE during service challenge
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Jie <[email protected]>
[ Upstream commit c43ffdcfdbb5567b1f143556df8a04b4eeea041c ]
Only process RESPONSE packets while the service connection is still in RXRPC_CONN_SERVICE_CHALLENGING. Check that state under state_lock before running response verification and security initialization, then use a local secured flag to decide whether to queue the secured-connection work after the state transition. This keeps duplicate or late RESPONSE packets from re-running the setup path and removes the unlocked post-transition state test.
--- net/rxrpc/conn_event.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
net/rxrpc/conn_event.c +13 -4
@@ -293,6 +293,7 @@ static int rxrpc_process_event(struct rx u32 *_abort_code) {struct rxrpc_skb_priv *sp =rxrpc_skb (skb); +bool secured = false;__be32 wtmp;u32 abort_code;int loop, ret;
@@ -337,6 +338,13 @@ static int rxrpc_process_event(struct rx _abort_code);case RXRPC_PACKET_TYPE_RESPONSE : +spin_lock_bh (&conn->state_lock); +if (conn->state !=RXRPC_CONN_SERVICE_CHALLENGING ) { +spin_unlock_bh (&conn->state_lock); +return 0 ; + } +spin_unlock_bh (&conn->state_lock); + ret = conn->security->verify_response (conn, skb, _abort_code);if (ret <0 )return ret;
@@ -348,17 +356,18 @@ static int rxrpc_process_event(struct rxspin_lock (&conn->bundle->channel_lock);spin_lock_bh (&conn->state_lock); -if (conn->state ==RXRPC_CONN_SERVICE_CHALLENGING ) { conn->state =RXRPC_CONN_SERVICE ; -spin_unlock_bh (&conn->state_lock); + secured = true; + } +spin_unlock_bh (&conn->state_lock); + +if (secured) {for (loop =0 ; loop <RXRPC_MAXCALLS ; loop++)rxrpc_call_is_secure (rcu_dereference_protected ( conn->channels[loop].call,lockdep_is_held (&conn->bundle->channel_lock))); - }else { -spin_unlock_bh (&conn->state_lock); }spin_unlock (&conn->bundle->channel_lock);
Greg Kroah-Hartman
maintainerPATCH 168/776 rxrpc: Fix anonymous key handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 6a59d84b4fc2f27f7b40e348506cc686712e260b ]
In rxrpc_new_client_call_for_sendmsg(), a key with no payload is meant to be substituted for a NULL key pointer, but the variable this is done with is subsequently not used.
Fix this by using "key" rather than "rx->key" when filling in the connection parameters.
Note that this only affects direct use of AF_RXRPC; the kAFS filesystem doesn't use sendmsg() directly and so bypasses the issue. Further, AF_RXRPC passes a NULL key in if no key is set, so using an anonymous key in that manner works. Since this hasn't been noticed to this point, it might be better just to remove the "key" variable and the code that sets it
- and, arguably, rxrpc_init_client_call_security() would be a better place to handle it.
--- net/rxrpc/sendmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/sendmsg.c +1 -1
@@ -624,7 +624,7 @@ rxrpc_new_client_call_for_sendmsg(structmemset (&cp,0 ,sizeof (cp)); cp.local = rx->local; - cp.key = rx->key; + cp.key = key; cp.security_level = rx->min_sec_level; cp.exclusive = rx->exclusive | p->exclusive; cp.upgrade = p->upgrade;
Greg Kroah-Hartman
maintainerPATCH 169/776 iommu: fix a reference count leak in iommu_sva_bind_device()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasant Karasulli <[email protected]>
commit b34289505180 ("iommu: disable SVA when CONFIG_X86 is set") disables SVA to mitigate a security vulnerability.
Due the current placement of the condition check, function returns after iommu_group_get() without a corresponding iommu_group_put(). So move the condition check above.
This is a stable-only fix applicable to linux-5.15.y.
---
v2:
- addressed formatting mistakes in the changelog
drivers/iommu/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/iommu.c +3 -3
@@ -3061,6 +3061,9 @@ iommu_sva_bind_device(struct device *devstruct iommu_sva *handle =ERR_PTR (-EINVAL );const struct iommu_ops *ops = dev->bus->iommu_ops; +if (IS_ENABLED (CONFIG_X86 )) +return ERR_PTR (-EOPNOTSUPP ); +if (!ops || !ops->sva_bind)return ERR_PTR (-ENODEV );
@@ -3068,9 +3071,6 @@ iommu_sva_bind_device(struct device *devif (!group)return ERR_PTR (-ENODEV ); -if (IS_ENABLED (CONFIG_X86 )) -return ERR_PTR (-EOPNOTSUPP ); -/* Ensure device count and domain don't change while we're binding */ mutex_lock (&group->mutex);
Greg Kroah-Hartman
maintainerPATCH 170/776 fs/ntfs3: validate rec->used in journal-replay file record check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 0ca0485e4b2e837ebb6cbd4f2451aba665a03e4b upstream.
check_file_record() validates rec->total against the record size but never validates rec->used. The do_action() journal-replay handlers read rec->used from disk and use it to compute memmove lengths:
DeleteAttribute: memmove(attr, ..., used - asize - roff) CreateAttribute: memmove(..., attr, used - roff) change_attr_size: memmove(..., used - PtrOffset(rec, next))
When rec->used is smaller than the offset of a validated attribute, or larger than the record size, these subtractions can underflow allowing us to copy huge amounts of memory in to a 4kb buffer, generally considered a bad idea overall.
This requires a corrupted filesystem, which isn't a threat model the kernel really needs to worry about, but checking for such an obvious out-of-bounds value is good to keep things robust, especially on journal replay
Fix this up by bounding rec->used correctly.
This is much like commit b2bc7c44ed17 ("fs/ntfs3: Fix slab-out-of-bounds read in DeleteIndexEntryRoot") which checked different values in this same switch statement.
--- fs/ntfs3/fslog.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
fs/ntfs3/fslog.c +11 -1
@@ -2792,13 +2792,14 @@ static inline bool check_file_record(conu16 fn =le16_to_cpu (rec->rhdr.fix_num);u16 ao =le16_to_cpu (rec->attr_off);u32 rs = sbi->record_size; +u32 used =le32_to_cpu (rec->used);/* Check the file record header for consistency. */ if (rec->rhdr.sign !=NTFS_FILE_SIGNATURE || fo > (SECTOR_SIZE - ((rs >>SECTOR_SHIFT ) +1 ) *sizeof (short )) || (fn -1 ) *SECTOR_SIZE != rs || ao <MFTRECORD_FIXUP_OFFSET_1 || ao > sbi->record_size -SIZEOF_RESIDENT || !is_rec_inuse (rec) || -le32_to_cpu (rec->total) != rs) { +le32_to_cpu (rec->total) != rs || used > rs || used < ao) {return false; }
@@ -2810,6 +2811,15 @@ static inline bool check_file_record(conreturn false; } +/* +* The do_action() handlers compute memmove lengths as +* "rec->used - <offset of validated attr>", which underflows when +* rec->used is smaller than the attribute walk reached. At this +* point attr is the ATTR_END marker; rec->used must cover it. +*/ +if (used <PtrOffset (rec, attr) +sizeof (attr->type)) +return false; +return true; }
Greg Kroah-Hartman
maintainerPATCH 171/776 fuse: reject oversized dirents in page cache
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Page <[email protected]>
commit 51a8de6c50bf947c8f534cd73da4c8f0a13e7bed upstream.
fuse_add_dirent_to_cache() computes a serialized dirent size from the server-controlled namelen field and copies the dirent into a single page-cache page. The existing logic only checks whether the dirent fits in the remaining space of the current page and advances to a fresh page if not. It never checks whether the dirent itself exceeds PAGE_SIZE.
As a result, a malicious FUSE server can return a dirent with namelen=4095, producing a serialized record size of 4120 bytes. On 4 KiB page systems this causes memcpy() to overflow the cache page by 24 bytes into the following kernel page.
Reject dirents that cannot fit in a single page before copying them into the readdir cache.
--- fs/fuse/readdir.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/fuse/readdir.c +4 -0
@@ -41,6 +41,10 @@ static void fuse_add_dirent_to_cache(strunsigned int offset;void *addr; +/* Dirent doesn't fit in readdir cache page? Skip caching. */ +if (reclen >PAGE_SIZE ) +return ; +spin_lock (&fi->rdc.lock);/* * Is cache already completed? Or this entry does not go at the end of
Greg Kroah-Hartman
maintainerPATCH 172/776 fuse: quiet down complaints in fuse_conn_limit_write
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
commit 129a45f9755a89f573c6a513a6b9e3d234ce89b0 upstream.
gcc 15 complains about an uninitialized variable val that is passed by reference into fuse_conn_limit_write:
control.c: In function ‘fuse_conn_congestion_threshold_write’:
include/asm-generic/rwonce.h:55:37: warning: ‘val’ may be used uninitialized [-Wmaybe-uninitialized]
55 | *(volatile typeof(x) *)&(x) = (val); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
include/asm-generic/rwonce.h:61:9: note: in expansion of macro ‘__WRITE_ONCE’
61 | __WRITE_ONCE(x, val); \
| ^~~~~~~~~~~~
control.c:178:9: note: in expansion of macro ‘WRITE_ONCE’
178 | WRITE_ONCE(fc->congestion_threshold, val);
| ^~~~~~~~~~ control.c:166:18: note: ‘val’ was declared here
166 | unsigned val;
| ^~~
Unfortunately there's enough macro spew involved in kstrtoul_from_user that I think gcc gives up on its analysis and sprays the above warning. AFAICT it's not actually a bug, but we could just zero-initialize the variable to enable using -Wmaybe-uninitialized to find real problems.
Previously we would use some weird uninitialized_var annotation to quiet down the warnings, so clearly this code has been like this for quite some time.
--- fs/fuse/control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fuse/control.c +2 -2
@@ -120,7 +120,7 @@ static ssize_t fuse_conn_max_background_const char __user *buf, size_t count, loff_t *ppos) { - unsigned val; + unsigned int val = 0;ssize_t ret; ret = fuse_conn_limit_write(file, buf, count, ppos, &val,
@@ -162,7 +162,7 @@ static ssize_t fuse_conn_congestion_threconst char __user *buf, size_t count, loff_t *ppos) { - unsigned val; + unsigned int val = 0;struct fuse_conn *fc;struct fuse_mount *fm;ssize_t ret;
Greg Kroah-Hartman
maintainerPATCH 173/776 ALSA: usb-audio: apply quirk for MOONDROP JU Jiu
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cryolitia PukNgae <[email protected]>
commit 4513d3e0bbc0585b86ccf2631902593ff97e88f5 upstream.
It(ID 31b2:0111 JU Jiu) reports a MIN value -12800 for volume control, but will mute when setting it less than -10880.
Thanks to my girlfriend Kagura for reporting this issue.
--- sound/usb/mixer.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/usb/mixer.c +7 -0
@@ -1220,6 +1220,13 @@ static void volume_control_quirks(struct cval->res =16 ; }break ; +case USB_ID (0x31b2 ,0x0111 ):/* MOONDROP JU Jiu */ +if (!strcmp (kctl->id.name,"PCM Playback Volume" )) { +usb_audio_info (chip, +"set volume quirk for MOONDROP JU Jiu\n" ); + cval->min =-10880 ;/* Mute under it */ + } +break ; } }
Greg Kroah-Hartman
maintainerPATCH 174/776 ALSA: caiaq: take a reference on the USB device in create_card()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Berk Cem Goksel <[email protected]>
commit 80bb50e2d459213cccff3111d5ef98ed4238c0d5 upstream.
The caiaq driver stores a pointer to the parent USB device in cdev->chip.dev but never takes a reference on it. The card's private_free callback, snd_usb_caiaq_card_free(), can run asynchronously via snd_card_free_when_closed() after the USB device has already been disconnected and freed, so any access to cdev->chip.dev in that path dereferences a freed usb_device.
On top of the refcounting issue, the current card_free implementation calls usb_reset_device(cdev->chip.dev). A reset in a free callback is inappropriate: the device is going away, the call takes the device lock in a teardown context, and the reset races with the disconnect path that the callback is already cleaning up after.
Take a reference on the USB device in create_card() with usb_get_dev(), drop it with usb_put_dev() in the free callback, and remove the usb_reset_device() call.
--- sound/usb/caiaq/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/caiaq/device.c +2 -2
@@ -384,7 +384,7 @@ static void card_free(struct snd_card *csnd_usb_caiaq_input_free (cdev);#endif snd_usb_caiaq_audio_free (cdev); -usb_reset_device (cdev->chip.dev); +usb_put_dev (cdev->chip.dev); } static int create_card(struct usb_device *usb_dev,
@@ -410,7 +410,7 @@ static int create_card(struct usb_devicereturn err; cdev =caiaqdev (card); - cdev->chip.dev = usb_dev; + cdev->chip.dev =usb_get_dev (usb_dev); cdev->chip.card = card; cdev->chip.usb_id =USB_ID (le16_to_cpu (usb_dev->descriptor.idVendor),le16_to_cpu (usb_dev->descriptor.idProduct));
Greg Kroah-Hartman
maintainerPATCH 175/776 crypto: ccp: Dont attempt to copy CSR to userspace if PSP command failed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit abe4a6d6f606113251868c2c4a06ba904bb41eed upstream.
When retrieving the PEK CSR, don't attempt to copy the blob to userspace if the firmware command failed. If the failure was due to an invalid length, i.e. the userspace buffer+length was too small, copying the number of bytes _firmware_ requires will overflow the kernel-allocated buffer and leak data to userspace.
BUG: KASAN: slab-out-of-bounds in instrument_copy_to_user ../include/linux/instrumented.h:129 [inline] BUG: KASAN: slab-out-of-bounds in _inline_copy_to_user ../include/linux/uaccess.h:205 [inline] BUG: KASAN: slab-out-of-bounds in _copy_to_user+0x66/0xa0 ../lib/usercopy.c:26 Read of size 2084 at addr ffff898144612e20 by task syz.9.219/21405 CPU: 14 UID: 0 PID: 21405 Comm: syz.9.219 Tainted: G U O 7.0.0-smp-DEV #28 PREEMPTLAZY Tainted: [U]=USER, [O]=OOT_MODULE Hardware name: Google, Inc. Arcadia_IT_80/Arcadia_IT_80, BIOS 12.62.0-0 11/19/2025 Call Trace: <TASK> dump_stack_lvl+0xc5/0x110 ../lib/dump_stack.c:120 print_address_description ../mm/kasan/report.c:378 [inline] print_report+0xbc/0x260 ../mm/kasan/report.c:482 kasan_report+0xa2/0xe0 ../mm/kasan/report.c:595 check_region_inline ../mm/kasan/generic.c:-1 [inline] kasan_check_range+0x264/0x2c0 ../mm/kasan/generic.c:200 instrument_copy_to_user ../include/linux/instrumented.h:129 [inline] _inline_copy_to_user ../include/linux/uaccess.h:205 [inline] _copy_to_user+0x66/0xa0 ../lib/usercopy.c:26 copy_to_user ../include/linux/uaccess.h:236 [inline] sev_ioctl_do_pek_csr+0x31f/0x590 ../drivers/crypto/ccp/sev-dev.c:1872 sev_ioctl+0x3a4/0x490 ../drivers/crypto/ccp/sev-dev.c:2562 vfs_ioctl ../fs/ioctl.c:51 [inline] __do_sys_ioctl ../fs/ioctl.c:597 [inline] __se_sys_ioctl+0x11d/0x1b0 ../fs/ioctl.c:583 do_syscall_x64 ../arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe0/0x800 ../arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK>
WARN if the driver says the command succeeded, but the firmware error code says otherwise, as __sev_do_cmd_locked() is expected to return -EIO on any firwmware error.
--- drivers/crypto/ccp/sev-dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/crypto/ccp/sev-dev.c +7 -1
@@ -477,7 +477,10 @@ cmd: ret =__sev_do_cmd_locked (SEV_CMD_PEK_CSR , &data, &argp->error); -/* If we query the CSR length, FW responded with expected data. */ +/* +* Firmware will returns the length of the CSR blob (either the minimum +* required length or the actual length written), return it to the user. +*/ input.length = data.len;if (copy_to_user ((void __user *)argp->data, &input,sizeof (input))) {
@@ -485,6 +488,9 @@ cmd: goto e_free_blob; } +if (ret ||WARN_ON_ONCE (argp->error)) + goto e_free_blob; +if (blob) {if (copy_to_user (input_address, blob, input.length)) ret = -EFAULT ;
Greg Kroah-Hartman
maintainerPATCH 176/776 crypto: ccp: Dont attempt to copy PDH cert to userspace if PSP command failed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit e76239fed3cffd6d304d8ca3ce23984fd24f57d3 upstream.
When retrieving the PDH cert, don't attempt to copy the blobs to userspace if the firmware command failed. If the failure was due to an invalid length, i.e. the userspace buffer+length was too small, copying the number of bytes _firmware_ requires will overflow the kernel-allocated buffer and leak data to userspace.
BUG: KASAN: slab-out-of-bounds in instrument_copy_to_user ../include/linux/instrumented.h:129 [inline] BUG: KASAN: slab-out-of-bounds in _inline_copy_to_user ../include/linux/uaccess.h:205 [inline] BUG: KASAN: slab-out-of-bounds in _copy_to_user+0x66/0xa0 ../lib/usercopy.c:26 Read of size 2084 at addr ffff8885c4ab8aa0 by task syz.0.186/21033 CPU: 51 UID: 0 PID: 21033 Comm: syz.0.186 Tainted: G U O 7.0.0-smp-DEV #28 PREEMPTLAZY Tainted: [U]=USER, [O]=OOT_MODULE Hardware name: Google, Inc. Arcadia_IT_80/Arcadia_IT_80, BIOS 34.84.12-0 11/17/2025 Call Trace: <TASK> dump_stack_lvl+0xc5/0x110 ../lib/dump_stack.c:120 print_address_description ../mm/kasan/report.c:378 [inline] print_report+0xbc/0x260 ../mm/kasan/report.c:482 kasan_report+0xa2/0xe0 ../mm/kasan/report.c:595 check_region_inline ../mm/kasan/generic.c:-1 [inline] kasan_check_range+0x264/0x2c0 ../mm/kasan/generic.c:200 instrument_copy_to_user ../include/linux/instrumented.h:129 [inline] _inline_copy_to_user ../include/linux/uaccess.h:205 [inline] _copy_to_user+0x66/0xa0 ../lib/usercopy.c:26 copy_to_user ../include/linux/uaccess.h:236 [inline] sev_ioctl_do_pdh_export+0x3d3/0x7c0 ../drivers/crypto/ccp/sev-dev.c:2347 sev_ioctl+0x2a2/0x490 ../drivers/crypto/ccp/sev-dev.c:2568 vfs_ioctl ../fs/ioctl.c:51 [inline] __do_sys_ioctl ../fs/ioctl.c:597 [inline] __se_sys_ioctl+0x11d/0x1b0 ../fs/ioctl.c:583 do_syscall_x64 ../arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe0/0x800 ../arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK>
WARN if the driver says the command succeeded, but the firmware error code says otherwise, as __sev_do_cmd_locked() is expected to return -EIO on any firwmware error.
--- drivers/crypto/ccp/sev-dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/crypto/ccp/sev-dev.c +7 -1
@@ -836,7 +836,10 @@ static int sev_ioctl_do_pdh_export(struc cmd: ret =__sev_do_cmd_locked (SEV_CMD_PDH_CERT_EXPORT , &data, &argp->error); -/* If we query the length, FW responded with expected data. */ +/* +* Firmware will return the length of the blobs (either the minimum +* required length or the actual length written), return 'em to the user. +*/ input.cert_chain_len = data.cert_chain_len; input.pdh_cert_len = data.pdh_cert_len;
@@ -845,6 +848,9 @@ cmd: goto e_free_cert; } +if (ret ||WARN_ON_ONCE (argp->error)) + goto e_free_cert; +if (pdh_blob) {if (copy_to_user (input_pdh_cert_address, pdh_blob, input.pdh_cert_len)) {
Greg Kroah-Hartman
maintainerPATCH 177/776 crypto: ccp: Dont attempt to copy ID to userspace if PSP command failed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 4f685dbfa87c546e51d9dc6cab379d20f275e114 upstream.
When retrieving the ID for the CPU, don't attempt to copy the ID blob to userspace if the firmware command failed. If the failure was due to an invalid length, i.e. the userspace buffer+length was too small, copying the number of bytes _firmware_ requires will overflow the kernel-allocated buffer and leak data to userspace.
BUG: KASAN: slab-out-of-bounds in instrument_copy_to_user ../include/linux/instrumented.h:129 [inline] BUG: KASAN: slab-out-of-bounds in _inline_copy_to_user ../include/linux/uaccess.h:205 [inline] BUG: KASAN: slab-out-of-bounds in _copy_to_user+0x66/0xa0 ../lib/usercopy.c:26 Read of size 64 at addr ffff8881867f5960 by task syz.0.906/24388 CPU: 130 UID: 0 PID: 24388 Comm: syz.0.906 Tainted: G U O 7.0.0-smp-DEV #28 PREEMPTLAZY Tainted: [U]=USER, [O]=OOT_MODULE Hardware name: Google, Inc. Arcadia_IT_80/Arcadia_IT_80, BIOS 12.62.0-0 11/19/2025 Call Trace: <TASK> dump_stack_lvl+0xc5/0x110 ../lib/dump_stack.c:120 print_address_description ../mm/kasan/report.c:378 [inline] print_report+0xbc/0x260 ../mm/kasan/report.c:482 kasan_report+0xa2/0xe0 ../mm/kasan/report.c:595 check_region_inline ../mm/kasan/generic.c:-1 [inline] kasan_check_range+0x264/0x2c0 ../mm/kasan/generic.c:200 instrument_copy_to_user ../include/linux/instrumented.h:129 [inline] _inline_copy_to_user ../include/linux/uaccess.h:205 [inline] _copy_to_user+0x66/0xa0 ../lib/usercopy.c:26 copy_to_user ../include/linux/uaccess.h:236 [inline] sev_ioctl_do_get_id2+0x361/0x490 ../drivers/crypto/ccp/sev-dev.c:2222 sev_ioctl+0x25f/0x490 ../drivers/crypto/ccp/sev-dev.c:2575 vfs_ioctl ../fs/ioctl.c:51 [inline] __do_sys_ioctl ../fs/ioctl.c:597 [inline] __se_sys_ioctl+0x11d/0x1b0 ../fs/ioctl.c:583 do_syscall_x64 ../arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe0/0x800 ../arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK>
WARN if the driver says the command succeeded, but the firmware error code says otherwise, as __sev_do_cmd_locked() is expected to return -EIO on any firwmware error.
--- drivers/crypto/ccp/sev-dev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/ccp/sev-dev.c +3 -0
@@ -722,6 +722,9 @@ static int sev_ioctl_do_get_id2(struct s goto e_free; } +if (ret ||WARN_ON_ONCE (argp->error)) + goto e_free; +if (id_blob) {if (copy_to_user (input_address, id_blob, data.len)) { ret = -EFAULT ;
Greg Kroah-Hartman
maintainerPATCH 178/776 rxrpc: Fix missing validation of ticket length in non-XDR key preparsing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anderson Nascimento <[email protected]>
commit ac33733b10b484d666f97688561670afd5861383 upstream.
In rxrpc_preparse(), there are two paths for parsing key payloads: the XDR path (for large payloads) and the non-XDR path (for payloads <= 28 bytes). While the XDR path (rxrpc_preparse_xdr_rxkad()) correctly validates the ticket length against AFSTOKEN_RK_TIX_MAX, the non-XDR path fails to do so.
This allows an unprivileged user to provide a very large ticket length. When this key is later read via rxrpc_read(), the total token size (toksize) calculation results in a value that exceeds AFSTOKEN_LENGTH_MAX, triggering a WARN_ON().
[ 2001.302904] WARNING: CPU: 2 PID: 2108 at net/rxrpc/key.c:778 rxrpc_read+0x109/0x5c0 [rxrpc]
Fix this by adding a check in the non-XDR parsing path of rxrpc_preparse() to ensure the ticket length does not exceed AFSTOKEN_RK_TIX_MAX, bringing it into parity with the XDR parsing logic.
--- net/rxrpc/key.c | 4 ++++ 1 file changed, 4 insertions(+)
net/rxrpc/key.c +4 -0
@@ -340,6 +340,10 @@ static int rxrpc_preparse(struct key_preif (v1->security_index !=RXRPC_SECURITY_RXKAD ) goto error; + ret = -EKEYREJECTED ; +if (v1->ticket_length >AFSTOKEN_RK_TIX_MAX ) + goto error; + plen =sizeof (*token->kad) + v1->ticket_length; prep->quotalen += plen +sizeof (*token);
Greg Kroah-Hartman
maintainerPATCH 179/776 tty: n_gsm: fix flow control handling in tx path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Starke <[email protected]>
commit 59ff0680ecbfec742b1e0381e7cc46b41eb06647 upstream.
The current implementation constipates all transmission paths during flow control except for flow control frames. However, these may not be located at the beginning of the transmission queue of the control channel. Ensure that flow control frames in the transmission queue for the control channel are always handled even if constipated by skipping through other messages.
--- drivers/tty/n_gsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/n_gsm.c +1 -1
@@ -897,7 +897,7 @@ static int gsm_data_kick(struct gsm_mux/* Serialize control messages and control channel messages first */ list_for_each_entry_safe (msg, nmsg, &gsm->tx_ctrl_list, list) {if (gsm->constipated && !gsm_is_flow_ctrl_msg (msg)) -return -EAGAIN ; +continue ; ret =gsm_send_packet (gsm, msg);switch (ret) {case -ENOSPC :
Greg Kroah-Hartman
maintainerPATCH 180/776 ALSA: usb-audio: fix race condition to UAF in snd_usbmidi_free
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit 9f2c0ac1423d5f267e7f1d1940780fc764b0fee3 upstream.
The previous commit 0718a78f6a9f ("ALSA: usb-audio: Kill timer properly at removal") patched a UAF issue caused by the error timer.
However, because the error timer kill added in this patch occurs after the endpoint delete, a race condition to UAF still occurs, albeit rarely.
Additionally, since kill-cleanup for urb is also missing, freed memory can be accessed in interrupt context related to urb, which can cause UAF.
Therefore, to prevent this, error timer and urb must be killed before freeing the heap memory.
--- sound/usb/midi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
sound/usb/midi.c +4 -5
@@ -1522,15 +1522,14 @@ static void snd_usbmidi_free(struct snd_ {int i; +if (!umidi->disconnected) +snd_usbmidi_disconnect (&umidi->list); +for (i =0 ; i <MIDI_MAX_ENDPOINTS ; ++i) {struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i]; -if (ep->out) -snd_usbmidi_out_endpoint_delete (ep->out); -if (ep->in) -snd_usbmidi_in_endpoint_delete (ep->in); +kfree (ep->out); }mutex_destroy (&umidi->mutex); -timer_shutdown_sync (&umidi->error_timer);kfree (umidi); }
Greg Kroah-Hartman
maintainerPATCH 181/776 ALSA: usb-audio: stop parsing UAC2 rates at MAX_NR_RATES
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit 3c318f97dcc50b2e0556a1813bd6958678e881fd upstream.
parse_uac2_sample_rate_range() caps the number of enumerated rates at MAX_NR_RATES, but it only breaks out of the current rate loop. A malformed UAC2 RANGE response with additional triplets continues parsing the remaining triplets and repeatedly prints "invalid uac2 rates" while probe still holds register_mutex.
Stop the whole parse once the cap is reached and return the number of rates collected so far.
--- sound/usb/format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/format.c +1 -1
@@ -461,7 +461,7 @@ static int parse_uac2_sample_rate_range( nr_rates++;if (nr_rates >=MAX_NR_RATES ) {usb_audio_err (chip,"invalid uac2 rates\n" ); -break ; +return nr_rates; } skip_rate:
Greg Kroah-Hartman
maintainerPATCH 182/776 ALSA: usb-audio: Avoid false E-MU sample-rate notifications
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit fca9c850042a7ab4828ce3a9caa8bc40ea09856a upstream.
snd_emuusb_set_samplerate() unconditionally notifies the E-MU SampleRate Extension Unit control after issuing SET_CUR.
If snd_usb_mixer_set_ctl_value() fails, the control value has not changed, yet snd_usb_mixer_notify_id() still invalidates the cache and emits a value-change event to userspace.
Notify the control only after a successful write.
--- sound/usb/mixer_quirks.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
sound/usb/mixer_quirks.c +6 -4
@@ -1561,15 +1561,17 @@ void snd_emuusb_set_samplerate(struct sn {struct usb_mixer_interface *mixer;struct usb_mixer_elem_info *cval; +int err;int unitid =12 ;/* SampleRate ExtensionUnit ID */ list_for_each_entry (mixer, &chip->mixer_list, list) {if (mixer->id_elems[unitid]) { cval =mixer_elem_list_to_info (mixer->id_elems[unitid]); -snd_usb_mixer_set_ctl_value (cval,UAC_SET_CUR , - cval->control <<8 , - samplerate_id); -snd_usb_mixer_notify_id (mixer, unitid); + err =snd_usb_mixer_set_ctl_value (cval,UAC_SET_CUR , + cval->control <<8 , + samplerate_id); +if (!err) +snd_usb_mixer_notify_id (mixer, unitid);break ; } }
Greg Kroah-Hartman
maintainerPATCH 183/776 ALSA: usb-audio: Fix Audio Advantage Micro II SPDIF switch
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit a9224f26b754b5034719248891ff3c2ea0d11144 upstream.
snd_microii_spdif_switch_put() returns 0 when the requested vendor register value differs from the cached one.
This comparison was inverted by the resume-support conversion, so real SPDIF switch toggles are ignored while no-op writes still issue SET_CUR and report success.
Return early only when the requested value matches the cached one.
--- sound/usb/mixer_quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/mixer_quirks.c +1 -1
@@ -2066,7 +2066,7 @@ static int snd_microii_spdif_switch_put(int err; reg = ucontrol->value.integer.value[0 ] ?0x28 :0x2a ; -if (reg != list->kctl->private_value) +if (reg == list->kctl->private_value)return 0 ; kcontrol->private_value = reg;
Greg Kroah-Hartman
maintainerPATCH 184/776 usb: xhci: Make usb_host_endpoint.hcpriv survive endpoint_disable()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
commit 25e531b422dc2ac90cdae3b6e74b5cdeb081440d upstream.
xHCI hardware maintains its endpoint state between add_endpoint() and drop_endpoint() calls followed by successful check_bandwidth(). So does the driver.
Core may call endpoint_disable() during xHCI endpoint life, so don't clear host_ep->hcpriv then, because this breaks endpoint_reset().
If a driver calls usb_set_interface(), submits URBs which make host sequence state non-zero and calls usb_clear_halt(), the device clears its sequence state but xhci_endpoint_reset() bails out. The next URB
malfunctions: USB2 loses one packet, USB3 gets Transaction Error or may not complete at all on some (buggy?) HCs from ASMedia and AMD. This is triggered by uvcvideo on bulk video devices.
The code was copied from ehci_endpoint_disable() but it isn't needed here - hcpriv should only be NULL on emulated root hub endpoints. It might prevent resetting and inadvertently enabling a disabled and dropped endpoint, but core shouldn't try to reset dropped endpoints.
Document xhci requirements regarding hcpriv. They are currently met.
--- drivers/usb/host/xhci.c | 1 - include/linux/usb.h | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +0 -1
@@ -3233,7 +3233,6 @@ rescan:xhci_dbg (xhci,"endpoint disable with ep_state 0x%x\n" , ep->ep_state); done: - host_ep->hcpriv =NULL ;spin_unlock_irqrestore (&xhci->lock, flags); }
include/linux/usb.h +2 -1
@@ -54,7 +54,8 @@ struct ep_device;* @ssp_isoc_ep_comp: SuperSpeedPlus isoc companion descriptor for this endpoint * @urb_list: urbs queued to this endpoint; maintained by usbcore * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH) -* with one or more transfer descriptors (TDs) per urb +* with one or more transfer descriptors (TDs) per urb; must be preserved +* by core while BW is allocated for the endpoint * @ep_dev: ep_device for sysfs info * @extra: descriptors following this endpoint in the configuration * @extralen: how many bytes of "extra" are valid
Greg Kroah-Hartman
maintainerPATCH 185/776 ALSA: usb-audio: Evaluate packsize caps at the right place
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 52521e8398839105ef8eb22b3f0993f9b0d11a57 upstream.
We introduced the upper bound checks of the packet sizes by the ep->maxframesize for avoiding the URB submission errors. However, the check was applied at an incorrect place in the function snd_usb_endpoint_set_params() where ep->maxframesize isn't defined yet; the value is defined at a bit later position. So this ended up with a failure at the first run while the second run works.
For fixing it, move the check at the correct place, right after the calculation of ep->maxframesize in the same function.
--- sound/usb/endpoint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/usb/endpoint.c +3 -3
@@ -1388,9 +1388,6 @@ int snd_usb_endpoint_set_params(struct s goto unlock; } - ep->packsize[0 ] =min (ep->packsize[0 ], ep->maxframesize); - ep->packsize[1 ] =min (ep->packsize[1 ], ep->maxframesize); -/* calculate the frequency in 16.16 format */ ep->freqm = ep->freqn; ep->freqshift =INT_MIN ;
@@ -1417,6 +1414,9 @@ int snd_usb_endpoint_set_params(struct s ep->maxframesize = ep->maxpacksize / ep->cur_frame_bytes; ep->curframesize = ep->curpacksize / ep->cur_frame_bytes; + ep->packsize[0 ] =min (ep->packsize[0 ], ep->maxframesize); + ep->packsize[1 ] =min (ep->packsize[1 ], ep->maxframesize); + err =update_clock_ref_rate (chip, ep);if (err >=0 ) { ep->need_setup = false;
Greg Kroah-Hartman
maintainerPATCH 186/776 drm/nouveau: fix u32 overflow in pushbuf reloc bounds check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 2fc87d37be1b730a149b035f9375fdb8cc5333a5 upstream.
nouveau_gem_pushbuf_reloc_apply() validates each relocation with
if (r->reloc_bo_offset + 4 > nvbo->bo.base.size)
but reloc_bo_offset is __u32 (uapi/drm/nouveau_drm.h) and the integer literal 4 promotes to unsigned int, so the addition is performed in 32 bits and wraps before the comparison against the size_t bo size.
Cast to u64 so the addition happens in 64-bit arithmetic.
--- drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_gem.c +1 -1
@@ -668,7 +668,7 @@ nouveau_gem_pushbuf_reloc_apply(struct n } nvbo = (void *)(unsigned long )bo[r->reloc_bo_index].user_priv; -if (unlikely (r->reloc_bo_offset +4 > +if (unlikely ((u64 )r->reloc_bo_offset +4 > nvbo->bo.base.size)) {NV_PRINTK (err, cli,"reloc outside of bo\n" ); ret = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 187/776 misc: ibmasm: fix OOB MMIO read in ibmasm_handle_mouse_interrupt()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyllis Xu <[email protected]>
commit 4b6e6ead556734bdc14024c5f837132b1e7a4b84 upstream.
ibmasm_handle_mouse_interrupt() performs an out-of-bounds MMIO read when the queue reader or writer index from hardware exceeds REMOTE_QUEUE_SIZE (60).
A compromised service processor can trigger this by writing an out-of-range value to the reader or writer MMIO register before asserting an interrupt. Since writer is re-read from hardware on every loop iteration, it can also be set to an out-of-range value after the loop has already started.
The root cause is that get_queue_reader() and get_queue_writer() return raw readl() values that are passed directly into get_queue_entry(), which computes:
queue_begin + reader * sizeof(struct remote_input)
with no bounds check. This unchecked MMIO address is then passed to memcpy_fromio(), reading 8 bytes from unintended device registers. For sufficiently large values the address falls outside the PCI BAR mapping entirely, triggering a machine check exception.
Fix by checking both indices against REMOTE_QUEUE_SIZE at the top of the loop body, before any call to get_queue_entry(). On an out-of-range value, reset the reader register to 0 via set_queue_reader() before breaking, so that normal queue operation can resume if the corrupted hardware state is transient.
--- drivers/misc/ibmasm/remote.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/misc/ibmasm/remote.c +5 -0
@@ -177,6 +177,11 @@ void ibmasm_handle_mouse_interrupt(struc writer =get_queue_writer (sp);while (reader != writer) { +if (reader >=REMOTE_QUEUE_SIZE || writer >=REMOTE_QUEUE_SIZE ) { +set_queue_reader (sp,0 ); +break ; + } +memcpy_fromio (&input,get_queue_entry (sp, reader),sizeof (struct remote_input ));
Greg Kroah-Hartman
maintainerPATCH 188/776 ibmasm: fix OOB reads in command_file_write due to missing size checks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyllis Xu <[email protected]>
commit 0eb09f737428e482a32a2e31e5e223f2b35a71d3 upstream.
The command_file_write() handler allocates a kernel buffer of exactly count bytes and copies user data into it, but does not validate the buffer against the dot command protocol before passing it to get_dot_command_size() and get_dot_command_timeout().
Since both the allocation size (count) and the header fields (command_size, data_size) are independently user-controlled, an attacker can cause get_dot_command_size() to return a value exceeding the allocation, triggering OOB reads in get_dot_command_timeout() and an out-of-bounds memcpy_toio() that leaks kernel heap memory to the service processor.
Fix with two guards: reject writes smaller than sizeof(struct dot_command_header) before allocation, then after copying user data reject commands where the buffer is smaller than the total size declared by the header (sizeof(header) + command_size + data_size). This ensures all subsequent header and payload field accesses stay within the buffer.
--- drivers/misc/ibmasm/ibmasmfs.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/misc/ibmasm/ibmasmfs.c +7 -0
@@ -303,6 +303,8 @@ static ssize_t command_file_write(structreturn -EINVAL ;if (count ==0 || count >IBMASM_CMD_MAX_BUFFER_SIZE )return 0 ; +if (count <sizeof (struct dot_command_header )) +return -EINVAL ;if (*offset !=0 )return 0 ;
@@ -319,6 +321,11 @@ static ssize_t command_file_write(structreturn -EFAULT ; } +if (count <get_dot_command_size (cmd->buffer)) { +command_put (cmd); +return -EINVAL ; + } +spin_lock_irqsave (&command_data->sp->lock, flags);if (command_data->command) {spin_unlock_irqrestore (&command_data->sp->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 189/776 ibmasm: fix heap over-read in ibmasm_send_i2o_message()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyllis Xu <[email protected]>
commit 9aad71144fa3682cca3837a06c8623016790e7ec upstream.
The ibmasm_send_i2o_message() function uses get_dot_command_size() to compute the byte count for memcpy_toio(), but this value is derived from user-controlled fields in the dot_command_header (command_size: u8,data_size: u16) and is never validated against the actual allocation size. A root user can write a small buffer with inflated header fields, causing memcpy_toio() to read up to ~65 KB past the end of the allocation into adjacent kernel heap, which is then forwarded to the service processor over MMIO.
Silently clamping the copy size is not sufficient: if the header fields claim a larger size than the buffer, the SP receives a dot command whose own header is inconsistent with the I2O message length, which can cause the SP to desynchronize. Reject such commands outright by returning failure.
Validate command_size before calling get_mfa_inbound() to avoid leaking an I2O message frame: reading INBOUND_QUEUE_PORT dequeues a hardware frame from the controller's free pool, and returning without a corresponding set_mfa_inbound() call would permanently exhaust it.
Additionally, clamp command_size to I2O_COMMAND_SIZE before the memcpy_toio() so the MMIO write stays within the I2O message frame, consistent with the clamping already performed by outgoing_message_size() for the header field.
--- drivers/misc/ibmasm/lowlevel.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/misc/ibmasm/lowlevel.c +8 -4
@@ -19,17 +19,21 @@ static struct i2o_header header = I2O_HEint ibmasm_send_i2o_message (struct service_processor *sp) {u32 mfa; -unsigned int command_size; +size_t command_size;struct i2o_message *message;struct command *command = sp->current_command; + command_size =get_dot_command_size (command->buffer); +if (command_size > command->buffer_size) +return 1 ; +if (command_size >I2O_COMMAND_SIZE ) + command_size =I2O_COMMAND_SIZE ; + mfa =get_mfa_inbound (sp->base_address);if (!mfa)return 1 ; - command_size =get_dot_command_size (command->buffer); - header.message_size =outgoing_message_size (command_size); - + header.message_size =outgoing_message_size ((unsigned int )command_size); message =get_i2o_message (sp->base_address, mfa);memcpy_toio (&message->header, &header,sizeof (struct i2o_header ));
Greg Kroah-Hartman
maintainerPATCH 190/776 firmware: google: framebuffer: Do not mark framebuffer as busy
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
commit f3850d399de3b6142b02315227ef9e772ed0c302 upstream.
Remove the flag IORESOURCE_BUSY flag from coreboot's framebuffer resource. It prevents simpledrm from successfully requesting the range for its own use; resulting in errors such as
[ 2.775430] simple-framebuffer simple-framebuffer.0: [drm] could not acquire memory region [mem 0x80000000-0x80407fff flags 0x80000200]
As with other uses of simple-framebuffer, the simple-framebuffer device should only declare it's I/O resources, but not actively use them.
--- drivers/firmware/google/framebuffer-coreboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/google/framebuffer-coreboot.c +1 -1
@@ -50,7 +50,7 @@ static int framebuffer_probe(struct corereturn -ENODEV ;memset (&res,0 ,sizeof (res)); - res.flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res.flags =IORESOURCE_MEM ; res.name ="Coreboot Framebuffer" ; res.start = fb->physical_address; length =PAGE_ALIGN (fb->y_resolution * fb->bytes_per_line);
Greg Kroah-Hartman
maintainerPATCH 191/776 scsi: ufs: core: Fix use-after free in init error and remove paths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Draszik <[email protected]>
[ Upstream commit f8fb2403ddebb5eea0033d90d9daae4c88749ada ]
devm_blk_crypto_profile_init() registers a cleanup handler to run when the associated (platform-) device is being released. For UFS, the crypto private data and pointers are stored as part of the ufs_hba's data structure 'struct ufs_hba::crypto_profile'. This structure is allocated as part of the underlying ufshcd and therefore Scsi_host allocation.
During driver release or during error handling in ufshcd_pltfrm_init(), this structure is released as part of ufshcd_dealloc_host() before the (platform-) device associated with the crypto call above is released. Once this device is released, the crypto cleanup code will run, using the just-released 'struct ufs_hba::crypto_profile'. This causes a use-after-free situation:
Call trace: kfree+0x60/0x2d8 (P) kvfree+0x44/0x60 blk_crypto_profile_destroy_callback+0x28/0x70 devm_action_release+0x1c/0x30 release_nodes+0x6c/0x108 devres_release_all+0x98/0x100 device_unbind_cleanup+0x20/0x70 really_probe+0x218/0x2d0
In other words, the initialisation code flow is:
platform-device probe
ufshcd_pltfrm_init()
ufshcd_alloc_host()
scsi_host_alloc()
allocation of struct ufs_hba
creation of scsi-host devices
devm_blk_crypto_profile_init()
devm registration of cleanup handler using platform-device
and during error handling of ufshcd_pltfrm_init() or during driver removal:
ufshcd_dealloc_host()
scsi_host_put()
put_device(scsi-host)
release of struct ufs_hba
put_device(platform-device)
crypto cleanup handler
To fix this use-after free, change ufshcd_alloc_host() to register a devres action to automatically cleanup the underlying SCSI device on ufshcd destruction, without requiring explicit calls to ufshcd_dealloc_host(). This way:
* the crypto profile and all other ufs_hba-owned resources are destroyed before SCSI (as they've been registered after)
* a memleak is plugged in tc-dwc-g210-pci.c remove() as a side-effect
* EXPORT_SYMBOL_GPL(ufshcd_dealloc_host) can be removed fully as it's not needed anymore
* no future drivers using ufshcd_alloc_host() could ever forget adding the cleanup
[ Delete modifications about ufshcd_parse_operating_points() for it's added from commit 72208ebe181e3("scsi: ufs: core: Add support for parsing OPP") and that in ufshcd_pltfrm_remove() for it's added from commit 897df60c16d54("scsi: ufs: pltfrm: Dellocate HBA during ufshcd_pltfrm_remove()"). ]
--- drivers/scsi/ufs/ufshcd-pci.c | 2 -- drivers/scsi/ufs/ufshcd-pltfrm.c | 25 ++++++++----------------- drivers/scsi/ufs/ufshcd.c | 31 +++++++++++++++++++++---------- drivers/scsi/ufs/ufshcd.h | 1 - 4 files changed, 29 insertions(+), 30 deletions(-)
drivers/scsi/ufs/ufshcd-pci.c +0 -2
@@ -554,7 +554,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)pm_runtime_forbid (&pdev->dev);pm_runtime_get_noresume (&pdev->dev);ufshcd_remove (hba); -ufshcd_dealloc_host (hba); }/**
@@ -599,7 +598,6 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =ufshcd_init (hba, mmio_base, pdev->irq);if (err) {dev_err (&pdev->dev,"Initialization failed\n" ); -ufshcd_dealloc_host (hba);return err; }
drivers/scsi/ufs/ufshcd-pltfrm.c +8 -17
@@ -339,21 +339,17 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,struct device *dev = &pdev->dev; mmio_base =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (mmio_base)) { - err =PTR_ERR (mmio_base); - goto out; - } +if (IS_ERR (mmio_base)) +return PTR_ERR (mmio_base); irq =platform_get_irq (pdev,0 ); -if (irq <0 ) { - err = irq; - goto out; - } +if (irq <0 ) +return irq; err =ufshcd_alloc_host (dev, &hba);if (err) {dev_err (&pdev->dev,"Allocation failed\n" ); - goto out; +return err; } hba->vops = vops;
@@ -362,13 +358,13 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,if (err) {dev_err (&pdev->dev,"%s: clock parse failed %d\n" , __func__, err); - goto dealloc_host; +return err; } err =ufshcd_parse_regulator_info (hba);if (err) {dev_err (&pdev->dev,"%s: regulator init failed %d\n" , __func__, err); - goto dealloc_host; +return err; }ufshcd_init_lanes_per_dir (hba);
@@ -376,18 +372,13 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, err =ufshcd_init (hba, mmio_base, irq);if (err) {dev_err (dev,"Initialization failed\n" ); - goto dealloc_host; +return err; }pm_runtime_set_active (&pdev->dev);pm_runtime_enable (&pdev->dev);return 0 ; - -dealloc_host: -ufshcd_dealloc_host (hba); -out: -return err; }EXPORT_SYMBOL_GPL (ufshcd_pltfrm_init);
drivers/scsi/ufs/ufshcd.c +21 -10
@@ -9322,16 +9322,6 @@ void ufshcd_remove(struct ufs_hba *hba) }EXPORT_SYMBOL_GPL (ufshcd_remove); -/** -* ufshcd_dealloc_host - deallocate Host Bus Adapter (HBA) -* @hba: pointer to Host Bus Adapter (HBA) -*/ -void ufshcd_dealloc_host (struct ufs_hba *hba) -{ -scsi_host_put (hba->host); -} -EXPORT_SYMBOL_GPL (ufshcd_dealloc_host); -/** * ufshcd_set_dma_mask - Set dma mask based on the controller * addressing capability
@@ -9348,11 +9338,25 @@ static int ufshcd_set_dma_mask(struct ufs_hba *hba)return dma_set_mask_and_coherent (hba->dev,DMA_BIT_MASK (32 )); } +/** +* ufshcd_devres_release - devres cleanup handler, invoked during release of +* hba->dev +* @host: pointer to SCSI host +*/ +static void ufshcd_devres_release (void *host) +{ +scsi_host_put (host); +} +/** * ufshcd_alloc_host - allocate Host Bus Adapter (HBA) * @dev: pointer to device handle * @hba_handle: driver private handle * Returns 0 on success, non-zero value on failure +* +* NOTE: There is no corresponding ufshcd_dealloc_host() because this function +* keeps track of its allocations using devres and deallocates everything on +* device removal automatically. */ int ufshcd_alloc_host (struct device *dev,struct ufs_hba **hba_handle) {
@@ -9374,6 +9378,13 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle) err = -ENOMEM ; goto out_error; } + + err =devm_add_action_or_reset (dev, ufshcd_devres_release, + host); +if (err) +return dev_err_probe (dev, err, +"failed to add ufshcd dealloc action\n" ); + hba =shost_priv (host); hba->host = host; hba->dev = dev;
drivers/scsi/ufs/ufshcd.h +0 -1
@@ -1001,7 +1001,6 @@ static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg) }int ufshcd_alloc_host (struct device *,struct ufs_hba **); -void ufshcd_dealloc_host (struct ufs_hba *);int ufshcd_hba_enable (struct ufs_hba *hba);int ufshcd_init (struct ufs_hba *,void __iomem *,unsigned int );int ufshcd_link_recovery (struct ufs_hba *hba);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 192/776 device property: Make modifications of fwnode "flags" thread safe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
commit f72e77c33e4b5657af35125e75bab249256030f3 upstream.
In various places in the kernel, we modify the fwnode "flags" member by doing either:
fwnode->flags |= SOME_FLAG;
fwnode->flags &= ~SOME_FLAG;
This type of modification is not thread-safe. If two threads are both mucking with the flags at the same time then one can clobber the other.
While flags are often modified while under the "fwnode_link_lock", this is not universally true.
Create some accessor functions for setting, clearing, and testing the FWNODE flags and move all users to these accessor functions. New accessor functions use set_bit() and clear_bit(), which are thread-safe.
[ Fix fwnode_clear_flag() argument alignment, restore dropped blank
line in fwnode_dev_initialized(), and remove unnecessary parentheses around fwnode_test_flag() calls. - Danilo ]
--- drivers/base/core.c | 12 ++++++------ drivers/net/phy/mdio_bus.c | 4 ++-- drivers/of/property.c | 2 +- include/linux/fwnode.h | 40 +++++++++++++++++++++++++++++++--------- 4 files changed, 40 insertions(+), 18 deletions(-)
drivers/base/core.c +6 -6
@@ -171,7 +171,7 @@ void fw_devlink_purge_absent_suppliers(sif (fwnode->dev)return ; - fwnode->flags |=FWNODE_FLAG_NOT_DEVICE ; +fwnode_set_flag (fwnode,FWNODE_FLAG_NOT_DEVICE );fwnode_links_purge_consumers (fwnode);fwnode_for_each_available_child_node (fwnode, child)
@@ -1620,11 +1620,11 @@ bool fw_devlink_is_strict(void)static void fw_devlink_parse_fwnode (struct fwnode_handle *fwnode) { -if (fwnode->flags &FWNODE_FLAG_LINKS_ADDED ) +if (fwnode_test_flag (fwnode,FWNODE_FLAG_LINKS_ADDED ))return ;fwnode_call_int_op (fwnode, add_links); - fwnode->flags |=FWNODE_FLAG_LINKS_ADDED ; +fwnode_set_flag (fwnode,FWNODE_FLAG_LINKS_ADDED ); }static void fw_devlink_parse_fwtree (struct fwnode_handle *fwnode)
@@ -1765,7 +1765,7 @@ static int fw_devlink_create_devlink(str* When such a flag is set, we can't create device links where P is the * supplier of C as that would delay the probe of C. */ -if (sup_handle->flags &FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD && +if (fwnode_test_flag (sup_handle,FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD ) &&fwnode_is_ancestor_of (sup_handle, con->fwnode))return -EINVAL ;
@@ -1777,7 +1777,7 @@ static int fw_devlink_create_devlink(str* supplier device indefinitely. */ if (sup_dev->links.status ==DL_DEV_NO_DRIVER && - sup_handle->flags &FWNODE_FLAG_INITIALIZED ) { +fwnode_test_flag (sup_handle,FWNODE_FLAG_INITIALIZED )) { ret = -EINVAL ; goto out; }
@@ -1802,7 +1802,7 @@ static int fw_devlink_create_devlink(str }/* Supplier that's already initialized without a struct device. */ -if (sup_handle->flags &FWNODE_FLAG_INITIALIZED ) +if (fwnode_test_flag (sup_handle,FWNODE_FLAG_INITIALIZED ))return -EINVAL ;/*
drivers/net/phy/mdio_bus.c +2 -2
@@ -534,8 +534,8 @@ int __mdiobus_register(struct mii_bus *breturn -EINVAL ;if (bus->parent && bus->parent->of_node) - bus->parent->of_node->fwnode.flags |= -FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD ; +fwnode_set_flag (&bus->parent->of_node->fwnode, +FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD );BUG_ON (bus->state !=MDIOBUS_ALLOCATED && bus->state !=MDIOBUS_UNREGISTERED );
drivers/of/property.c +1 -1
@@ -1130,7 +1130,7 @@ static int of_link_to_phandle(struct dev sup_dev =get_dev_from_fwnode (&sup_np->fwnode);if (!sup_dev && (of_node_check_flag (sup_np,OF_POPULATED ) || - sup_np->fwnode.flags &FWNODE_FLAG_NOT_DEVICE )) { +fwnode_test_flag (&sup_np->fwnode,FWNODE_FLAG_NOT_DEVICE ))) {pr_debug ("Not linking %pOFP to %pOFP - No struct device\n" , con_np, sup_np);of_node_put (sup_np);
include/linux/fwnode.h +31 -9
@@ -11,6 +11,7 @@#include <linux/types.h> #include <linux/list.h> +#include <linux/bitops.h> #include <linux/err.h> struct fwnode_operations ;
@@ -27,10 +28,10 @@ struct device;* their respective drivers as soon as they are * added. */ -#define FWNODE_FLAG_LINKS_ADDED BIT(0) -#define FWNODE_FLAG_NOT_DEVICE BIT(1) -#define FWNODE_FLAG_INITIALIZED BIT(2) -#define FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD BIT(3) +#define FWNODE_FLAG_LINKS_ADDED 0 +#define FWNODE_FLAG_NOT_DEVICE 1 +#define FWNODE_FLAG_INITIALIZED 2 +#define FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD 3struct fwnode_handle {struct fwnode_handle *secondary;
@@ -38,7 +39,7 @@ struct fwnode_handle {struct device *dev;struct list_head suppliers;struct list_head consumers; -u8 flags; +unsigned long flags; };struct fwnode_link {
@@ -176,16 +177,37 @@ static inline void fwnode_init(struct fwINIT_LIST_HEAD (&fwnode->suppliers); } +static inline void fwnode_set_flag (struct fwnode_handle *fwnode, +unsigned int bit) +{ +set_bit (bit, &fwnode->flags); +} + +static inline void fwnode_clear_flag (struct fwnode_handle *fwnode, +unsigned int bit) +{ +clear_bit (bit, &fwnode->flags); +} + +static inline void fwnode_assign_flag (struct fwnode_handle *fwnode, +unsigned int bit,bool value) +{ +assign_bit (bit, &fwnode->flags, value); +} + +static inline bool fwnode_test_flag (struct fwnode_handle *fwnode, +unsigned int bit) +{ +return test_bit (bit, &fwnode->flags); +} +static inline void fwnode_dev_initialized (struct fwnode_handle *fwnode,bool initialized) {if (IS_ERR_OR_NULL (fwnode))return ; -if (initialized) - fwnode->flags |=FWNODE_FLAG_INITIALIZED ; -else - fwnode->flags &= ~FWNODE_FLAG_INITIALIZED ; +fwnode_assign_flag (fwnode,FWNODE_FLAG_INITIALIZED , initialized); }extern u32 fw_devlink_get_flags (void );
Greg Kroah-Hartman
maintainerPATCH 193/776 ocfs2: split transactions in dio completion to avoid credit exhaustion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heming Zhao <[email protected]>
commit d647c5b2fbf81560818dacade360abc8c00a9665 upstream.
During ocfs2 dio operations, JBD2 may report warnings via following
call trace:ocfs2_dio_end_io_write
ocfs2_mark_extent_written
ocfs2_change_extent_flag
ocfs2_split_extent
ocfs2_try_to_merge_extent
ocfs2_extend_rotate_transaction
ocfs2_extend_trans
jbd2__journal_restart
start_this_handle
output: JBD2: kworker/6:2 wants too many credits credits:5450 rsv_credits:0 max:5449
To prevent exceeding the credits limit, modify ocfs2_dio_end_io_write() to handle extents in a batch of transaction.
Additionally, relocate ocfs2_del_inode_from_orphan(). The orphan inode should only be removed from the orphan list after the extent tree update is complete. This ensures that if a crash occurs in the middle of extent tree updates, we won't leave stale blocks beyond EOF.
This patch also changes the logic for updating the inode size and removing orphan, making it similar to ext4_dio_write_end_io(). Both operations are performed only when everything looks good.
Finally, thanks to Jans and Joseph for providing the bug fix prototype and suggestions.
--- fs/ocfs2/aops.c | 74 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 29 deletions(-)
fs/ocfs2/aops.c +45 -29
@@ -37,6 +37,8 @@#include "namei.h" #include "sysfile.h" +#define OCFS2_DIO_MARK_EXTENT_BATCH 200 +static int ocfs2_symlink_get_block (struct inode *inode,sector_t iblock,struct buffer_head *bh_result,int create) {
@@ -2305,7 +2307,7 @@ static int ocfs2_dio_end_io_write(structstruct ocfs2_alloc_context *meta_ac =NULL ;handle_t *handle =NULL ;loff_t end = offset + bytes; -int ret =0 , credits =0 ; +int ret =0 , credits =0 , batch =0 ;ocfs2_init_dealloc_ctxt (&dealloc);
@@ -2322,18 +2324,6 @@ static int ocfs2_dio_end_io_write(struct goto out; } -/* Delete orphan before acquire i_rwsem. */ -if (dwc->dw_orphaned) { -BUG_ON (dwc->dw_writer_pid !=task_pid_nr (current)); - - end = end >i_size_read (inode) ? end :0 ; - - ret =ocfs2_del_inode_from_orphan (osb, inode, di_bh, - !!end, end); -if (ret <0 ) -mlog_errno (ret); - } -down_write (&oi->ip_alloc_sem); di = (struct ocfs2_dinode *)di_bh->b_data;
@@ -2354,24 +2344,25 @@ static int ocfs2_dio_end_io_write(struct credits =ocfs2_calc_extend_credits (inode->i_sb, &di->id2.i_list); - handle =ocfs2_start_trans (osb, credits); -if (IS_ERR (handle)) { - ret =PTR_ERR (handle); -mlog_errno (ret); - goto unlock; - } - ret =ocfs2_journal_access_di (handle,INODE_CACHE (inode), di_bh, -OCFS2_JOURNAL_ACCESS_WRITE ); -if (ret) { -mlog_errno (ret); - goto commit; - } -list_for_each_entry (ue, &dwc->dw_zero_list, ue_node) { +if (!handle) { + handle =ocfs2_start_trans (osb, credits); +if (IS_ERR (handle)) { + ret =PTR_ERR (handle); +mlog_errno (ret); + goto unlock; + } + ret =ocfs2_journal_access_di (handle,INODE_CACHE (inode), di_bh, +OCFS2_JOURNAL_ACCESS_WRITE ); +if (ret) { +mlog_errno (ret); + goto commit; + } + } ret =ocfs2_assure_trans_credits (handle, credits);if (ret <0 ) {mlog_errno (ret); -break ; + goto commit; } ret = ocfs2_mark_extent_written(inode, &et, handle, ue->ue_cpos, 1,
@@ -2379,19 +2370,44 @@ static int ocfs2_dio_end_io_write(struct meta_ac, &dealloc);if (ret <0 ) {mlog_errno (ret); -break ; + goto commit; + } + +if (++batch ==OCFS2_DIO_MARK_EXTENT_BATCH ) { +ocfs2_commit_trans (osb, handle); + handle =NULL ; + batch =0 ; } }if (end >i_size_read (inode)) { +if (!handle) { + handle =ocfs2_start_trans (osb, credits); +if (IS_ERR (handle)) { + ret =PTR_ERR (handle); +mlog_errno (ret); + goto unlock; + } + } ret =ocfs2_set_inode_size (handle, inode, di_bh, end);if (ret <0 )mlog_errno (ret); } + commit: -ocfs2_commit_trans (osb, handle); +if (handle) +ocfs2_commit_trans (osb, handle); unlock:up_write (&oi->ip_alloc_sem); + +/* everything looks good, let's start the cleanup */ +if (!ret && dwc->dw_orphaned) { +BUG_ON (dwc->dw_writer_pid !=task_pid_nr (current)); + + ret =ocfs2_del_inode_from_orphan (osb, inode, di_bh,0 ,0 ); +if (ret <0 ) +mlog_errno (ret); + }ocfs2_inode_unlock (inode,1 );brelse (di_bh); out:
Greg Kroah-Hartman
maintainerPATCH 194/776 padata: Fix pd UAF once and for all
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 71203f68c7749609d7fc8ae6ad054bdedeb24f91 ]
There is a race condition/UAF in padata_reorder that goes back to the initial commit. A reference count is taken at the start of the process in padata_do_parallel, and released at the end in padata_serial_worker.
This reference count is (and only is) required for padata_replace to function correctly. If padata_replace is never called then there is no issue.
In the function padata_reorder which serves as the core of padata, as soon as padata is added to queue->serial.list, and the associated spin lock released, that padata may be processed and the reference count on pd would go away.
Fix this by getting the next padata before the squeue->serial lock is released.
In order to make this possible, simplify padata_reorder by only calling it once the next padata arrives.
[ Adjust context of padata_find_next(). Replace cpumask_next_wrap(cpu, pd->cpumask.pcpu) with cpumask_next_wrap(cpu, pd->cpumask.pcpu, -1, false) in padata_reorder() in v5.15 according to dc5bb9b769c9 ("cpumask: deprecate cpumask_next_wrap()") and f954a2d37637 ("padata: switch padata_find_next() to using cpumask_next_wrap()") . ]
--- include/linux/padata.h | 3 - kernel/padata.c | 136 +++++++++++------------------------------ 2 files changed, 37 insertions(+), 102 deletions(-)
include/linux/padata.h +0 -3
@@ -91,7 +91,6 @@ struct padata_cpumask {* @cpu: Next CPU to be processed. * @cpumask: The cpumasks in use for parallel and serial workers. * @reorder_work: work struct for reordering. -* @lock: Reorder lock. */ struct parallel_data {struct padata_shell *ps;
@@ -102,8 +101,6 @@ struct parallel_data {unsigned int processed;int cpu;struct padata_cpumask cpumask; -struct work_struct reorder_work; -spinlock_t ____cacheline_aligned lock; };/**
kernel/padata.c +37 -99
202 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 195/776 padata: Remove comment for reorder_work
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 82a0302e7167d0b7c6cde56613db3748f8dd806d ]
Remove comment for reorder_work which no longer exists.
--- include/linux/padata.h | 1 - 1 file changed, 1 deletion(-)
include/linux/padata.h +0 -1
@@ -90,7 +90,6 @@ struct padata_cpumask {* @processed: Number of already processed objects. * @cpu: Next CPU to be processed. * @cpumask: The cpumasks in use for parallel and serial workers. -* @reorder_work: work struct for reordering. */ struct parallel_data {struct padata_shell *ps;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 196/776 driver core: Dont let a device probe until its ready
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
[ Upstream commit a2225b6e834a838ae3c93709760edc0a169eb2f2 ]
The moment we link a "struct device" into the list of devices for the bus, it's possible probe can happen. This is because another thread can load the driver at any time and that can cause the device to probe. This has been seen in practice with a stack crawl that looks like this [1]:
really_probe()
__driver_probe_device()
driver_probe_device()
__driver_attach()
bus_for_each_dev()
driver_attach()
bus_add_driver()
driver_register()
__platform_driver_register()
init_module() [some module]
do_one_initcall()
do_init_module()
load_module()
__arm64_sys_finit_module()
invoke_syscall()
As a result of the above, it was seen that device_links_driver_bound() could be called for the device before "dev->fwnode->dev" was assigned. This prevented __fw_devlink_pickup_dangling_consumers() from being called which meant that other devices waiting on our driver's sub-nodes were stuck deferring forever.
It's believed that this problem is showing up suddenly for two reasons:
1. Android has recently (last ~1 year) implemented an optimization to the order it loads modules [2]. When devices opt-in to this faster loading, modules are loaded one-after-the-other very quickly. This is unlike how other distributions do it. The reproduction of this problem has only been seen on devices that opt-in to Android's "parallel module loading".
2. Android devices typically opt-in to fw_devlink, and the most noticeable issue is the NULL "dev->fwnode->dev" in device_links_driver_bound(). fw_devlink is somewhat new code and also not in use by all Linux devices.
Even though the specific symptom where "dev->fwnode->dev" wasn't assigned could be fixed by moving that assignment higher in device_add(), other parts of device_add() (like the call to device_pm_add()) are also important to run before probe. Only moving the "dev->fwnode->dev" assignment would likely fix the current symptoms but lead to difficult-to-debug problems in the future.
Fix the problem by preventing probe until device_add() has run far enough that the device is ready to probe. If somehow we end up trying to probe before we're allowed, __driver_probe_device() will return -EPROBE_DEFER which will make certain the device is noticed.
In the race condition that was seen with Android's faster module loading, we will temporarily add the device to the deferred list and then take it off immediately when device_add() probes the device.
Instead of adding another flag to the bitfields already in "struct device", instead add a new "flags" field and use that. This allows us to freely change the bit from different thread without worrying about corrupting nearby bits (and means threads changing other bit won't corrupt us).
[1] Captured on a machine running a downstream 6.6 kernel
[2] https://cs.android.com/android/platform/superproject/main/+/main:system/core/libmodprobe/libmodprobe.cpp?q=LoadModulesParallel
--- drivers/base/core.c | 15 ++++++++++++++ drivers/base/dd.c | 20 +++++++++++++++++++ include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+)
drivers/base/core.c +15 -0
@@ -3409,6 +3409,21 @@ int device_add(struct device *dev)fw_devlink_link_device (dev); } +/* +* The moment the device was linked into the bus's "klist_devices" in +* bus_add_device() then it's possible that probe could have been +* attempted in a different thread via userspace loading a driver +* matching the device. "ready_to_probe" being unset would have +* blocked those attempts. Now that all of the above initialization has +* happened, unblock probe. If probe happens through another thread +* after this point but before bus_probe_device() runs then it's fine. +* bus_probe_device() -> device_initial_probe() -> __device_attach() +* will notice (under device_lock) that the device is already bound. +*/ +device_lock (dev); +dev_set_ready_to_probe (dev); +device_unlock (dev); +bus_probe_device (dev);/*
drivers/base/dd.c +20 -0
@@ -740,6 +740,26 @@ static int __driver_probe_device(struct device_driver *drv, struct device *dev)if (dev->driver)return -EBUSY ; +/* +* In device_add(), the "struct device" gets linked into the subsystem's +* list of devices and broadcast to userspace (via uevent) before we're +* quite ready to probe. Those open pathways to driver probe before +* we've finished enough of device_add() to reliably support probe. +* Detect this and tell other pathways to try again later. device_add() +* itself will also try to probe immediately after setting +* "ready_to_probe". +*/ +if (!dev_ready_to_probe (dev)) +return dev_err_probe (dev, -EPROBE_DEFER ,"Device not ready to probe\n" ); + +/* +* Set can_match = true after calling dev_ready_to_probe(), so +* driver_deferred_probe_add() won't actually add the device to the +* deferred probe list when dev_ready_to_probe() returns false. +* +* When dev_ready_to_probe() returns false, it means that device_add() +* will do another probe() attempt for us. +*/ dev->can_match = true;pr_debug ("bus: '%s': %s: matched device %s with driver %s\n" , drv->bus->name, __func__,dev_name (dev), drv->name);
include/linux/device.h +44 -0
64 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 197/776 um: drivers: call kernel_strrchr() explicitly in cow_user.c
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 91e901c65b4da02a6fd543e3f0049829ae9645b7 upstream.
Building ARCH=um on glibc >= 2.43 fails:
arch/um/drivers/cow_user.c: error: implicit declaration of function 'strrchr' [-Wimplicit-function-declaration]
glibc 2.43's C23 const-preserving strrchr() macro does not survive UML's global -Dstrrchr=kernel_strrchr remap from arch/um/Makefile. Call kernel_strrchr() directly in cow_user.c so the source no longer depends on the -D rewrite.
--- arch/um/drivers/cow_user.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/um/drivers/cow_user.c +7 -1
@@ -15,6 +15,12 @@#include "cow.h" #include "cow_sys.h" +/* +* arch/um/Makefile remaps strrchr to kernel_strrchr; call the kernel +* name directly to avoid glibc >= 2.43's C23 strrchr macro. +*/ +char *kernel_strrchr (const char *,int ); +#define PATH_LEN_V1 256/* unsigned time_t works until year 2106 */
@@ -153,7 +159,7 @@ static int absolutize(char *to, int size errno);return -1 ; } - slash =strrchr (from,'/' ); + slash =kernel_strrchr (from,'/' );if (slash !=NULL ) { *slash ='\0' ;if (chdir (from)) {
Greg Kroah-Hartman
maintainerPATCH 198/776 crypto: pcrypt - Fix handling of MAY_BACKLOG requests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit 915b692e6cb723aac658c25eb82c58fd81235110 upstream.
MAY_BACKLOG requests can return EBUSY. Handle them by checking for that value and filtering out EINPROGRESS notifications.
--- crypto/pcrypt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
crypto/pcrypt.c +5 -2
@@ -69,6 +69,9 @@ static void pcrypt_aead_done(struct crypstruct pcrypt_request *preq =aead_request_ctx (req);struct padata_priv *padata =pcrypt_request_padata (preq); +if (err == -EINPROGRESS ) +return ; + padata->info = err;padata_do_serial (padata);
@@ -82,7 +85,7 @@ static void pcrypt_aead_enc(struct padat ret =crypto_aead_encrypt (req); -if (ret == -EINPROGRESS ) +if (ret == -EINPROGRESS || ret == -EBUSY )return ; padata->info = ret;
@@ -133,7 +136,7 @@ static void pcrypt_aead_dec(struct padat ret =crypto_aead_decrypt (req); -if (ret == -EINPROGRESS ) +if (ret == -EINPROGRESS || ret == -EBUSY )return ; padata->info = ret;
Greg Kroah-Hartman
maintainerPATCH 199/776 ALSA: control: Validate buf_len before strnlen() in snd_ctl_elem_init_enum_names()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ziqing Chen <[email protected]>
commit e0da8a8cac74f4b9f577979d131f0d2b88a84487 upstream.
snd_ctl_elem_init_enum_names() advances pointer p through the names buffer while decrementing buf_len. If buf_len reaches zero but items remain, the next iteration calls strnlen(p, 0).
While strnlen(p, 0) returns 0 and would hit the existing name_len == 0 error path, CONFIG_FORTIFY_SOURCE's fortified strnlen() first checks maxlen against __builtin_dynamic_object_size(). When Clang loses track of p's object size inside the loop, this triggers a BRK exception panic before the return value is examined.
Add a buf_len == 0 guard at the loop entry to prevent calling fortified strnlen() on an exhausted buffer.
Found by kernel fuzz testing through Xiaomi Smartphone.
--- sound/core/control.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/control.c +4 -0
@@ -1441,6 +1441,10 @@ static int snd_ctl_elem_init_enum_names(/* check that there are enough valid names */ p = names;for (i =0 ; i < ue->info.value.enumerated.items; ++i) { +if (buf_len ==0 ) { +kvfree (names); +return -EINVAL ; + } name_len =strnlen (p, buf_len);if (name_len ==0 || name_len >=64 || name_len == buf_len) {kvfree (names);
Greg Kroah-Hartman
maintainerPATCH 200/776 net: caif: clear client service pointer on teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengchuan Liang <[email protected]>
commit f7cf8ece8cee3c1ee361991470cdb1eb65ab02e8 upstream.
caif_connect() can tear down an existing client after remote shutdown by calling caif_disconnect_client() followed by caif_free_client(). caif_free_client() releases the service layer referenced by adap_layer->dn, but leaves that pointer stale.
When the socket is later destroyed, caif_sock_destructor() calls caif_free_client() again and dereferences the freed service pointer.
Clear the client/service links before releasing the service object so repeated teardown becomes harmless.
--- net/caif/cfsrvl.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/caif/cfsrvl.c +12 -2
@@ -197,10 +197,20 @@ bool cfsrvl_phyid_match(struct cflayer *void caif_free_client (struct cflayer *adap_layer) { +struct cflayer *serv_layer;struct cfsrvl *servl; -if (adap_layer ==NULL || adap_layer->dn ==NULL ) + +if (!adap_layer) +return ; + + serv_layer = adap_layer->dn; +if (!serv_layer)return ; - servl =container_obj (adap_layer->dn); + +layer_set_dn (adap_layer,NULL ); +layer_set_up (serv_layer,NULL ); + + servl =container_obj (serv_layer); servl->release (&servl->layer); }EXPORT_SYMBOL (caif_free_client);
Greg Kroah-Hartman
maintainerPATCH 201/776 net: strparser: fix skb_head leak in strp_abort_strp()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luxiao Xu <[email protected]>
commit fe72340daaf1af588be88056faf98965f39e6032 upstream.
When the stream parser is aborted, for example after a message assembly timeout, it can still hold a reference to a partially assembled message in strp->skb_head.
That skb is not released in strp_abort_strp(), which leaks the partially assembled message and can be triggered repeatedly to exhaust memory.
Fix this by freeing strp->skb_head and resetting the parser state in the abort path. Leave strp_stop() unchanged so final cleanup still happens in strp_done() after the work and timer have been synchronized.
--- net/strparser/strparser.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/strparser/strparser.c +8 -0
@@ -45,6 +45,14 @@ static void strp_abort_strp(struct strpa strp->stopped =1 ; +if (strp->skb_head) { +kfree_skb (strp->skb_head); + strp->skb_head =NULL ; + } + + strp->skb_nextp =NULL ; + strp->need_bytes =0 ; +if (strp->sk) {struct sock *sk = strp->sk;
Greg Kroah-Hartman
maintainerPATCH 202/776 PCI: endpoint: pci-epf-ntb: Remove duplicate resource teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
commit 3446beddba450c8d6f9aca2f028712ac527fead3 upstream.
epf_ntb_epc_destroy() duplicates the teardown that the caller is supposed to do later. This leads to an oops when .allow_link fails or when .drop_link is performed. Remove the helper.
Also drop pci_epc_put(). EPC device refcounting is tied to configfs EPC group lifetime, and pci_epc_put() in the .drop_link path is sufficient.
--- drivers/pci/endpoint/functions/pci-epf-ntb.c | 56 --------------------------- 1 file changed, 2 insertions(+), 54 deletions(-)
drivers/pci/endpoint/functions/pci-epf-ntb.c +2 -54
@@ -1495,47 +1495,6 @@ err_alloc_peer_mem: }/** -* epf_ntb_epc_destroy_interface() - Cleanup NTB EPC interface -* @ntb: NTB device that facilitates communication between HOST1 and HOST2 -* @type: PRIMARY interface or SECONDARY interface -* -* Unbind NTB function device from EPC and relinquish reference to pci_epc -* for each of the interface. -*/ -static void epf_ntb_epc_destroy_interface (struct epf_ntb *ntb, -enum pci_epc_interface_type type) -{ -struct epf_ntb_epc *ntb_epc; -struct pci_epc *epc; -struct pci_epf *epf; - -if (type <0 ) -return ; - - epf = ntb->epf; - ntb_epc = ntb->epc[type]; -if (!ntb_epc) -return ; - epc = ntb_epc->epc; -pci_epc_remove_epf (epc, epf, type); -pci_epc_put (epc); -} - -/** -* epf_ntb_epc_destroy() - Cleanup NTB EPC interface -* @ntb: NTB device that facilitates communication between HOST1 and HOST2 -* -* Wrapper for epf_ntb_epc_destroy_interface() to cleanup all the NTB interfaces -*/ -static void epf_ntb_epc_destroy (struct epf_ntb *ntb) -{ -enum pci_epc_interface_type type; - -for (type =PRIMARY_INTERFACE ; type <=SECONDARY_INTERFACE ; type++) -epf_ntb_epc_destroy_interface (ntb, type); -} - -/** * epf_ntb_epc_create_interface() - Create and initialize NTB EPC interface * @ntb: NTB device that facilitates communication between HOST1 and HOST2 * @epc: struct pci_epc to which a particular NTB interface should be associated
@@ -1614,15 +1573,8 @@ static int epf_ntb_epc_create(struct epf ret =epf_ntb_epc_create_interface (ntb, epf->sec_epc,SECONDARY_INTERFACE ); -if (ret) { +if (ret)dev_err (dev,"SECONDARY intf: Fail to create NTB EPC\n" ); - goto err_epc_create; - } - -return 0 ; - -err_epc_create: -epf_ntb_epc_destroy_interface (ntb,PRIMARY_INTERFACE );return ret; }
@@ -1887,7 +1839,7 @@ static int epf_ntb_bind(struct pci_epf * ret =epf_ntb_init_epc_bar (ntb);if (ret) {dev_err (dev,"Failed to create NTB EPC\n" ); - goto err_bar_init; +return ret; } ret =epf_ntb_config_spad_bar_alloc_interface (ntb);
@@ -1909,9 +1861,6 @@ static int epf_ntb_bind(struct pci_epf * err_bar_alloc:epf_ntb_config_spad_bar_free (ntb); -err_bar_init: -epf_ntb_epc_destroy (ntb); -return ret; }
@@ -1927,7 +1876,6 @@ static void epf_ntb_unbind(struct pci_epepf_ntb_epc_cleanup (ntb);epf_ntb_config_spad_bar_free (ntb); -epf_ntb_epc_destroy (ntb); }#define EPF_NTB_R (_name) \
Greg Kroah-Hartman
maintainerPATCH 203/776 Revert "ALSA: usb: Increase volume range that triggers a warning"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rong Zhang <[email protected]>
commit 41d78cb724f4b40b7548af420ccfe524b14023bb upstream.
UAC uses 2 bytes to store volume values, so the maximum volume range is 0xFFFF (65535, val = -32768/32767/1).
The reverted commit bumpped the range of triggering the warning to > 65535, effectively making the range check a no-op. It didn't fix anything but covered any potential problems and deviated from the original intention of the range check.
This reverts commit 6b971191fcfc9e3c2c0143eea22534f1f48dbb62.
--- sound/usb/mixer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/usb/mixer.c +4 -3
@@ -1804,10 +1804,11 @@ static void __build_feature_ctl(struct u range = (cval->max - cval->min) / cval->res;/* -* There are definitely devices with a range of ~20,000, so let's be -* conservative and allow for a bit more. +* Are there devices with volume range more than 255? I use a bit more +* to be sure. 384 is a resolution magic number found on Logitech +* devices. It will definitively catch all buggy Logitech devices. */ -if (range >65535 ) { +if (range >384 ) {usb_audio_warn (mixer->chip,"Warning! Unlikely big volume range (=%u), cval->res is probably wrong." , range);
Greg Kroah-Hartman
maintainerPATCH 204/776 lib/ts_kmp: fix integer overflow in pattern length calculation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Law <[email protected]>
commit 8cdf30813ea8ce881cecc08664144416dbdb3e16 upstream.
The ts_kmp algorithm stores its prefix_tbl[] table and pattern in a single allocation sized from the pattern length. If the prefix_tbl[] size calculation wraps, the resulting allocation can be too small and subsequent pattern copies can overflow it.
Fix this by rejecting zero-length patterns and by using overflow helpers before calculating the combined allocation size.
This fixes a potential heap overflow. The pattern length calculation can wrap during a size_t addition, leading to an undersized allocation. Because the textsearch library is reachable from userspace via Netfilter's xt_string module, this is a security risk that should be backported to LTS kernels.
--- lib/ts_kmp.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
lib/ts_kmp.c +16 -2
@@ -94,8 +94,22 @@ static struct ts_config *kmp_init(conststruct ts_config *conf;struct ts_kmp *kmp;int i; -unsigned int prefix_tbl_len = len *sizeof (unsigned int ); -size_t priv_size =sizeof (*kmp) + len + prefix_tbl_len; +unsigned int prefix_tbl_len; +size_t priv_size; + +/* Zero-length patterns would make kmp_find() read beyond kmp->pattern. */ +if (unlikely (!len)) +return ERR_PTR (-EINVAL ); + +/* +* kmp->pattern is stored immediately after the prefix_tbl[] table. +* Reject lengths that would wrap while sizing either region. +*/ +if (unlikely (check_mul_overflow (len,sizeof (*kmp->prefix_tbl), + &prefix_tbl_len) || +check_add_overflow (sizeof (*kmp), (size_t )len, &priv_size) || +check_add_overflow (priv_size, prefix_tbl_len, &priv_size))) +return ERR_PTR (-EINVAL ); conf =alloc_ts_config (priv_size, gfp_mask);if (IS_ERR (conf))
Greg Kroah-Hartman
maintainerPATCH 205/776 media: i2c: imx219: Check return value of devm_gpiod_get_optional() in imx219_probe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
commit 943b1f27a3eead21b22e2531a5432ea5910b60eb upstream.
The devm_gpiod_get_optional() function may return an error pointer (ERR_PTR) in case of a genuine failure during GPIO acquisition, not just NULL which indicates the legitimate absence of an optional GPIO.
Add an IS_ERR() check after the function call to catch such errors and propagate them to the probe function, ensuring the driver fails to load safely rather than proceeding with an invalid pointer.
--- drivers/media/i2c/imx219.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/i2c/imx219.c +3 -0
@@ -1435,6 +1435,9 @@ static int imx219_probe(struct i2c_clien/* Request optional enable pin */ imx219->reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (imx219->reset_gpio)) +return dev_err_probe (dev,PTR_ERR (imx219->reset_gpio), +"failed to get reset gpio\n" );/* * The sensor must be powered for imx219_identify_module()
Greg Kroah-Hartman
maintainerPATCH 206/776 net: qrtr: ns: Fix use-after-free in driver remove()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
commit 7809fea20c9404bfcfa6112ec08d1fe1d3520beb upstream.
In the remove callback, if a packet arrives after destroy_workqueue() is called, but before sock_release(), the qrtr_ns_data_ready() callback will try to queue the work, causing use-after-free issue.
Fix this issue by saving the default 'sk_data_ready' callback during qrtr_ns_init() and use it to replace the qrtr_ns_data_ready() callback at the start of remove(). This ensures that even if a packet arrives after destroy_workqueue(), the work struct will not be dereferenced.
Note that it is also required to ensure that the RX threads are completed before destroying the workqueue, because the threads could be using the qrtr_ns_data_ready() callback.
--- net/qrtr/ns.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/qrtr/ns.c +11 -0
@@ -23,6 +23,7 @@ static struct {struct list_head lookups;struct workqueue_struct *workqueue;struct work_struct work; +void (*saved_data_ready)(struct sock *sk);int local_node; } qrtr_ns;
@@ -788,6 +789,7 @@ int qrtr_ns_init(void) goto err_sock; } + qrtr_ns.saved_data_ready = qrtr_ns.sock->sk->sk_data_ready; qrtr_ns.sock->sk->sk_data_ready = qrtr_ns_data_ready; sq.sq_port =QRTR_PORT_CTRL ;
@@ -828,6 +830,10 @@ int qrtr_ns_init(void)return 0 ; err_wq: +write_lock_bh (&qrtr_ns.sock->sk->sk_callback_lock); + qrtr_ns.sock->sk->sk_data_ready = qrtr_ns.saved_data_ready; +write_unlock_bh (&qrtr_ns.sock->sk->sk_callback_lock); +destroy_workqueue (qrtr_ns.workqueue); err_sock:sock_release (qrtr_ns.sock);
@@ -837,7 +843,12 @@ EXPORT_SYMBOL_GPL(qrtr_ns_init);void qrtr_ns_remove (void ) { +write_lock_bh (&qrtr_ns.sock->sk->sk_callback_lock); + qrtr_ns.sock->sk->sk_data_ready = qrtr_ns.saved_data_ready; +write_unlock_bh (&qrtr_ns.sock->sk->sk_callback_lock); +cancel_work_sync (&qrtr_ns.work); +synchronize_net ();destroy_workqueue (qrtr_ns.workqueue);/* sock_release() expects the two references that were put during
Greg Kroah-Hartman
maintainerPATCH 207/776 ext2: reject inodes with zero i_nlink and valid mode in ext2_iget()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasiliy Kovalev <[email protected]>
commit 25947cc5b2374cd5bf627fe3141496444260d04f upstream.
ext2_iget() already rejects inodes with i_nlink == 0 when i_mode is zero or i_dtime is set, treating them as deleted. However, the case of i_nlink == 0 with a non-zero mode and zero dtime slips through. Since ext2 has no orphan list, such a combination can only result from filesystem corruption - a legitimate inode deletion always sets either i_dtime or clears i_mode before freeing the inode.
A crafted image can exploit this gap to present such an inode to the VFS, which then triggers WARN_ON inside drop_nlink() (fs/inode.c) via ext2_unlink(), ext2_rename() and ext2_rmdir():
WARNING: CPU: 3 PID: 609 at fs/inode.c:336 drop_nlink+0xad/0xd0 fs/inode.c:336 CPU: 3 UID: 0 PID: 609 Comm: syz-executor Not tainted 6.12.77+ #1 Call Trace: <TASK> inode_dec_link_count include/linux/fs.h:2518 [inline] ext2_unlink+0x26c/0x300 fs/ext2/namei.c:295 vfs_unlink+0x2fc/0x9b0 fs/namei.c:4477 do_unlinkat+0x53e/0x730 fs/namei.c:4541 __x64_sys_unlink+0xc6/0x110 fs/namei.c:4587 do_syscall_64+0xf5/0x220 arch/x86/entry/common.c:78 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> WARNING: CPU: 0 PID: 646 at fs/inode.c:336 drop_nlink+0xad/0xd0 fs/inode.c:336 CPU: 0 UID: 0 PID: 646 Comm: syz.0.17 Not tainted 6.12.77+ #1 Call Trace: <TASK> inode_dec_link_count include/linux/fs.h:2518 [inline] ext2_rename+0x35e/0x850 fs/ext2/namei.c:374 vfs_rename+0xf2f/0x2060 fs/namei.c:5021 do_renameat2+0xbe2/0xd50 fs/namei.c:5178 __x64_sys_rename+0x7e/0xa0 fs/namei.c:5223 do_syscall_64+0xf5/0x220 arch/x86/entry/common.c:78 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> WARNING: CPU: 0 PID: 634 at fs/inode.c:336 drop_nlink+0xad/0xd0 fs/inode.c:336 CPU: 0 UID: 0 PID: 634 Comm: syz-executor Not tainted 6.12.77+ #1 Call Trace: <TASK> inode_dec_link_count include/linux/fs.h:2518 [inline] ext2_rmdir+0xca/0x110 fs/ext2/namei.c:311 vfs_rmdir+0x204/0x690 fs/namei.c:4348 do_rmdir+0x372/0x3e0 fs/namei.c:4407 __x64_sys_unlinkat+0xf0/0x130 fs/namei.c:4577 do_syscall_64+0xf5/0x220 arch/x86/entry/common.c:78 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
Extend the existing i_nlink == 0 check to also catch this case, reporting the corruption via ext2_error() and returning -EFSCORRUPTED. This rejects the inode at load time and prevents it from reaching any of the namei.c paths.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- fs/ext2/inode.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
fs/ext2/inode.c +11 -3
@@ -1457,9 +1457,17 @@ struct inode *ext2_iget (struct super_bl* the test is that same one that e2fsck uses * NeilBrown 1999oct15 */ -if (inode->i_nlink ==0 && (inode->i_mode ==0 || ei->i_dtime)) { -/* this inode is deleted */ - ret = -ESTALE ; +if (inode->i_nlink ==0 ) { +if (inode->i_mode ==0 || ei->i_dtime) { +/* this inode is deleted */ + ret = -ESTALE ; + }else { +ext2_error (sb, __func__, +"inode %lu has zero i_nlink with mode 0%o and no dtime, " +"filesystem may be corrupt" , + ino, inode->i_mode); + ret = -EFSCORRUPTED ; + } goto bad_inode; } inode->i_blocks =le32_to_cpu (raw_inode->i_blocks);
Greg Kroah-Hartman
maintainerPATCH 208/776 ALSA: aoa: i2sbus: fix OF node lifetime handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit 4ec93f070eda6b765b62efcaed9241c3b3b0b6ad upstream.
i2sbus_add_dev() keeps the matched "sound" child pointer after for_each_child_of_node() has dropped the iterator reference. Take an extra reference before saving that node and drop it after the layout-id/device-id lookup is complete.
The function also stores np in dev->sound.ofdev.dev.of_node without taking a reference for the embedded soundbus device. Since i2sbus overrides the embedded platform device release callback, balance that reference explicitly in the local error path and in i2sbus_release_dev().
--- sound/aoa/soundbus/i2sbus/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/aoa/soundbus/i2sbus/core.c +6 -3
@@ -83,6 +83,7 @@ static void i2sbus_release_dev(struct defor (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++)free_irq (i2sdev->interrupts[i], i2sdev);i2sbus_control_remove_dev (i2sdev->control, i2sdev); +of_node_put (i2sdev->sound.ofdev.dev.of_node);mutex_destroy (&i2sdev->lock);kfree (i2sdev); }
@@ -148,7 +149,6 @@ static int i2sbus_get_and_fixup_rsrc(str }/* Returns 1 if added, 0 for otherwise; don't return a negative value! */ -/* FIXME: look at device node refcounting */ static int i2sbus_add_dev (struct macio_dev *macio,struct i2sbus_control *control,struct device_node *np)
@@ -179,8 +179,9 @@ static int i2sbus_add_dev(struct macio_d i =0 ;for_each_child_of_node (np, child) {if (of_node_name_eq (child,"sound" )) { +of_node_put (sound); i++; - sound = child; + sound =of_node_get (child); } }if (i ==1 ) {
@@ -206,6 +207,7 @@ static int i2sbus_add_dev(struct macio_d } } } +of_node_put (sound);/* for the time being, until we can handle non-layout-id * things in some fabric, refuse to attach if there is no * layout-id property or we haven't been forced to attach.
@@ -220,7 +222,7 @@ static int i2sbus_add_dev(struct macio_dmutex_init (&dev->lock);spin_lock_init (&dev->low_lock); dev->sound.ofdev.archdata.dma_mask = macio->ofdev.archdata.dma_mask; - dev->sound.ofdev.dev.of_node = np; + dev->sound.ofdev.dev.of_node =of_node_get (np); dev->sound.ofdev.dev.dma_mask = &dev->sound.ofdev.archdata.dma_mask; dev->sound.ofdev.dev.parent = &macio->ofdev.dev; dev->sound.ofdev.dev.release = i2sbus_release_dev;
@@ -328,6 +330,7 @@ static int i2sbus_add_dev(struct macio_dfor (i=0 ;i<3 ;i++)release_and_free_resource (dev->allocated_resource[i]);mutex_destroy (&dev->lock); +of_node_put (dev->sound.ofdev.dev.of_node);kfree (dev);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 209/776 ALSA: ctxfi: Add fallback to default RSR for S/PDIF
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harin Lee <[email protected]>
commit 7d61662197ecdc458e33e475b6ada7f6da61d364 upstream.
spdif_passthru_playback_get_resources() uses atc->pll_rate as the RSR for the MSR calculation loop. However, pll_rate is only updated in atc_pll_init() and not in hw_pll_init(), so it remains 0 after the card init.
When spdif_passthru_playback_setup() skips atc_pll_init() for 32000 Hz, (rsr * desc.msr) always becomes 0, causing the loop to spin indefinitely.
Add fallback to use atc->rsr when atc->pll_rate is 0. This reflects the hardware state, since hw_card_init() already configures the PLL to the default RSR.
--- sound/pci/ctxfi/ctatc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/pci/ctxfi/ctatc.c +2 -1
@@ -791,7 +791,8 @@ static int spdif_passthru_playback_get_rstruct src *src;int err;int n_amixer = apcm->substream->runtime->channels, i; -unsigned int pitch, rsr = atc->pll_rate; +unsigned int pitch; +unsigned int rsr = atc->pll_rate ? atc->pll_rate : atc->rsr;/* first release old resources */ atc_pcm_release_resources (atc, apcm);
Greg Kroah-Hartman
maintainerPATCH 210/776 ALSA: seq_oss: return full count for successful SEQ_FULLSIZE writes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit bbc6c0dda54fc0ad8f8aed0b796c23e186e1a188 upstream.
snd_seq_oss_write() currently returns the raw load_patch() callback result for SEQ_FULLSIZE events.
That callback is documented as returning 0 on success and -errno on failure, but snd_seq_oss_write() is the file write path and should report the number of user bytes consumed on success. Some in-tree backends also return backend-specific positive values, which can still be shorter than the original write size.
Return the full byte count for successful SEQ_FULLSIZE writes. Preserve negative errors and convert any nonnegative completion to the original count.
--- sound/core/seq/oss/seq_oss_rw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/core/seq/oss/seq_oss_rw.c +3 -3
@@ -101,9 +101,9 @@ snd_seq_oss_write(struct seq_oss_devinfobreak ; } fmt = (*(unsigned short *)rec.c) &0xffff ; -/* FIXME the return value isn't correct */ -return snd_seq_oss_synth_load_patch (dp, rec.s.dev, - fmt, buf,0 , count); + err =snd_seq_oss_synth_load_patch (dp, rec.s.dev, + fmt, buf,0 , count); +return err <0 ? err : count; }if (ev_is_long (&rec)) {/* extended code */
Greg Kroah-Hartman
maintainerPATCH 211/776 md/raid10: fix deadlock with check operation and nowait requests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Hunt <[email protected]>
commit 7d96f3120a7fb7210d21b520c5b6f495da6ba436 upstream.
When an array check is running it will raise the barrier at which point normal requests will become blocked and increment the nr_pending value to signal there is work pending inside of wait_barrier(). NOWAIT requests do not block and so will return immediately with an error, and additionally do not increment nr_pending in wait_barrier(). Upstream change commit 43806c3d5b9b ("raid10: cleanup memleak at raid10_make_request") added a call to raid_end_bio_io() to fix a memory leak when NOWAIT requests hit this condition. raid_end_bio_io() eventually calls allow_barrier() and it will unconditionally do an atomic_dec_and_test(&conf->nr_pending) even though the corresponding increment on nr_pending didn't happen in the NOWAIT case.
This can be easily seen by starting a check operation while an application is doing nowait IO on the same array. This results in a deadlocked state due to nr_pending value underflowing and so the md resync thread gets stuck waiting for nr_pending to == 0.
Output of r10conf state of the array when we hit this condition:
crash> struct r10conf
barrier = 1,
nr_pending = {
counter = -41
},
nr_waiting = 15,
nr_queued = 0,Example of md_sync thread stuck waiting on raise_barrier() and other requests stuck in wait_barrier():
md1_resync
[<0>] raise_barrier+0xce/0x1c0 [<0>] raid10_sync_request+0x1ca/0x1ed0 [<0>] md_do_sync+0x779/0x1110 [<0>] md_thread+0x90/0x160 [<0>] kthread+0xbe/0xf0 [<0>] ret_from_fork+0x34/0x50 [<0>] ret_from_fork_asm+0x1a/0x30
kworker/u1040:2+flush-253:4
[<0>] wait_barrier+0x1de/0x220 [<0>] regular_request_wait+0x30/0x180 [<0>] raid10_make_request+0x261/0x1000 [<0>] md_handle_request+0x13b/0x230 [<0>] __submit_bio+0x107/0x1f0 [<0>] submit_bio_noacct_nocheck+0x16f/0x390 [<0>] ext4_io_submit+0x24/0x40 [<0>] ext4_do_writepages+0x254/0xc80 [<0>] ext4_writepages+0x84/0x120 [<0>] do_writepages+0x7a/0x260 [<0>] __writeback_single_inode+0x3d/0x300 [<0>] writeback_sb_inodes+0x1dd/0x470 [<0>] __writeback_inodes_wb+0x4c/0xe0 [<0>] wb_writeback+0x18b/0x2d0 [<0>] wb_workfn+0x2a1/0x400 [<0>] process_one_work+0x149/0x330 [<0>] worker_thread+0x2d2/0x410 [<0>] kthread+0xbe/0xf0 [<0>] ret_from_fork+0x34/0x50 [<0>] ret_from_fork_asm+0x1a/0x30
--- drivers/md/raid10.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/raid10.c +2 -2
@@ -1197,7 +1197,7 @@ static void raid10_read_request(struct m }if (!regular_request_wait (mddev, conf, bio, r10_bio->sectors)) { -raid_end_bio_io (r10_bio); +free_r10bio (r10_bio);return ; }
@@ -1435,7 +1435,7 @@ static void raid10_write_request(struct sectors = r10_bio->sectors;if (!regular_request_wait (mddev, conf, bio, sectors)) { -raid_end_bio_io (r10_bio); +free_r10bio (r10_bio);return ; }
Greg Kroah-Hartman
maintainerPATCH 212/776 nvme-pci: add NVME_QUIRK_DISABLE_WRITE_ZEROES for Kingston OM3SGP4
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Beckett <[email protected]>
commit a8eebf9699d69987cc49cec4e4fdb4111ab32423 upstream.
The Kingston OM3SGP42048K2-A00 (PCI ID 2646:502f) firmware has a race condition when processing concurrent write zeroes and DSM (discard) commands, causing spurious "LBA Out of Range" errors and IOMMU page faults at address 0x0.
The issue is reliably triggered by running two concurrent mkfs commands on different partitions of the same drive, which generates interleaved write zeroes and discard operations.
Disable write zeroes for this device, matching the pattern used for other Kingston OM* drives that have similar firmware issues.
--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/pci.c +2 -0
@@ -3478,6 +3478,8 @@ static const struct pci_device_id nvme_i .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, { PCI_DEVICE(0x2646, 0x501E), /* KINGSTON OM3PGP4xxxxQ OS21011 NVMe SSD */ .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, + { PCI_DEVICE(0x2646, 0x502F), /* KINGSTON OM3SGP4xxxxK NVMe SSD */ + .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, { PCI_DEVICE(0x1f40, 0x1202), /* Netac Technologies Co. NV3000 NVMe SSD */ .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x1f40, 0x5236), /* Netac Technologies Co. NV7000 NVMe SSD */
Greg Kroah-Hartman
maintainerPATCH 213/776 parisc: _llseek syscall is only available for 32-bit userspace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit da3680f564bd787ce974f9931e6e924d908b3b2a upstream.
--- arch/parisc/kernel/syscalls/syscall.tbl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/kernel/syscalls/syscall.tbl +1 -1
@@ -154,7 +154,7 @@ # 137 was afs_syscall 138 common setfsuid sys_setfsuid 139 common setfsgid sys_setfsgid -140 common _llseek sys_llseek +140 32 _llseek sys_llseek 141 common getdents sys_getdents compat_sys_getdents 142 common _newselect sys_select compat_sys_select 143 common flock sys_flock
Greg Kroah-Hartman
maintainerPATCH 214/776 selftests/mqueue: Fix incorrectly named file
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Liebold <[email protected]>
commit 64fac99037689020ad97e472ae898e96ea3616dc upstream.
Commit 85506aca2eb4 ("selftests/mqueue: Set timeout to 180 seconds") intended to increase the timeout for mq_perf_tests from the default kselftest limit of 45 seconds to 180 seconds.
Unfortunately, the file storing this information was incorrectly named setting instead of settings, causing the kselftest runner not to pick up the limit and keep using the default 45 seconds limit.
Fix this by renaming it to settings to ensure that the kselftest runner uses the increased timeout of 180 seconds for this test.
---
tools/testing/selftests/mqueue/{setting => settings} | 0
tools/testing/selftests/mqueue/setting | 1 -
tools/testing/selftests/mqueue/settings | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
rename tools/testing/selftests/mqueue/{setting => settings} (100%)tools/testing/selftests/mqueue/setting deleted +0 -1
@@ -1 +0,0 @@ -timeout=180
tools/testing/selftests/mqueue/settings new file +1 -0
@@ -0,0 +1 @@ +timeout=180
Greg Kroah-Hartman
maintainerPATCH 215/776 ALSA: caiaq: Fix control_put() result and cache rollback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit a3542d1b30f92307f545f2def14e8d988dffdff0 upstream.
control_put() always returns 1 and updates cdev->control_state[] before sending the USB command. It also ignores transport errors from usb_bulk_msg(), snd_usb_caiaq_send_command(), and snd_usb_caiaq_send_command_bank().
That breaks the ALSA .put() contract and can leave control_get() reporting a cached value the device never accepted.
Return 0 for unchanged values, propagate transport failures, and restore the cached byte when the write fails.
--- sound/usb/caiaq/control.c | 54 +++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 17 deletions(-)
sound/usb/caiaq/control.c +37 -17
@@ -87,6 +87,7 @@ static int control_put(struct snd_kcontrstruct snd_usb_caiaqdev *cdev =caiaqdev (chip->card);int pos = kcontrol->private_value;int v = ucontrol->value.integer.value[0 ]; +int ret;unsigned char cmd;switch (cdev->chip.usb_id) {
@@ -103,6 +104,10 @@ static int control_put(struct snd_kcontrif (pos &CNT_INTVAL ) {int i = pos & ~CNT_INTVAL ; +unsigned char old = cdev->control_state[i]; + +if (old == v) +return 0 ; cdev->control_state[i] = v;
@@ -113,10 +118,11 @@ static int control_put(struct snd_kcontr cdev->ep8_out_buf[0 ] = i; cdev->ep8_out_buf[1 ] = v; -usb_bulk_msg (cdev->chip.dev, -usb_sndbulkpipe (cdev->chip.dev,8 ), - cdev->ep8_out_buf,sizeof (cdev->ep8_out_buf), - &actual_len,200 ); + ret =usb_bulk_msg (cdev->chip.dev, +usb_sndbulkpipe (cdev->chip.dev,8 ), + cdev->ep8_out_buf, +sizeof (cdev->ep8_out_buf), + &actual_len,200 ); }else if (cdev->chip.usb_id ==USB_ID (USB_VID_NATIVEINSTRUMENTS ,USB_PID_MASCHINECONTROLLER )) {
@@ -128,21 +134,36 @@ static int control_put(struct snd_kcontr offset =MASCHINE_BANK_SIZE ; } -snd_usb_caiaq_send_command_bank (cdev, cmd, bank, - cdev->control_state + offset, -MASCHINE_BANK_SIZE ); + ret =snd_usb_caiaq_send_command_bank (cdev, cmd, bank, + cdev->control_state + offset, +MASCHINE_BANK_SIZE ); }else { -snd_usb_caiaq_send_command (cdev, cmd, - cdev->control_state,sizeof (cdev->control_state)); + ret =snd_usb_caiaq_send_command (cdev, cmd, + cdev->control_state, +sizeof (cdev->control_state)); } - }else { -if (v) - cdev->control_state[pos /8 ] |=1 << (pos %8 ); -else - cdev->control_state[pos /8 ] &= ~(1 << (pos %8 )); -snd_usb_caiaq_send_command (cdev, cmd, - cdev->control_state,sizeof (cdev->control_state)); +if (ret <0 ) { + cdev->control_state[i] = old; +return ret; + } + }else { +int idx = pos /8 ; +unsigned char mask =1 << (pos %8 ); +unsigned char old = cdev->control_state[idx]; +unsigned char val = v ? (old | mask) : (old & ~mask); + +if (old == val) +return 0 ; + + cdev->control_state[idx] = val; + ret =snd_usb_caiaq_send_command (cdev, cmd, + cdev->control_state, +sizeof (cdev->control_state)); +if (ret <0 ) { + cdev->control_state[idx] = old; +return ret; + } }return 1 ;
@@ -640,4 +661,3 @@ int snd_usb_caiaq_control_init(struct snreturn ret; } -
Greg Kroah-Hartman
maintainerPATCH 216/776 ALSA: caiaq: Handle probe errors properly
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 28abd224db4a49560b452115bca3672a20e45b2f upstream.
The probe procedure of setup_card() in caiaq driver doesn't treat the error cases gracefully, e.g. the error from snd_card_register() calls snd_card_free() but continues. This would lead to a UAF for the further calls like snd_usb_caiaq_control_init(), as Berk suggested in another patch in the link below.
However, the problem is not only that; in general, this function drops the all error handlings (as it's a void function) although its caller can propagate an error to snd_probe(), which eventually calls snd_card_free() as a proper error path. That said, we should treat each error case in setup_card(), and just return the error code promptly, which is then handled later as a fatal error in snd_probe().
This patch achieves it by changing the setup_card() to return an error code. Also, the superfluous snd_card_free() call is removed, too.
Note that card->private_free can be set still safely at returning an error. All called functions in card_free() have checks of the unassigned resources or NULL checks.
--- sound/usb/caiaq/device.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
sound/usb/caiaq/device.c +24 -9
@@ -290,7 +290,7 @@ int snd_usb_caiaq_set_auto_msg(struct sn tmp, sizeof(tmp)); } -static void setup_card (struct snd_usb_caiaqdev *cdev) +static int setup_card (struct snd_usb_caiaqdev *cdev) {int ret;char val[4 ];
@@ -325,8 +325,10 @@ static void setup_card(struct snd_usb_casnd_usb_caiaq_send_command (cdev,EP1_CMD_READ_IO ,NULL ,0 );if (!wait_event_timeout (cdev->ep1_wait_queue, - cdev->control_state[0 ] !=0xff ,HZ )) -return ; + cdev->control_state[0 ] !=0xff ,HZ )) { +dev_err (dev,"Read timeout for control state\n" ); +return -EINVAL ; + }/* fix up some defaults */ if ((cdev->control_state[1] != 2) ||
@@ -347,33 +349,43 @@ static void setup_card(struct snd_usb_ca cdev->spec.num_digital_audio_out + cdev->spec.num_digital_audio_in > 0) { ret =snd_usb_caiaq_audio_init (cdev); -if (ret <0 ) +if (ret <0 ) {dev_err (dev,"Unable to set up audio system (ret=%d)\n" , ret); +return ret; + } }if (cdev->spec.num_midi_in + cdev->spec.num_midi_out >0 ) { ret =snd_usb_caiaq_midi_init (cdev); -if (ret <0 ) +if (ret <0 ) {dev_err (dev,"Unable to set up MIDI system (ret=%d)\n" , ret); +return ret; + } }#ifdef CONFIG_SND_USB_CAIAQ_INPUT ret =snd_usb_caiaq_input_init (cdev); -if (ret <0 ) +if (ret <0 ) {dev_err (dev,"Unable to set up input system (ret=%d)\n" , ret); +return ret; + }#endif /* finally, register the card and all its sub-instances */ ret =snd_card_register (cdev->chip.card);if (ret <0 ) {dev_err (dev,"snd_card_register() returned %d\n" , ret); -snd_card_free (cdev->chip.card); +return ret; } ret =snd_usb_caiaq_control_init (cdev); -if (ret <0 ) +if (ret <0 ) {dev_err (dev,"Unable to set up control system (ret=%d)\n" , ret); +return ret; + } + +return 0 ; }static void card_free (struct snd_card *card)
@@ -499,8 +511,11 @@ static int init_card(struct snd_usb_caiasnprintf (card->longname,sizeof (card->longname),"%s %s (%s)" , cdev->vendor_name, cdev->product_name, usbpath); -setup_card (cdev); card->private_free = card_free; + err =setup_card (cdev); +if (err <0 ) +return err; +return 0 ; err_kill_urb:
Greg Kroah-Hartman
maintainerPATCH 217/776 ALSA: 6fire: Fix input volume change detection
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit dc88eef8f55e85e92d016cdf7e291f5560efd79b upstream.
usb6fire_control_input_vol_put() stores the analog capture volume as a signed offset in rt->input_vol[] (-15..+15), but it compares the cached value against the user-visible mixer value (0..30) before subtracting 15.
This mixes two domains in the change detection path. Since the runtime is zero-initialized, the visible default is 15; writing 0 right after probe is ignored, while writing 15 is reported as a change even though the cached value remains 0.
Normalize the user value before comparing it with the cached offset.
--- sound/usb/6fire/control.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
sound/usb/6fire/control.c +6 -4
@@ -290,15 +290,17 @@ static int usb6fire_control_input_vol_pu struct snd_ctl_elem_value *ucontrol) {struct control_runtime *rt =snd_kcontrol_chip (kcontrol); +int vol0 = ucontrol->value.integer.value[0 ] -15 ; +int vol1 = ucontrol->value.integer.value[1 ] -15 ;int changed =0 ; -if (rt->input_vol[0 ] != ucontrol->value.integer.value[0 ]) { - rt->input_vol[0 ] = ucontrol->value.integer.value[0 ] -15 ; +if (rt->input_vol[0 ] != vol0) { + rt->input_vol[0 ] = vol0; rt->ivol_updated &= ~(1 <<0 ); changed =1 ; } -if (rt->input_vol[1 ] != ucontrol->value.integer.value[1 ]) { - rt->input_vol[1 ] = ucontrol->value.integer.value[1 ] -15 ; +if (rt->input_vol[1 ] != vol1) { + rt->input_vol[1 ] = vol1; rt->ivol_updated &= ~(1 <<1 ); changed =1 ; }
Greg Kroah-Hartman
maintainerPATCH 218/776 iio: adc: ad7768-1: fix one-shot mode data acquisition
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Santos <[email protected]>
commit 8be19e233744961db6069da9c9ab63eb085a0447 upstream.
According to the datasheet, one-shot mode requires a SYNC_IN pulse to trigger a new sample conversion. In the current implementation, No sync pulse was sent after switching to one-shot mode and reinit_completion() was called before mode switching, creating a race condition where spurious interrupts during mode change could trigger completion prematurely.
Fix by sending a sync pulse after configuring one-shot mode and reinit_completion() to ensure it only waits for the actual conversion completion.
--- drivers/iio/adc/ad7768-1.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/iio/adc/ad7768-1.c +7 -2
@@ -241,12 +241,17 @@ static int ad7768_scan_direct(struct iiostruct ad7768_state *st =iio_priv (indio_dev);int readval, ret; -reinit_completion (&st->completion); - ret =ad7768_set_mode (st,AD7768_ONE_SHOT );if (ret <0 )return ret; +reinit_completion (&st->completion); + +/* One-shot mode requires a SYNC pulse to generate a new sample */ + ret =ad7768_send_sync_pulse (st); +if (ret) +return ret; + ret =wait_for_completion_timeout (&st->completion,msecs_to_jiffies (1000 ));if (!ret)
Greg Kroah-Hartman
maintainerPATCH 219/776 net: rds: fix MR cleanup on copy error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ao Zhou <[email protected]>
commit 8141a2dc70080eda1aedc0389ed2db2b292af5bd upstream.
__rds_rdma_map() hands sg/pages ownership to the transport after get_mr() succeeds. If copying the generated cookie back to user space fails after that point, the error path must not free those resources again before dropping the MR reference.
Remove the duplicate unpin/free from the put_user() failure branch so that MR teardown is handled only through the existing final cleanup path.
--- net/rds/rdma.c | 4 ---- 1 file changed, 4 deletions(-)
net/rds/rdma.c +0 -4
@@ -326,10 +326,6 @@ static int __rds_rdma_map(struct rds_socif (args->cookie_addr &&put_user (cookie, (u64 __user *)(unsigned long )args->cookie_addr)) { -if (!need_odp) { -unpin_user_pages (pages, nr_pages); -kfree (sg); - } ret = -EFAULT ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 220/776 net/smc: avoid early lgr access in smc_clc_wait_msg
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruijie Li <[email protected]>
commit 5a8db80f721deee8e916c2cfdee78decda02ce4f upstream.
A CLC decline can be received while the handshake is still in an early stage, before the connection has been associated with a link group.
The decline handling in smc_clc_wait_msg() updates link-group level sync state for first-contact declines, but that state only exists after link group setup has completed. Guard the link-group update accordingly and keep the per-socket peer diagnosis handling unchanged.
This preserves the existing sync_err handling for established link-group contexts and avoids touching link-group state before it is available.
--- net/smc/smc_clc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/smc_clc.c +2 -2
@@ -440,8 +440,8 @@ int smc_clc_wait_msg(struct smc_sock *sm dclc = (struct smc_clc_msg_decline *)clcm; reason_code =SMC_CLC_DECL_PEERDECL ; smc->peer_diagnosis =ntohl (dclc->peer_diagnosis); -if (((struct smc_clc_msg_decline *)buf)->hdr.typev2 & -SMC_FIRST_CONTACT_MASK ) { +if ((dclc->hdr.typev2 &SMC_FIRST_CONTACT_MASK ) && + smc->conn.lgr) { smc->conn.lgr->sync_err =1 ;smc_lgr_terminate_sched (smc->conn.lgr); }
Greg Kroah-Hartman
maintainerPATCH 221/776 drm/arcpgu: fix device node leak
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
commit ad3ac32a3893a2bbcad545efc005a8e4e7ecf10c upstream.
This function gets a device_node reference via of_graph_get_remote_port_parent() and stores it in encoder_node, but never puts that reference. Add it.
There used to be a of_node_put(encoder_node) but it has been removed by mistake during a rework in commit 3ea66a794fdc ("drm/arc: Inline arcpgu_drm_hdmi_init").
--- drivers/gpu/drm/tiny/arcpgu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/tiny/arcpgu.c +2 -1
@@ -245,7 +245,8 @@ DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);static int arcpgu_load (struct arcpgu_drm_private *arcpgu) {struct platform_device *pdev =to_platform_device (arcpgu->drm.dev); -struct device_node *encoder_node =NULL , *endpoint_node =NULL ; + struct device_node *encoder_node __free(device_node) = NULL; +struct device_node *endpoint_node =NULL ;struct drm_connector *connector =NULL ;struct drm_device *drm = &arcpgu->drm;struct resource *res;
Greg Kroah-Hartman
maintainerPATCH 222/776 RDMA/rxe: Validate pad and ICRC before payload_size() in rxe_rcv
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: hkbinbin <[email protected]>
commit 7244491dab347f648e661da96dc0febadd9daec3 upstream.
rxe_rcv() currently checks only that the incoming packet is at least header_size(pkt) bytes long before payload_size() is used.
However, payload_size() subtracts both the attacker-controlled BTH pad field and RXE_ICRC_SIZE from pkt->paylen:
payload_size = pkt->paylen - offset[RXE_PAYLOAD] - bth_pad(pkt)
- RXE_ICRC_SIZE
This means a short packet can still make payload_size() underflow even if it includes enough bytes for the fixed headers. Simply requiring header_size(pkt) + RXE_ICRC_SIZE is not sufficient either, because a packet with a forged non-zero BTH pad can still leave payload_size() negative and pass an underflowed value to later receive-path users.
Fix this by validating pkt->paylen against the full minimum length required by payload_size(): header_size(pkt) + bth_pad(pkt) + RXE_ICRC_SIZE.
--- drivers/infiniband/sw/rxe/rxe_recv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_recv.c +2 -1
@@ -375,7 +375,8 @@ void rxe_rcv(struct sk_buff *skb) pkt->qp =NULL ; pkt->mask |= rxe_opcode[pkt->opcode].mask; -if (unlikely (skb->len <header_size (pkt))) +if (unlikely (pkt->paylen <header_size (pkt) +bth_pad (pkt) + +RXE_ICRC_SIZE )) goto drop; err =hdr_check (pkt);
Greg Kroah-Hartman
maintainerPATCH 223/776 ipv4: icmp: validate reply type before using icmp_pointers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruide Cao <[email protected]>
commit 67bf002a2d7387a6312138210d0bd06e3cf4879b upstream.
Extended echo replies use ICMP_EXT_ECHOREPLY as the outbound reply type. That value is outside the range covered by icmp_pointers[], which only describes the traditional ICMP types up to NR_ICMP_TYPES.
Avoid consulting icmp_pointers[] for reply types outside that range, and use array_index_nospec() for the remaining in-range lookup. Normal ICMP replies keep their existing behavior unchanged.
--- net/ipv4/icmp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/icmp.c +4 -1
@@ -64,6 +64,7 @@#include <linux/jiffies.h> #include <linux/kernel.h> #include <linux/fcntl.h> +#include <linux/nospec.h> #include <linux/socket.h> #include <linux/in.h> #include <linux/inet.h>
@@ -361,7 +362,9 @@ static int icmp_glue_bits(void *from, ch to, len); skb->csum =csum_block_add (skb->csum, csum, odd); -if (icmp_pointers[icmp_param->data.icmph.type].error) +if (icmp_param->data.icmph.type <=NR_ICMP_TYPES && + icmp_pointers[array_index_nospec (icmp_param->data.icmph.type, +NR_ICMP_TYPES +1 )].error)nf_ct_attach (skb, icmp_param->skb);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 224/776 libceph: Prevent potential null-ptr-deref in ceph_handle_auth_reply()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit 5199c125d25aeae8615c4fc31652cc0fe624338e upstream.
If a message of type CEPH_MSG_AUTH_REPLY contains a zero value for both protocol and result, this is currently not treated as an error. In case of ac->negotiating == true and ac->protocol > 0, this leads to setting ac->protocol = 0 and ac->ops = NULL. Thereafter, the check for ac->protocol != protocol returns false, and init_protocol() is not called. Subsequently, ac->ops->handle_reply() is called, which leads to a null pointer dereference, because ac->ops is still NULL.
This patch changes the check for ac->protocol != protocol to !ac->protocol, as this also includes the case when the protocol was set to zero in the message. This causes the message to be treated as containing a bad auth protocol.
--- net/ceph/auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ceph/auth.c +1 -1
@@ -245,7 +245,7 @@ int ceph_handle_auth_reply(struct ceph_a ac->protocol =0 ; ac->ops =NULL ; } -if (ac->protocol != protocol) { +if (!ac->protocol) { ret =init_protocol (ac, protocol);if (ret) { pr_err("auth protocol '%s' init failed: %d\n",
Greg Kroah-Hartman
maintainerPATCH 225/776 tpm: avoid -Wunused-but-set-variable
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 6f1d4d2ecfcd1b577dc87350ea965fe81f272e83 upstream.
Outside of the EFI tpm code, the TPM_MEMREMAP()/TPM_MEMUNMAP functions are defined as trivial macros, leading to the mapping_size variable ending up unused:
In file included from drivers/char/tpm/tpm-sysfs.c:16:
In file included from drivers/char/tpm/tpm.h:28:include/linux/tpm_eventlog.h:167:6: error: variable 'mapping_size' set but not used [-Werror,-Wunused-but-set-variable]
167 | int mapping_size;
Turn the stubs into inline functions to avoid this warning.
--- include/linux/tpm_eventlog.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
include/linux/tpm_eventlog.h +7 -2
@@ -131,11 +131,16 @@ struct tcg_algorithm_info { };#ifndef TPM_MEMREMAP -#define TPM_MEMREMAP (start, size) NULL +static inline void *TPM_MEMREMAP (unsigned long start,size_t size) +{ +return NULL ; +}#endif #ifndef TPM_MEMUNMAP -#define TPM_MEMUNMAP (start, size) do{} while(0) +static inline void TPM_MEMUNMAP (void *mapping,size_t size) +{ +}#endif /**
Greg Kroah-Hartman
maintainerPATCH 226/776 power: supply: axp288_charger: Do not cancel work before initializing it
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 658342fd75b582cbb06544d513171c3d645faead upstream.
Driver registered devm handler to cancel_work_sync() before even the work was initialized, thus leading to possible warning from kernel/workqueue.c on (!work->func) check, if the error path was hit before the initialization happened.
Use devm_work_autocancel() on each work item independently, which handles the initialization and handler to cancel work.
--- drivers/power/supply/axp288_charger.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/power/supply/axp288_charger.c +8 -11
@@ -10,6 +10,7 @@#include <linux/acpi.h> #include <linux/bitops.h> #include <linux/module.h> +#include <linux/devm-helpers.h> #include <linux/device.h> #include <linux/regmap.h> #include <linux/workqueue.h>
@@ -796,14 +797,6 @@ static int charger_init_hw_regs(struct areturn 0 ; } -static void axp288_charger_cancel_work (void *data) -{ -struct axp288_chrg_info *info = data; - -cancel_work_sync (&info->otg.work); -cancel_work_sync (&info->cable.work); -} -static int axp288_charger_probe (struct platform_device *pdev) {int ret, i, pirq;
@@ -867,12 +860,12 @@ static int axp288_charger_probe(struct p }/* Cancel our work on cleanup, register this before the notifiers */ - ret =devm_add_action (dev, axp288_charger_cancel_work, info); + ret =devm_work_autocancel (dev, &info->cable.work, + axp288_charger_extcon_evt_worker);if (ret)return ret;/* Register for extcon notification */ -INIT_WORK (&info->cable.work, axp288_charger_extcon_evt_worker); info->cable.nb.notifier_call = axp288_charger_handle_cable_evt; ret =devm_extcon_register_notifier_all (dev, info->cable.edev, &info->cable.nb);
@@ -882,8 +875,12 @@ static int axp288_charger_probe(struct p }schedule_work (&info->cable.work); + ret =devm_work_autocancel (dev, &info->otg.work, + axp288_charger_otg_evt_worker); +if (ret) +return ret; +/* Register for OTG notification */ -INIT_WORK (&info->otg.work, axp288_charger_otg_evt_worker); info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt;if (info->otg.cable) { ret = devm_extcon_register_notifier(dev, info->otg.cable,
Greg Kroah-Hartman
maintainerPATCH 227/776 mmc: block: use single block write in retry
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bin Liu <[email protected]>
commit c7c6d4f5103864f73ee3a78bfd6da241f84197dd upstream.
Due to errata i2493[0], multi-block write would still fail in retries.
With i2493, the MMC interface has the potential of write failures when issuing multi-block writes operating in HS200 mode with excessive IO supply noise.
While the errata provides guidance in hardware design and layout to minimize the IO supply noise, in theory the write failure cannot be resolved in hardware. The software solution to ensure the data integrity is to add minimum 5us delay between block writes. Single-block write is the practical way to introduce the delay.
This patch reuses recovery_mode flag, and switches to single-block write in retry when multi-block write fails. It covers both CQE and non-CQE cases.
[0] https://www.ti.com/lit/pdf/sprz582
--- drivers/mmc/core/block.c | 12 ++++++++++-- drivers/mmc/core/queue.h | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/core/block.c +10 -2
@@ -1361,6 +1361,9 @@ static void mmc_blk_data_prep(struct mmcrq_data_dir (req) ==WRITE && (md->flags &MMC_BLK_REL_WR ); +if (mqrq->flags &MQRQ_XFER_SINGLE_BLOCK ) + recovery_mode =1 ; +memset (brq,0 ,sizeof (struct mmc_blk_request ));mmc_crypto_prepare_req (mqrq);
@@ -1500,10 +1503,13 @@ static void mmc_blk_cqe_complete_rq(stru err =0 ;if (err) { -if (mqrq->retries++ <MMC_CQE_RETRIES ) +if (mqrq->retries++ <MMC_CQE_RETRIES ) { +if (rq_data_dir (req) ==WRITE ) + mqrq->flags |=MQRQ_XFER_SINGLE_BLOCK ;blk_mq_requeue_request (req, true); -else + }else {blk_mq_end_request (req,BLK_STS_IOERR ); + } }else if (mrq->data) {if (blk_update_request (req,BLK_STS_OK , mrq->data->bytes_xfered))blk_mq_requeue_request (req, true);
@@ -2041,6 +2047,8 @@ static void mmc_blk_mq_complete_rq(struc }else if (!blk_rq_bytes (req)) {__blk_mq_end_request (req,BLK_STS_IOERR ); }else if (mqrq->retries++ <MMC_MAX_RETRIES ) { +if (rq_data_dir (req) ==WRITE ) + mqrq->flags |=MQRQ_XFER_SINGLE_BLOCK ;blk_mq_requeue_request (req, true); }else {if (mmc_card_removed (mq->card))
drivers/mmc/core/queue.h +3 -0
@@ -61,6 +61,8 @@ enum mmc_drv_op { MMC_DRV_OP_GET_EXT_CSD, }; +#define MQRQ_XFER_SINGLE_BLOCK BIT(0) +struct mmc_queue_req {struct mmc_blk_request brq;struct scatterlist *sg;
@@ -69,6 +71,7 @@ struct mmc_queue_req {void *drv_op_data;unsigned int ioc_count;int retries; +u32 flags; };struct mmc_queue {
Greg Kroah-Hartman
maintainerPATCH 228/776 tpm: tpm_tis: add error logging for data transfer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacqueline Wong <[email protected]>
commit 0471921e2d1043dcc6de5cffb49dd37709521abe upstream.
Add logging to more easily determine reason for transmit failure
--- drivers/char/tpm/tpm_tis_core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/char/tpm/tpm_tis_core.c +4 -0
@@ -410,6 +410,8 @@ static int tpm_tis_send_data(struct tpm_ status =tpm_tis_status (chip);if (!itpm && (status &TPM_STS_DATA_EXPECT ) ==0 ) { rc = -EIO ; +dev_err (&chip->dev,"TPM_STS_DATA_EXPECT should be set. sts = 0x%08x\n" , + status); goto out_err; } }
@@ -427,6 +429,8 @@ static int tpm_tis_send_data(struct tpm_ status =tpm_tis_status (chip);if (!itpm && (status &TPM_STS_DATA_EXPECT ) !=0 ) { rc = -EIO ; +dev_err (&chip->dev,"TPM_STS_DATA_EXPECT should be unset. sts = 0x%08x\n" , + status); goto out_err; }
Greg Kroah-Hartman
maintainerPATCH 229/776 rtc: ntxec: fix OF node reference imbalance
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 30c4d2f26bb3538c328035cea2e6265c8320539e upstream.
The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.
Fix this by using the intended helper for reusing OF nodes.
--- drivers/rtc/rtc-ntxec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ntxec.c +1 -1
@@ -110,7 +110,7 @@ static int ntxec_rtc_probe(struct platfostruct rtc_device *dev;struct ntxec_rtc *rtc; - pdev->dev.of_node = pdev->dev.parent->of_node; +device_set_of_node_from_dev (&pdev->dev, pdev->dev.parent); rtc =devm_kzalloc (&pdev->dev,sizeof (*rtc),GFP_KERNEL );if (!rtc)
Greg Kroah-Hartman
maintainerPATCH 230/776 userfaultfd: allow registration of ranges below mmap_min_addr
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis M. Karpov <[email protected]>
commit 161ce69c2c89781784b945d8e281ff2da9dede9c upstream.
The current implementation of validate_range() in fs/userfaultfd.c performs a hard check against mmap_min_addr. This is redundant because UFFDIO_REGISTER operates on memory ranges that must already be backed by a VMA.
Enforcing mmap_min_addr or capability checks again in userfaultfd is unnecessary and prevents applications like binary compilers from using UFFD for valid memory regions mapped by application.
Remove the redundant check for mmap_min_addr.
We started using UFFD instead of the classic mprotect approach in the binary translator to track application writes. During development, we encountered this bug. The translator cannot control where the translated application chooses to map its memory and if the app requires a low-address area, UFFD fails, whereas mprotect would work just fine. I believe this is a genuine logic bug rather than an improvement, and I would appreciate including the fix in stable.
--- fs/userfaultfd.c | 2 -- 1 file changed, 2 deletions(-)
fs/userfaultfd.c +0 -2
@@ -1242,8 +1242,6 @@ static __always_inline int validate_rangreturn -EINVAL ;if (!len)return -EINVAL ; -if (start < mmap_min_addr) -return -EINVAL ;if (start >= task_size)return -EINVAL ;if (len > task_size - start)
Greg Kroah-Hartman
maintainerPATCH 231/776 KVM: nSVM: Mark all of vmcb02 dirty when restoring nested state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
commit e63fb1379f4b9300a44739964e69549bebbcdca4 upstream.
When restoring a vCPU in guest mode, any state restored before KVM_SET_NESTED_STATE (e.g. KVM_SET_SREGS) will mark the corresponding dirty bits in vmcb01, as it is the active VMCB before switching to vmcb02 in svm_set_nested_state().
Hence, mark all fields in vmcb02 dirty in svm_set_nested_state() to capture any previously restored fields.
--- arch/x86/kvm/svm/nested.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/kvm/svm/nested.c +6 -0
@@ -1387,6 +1387,12 @@ static int svm_set_nested_state(struct knested_vmcb02_prepare_control (svm);/* +* Any previously restored state (e.g. KVM_SET_SREGS) would mark fields +* dirty in vmcb01 instead of vmcb02, so mark all of vmcb02 dirty here. +*/ +vmcb_mark_all_dirty (svm->vmcb); + +/* * While the nested guest CR3 is already checked and set by * KVM_SET_SREGS, it was set when nested state was yet loaded, * thus MMU might not be initialized correctly.
Greg Kroah-Hartman
maintainerPATCH 232/776 KVM: nSVM: Sync NextRIP to cached vmcb12 after VMRUN of L2
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
commit 778d8c1b2a6ffe622ddcd3bb35b620e6e41f4da0 upstream.
After VMRUN in guest mode, nested_sync_control_from_vmcb02() syncs fields written by the CPU from vmcb02 to the cached vmcb12. This is because the cached vmcb12 is used as the authoritative copy of some of the controls, and is the payload when saving/restoring nested state.
NextRIP is also written by the CPU (in some cases) after VMRUN, but is not sync'd to the cached vmcb12. As a result, it is corrupted after save/restore (replaced by the original value written by L1 on nested VMRUN). This could cause problems for both KVM (e.g. when injecting a soft IRQ) or L1 (e.g. when using NextRIP to advance RIP after emulating an instruction).
Fix this by sync'ing NextRIP to the cache after VMRUN of L2, but only after completing interrupts (not in nested_sync_control_from_vmcb02()), as KVM may update NextRIP (e.g. when re-injecting a soft IRQ).
--- arch/x86/kvm/svm/svm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/x86/kvm/svm/svm.c +10 -0
@@ -3952,6 +3952,16 @@ static __no_kcsan fastpath_t svm_vcpu_ruif (is_guest_mode (vcpu))return EXIT_FASTPATH_NONE ; +/* +* Update the cache after completing interrupts to get an accurate +* NextRIP, e.g. when re-injecting a soft interrupt. +* +* FIXME: Rework svm_get_nested_state() to not pull data from the +* cache (except for maybe int_ctl). +*/ +if (is_guest_mode (vcpu)) + svm->nested.ctl.next_rip = svm->vmcb->control.next_rip; +return svm_exit_handlers_fastpath (vcpu); }
Greg Kroah-Hartman
maintainerPATCH 233/776 KVM: nSVM: Sync interrupt shadow to cached vmcb12 after VMRUN of L2
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
commit 03bee264f8ebfd39e0254c98e112d033a7aa9055 upstream.
After VMRUN in guest mode, nested_sync_control_from_vmcb02() syncs fields written by the CPU from vmcb02 to the cached vmcb12. This is because the cached vmcb12 is used as the authoritative copy of some of the controls, and is the payload when saving/restoring nested state.
int_state is also written by the CPU, specifically bit 0 (i.e. SVM_INTERRUPT_SHADOW_MASK) for nested VMs, but it is not sync'd to cached vmcb12. This does not cause a problem if KVM_SET_NESTED_STATE preceeds KVM_SET_VCPU_EVENTS in the restore path, as an interrupt shadow would be correctly restored to vmcb02 (KVM_SET_VCPU_EVENTS overwrites what KVM_SET_NESTED_STATE restored in int_state).
However, if KVM_SET_VCPU_EVENTS preceeds KVM_SET_NESTED_STATE, an interrupt shadow would be restored into vmcb01 instead of vmcb02. This would mostly be benign for L1 (delays an interrupt), but not for L2. For L2, the vCPU could hang (e.g. if a wakeup interrupt is delivered before a HLT that should have been in an interrupt shadow).
Sync int_state to the cached vmcb12 in nested_sync_control_from_vmcb02() to avoid this problem. With that, KVM_SET_NESTED_STATE restores the correct interrupt shadow state, and if KVM_SET_VCPU_EVENTS follows it would overwrite it with the same value.
--- arch/x86/kvm/svm/nested.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/svm/nested.c +1 -0
@@ -336,6 +336,7 @@ void nested_sync_control_from_vmcb02(stru32 mask; svm->nested.ctl.event_inj = svm->vmcb->control.event_inj; svm->nested.ctl.event_inj_err = svm->vmcb->control.event_inj_err; + svm->nested.ctl.int_state = svm->vmcb->control.int_state;/* Only a few fields of int_ctl are written by the processor. */ mask =V_IRQ_MASK |V_TPR_MASK ;
Greg Kroah-Hartman
maintainerPATCH 234/776 KVM: SVM: Inject #UD for INVLPGA if EFER.SVME=0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kevin Cheng <[email protected]>
commit d99df02ff427f461102230f9c5b90a6c64ee8e23 upstream.
INVLPGA should cause a #UD when EFER.SVME is not set. Add a check to properly inject #UD when EFER.SVME=0.
--- arch/x86/kvm/svm/svm.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/svm/svm.c +3 -0
@@ -2363,6 +2363,9 @@ static int invlpga_interception(struct kgva_t gva =kvm_rax_read (vcpu);u32 asid =kvm_rcx_read (vcpu); +if (nested_svm_check_permissions (vcpu)) +return 1 ; +/* FIXME: Handle an address size prefix. */ if (!is_long_mode (vcpu)) gva = (u32 )gva;
Greg Kroah-Hartman
maintainerPATCH 235/776 KVM: SVM: Explicitly mark vmcb01 dirty after modifying VMCB intercepts
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit d5bde6113aed8315a2bfe708730b721be9c2f48b upstream.
When reacting to an intercept update, explicitly mark vmcb01's intercepts dirty, as KVM always initially operates on vmcb01, and nested_svm_vmexit() isn't guaranteed to mark VMCB_INTERCEPTS as dirty. I.e. if L2 is active, KVM will modify the intercepts for L1, but might not mark them as dirty before the next VMRUN of L1.
--- arch/x86/kvm/svm/nested.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/nested.c +3 -1
@@ -128,11 +128,13 @@ void recalc_intercepts(struct vcpu_svm *struct vmcb_control_area *c, *h, *g;unsigned int i; -vmcb_mark_dirty (svm->vmcb,VMCB_INTERCEPTS ); +vmcb_mark_dirty (svm->vmcb01.ptr,VMCB_INTERCEPTS );if (!is_guest_mode (&svm->vcpu))return ; +vmcb_mark_dirty (svm->vmcb,VMCB_INTERCEPTS ); + c = &svm->vmcb->control; h = &svm->vmcb01.ptr->control; g = &svm->nested.ctl;
Greg Kroah-Hartman
maintainerPATCH 236/776 KVM: nSVM: Ensure AVIC is inhibited when restoring a vCPU to guest mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
commit 24f7d36b824b65cf1a2db3db478059187b2a37b0 upstream.
On nested VMRUN, KVM ensures AVIC is inhibited by requesting KVM_REQ_APICV_UPDATE, triggering a check of inhibit reasons, finding APICV_INHIBIT_REASON_NESTED, and disabling AVIC.
However, when KVM_SET_NESTED_STATE is performed on a vCPU not in guest mode with AVIC enabled, KVM_REQ_APICV_UPDATE is not requested, and AVIC is not inhibited.
Request KVM_REQ_APICV_UPDATE in the KVM_SET_NESTED_STATE path if AVIC is active, similar to the nested VMRUN path.
--- arch/x86/kvm/svm/nested.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/svm/nested.c +3 -0
@@ -1407,6 +1407,9 @@ static int svm_set_nested_state(struct k goto out_free; +if (kvm_vcpu_apicv_active (vcpu)) +kvm_make_request (KVM_REQ_APICV_UPDATE , vcpu); +kvm_make_request (KVM_REQ_GET_NESTED_STATE_PAGES , vcpu); ret =0 ; out_free:
Greg Kroah-Hartman
maintainerPATCH 237/776 KVM: nSVM: Always inject a #GP if mapping VMCB12 fails on nested VMRUN
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
commit 01ddcdc55e097ca38c28ae656711b8e6d1df71f8 upstream.
nested_svm_vmrun() currently only injects a #GP if kvm_vcpu_map() fails with -EINVAL. But it could also fail with -EFAULT if creating a host mapping failed. Inject a #GP in all cases, no reason to treat failure modes differently.
--- arch/x86/kvm/svm/nested.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kvm/svm/nested.c +1 -4
@@ -651,12 +651,9 @@ int nested_svm_vmrun(struct kvm_vcpu *vc } vmcb12_gpa = svm->vmcb->save.rax; - ret =kvm_vcpu_map (vcpu,gpa_to_gfn (vmcb12_gpa), &map); -if (ret == -EINVAL ) { +if (kvm_vcpu_map (vcpu,gpa_to_gfn (vmcb12_gpa), &map)) {kvm_inject_gp (vcpu,0 );return 1 ; - }else if (ret) { -return kvm_skip_emulated_instruction (vcpu); } ret =kvm_skip_emulated_instruction (vcpu);
Greg Kroah-Hartman
maintainerPATCH 238/776 KVM: nSVM: Clear GIF on nested #VMEXIT(INVALID)
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
commit f85a6ce06e4a0d49652f57967a649ab09e06287c upstream.
According to the APM, GIF is set to 0 on any #VMEXIT, including an #VMEXIT(INVALID) due to failed consistency checks. Clear GIF on consistency check failures.
--- arch/x86/kvm/svm/nested.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/svm/nested.c +1 -0
@@ -671,6 +671,7 @@ int nested_svm_vmrun(struct kvm_vcpu *vc vmcb12->control.exit_code_hi =-1u ; vmcb12->control.exit_info_1 =0 ; vmcb12->control.exit_info_2 =0 ; +svm_set_gif (svm, false); goto out; }
Greg Kroah-Hartman
maintainerPATCH 239/776 KVM: nSVM: Add missing consistency check for nCR3 validity
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
commit b71138fcc362c67ebe66747bb22cb4e6b4d6a651 upstream.
Quoted 1 line
From the APM Volume #2, 15.25.4 (24593—Rev. 3.42—March 2024):
When VMRUN is executed with nested paging enabled (NP_ENABLE = 1), the following conditions are considered illegal state combinations, in addition to those mentioned in “Canonicalization and Consistency Checks”:
• Any MBZ bit of nCR3 is set.
• Any G_PAT.PA field has an unsupported type encoding or any reserved field in G_PAT has a nonzero value.
Add the consistency check for nCR3 being a legal GPA with no MBZ bits set. Note, the G_PAT.PA check is being handled separately[*].
--- arch/x86/kvm/svm/nested.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/svm/nested.c +4 -0
@@ -256,6 +256,10 @@ static bool nested_vmcb_check_controls(sif (CC ((control->nested_ctl &SVM_NESTED_CTL_NP_ENABLE ) && !npt_enabled))return false; +if (CC ((control->nested_ctl &SVM_NESTED_CTL_NP_ENABLE ) && + !kvm_vcpu_is_legal_gpa (vcpu, control->nested_cr3))) +return false; +if (CC (!nested_svm_check_bitmap_pa (vcpu, control->msrpm_base_pa,MSRPM_SIZE )))return false;
Greg Kroah-Hartman
maintainerPATCH 240/776 io_uring/poll: fix EPOLL_URING_WAKE sometimes not being honored
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
Rather than do the masking only when we jump straight to execution, mark it as EPOLLONESHOT regardless. This ensures it doesn't get lost. And just kill the poll entry upfront, if marked. This is an optimization in later kernels, but it's actually required on the older kernels to note the EPOLL_URING_WAKE mask correctly.
--- io_uring/io_uring.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
io_uring/io_uring.c +12 -7
@@ -5794,14 +5794,19 @@ static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,if (mask && !(mask & poll->events))return 0 ; +/* +* If we trigger a multishot poll off our own wakeup path, +* disable multishot as there is a circular dependency between +* CQ posting and triggering the event. +*/ +if (mask &EPOLL_URING_WAKE ) + poll->events |=EPOLLONESHOT ; +if (io_poll_get_ownership (req)) { -/* -* If we trigger a multishot poll off our own wakeup path, -* disable multishot as there is a circular dependency between -* CQ posting and triggering the event. -*/ -if (mask &EPOLL_URING_WAKE ) - poll->events |=EPOLLONESHOT ; +if (mask && poll->events &EPOLLONESHOT ) { +list_del_init (&poll->wait.entry); +smp_store_release (&poll->head,NULL ); + }__io_poll_execute (req, mask); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 241/776 io_uring/poll: fix backport of io_poll_add() changes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
The 5.15/5.10 backport of 84230ad2d2af had a few issues, due to the older poll base. Notably return value handling __io_arm_poll_handler() and in return __io_poll_add() as well. Fix them up.
--- io_uring/io_uring.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
io_uring/io_uring.c +6 -10
@@ -6144,26 +6144,22 @@ static int __io_poll_add(struct io_kiocb *req, unsigned int issue_flags)if (!ret && ipt.error)req_set_fail (req); ret = ret ?: ipt.error; -if (ret >0 ) { +if (ret)__io_req_complete (req, issue_flags, ret,0 ); -return ret; - } -return 0 ; +return ret; }static int io_poll_add (struct io_kiocb *req,unsigned int issue_flags) { -int ret; - - ret =__io_poll_add (req, issue_flags); -return ret <0 ? ret :0 ; +__io_poll_add (req, issue_flags); +return 0 ; }static int io_poll_update (struct io_kiocb *req,unsigned int issue_flags) {struct io_ring_ctx *ctx = req->ctx;struct io_kiocb *preq; -int ret2, ret =0 ; +int ret2 = -ECANCELED , ret =0 ;io_ring_submit_lock (ctx, !(issue_flags &IO_URING_F_NONBLOCK ));
@@ -6194,7 +6190,7 @@ static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags) preq->result = ret2; } -if (preq->result <0 ) +if (ret2 <0 )req_set_fail (preq);io_req_complete (preq, preq->result); out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 242/776 mtd: docg3: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit eb0cec77d534413a800ec20944a2b1e37cfecdcf ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: ca19808bc6fa ("mtd: docg3: fix use-after-free in docg3_release()")
--- drivers/mtd/devices/docg3.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mtd/devices/docg3.c +2 -3
@@ -2038,7 +2038,7 @@ static int __init docg3_probe(struct platform_device *pdev)* * Returns 0 */ -static int docg3_release (struct platform_device *pdev) +static void docg3_release (struct platform_device *pdev) {struct docg3_cascade *cascade =platform_get_drvdata (pdev);struct docg3 *docg3 = cascade->floors[0 ]->priv;
@@ -2050,7 +2050,6 @@ static int docg3_release(struct platform_device *pdev)doc_release_device (cascade->floors[floor]);bch_free (docg3->cascade->bch); -return 0 ; }#ifdef CONFIG_OF
@@ -2068,7 +2067,7 @@ static struct platform_driver g3_driver = { }, .suspend = docg3_suspend, .resume = docg3_resume, - .remove = docg3_release, + .remove_new = docg3_release, };module_platform_driver_probe (g3_driver, docg3_probe);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 243/776 mtd: docg3: fix use-after-free in docg3_release()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Kim <[email protected]>
[ Upstream commit ca19808bc6fac7e29420d8508df569b346b3e339 ]
In docg3_release(), the docg3 pointer is obtained from cascade->floors[0]->priv before the loop that calls doc_release_device() on each floor. doc_release_device() frees the docg3 struct via kfree(docg3) at line 1881. After the loop, docg3->cascade->bch dereferences the already-freed pointer.
Fix this by accessing cascade->bch directly, which is equivalent since docg3->cascade points back to the same cascade struct, and is already available as a local variable. This also removes the now-unused docg3 local variable.
--- drivers/mtd/devices/docg3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/devices/docg3.c +1 -2
@@ -2041,7 +2041,6 @@ static int __init docg3_probe(struct platform_device *pdev)static void docg3_release (struct platform_device *pdev) {struct docg3_cascade *cascade =platform_get_drvdata (pdev); -struct docg3 *docg3 = cascade->floors[0 ]->priv;int floor;doc_unregister_sysfs (pdev, cascade);
@@ -2049,7 +2048,7 @@ static void docg3_release(struct platform_device *pdev)if (cascade->floors[floor])doc_release_device (cascade->floors[floor]); -bch_free (docg3->cascade->bch); +bch_free (cascade->bch); }#ifdef CONFIG_OF
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 244/776 ext4: fix missing brelse() in ext4_xattr_inode_dec_ref_all()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sohei Koyama <[email protected]>
commit 77d059519382bd66283e6a4e83ee186e87e7708f upstream.
The commit c8e008b60492 ("ext4: ignore xattrs past end") introduced a refcount leak in when block_csum is false.
ext4_xattr_inode_dec_ref_all() calls ext4_get_inode_loc() to get iloc.bh, but never releases it with brelse().
--- fs/ext4/xattr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/xattr.c +3 -1
@@ -1112,7 +1112,7 @@ ext4_xattr_inode_dec_ref_all(handle_t *h {struct inode *ea_inode;struct ext4_xattr_entry *entry; -struct ext4_iloc iloc; +struct ext4_iloc iloc = { .bh =NULL };bool dirty = false;unsigned int ea_ino;int err;
@@ -1207,6 +1207,8 @@ ext4_xattr_inode_dec_ref_all(handle_t *hext4_warning_inode (parent,"handle dirty metadata err=%d" , err); } + +brelse (iloc.bh); }/*
Greg Kroah-Hartman
maintainerPATCH 245/776 md/raid5: fix soft lockup in retry_aligned_read()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chia-Ming Chang <[email protected]>
commit 7f9f7c697474268d9ef9479df3ddfe7cdcfbbffc upstream.
When retry_aligned_read() encounters an overlapped stripe, it releases the stripe via raid5_release_stripe() which puts it on the lockless released_stripes llist. In the next raid5d loop iteration, release_stripe_list() drains the stripe onto handle_list (since STRIPE_HANDLE is set by the original IO), but retry_aligned_read() runs before handle_active_stripes() and removes the stripe from handle_list via find_get_stripe() -> list_del_init(). This prevents handle_stripe() from ever processing the stripe to resolve the overlap, causing an infinite loop and soft lockup.
Fix this by using __release_stripe() with temp_inactive_list instead of raid5_release_stripe() in the failure path, so the stripe does not go through the released_stripes llist. This allows raid5d to break out of its loop, and the overlap will be resolved when the stripe is eventually processed by handle_stripe().
--- drivers/md/raid5.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/md/raid5.c +7 -1
@@ -6351,7 +6351,13 @@ static int retry_aligned_read(struct r5 }if (!add_stripe_bio (sh, raid_bio, dd_idx,0 ,0 )) { -raid5_release_stripe (sh); +int hash; + +spin_lock_irq (&conf->device_lock); + hash = sh->hash_lock_index; +__release_stripe (conf, sh, + &conf->temp_inactive_list[hash]); +spin_unlock_irq (&conf->device_lock); conf->retry_read_aligned = raid_bio; conf->retry_read_offset = scnt;return handled;
Greg Kroah-Hartman
maintainerPATCH 246/776 md/raid5: validate payload size before accessing journal metadata
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
commit b0cc3ae97e893bf54bbce447f4e9fd2e0b88bff9 upstream.
r5c_recovery_analyze_meta_block() and r5l_recovery_verify_data_checksum_for_mb() iterate over payloads in a journal metadata block using on-disk payload size fields without validating them against the remaining space in the metadata block.
A corrupted journal contains payload sizes extending beyond the PAGE_SIZE boundary can cause out-of-bounds reads when accessing payload fields or computing offsets.
Add bounds validation for each payload type to ensure the full payload fits within meta_size before processing.
--- drivers/md/raid5-cache.c | 48 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-)
drivers/md/raid5-cache.c +33 -15
@@ -2017,15 +2017,27 @@ r5l_recovery_verify_data_checksum_for_mbreturn -ENOMEM ;while (mb_offset <le32_to_cpu (mb->meta_size)) { +sector_t payload_len; + payload = (void *)mb + mb_offset; payload_flush = (void *)mb + mb_offset;if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_DATA ) { + payload_len =sizeof (struct r5l_payload_data_parity ) + + (sector_t )sizeof (__le32) * + (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 )); +if (mb_offset + payload_len >le32_to_cpu (mb->meta_size)) + goto mismatch;if (r5l_recovery_verify_data_checksum ( log, ctx, page, log_offset, payload->checksum[0 ]) <0 ) goto mismatch; }else if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_PARITY ) { + payload_len =sizeof (struct r5l_payload_data_parity ) + + (sector_t )sizeof (__le32) * + (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 )); +if (mb_offset + payload_len >le32_to_cpu (mb->meta_size)) + goto mismatch;if (r5l_recovery_verify_data_checksum ( log, ctx, page, log_offset, payload->checksum[0 ]) <0 )
@@ -2038,22 +2050,18 @@ r5l_recovery_verify_data_checksum_for_mb payload->checksum[1]) < 0) goto mismatch; }else if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_FLUSH ) { -/* nothing to do for R5LOG_PAYLOAD_FLUSH here */ + payload_len =sizeof (struct r5l_payload_flush ) + + (sector_t )le32_to_cpu (payload_flush->size); +if (mb_offset + payload_len >le32_to_cpu (mb->meta_size)) + goto mismatch; }else /* not R5LOG_PAYLOAD_DATA/PARITY/FLUSH */ goto mismatch; -if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_FLUSH ) { - mb_offset +=sizeof (struct r5l_payload_flush ) + -le32_to_cpu (payload_flush->size); - }else { -/* DATA or PARITY payload */ +if (le16_to_cpu (payload->header.type) !=R5LOG_PAYLOAD_FLUSH ) { log_offset =r5l_ring_add (log, log_offset,le32_to_cpu (payload->size)); - mb_offset +=sizeof (struct r5l_payload_data_parity ) + -sizeof (__le32) * - (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 )); } - + mb_offset += payload_len; }put_page (page);
@@ -2104,6 +2112,7 @@ r5c_recovery_analyze_meta_block(struct r log_offset =r5l_ring_add (log, ctx->pos,BLOCK_SECTORS );while (mb_offset <le32_to_cpu (mb->meta_size)) { +sector_t payload_len;int dd; payload = (void *)mb + mb_offset;
@@ -2112,6 +2121,12 @@ r5c_recovery_analyze_meta_block(struct rif (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_FLUSH ) {int i, count; + payload_len =sizeof (struct r5l_payload_flush ) + + (sector_t )le32_to_cpu (payload_flush->size); +if (mb_offset + payload_len > +le32_to_cpu (mb->meta_size)) +return -EINVAL ; + count =le32_to_cpu (payload_flush->size) /sizeof (__le64);for (i =0 ; i < count; ++i) { stripe_sect =le64_to_cpu (payload_flush->flush_stripes[i]);
@@ -2125,12 +2140,17 @@ r5c_recovery_analyze_meta_block(struct r } } - mb_offset +=sizeof (struct r5l_payload_flush ) + -le32_to_cpu (payload_flush->size); + mb_offset += payload_len;continue ; }/* DATA or PARITY payload */ + payload_len =sizeof (struct r5l_payload_data_parity ) + + (sector_t )sizeof (__le32) * + (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 )); +if (mb_offset + payload_len >le32_to_cpu (mb->meta_size)) +return -EINVAL ; + stripe_sect = (le16_to_cpu(payload->header.type) == R5LOG_PAYLOAD_DATA) ? raid5_compute_sector( conf, le64_to_cpu(payload->location), 0, &dd,
@@ -2195,9 +2215,7 @@ r5c_recovery_analyze_meta_block(struct r log_offset =r5l_ring_add (log, log_offset,le32_to_cpu (payload->size)); - mb_offset +=sizeof (struct r5l_payload_data_parity ) + -sizeof (__le32) * - (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 )); + mb_offset += payload_len; }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 247/776 inotify: fix watch count leak when fsnotify_add_inode_mark_locked() fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chia-Ming Chang <[email protected]>
commit 6a320935fa4293e9e599ec9f85dc9eb3be7029f8 upstream.
When fsnotify_add_inode_mark_locked() fails in inotify_new_watch(), the error path calls inotify_remove_from_idr() but does not call dec_inotify_watches() to undo the preceding inc_inotify_watches(). This leaks a watch count, and repeated failures can exhaust the max_user_watches limit with -ENOSPC even when no watches are active.
Prior to commit 1cce1eea0aff ("inotify: Convert to using per-namespace limits"), the watch count was incremented after fsnotify_add_mark_locked() succeeded, so this path was not affected. The conversion moved inc_inotify_watches() before the mark insertion without adding the corresponding rollback.
Add the missing dec_inotify_watches() call in the error path.
--- fs/notify/inotify/inotify_user.c | 1 + 1 file changed, 1 insertion(+)
fs/notify/inotify/inotify_user.c +1 -0
@@ -614,6 +614,7 @@ static int inotify_new_watch(struct fsnoif (ret) {/* we failed to get on the inode, get off the idr */ inotify_remove_from_idr (group, tmp_i_mark); +dec_inotify_watches (group->inotify_data.ucounts); goto out_err; }
Greg Kroah-Hartman
maintainerPATCH 248/776 tcp: call sk_data_ready() after listener migration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenzhong Wu <[email protected]>
commit 3864c6ba1e041bc75342353a70fa2a2c6f909923 upstream.
When inet_csk_listen_stop() migrates an established child socket from a closing listener to another socket in the same SO_REUSEPORT group, the target listener gets a new accept-queue entry via inet_csk_reqsk_queue_add(), but that path never notifies the target listener's waiters. A nonblocking accept() still works because it checks the queue directly, but poll()/epoll_wait() waiters and blocking accept() callers can also remain asleep indefinitely.
Call READ_ONCE(nsk->sk_data_ready)(nsk) after a successful migration in inet_csk_listen_stop().
However, after inet_csk_reqsk_queue_add() succeeds, the ref acquired in reuseport_migrate_sock() is effectively transferred to nreq->rsk_listener. Another CPU can then dequeue nreq via accept() or listener shutdown, hit reqsk_put(), and drop that listener ref. Since listeners are SOCK_RCU_FREE, wrap the post-queue_add() dereferences of nsk in rcu_read_lock()/rcu_read_unlock(), which also covers the existing sock_net(nsk) access in that path.
The reqsk_timer_handler() path does not need the same changes for two
reasons: half-open requests become readable only after the final ACK, where tcp_child_process() already wakes the listener; and once nreq is visible via inet_ehash_insert(), the success path no longer touches nsk directly.
--- net/ipv4/inet_connection_sock.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/inet_connection_sock.c +3 -0
@@ -1251,16 +1251,19 @@ void inet_csk_listen_stop(struct sock *sif (nreq) {refcount_set (&nreq->rsk_refcnt,1 ); +rcu_read_lock ();if (inet_csk_reqsk_queue_add (nsk, nreq, child)) {__NET_INC_STATS (sock_net (nsk),LINUX_MIB_TCPMIGRATEREQSUCCESS );reqsk_migrate_reset (req); +READ_ONCE (nsk->sk_data_ready)(nsk); }else {__NET_INC_STATS (sock_net (nsk),LINUX_MIB_TCPMIGRATEREQFAILURE );reqsk_migrate_reset (nreq);__reqsk_free (nreq); } +rcu_read_unlock ();/* inet_csk_reqsk_queue_add() has already * called inet_child_forget() on failure case.
Greg Kroah-Hartman
maintainerPATCH 249/776 taskstats: set version in TGID exit notifications
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yiyang Chen <[email protected]>
commit 16c4f0211aaa1ec1422b11b59f64f1abe9009fc0 upstream.
delay accounting started populating taskstats records with a valid version field via fill_pid() and fill_tgid().
Later, commit ad4ecbcba728 ("[PATCH] delay accounting taskstats interface send tgid once") changed the TGID exit path to send the cached signal->stats aggregate directly instead of building the outgoing record through fill_tgid(). Unlike fill_tgid(), fill_tgid_exit() only accumulates accounting data and never initializes stats->version.
As a result, TGID exit notifications can reach userspace with version == 0 even though PID exit notifications and TASKSTATS_CMD_GET replies carry a valid taskstats version.
This is easy to reproduce with tools/accounting/getdelays.c.
I have a small follow-up patch for that tool which:
1. increases the receive buffer/message size so the pid+tgid combined exit notification is not dropped/truncated
2. prints stats->version.
With that patch, the reproducer is:
Terminal 1:
./getdelays -d -v -l -m 0
Terminal 2:
taskset -c 0 python3 -c 'import threading,time; t=threading.Thread(target=time.sleep,args=(0.1,)); t.start(); t.join()'
That produces both PID and TGID exit notifications for the same process. The PID exit record reports a valid taskstats version, while the TGID exit record reports version 0.
This patch (of 2):
Set stats->version = TASKSTATS_VERSION after copying the cached TGID aggregate into the outgoing netlink payload so all taskstats records are self-describing again.
--- kernel/taskstats.c | 1 + 1 file changed, 1 insertion(+)
kernel/taskstats.c +1 -0
@@ -632,6 +632,7 @@ void taskstats_exit(struct task_struct * goto err;memcpy (stats, tsk->signal->stats,sizeof (*stats)); + stats->version =TASKSTATS_VERSION ; send:send_cpu_listeners (rep_skb, listeners);
Greg Kroah-Hartman
maintainerPATCH 250/776 crypto: arm64/aes - Fix 32-bit aes_mac_update() arg treated as 64-bit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit f8f08d7cc43237e91e3aedf7b67d015d24c38fcc upstream.
Since the 'enc_after' argument to neon_aes_mac_update() and ce_aes_mac_update() has type 'int', it needs to be accessed using the corresponding 32-bit register, not the 64-bit register. The upper half of the corresponding 64-bit register may contain garbage.
--- arch/arm64/crypto/aes-modes.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/crypto/aes-modes.S +2 -2
@@ -697,7 +697,7 @@ AES_FUNC_START(aes_mac_update) encrypt_block v0, w2, x1, x7, w8 eor v0.16b, v0.16b, v4.16b cmp w3, wzr - csinv x5, x6, xzr, eq + csinv w5, w6, wzr, eq cbz w5, .Lmacout encrypt_block v0, w2, x1, x7, w8 st1 {v0.16b}, [x4] /* return dg */
@@ -711,7 +711,7 @@ AES_FUNC_START(aes_mac_update) eor v0.16b, v0.16b, v1.16b /* ..and xor with dg */ subs w3, w3, #1 - csinv x5, x6, xzr, eq + csinv w5, w6, wzr, eq cbz w5, .Lmacout .Lmacenc:
Greg Kroah-Hartman
maintainerPATCH 251/776 crypto: atmel-aes - Fix 3-page memory leak in atmel_aes_buff_cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit 3fcfff4ed35f963380a68741bcd52742baff7f76 upstream.
atmel_aes_buff_init() allocates 4 pages using __get_free_pages() with ATMEL_AES_BUFFER_ORDER, but atmel_aes_buff_cleanup() frees only the first page using free_page(), leaking the remaining 3 pages. Use free_pages() with ATMEL_AES_BUFFER_ORDER to fix the memory leak.
--- drivers/crypto/atmel-aes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/atmel-aes.c +1 -1
@@ -2329,7 +2329,7 @@ static int atmel_aes_buff_init(struct atstatic void atmel_aes_buff_cleanup (struct atmel_aes_dev *dd) { -free_page ((unsigned long )dd->buf); +free_pages ((unsigned long )dd->buf,ATMEL_AES_BUFFER_ORDER ); }static int atmel_aes_dma_init (struct atmel_aes_dev *dd)
Greg Kroah-Hartman
maintainerPATCH 252/776 crypto: atmel-ecc - Release client on allocation failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit 095d50008d55d13f8fcf1bbeb7c6eba51779bc85 upstream.
Call atmel_ecc_i2c_client_free() to release the I2C client reserved by atmel_ecc_i2c_client_alloc() when crypto_alloc_kpp() fails. Otherwise ->tfm_count will be out of sync.
--- drivers/crypto/atmel-ecc.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/atmel-ecc.c +1 -0
@@ -261,6 +261,7 @@ static int atmel_ecdh_init_tfm(struct crif (IS_ERR (fallback)) {dev_err (&ctx->client->dev,"Failed to allocate transformation for '%s': %ld\n" , alg,PTR_ERR (fallback)); +atmel_ecc_i2c_client_free (ctx->client);return PTR_ERR (fallback); }
Greg Kroah-Hartman
maintainerPATCH 253/776 crypto: hisilicon - Fix dma_unmap_single() direction
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
commit 1ee57ab93b75eb59f426aef37b5498a7ffc28278 upstream.
The direction used to map the buffer skreq->iv is DMA_TO_DEVICE but it is unmapped with direction DMA_BIDIRECTIONAL in the error path.
Change the unmap to match the mapping.
--- drivers/crypto/hisilicon/sec/sec_algs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/hisilicon/sec/sec_algs.c +1 -1
@@ -844,7 +844,7 @@ err_free_elements:if (crypto_skcipher_ivsize (atfm))dma_unmap_single (info->dev, sec_req->dma_iv,crypto_skcipher_ivsize (atfm), -DMA_BIDIRECTIONAL ); +DMA_TO_DEVICE ); err_unmap_out_sg:if (split) sec_unmap_sg_on_err(skreq->dst, steps, splits_out,
Greg Kroah-Hartman
maintainerPATCH 254/776 crypto: ccree - fix a memory leak in cc_mac_digest()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 02c64052fad03699b9c6d1df2f9b444d17e4ac50 upstream.
Add cc_unmap_result() if cc_map_hash_request_final() fails to prevent potential memory leak.
--- drivers/crypto/ccree/cc_hash.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/ccree/cc_hash.c +1 -0
@@ -1448,6 +1448,7 @@ static int cc_mac_digest(struct ahash_reif (cc_map_hash_request_final (ctx->drvdata, state, req->src, req->nbytes,1 , flags)) {dev_err (dev,"map_ahash_request_final() failed\n" ); +cc_unmap_result (dev, state, digestsize, req->result);cc_unmap_req (dev, state, ctx);return -ENOMEM ; }
Greg Kroah-Hartman
maintainerPATCH 255/776 crypto: atmel-tdes - fix DMA sync direction
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit c8a9a647532f5c2a04180352693215e24e9dba03 upstream.
Before DMA output is consumed by the CPU, ->dma_addr_out must be synced with dma_sync_single_for_cpu() instead of dma_sync_single_for_device(). Using the wrong direction can return stale cache data on non-coherent platforms.
--- drivers/crypto/atmel-tdes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/atmel-tdes.c +4 -4
@@ -304,8 +304,8 @@ static int atmel_tdes_crypt_pdc_stop(strdma_unmap_sg (dd->dev, dd->out_sg,1 ,DMA_FROM_DEVICE );dma_unmap_sg (dd->dev, dd->in_sg,1 ,DMA_TO_DEVICE ); }else { -dma_sync_single_for_device (dd->dev, dd->dma_addr_out, - dd->dma_size,DMA_FROM_DEVICE ); +dma_sync_single_for_cpu (dd->dev, dd->dma_addr_out, + dd->dma_size,DMA_FROM_DEVICE );/* copy data */ count = atmel_tdes_sg_copy(&dd->out_sg, &dd->out_offset,
@@ -660,8 +660,8 @@ static int atmel_tdes_crypt_dma_stop(strdma_unmap_sg (dd->dev, dd->out_sg,1 ,DMA_FROM_DEVICE );dma_unmap_sg (dd->dev, dd->in_sg,1 ,DMA_TO_DEVICE ); }else { -dma_sync_single_for_device (dd->dev, dd->dma_addr_out, - dd->dma_size,DMA_FROM_DEVICE ); +dma_sync_single_for_cpu (dd->dev, dd->dma_addr_out, + dd->dma_size,DMA_FROM_DEVICE );/* copy data */ count = atmel_tdes_sg_copy(&dd->out_sg, &dd->out_offset,
Greg Kroah-Hartman
maintainerPATCH 256/776 dm mirror: fix integer overflow in create_dirty_log()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
commit 4c788c6f921b22f9b6c3f316c4a071c05683e7de upstream.
The argument count calculation in create_dirty_log() performs *args_used = 2 + param_count before validating against argc. When a user provides a param_count close to UINT_MAX via the device mapper table string, this unsigned addition wraps around to a small value, causing the subsequent argc < *args_used check to be bypassed.
The overflowed param_count is then passed as argc to dm_dirty_log_create(), where it can cause out-of-bounds reads on the argv array.
Fix by comparing param_count against argc - 2 before performing the addition, following the same pattern used by parse_features() in the same file. Since argc >= 2 is already guaranteed, the subtraction is safe.
--- drivers/md/dm-raid1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/md/dm-raid1.c +3 -3
@@ -981,13 +981,13 @@ static struct dm_dirty_log *create_dirtyreturn NULL ; } - *args_used =2 + param_count; - -if (argc < *args_used) { +if (param_count > argc -2 ) { ti->error ="Insufficient mirror log arguments" ;return NULL ; } + *args_used =2 + param_count; + dl =dm_dirty_log_create (argv[0 ], ti, mirror_flush, param_count, argv +2 );if (!dl) {
Greg Kroah-Hartman
maintainerPATCH 257/776 IB/core: Fix zero dmac race in neighbor resolution
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Zhao <[email protected]>
commit 5e6de34d82b49cab9d8a42063e9cd0f22a4f31e5 upstream.
dst_fetch_ha() checks nud_state without holding the neighbor lock, then copies ha under the seqlock. A race in __neigh_update() where nud_state is set to NUD_REACHABLE before ha is written allows dst_fetch_ha() to read a zero MAC address while the seqlock reports no concurrent writer.
netevent_callback amplifies this by waking ALL pending addr_req workers when ANY neighbor becomes NUD_VALID. At scale (N peers resolving ARP concurrently), the hit probability scales as N^2, making it near-certain for large RDMA workloads.
N(A): neigh_update(A) W(A): addr_resolve(A)
| [sleep] | write_lock_bh(&A->lock) | | A->nud_state = NUD_REACHABLE | | // A->ha is still 0 | | [woken by netevent_cb() of | another neighbour] | | dst_fetch_ha(A) | | A->nud_state & NUD_VALID | | read_seqbegin(&A->ha_lock) | | snapshot = A->ha /* 0 */ | | read_seqretry(&A->ha_lock) | | return snapshot | seqlock(&A->ha_lock) | A->ha = mac_A /* too late */ | sequnlock(&A->ha_lock) | write_unlock_bh(&A->lock)
The incorrect/zero mac is read and programmed in the device QP while it was not yet updated. This causes silent packet loss and eventual RETRY_EXC_ERR.
Fix by holding the neighbor read lock across the nud_state check and ha copy in dst_fetch_ha(), ensuring it synchronizes with __neigh_update() which is updating while holding the write lock.
--- drivers/infiniband/core/addr.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/core/addr.c +3 -0
@@ -322,11 +322,14 @@ static int dst_fetch_ha(const struct dstif (!n)return -ENODATA ; +read_lock_bh (&n->lock);if (!(n->nud_state &NUD_VALID )) { +read_unlock_bh (&n->lock);neigh_event_send (n,NULL ); ret = -ENODATA ; }else {neigh_ha_snapshot (dev_addr->dst_dev_addr, n, dst->dev); +read_unlock_bh (&n->lock); }neigh_release (n);
Greg Kroah-Hartman
maintainerPATCH 258/776 ktest: Fix the month in the name of the failure directory
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit 768059ede35f197575a38b10797b52402d9d4d2f upstream.
The Perl localtime() function returns the month starting at 0 not 1. This caused the date produced to create the directory for saving files of a failed run to have the month off by one.
machine-test-useconfig-fail-20260314073628
The above happened in April, not March. The correct name should have been:
machine-test-useconfig-fail-20260414073628
This was somewhat confusing.
--- tools/testing/ktest/ktest.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/ktest/ktest.pl +1 -1
@@ -1770,7 +1770,7 @@ sub save_logs { my ($result, $basedir) = @_; my @t = localtime; my $date = sprintf "%04d%02d%02d%02d%02d%02d", - 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0]; + 1900+$t[5],$t[4]+1,$t[3],$t[2],$t[1],$t[0]; my $type = $build_type; if ($type =~ /useconfig/) {