5.10.271-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 279/595 net/rds: Pass a pointer to virt_to_page()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit a60511cf15204e41f4edbcdc4ee80208d528917c ]
Functions that work on a pointer to virtual memory such as virt_to_pfn() and users of that function such as virt_to_page() are supposed to pass a pointer to virtual memory, ideally a (void *) or other pointer. However since many architectures implement virt_to_pfn() as a macro, this function becomes polymorphic and accepts both a (unsigned long) and a (void *).
If we instead implement a proper virt_to_pfn(void *addr) function the following happens (occurred on arch/arm):
net/rds/message.c:357:56: warning: passing argument 1
of 'virt_to_pfn' makes pointer from integer without a cast [-Wint-conversion]
Fix this with an explicit cast.
Stable-dep-of: 2ac09b5353fe ("net/rds: fix tcp stream corruption with large pages")
--- net/rds/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rds/message.c +1 -1
@@ -364,7 +364,7 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned infor (i =0 ; i < rm->data.op_nents; ++i) {sg_set_page (&rm->data.op_sg[i], -virt_to_page (page_addrs[i]), +virt_to_page ((void *)page_addrs[i]),PAGE_SIZE ,0 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 280/595 net/rds: fix tcp stream corruption with large pages
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Marsden <[email protected]>
[ Upstream commit 2ac09b5353fe6858411fdc8c6efa60d832e20f13 ]
rds_message_map_pages() assigns PAGE_SIZE bytes to every scatterlist entry, even when total_len ends in a partial page. The RDS congestion map is defined as 8192 bytes, so on systems with PAGE_SIZE greater than 8192 the scatterlist maps bytes beyond the end of the congestion map. RDS-TCP transmits the SG contents according to those lengths, so the extra bytes become part of the TCP RDS stream and are interpreted as subsequent RDS message headers, corrupting the stream.
Limit the final scatterlist mapping to the number of bytes remaining. This has no effect on systems with a 4K page size and allows RDS-TCP to be used on systems with 16K and larger page sizes.
The RDS selftest, which previously hung on 16K pages, now passes.
--- net/rds/message.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/rds/message.c +3 -1
@@ -365,7 +365,9 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned infor (i =0 ; i < rm->data.op_nents; ++i) {sg_set_page (&rm->data.op_sg[i],virt_to_page ((void *)page_addrs[i]), -PAGE_SIZE ,0 ); + i == rm->data.op_nents -1 + ? total_len - (i *PAGE_SIZE ) + :PAGE_SIZE ,0 ); }return rm;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 281/595 sunvdc: unmap LDC cookies when the descriptor send fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stian Halseth <[email protected]>
[ Upstream commit 0c6da21fa35e03fc74f09895433ccd6d4a9c3530 ]
__send_request() maps the request's pages into the LDC channel's map table (ldc_map_sg()), fills in the descriptor and marks it VIO_DESC_READY before ringing the doorbell via __vdc_tx_trigger(). When the trigger fails, the error path only prints a message: the descriptor stays READY and the cookies are never unmapped. The mapping is normally released in vdc_end_one() when the peer completes the descriptor - but a descriptor whose doorbell was never sent will never complete, and since dr->prod is not advanced on failure, the reset path (vdc_requeue_inflight(), which walks [cons, prod)) never visits it either. The map table entries are leaked permanently.
Since commit a11f6ca9aef9 ("sunvdc: Do not spin in an infinite loop when vio_ldc_send() returns EAGAIN") trigger failures occur in practice under load, so every resulting I/O error also leaks one request's worth of entries from the fixed-size (8192 entries per channel) map table. Because the allocator hands out contiguous ranges, fragmentation makes large multi-segment requests fail first as the table drains, until ldc_map_sg() fails permanently and the disk is dead until reboot.
It also makes any retry-based recovery unusable: requeuing the request on -EAGAIN remaps the pages on every attempt, overwriting desc->cookies and orphaning the previous mapping, so the table drains at the retry rate. This is the memory exhaustion observed when the requeue approach was first tested in October 2025.
Roll back on failure: unmap the cookies, mark the descriptor FREE again and clear the request entry. If the trigger failed with -ENOTCONN, __vdc_tx_trigger() has already reset the port, which tears down and reallocates both the dring and the LDC channel including its map table - nothing to roll back, and the stale descriptor must not be touched.
--- drivers/block/sunvdc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/block/sunvdc.c +17 -0
@@ -524,6 +524,23 @@ static int __send_request(struct request *req) err =__vdc_tx_trigger (port);if (err <0 ) { printk(KERN_ERR PFX "vdc_tx_trigger() failure, err=%d\n", err); +/* +* If the port was reset (-ENOTCONN), the dring and the +* LDC channel including all of its mappings are already +* torn down and reallocated - there is nothing to undo +* and @desc must not be touched. +* +* For any other failure the descriptor was never handed +* to the peer: unmap the cookies and free the descriptor +* again, so that a later retry of the request does not +* leak LDC map table entries. +*/ +if (err != -ENOTCONN ) { +ldc_unmap (port->vio.lp, desc->cookies, + desc->ncookies); + desc->hdr.state =VIO_DESC_FREE ; + rqe->req =NULL ; + } }else { port->req_id++; dr->prod =vio_dring_next (dr, dr->prod);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 282/595 drm/amd/display: set new_stream to NULL after release
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: WenTao Liang <[email protected]>
commit 9fa26b9eed6195bf840f39ac183b9a6237548755 upstream.
In dm_update_crtc_state(), the skip_modeset path releases new_stream via dc_stream_release() but does not set the pointer to NULL.
If a later error (e.g., color management failure) triggers the fail label, the error path calls dc_stream_release() again on the same dangling pointer, causing a double release and potential use-after-free.
Fix this by setting new_stream to NULL after the initial release.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
@@ -8448,6 +8448,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,/* Release extra reference */ if (new_stream)dc_stream_release (new_stream); + new_stream =NULL ;/* * We want to do dc stream updates that do not require a
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 283/595 Revert "bluetooth/l2cap: sync sock recv cb and release"
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 2243127db6ba20cbef90c6349a2b1000af401d2e.
--- net/bluetooth/l2cap_sock.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-)
net/bluetooth/l2cap_sock.c +3 -22
@@ -1258,10 +1258,6 @@ static void l2cap_sock_kill(struct sock *sk)BT_DBG ("sk %p state %s" , sk,state_to_string (sk->sk_state)); -/* Sock is dead, so set chan data to NULL, avoid other task use invalid -* sock pointer. -*/ -l2cap_pi (sk)->chan->data =NULL ;/* Kill poor orphan */ l2cap_chan_put (l2cap_pi (sk)->chan);
@@ -1544,25 +1540,12 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)static int l2cap_sock_recv_cb (struct l2cap_chan *chan,struct sk_buff *skb) { -struct sock *sk; -struct l2cap_pinfo *pi; +struct sock *sk = chan->data; +struct l2cap_pinfo *pi =l2cap_pi (sk);int err; -/* To avoid race with sock_release, a chan lock needs to be added here -* to synchronize the sock. -*/ -l2cap_chan_hold (chan); -l2cap_chan_lock (chan); - sk = chan->data; - -if (!sk) { -l2cap_chan_unlock (chan); -l2cap_chan_put (chan); -return -ENXIO ; - } - - pi =l2cap_pi (sk);lock_sock (sk); +if (chan->mode ==L2CAP_MODE_ERTM && !list_empty (&pi->rx_busy)) { err = -ENOMEM ; goto done;
@@ -1611,8 +1594,6 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) done:release_sock (sk); -l2cap_chan_unlock (chan); -l2cap_chan_put (chan);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 284/595 scsi: target: iscsi: Handle abort for WRITE_PENDING cmds
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Bogdanov <[email protected]>
[ Upstream commit ea87981a0ee8fb8ced1c87d004a541b60623ff97 ]
Sometimes an initiator does not send data for a WRITE command and tries to abort it. The abort hangs waiting for frontend driver completion. iSCSI driver waits for data and that timeout eventually initiates connection reinstatment. The connection closing releases the commands in the connection, but those aborted commands still did not handle the abort and did not decrease a command ref counter. Because of that the connection reinstatement hangs indefinitely and prevents re-login for that initiator.
Add handling in TCM of the abort for the WRITE_PENDING commands at connection closing moment to make it possible to release them.
--- drivers/target/iscsi/iscsi_target.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/target/iscsi/iscsi_target.c +11 -0
@@ -26,6 +26,7 @@#include <target/target_core_base.h> #include <target/target_core_fabric.h> +#include <target/target_core_backend.h> #include <target/iscsi/iscsi_target_core.h> #include "iscsi_target_parameters.h" #include "iscsi_target_seq_pdu_list.h"
@@ -4102,6 +4103,16 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) }else { se_cmd->transport_state |=CMD_T_FABRIC_STOP ; } + +if (cmd->se_cmd.t_state ==TRANSPORT_WRITE_PENDING ) { +/* +* We never submitted the cmd to LIO core, so we have +* to tell LIO to perform the completion process. +*/ +spin_unlock_irq (&se_cmd->t_state_lock); +target_complete_cmd (&cmd->se_cmd,SAM_STAT_TASK_ABORTED ); +continue ; + }spin_unlock_irq (&se_cmd->t_state_lock); }spin_unlock_bh (&conn->cmd_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 285/595 scsi: target: iscsi: Fix hang for aborted WRITE_PENDING commands
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
[ Upstream commit d5869dae5080e976d4b03cc33eb7ceb527f242bf ]
When a LUN_RESET aborts a WRITE command that is in the TRANSPORT_WRITE_PENDING state, the target core sets CMD_T_ABORTED and waits for the frontend to finish processing.
If the initiator subsequently sends the remaining dataout PDUs, __iscsit_check_dataout_hdr() catches the payload, stops the dataout timer if the sequence is final and finally dumps the data. However, the iSCSI target doesn't trigger the completion process for these aborted commands. Because of this, the abort path hangs indefinitely in target_put_cmd_and_wait(), leading to a deadlocked target worker thread.
Fix this by explicitly calling target_complete_cmd() when the final dataout PDU is received for an aborted WRITE command. target_complete_cmd() detects the CMD_T_ABORTED flag and cleanly routes the command into target_abort_work, allowing the abort completion to successfully unblock.
--- drivers/target/iscsi/iscsi_target.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +3 -1
@@ -1528,8 +1528,10 @@ __iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf,*/ if (se_cmd->transport_state &CMD_T_ABORTED ) {if (hdr->flags &ISCSI_FLAG_CMD_FINAL && - --cmd->outstanding_r2ts <1 ) + --cmd->outstanding_r2ts <1 ) {iscsit_stop_dataout_timer (cmd); +target_complete_cmd (se_cmd,SAM_STAT_TASK_ABORTED ); + }return iscsit_dump_data_payload (conn, payload_length,1 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 286/595 macvlan: inherit needed_headroom and needed_tailroom from lowerdev
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit cef51860becd9700217c81732ca1eb1ea6ed6fe1 ]
macvlan devices inherit hard_header_len from lowerdev during macvlan_init(), but leave needed_headroom and needed_tailroom set to 0.
When the underlying lowerdev requires extra headroom or tailroom for headers/trailers (e.g. macsec, ipsec, wireguard, tunnels, or veth with rx headroom), upper layers calculating packet headroom and tailroom fail to reserve sufficient space.
This can result in reallocation overhead, skb headroom underflows, or KASAN slab-use-after-free crashes when dev_hard_header() / macvlan_hard_header() prepends header data or when lower devices append tailroom.
Fix this by:
1. Inheriting needed_headroom and needed_tailroom from lowerdev in macvlan_init().
2. Propagating needed_headroom and needed_tailroom updates to attached macvlans in macvlan_device_event() when receiving NETDEV_FEAT_CHANGE events.
--- drivers/net/macvlan.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/macvlan.c +4 -0
@@ -910,6 +910,8 @@ static int macvlan_init(struct net_device *dev) dev->gso_max_size = lowerdev->gso_max_size; dev->gso_max_segs = lowerdev->gso_max_segs; dev->hard_header_len = lowerdev->hard_header_len; + dev->needed_headroom = lowerdev->needed_headroom; + dev->needed_tailroom = lowerdev->needed_tailroom;macvlan_set_lockdep_class (dev); vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
@@ -1731,6 +1733,8 @@ static int macvlan_device_event(struct notifier_block *unused,list_for_each_entry (vlan, &port->vlans, list) { vlan->dev->gso_max_size = dev->gso_max_size; vlan->dev->gso_max_segs = dev->gso_max_segs; + vlan->dev->needed_headroom = dev->needed_headroom; + vlan->dev->needed_tailroom = dev->needed_tailroom;netdev_update_features (vlan->dev); }break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 287/595 powerpc/eeh: Fix recursive locking on devices without EEH sensitive driver
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivaprasad G Bhat <[email protected]>
commit c5e68706527968282e49de205cc2b935823cb88a upstream.
The commit 1010b4c012b0 ("powerpc/eeh: Make EEH driver device hotplug safe") refactored the EEH code such that the pci_rescan_remove_lock is held at the beginning of eeh_handle_normal_event() and the eeh_reset_device() is called with that lock being held. Looks like the commit missed to remove the existing lock/unlock inside eeh_rmv_device() which is no longer necessary. This is causing the eehd to hang on the lock which it actually holds when that code path is taken.
[<0>] 0xc00000011c78f870
[<0>] __switch_to+0xfc/0x1a0 [<0>] pci_lock_rescan_remove+0x30/0x44 [<0>] eeh_rmv_device+0x290/0x2e0 [<0>] eeh_pe_dev_traverse+0x80/0x130 [<0>] eeh_reset_device+0xcc/0x23c [<0>] eeh_handle_normal_event+0x830/0xa80 [<0>] eeh_event_handler+0xf8/0x190 [<0>] kthread+0x194/0x1b0 [<0>] start_kernel_thread+0x14/0x18
The issue is seen for cases where the errors are detected on the PHB directly AND|OR for devices where the driver error_detected() returns PCI_ERS_RESULT_NEED_RESET, and driver being not EEH sensitive(i.e no error handlers like slot_reset(), resume() etc defined).
--- arch/powerpc/kernel/eeh_driver.c | 2 -- 1 file changed, 2 deletions(-)
arch/powerpc/kernel/eeh_driver.c +0 -2
@@ -534,9 +534,7 @@ static void eeh_rmv_device(struct eeh_deif (rmv_data)list_add (&edev->rmv_entry, &rmv_data->removed_vf_list); }else { -pci_lock_rescan_remove ();pci_stop_and_remove_bus_device (dev); -pci_unlock_rescan_remove (); } }
Greg Kroah-Hartman
maintainerPATCH 288/595 ipv6: fix fib6 walker UAF on seq stop
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
commit 19b4ed644d68098cc62ab612727f40d30f43476c upstream.
ipv6_route_iter_active() treats a walker in FWS_U at the table root as already unlinked. fib6_del_route() can move a still-linked walker into that same state when the current leaf is the last route at the root, so ipv6_route_native_seq_stop() skips fib6_walker_unlink(). The seq private object can then be freed while it remains on net->ipv6.fib6_walkers. A later route deletion walks the dangling list and uses the freed walker.
Use the list head as membership state and reinitialize it when unlinking. Keep the existing w->node check so a never-started iterator with a zeroed private object is not treated as linked.
The same stop helper is used by /proc/net/ipv6_route and by the BPF ipv6_route iterator. The BPF show path only widens the race.
--- net/ipv6/ip6_fib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ip6_fib.c +2 -2
@@ -83,7 +83,7 @@ static void fib6_walker_link(struct netstatic void fib6_walker_unlink (struct net *net,struct fib6_walker *w) {write_lock_bh (&net->ipv6.fib6_walker_lock); -list_del (&w->lh); +list_del_init (&w->lh);write_unlock_bh (&net->ipv6.fib6_walker_lock); }
@@ -2637,7 +2637,7 @@ static void *ipv6_route_seq_start(structstatic bool ipv6_route_iter_active (struct ipv6_route_iter *iter) {struct fib6_walker *w = &iter->w; -return w->node && !(w->state ==FWS_U && w->node == w->root); +return w->node && !list_empty (&w->lh); }static void ipv6_route_native_seq_stop (struct seq_file *seq,void *v)
Greg Kroah-Hartman
maintainerPATCH 289/595 ALSA: ctxfi: Fix CA20K2 S/PDIF passthrough
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Prucha <[email protected]>
commit b26a7a80e6bbf8dd17dacb127d12435d79375cf2 upstream.
dao_rsc_init() encodes the DAIO configuration as
conf = (desc->msr & 0x7) | (desc->passthru << 3);
S/PDIF passthrough uses msr=1 and passthru=1, resulting in conf=9.
daio_mgr_dao_init() masks conf with 0xf, but handles only values 1, 2, 4 and 8 when programming ATXCTL_NUC. As a result, conf=9 falls through to the default case and leaves NUC at its previous setting.
On a Creative X-Fi Titanium HD SB1270 (CA20K2), this breaks AC3 IEC61937 passthrough when snd_ctxfi runs with reference_rate=48000,multiple=2. The receiver detects a non-audio stream but cannot decode the AC3 payload.
With the unmodified driver, multiple=1 makes the same stream work. Handle conf=9 through the same NUC=0 path as conf=1.
The change was runtime tested on the SB1270 with multiple=2 using IEC958 stereo PCM, pre-encoded AC3 IEC61937 passthrough and ALSA A52 live 5.1 encoding.
--- sound/pci/ctxfi/cthw20k2.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/ctxfi/cthw20k2.c +1 -0
@@ -993,6 +993,7 @@ static int daio_mgr_dao_init(void *blk,/* S/PDIF output */ switch ((conf &0xf )) {case 1 : +case 9 :set_field (&ctl->txctl[idx],ATXCTL_NUC ,0 );break ;case 2 :
Greg Kroah-Hartman
maintainerPATCH 290/595 dm/amdgpu: fix malformed link_settings debugfs output
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
commit 622b4e8505aa7453a53d17fa3a288871f270fc8b upstream.
[Why]dp_link_settings_read() passed strlen() of each format string as the size argument to snprintf() and then advanced rd_buf_ptr by that same fixed amount. The format-string length has no relation to the formatted output length, so snprintf() truncated each field at a NUL it wrote inside the buffer while the pointer was advanced past it. The result is a buffer peppered with embedded NUL bytes and fields that are silently cut short, so the data read back from the debugfs node does not reflect the actual link settings.
[How]
Use scnprintf() with the real remaining buffer size (rd_buf_size - (rd_buf_ptr - rd_buf)) and advance rd_buf_ptr by its return value, which is the number of characters actually written. This both bounds each write to the space left in rd_buf and keeps the output a single, properly terminated string. The now-unused str_len local is removed.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 20 +++++--------- 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +8 -12
@@ -185,7 +185,6 @@ static ssize_t dp_link_settings_read(strchar *rd_buf_ptr =NULL ;const uint32_t rd_buf_size =100 ;uint32_t result =0 ; -uint8_t str_len =0 ;int r;if (*pos &3 || size &3 )
@@ -197,29 +196,26 @@ static ssize_t dp_link_settings_read(str rd_buf_ptr = rd_buf; - str_len =strlen ("Current: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Current: %d 0x%x %d " , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Current: %d 0x%x %d " , link->cur_link_settings.lane_count, link->cur_link_settings.link_rate, link->cur_link_settings.link_spread); - rd_buf_ptr += str_len; - str_len =strlen ("Verified: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Verified: %d 0x%x %d " , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Verified: %d 0x%x %d " , link->verified_link_cap.lane_count, link->verified_link_cap.link_rate, link->verified_link_cap.link_spread); - rd_buf_ptr += str_len; - str_len =strlen ("Reported: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Reported: %d 0x%x %d " , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Reported: %d 0x%x %d " , link->reported_link_cap.lane_count, link->reported_link_cap.link_rate, link->reported_link_cap.link_spread); - rd_buf_ptr += str_len; - str_len =strlen ("Preferred: %d 0x%x %d " ); -snprintf (rd_buf_ptr, str_len,"Preferred: %d 0x%x %d\n" , + rd_buf_ptr +=scnprintf (rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf), +"Preferred: %d 0x%x %d\n" , link->preferred_link_setting.lane_count, link->preferred_link_setting.link_rate, link->preferred_link_setting.link_spread);
Greg Kroah-Hartman
maintainerPATCH 291/595 watchdog: sunxi_wdt: preserve boot-enabled watchdog
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
commit aab55360fa11a2c054798a484ac67ad606f563e4 upstream.
sunxi_wdt_probe() unconditionally stops the watchdog even when firmware left it running. This opens an unprotected interval during boot and prevents CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED from taking over the active watchdog.
Detect an enabled watchdog and decode its programmed interval. Preserve representable timeouts, and round the 0.5-second interval up to the minimum representable one-second timeout. Use the configured timeout for reserved interval encodings. Set the Linux reset mode and ping the watchdog without clearing its enable bit, then mark it hardware-running before registration so the watchdog core services it until userspace takes control. Leave disabled watchdogs untouched.
--- drivers/watchdog/sunxi_wdt.c | 45 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
drivers/watchdog/sunxi_wdt.c +44 -1
@@ -125,6 +125,38 @@ static int sunxi_wdt_ping(struct watchdoreturn 0 ; } +static bool sunxi_wdt_is_running (struct watchdog_device *wdt_dev) +{ +struct sunxi_wdt_dev *sunxi_wdt =watchdog_get_drvdata (wdt_dev); +const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; + +return readl (sunxi_wdt->wdt_base + regs->wdt_mode) &WDT_MODE_EN ; +} + +static unsigned int sunxi_wdt_get_timeout (struct watchdog_device *wdt_dev) +{ +struct sunxi_wdt_dev *sunxi_wdt =watchdog_get_drvdata (wdt_dev); +const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs; +unsigned int timeout; +u32 interval; + + interval =readl (sunxi_wdt->wdt_base + regs->wdt_mode); + interval >>= regs->wdt_timeout_shift; + interval &=WDT_TIMEOUT_MASK ; +/* Round the 0.5-second interval up to the minimum representable timeout. */ +if (!interval) +return WDT_MIN_TIMEOUT ; + +for (timeout =WDT_MIN_TIMEOUT ; + timeout <ARRAY_SIZE (wdt_timeout_map); timeout++) { +if (wdt_timeout_map[timeout] == interval) +return timeout; + } + +/* Reserved interval encoding. */ +return 0 ; +} +static int sunxi_wdt_set_timeout (struct watchdog_device *wdt_dev,unsigned int timeout) {
@@ -231,6 +263,7 @@ static int sunxi_wdt_probe(struct platfo {struct device *dev = &pdev->dev;struct sunxi_wdt_dev *sunxi_wdt; +unsigned int running_timeout;int err; sunxi_wdt =devm_kzalloc (dev,sizeof (*sunxi_wdt),GFP_KERNEL );
@@ -258,7 +291,17 @@ static int sunxi_wdt_probe(struct platfowatchdog_set_drvdata (&sunxi_wdt->wdt_dev, sunxi_wdt); -sunxi_wdt_stop (&sunxi_wdt->wdt_dev); +if (sunxi_wdt_is_running (&sunxi_wdt->wdt_dev)) { + running_timeout =sunxi_wdt_get_timeout (&sunxi_wdt->wdt_dev); +if (running_timeout) + sunxi_wdt->wdt_dev.timeout = running_timeout; + + err =sunxi_wdt_start (&sunxi_wdt->wdt_dev); +if (err) +return err; + +set_bit (WDOG_HW_RUNNING , &sunxi_wdt->wdt_dev.status); + }watchdog_stop_on_reboot (&sunxi_wdt->wdt_dev); err =devm_watchdog_register_device (dev, &sunxi_wdt->wdt_dev);
Greg Kroah-Hartman
maintainerPATCH 292/595 ufs: create the root dentry after loading cylinder metadata
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
commit 55a4c98abb9694b067c6a031d11501f06b6b523c upstream.
ufs_fill_super() installed sb->s_root before it loaded the cylinder group structures for a writable mount:
sb->s_root = d_make_root(inode); ... if (!sb_rdonly(sb)) if (!ufs_read_cylinder_structures(sb)) goto failed;
When ufs_read_cylinder_structures() failed, the error path freed the in-core superblock information and set sb->s_fs_info to NULL while sb->s_root stayed installed. get_tree_bdev() then reached deactivate_locked_super(), and because s_root was present, generic_shutdown_super() called sync_filesystem() and the put_super operation. Both dereference UFS_SB(sb), which is now NULL, so a mount that fails only while reading the cylinder groups oopses during teardown. A crafted image whose first cylinder group cannot be read reaches this path.
Load the cylinder group metadata first and create the root dentry last, so the superblock is published to the VFS only once it is fully set up. ufs_setup_cstotal() and ufs_read_cylinder_structures() take only the super_block and do not use the root inode, so the reordering is safe.
--- fs/ufs/super.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
fs/ufs/super.c +9 -8
@@ -1269,6 +1269,15 @@ magic_found: sb->s_maxbytes =ufs_max_bytes (sb); sb->s_max_links =UFS_LINK_MAX ; +ufs_setup_cstotal (sb); +/* +* Read cylinder group structures +*/ +if (!sb_rdonly (sb)) +if (!ufs_read_cylinder_structures (sb)) + goto failed; + +/* create the root dentry last, once UFS_SB(sb) is fully set up */ inode =ufs_iget (sb,UFS_ROOTINO );if (IS_ERR (inode)) { ret =PTR_ERR (inode);
@@ -1280,14 +1289,6 @@ magic_found: goto failed; } -ufs_setup_cstotal (sb); -/* -* Read cylinder group structures -*/ -if (!sb_rdonly (sb)) -if (!ufs_read_cylinder_structures (sb)) - goto failed; -UFSD ("EXIT\n" );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 293/595 ufs: validate cylinder group metadata before caching it
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
commit c9d263be26806d388129fab8c6904bed197fc6af upstream.
ufs_read_cylinder() copies the cylinder group index and the rotor positions straight from the on-disk group and caches them without any check:
ucpi->c_cgx = fs32_to_cpu(sb, ucg->cg_cgx); ucpi->c_rotor = fs32_to_cpu(sb, ucg->cg_rotor); ucpi->c_frotor = fs32_to_cpu(sb, ucg->cg_frotor); ucpi->c_irotor = fs32_to_cpu(sb, ucg->cg_irotor);
They are then used as indices during allocation and free:
- c_cgx indexes the cylinder summary array as UFS_SB(sb)->fs_cs(ucpi->c_cgx), so a value past s_ncg writes a 32 bit count outside the s_csp allocation.
- c_frotor becomes a bitmap scan start, start = c_frotor >> 3, and then length = ((s_fpg + 7) >> 3) - start. A start beyond the block bitmap wraps the unsigned length to a huge value, so ubh_scanc() walks far past the cylinder group buffers. c_irotor drives the inode bitmap the same way.
A crafted image can set any of these freely, turning an ordinary allocation into an out of bounds access.
Reject a cylinder group whose recorded index does not match the group being read, or whose rotors fall outside the group, before the metadata is cached. Valid filesystems keep cg_cgx equal to the group number and the rotors within the group, so only malformed images are rejected.
--- fs/ufs/cylinder.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ufs/cylinder.c +10 -0
@@ -66,6 +66,16 @@ static void ufs_read_cylinder (struct su ucpi->c_clustersumoff =fs32_to_cpu (sb, ucg->cg_u.cg_44.cg_clustersumoff); ucpi->c_clusteroff =fs32_to_cpu (sb, ucg->cg_u.cg_44.cg_clusteroff); ucpi->c_nclusterblks =fs32_to_cpu (sb, ucg->cg_u.cg_44.cg_nclusterblks); + +/* these on-disk values become array and bitmap indices */ +if (ucpi->c_cgx != cgno || + ucpi->c_rotor >= uspi->s_fpg || + ucpi->c_frotor >= uspi->s_fpg || + ucpi->c_irotor >= uspi->s_ipg) { +ufs_error (sb, __func__, +"inconsistent metadata in cylinder group %u\n" , cgno); + goto failed; + }UFSD ("EXIT\n" );return ;
Greg Kroah-Hartman
maintainerPATCH 294/595 tunnels: Drop stale dst when building an ICMP error for PMTUD
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
commit b58d749633203d92c265317b45fccee555090352 upstream.
Bridged UDP tunnels such as VXLAN and GENEVE build an ICMP error packet around an overlay packet if the packet is going to exceed the underlay path MTU. The ICMP error packet is then injected back into the Rx path with the source and destination addresses swapped, so that it will be delivered to the overlay source.
If the overlay packet was routed to the UDP tunnel or locally generated, then it is already carrying a valid dst entry and this entry is not dropped when transforming the packet to an ICMP error packet. This causes the IP layer to reuse the dst entry, leading to the ICMP error packet being dropped or routed out of the UDP tunnel interface in case of forwarding.
Prior to the blamed commit this could not happen, as skb_tunnel_check_pmtu() did not build ICMP errors for PACKET_HOST packets. Such packets were instead encapsulated and, unless the DF bit was set in the outer header, fragmented by the underlay.
Fix this by making sure that the ICMP error packet does not have a valid dst entry, thereby forcing the IP layer to perform a route lookup.
Adjust the bridged PMTU exception selftests accordingly. When the local sender in ns_a pings the overlay destination with a deadline (-w), ping exits on the first socket error before any reply is received and returns a non-zero exit code. The test therefore only passed because the ICMP error was never delivered. Use a packet count (-c) like the ns_c line above it, so that the ICMP error counts against the packet budget and the exit code depends on whether echo replies were received. This passes with and without the fix.
--- net/ipv4/ip_tunnel_core.c | 6 ++++++ tools/testing/selftests/net/pmtu.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
net/ipv4/ip_tunnel_core.c +6 -0
@@ -250,6 +250,9 @@ static int iptunnel_pmtud_build_icmp(streth_header (skb, skb->dev,htons (eh.h_proto), eh.h_source, eh.h_dest,0 );skb_reset_mac_header (skb); +if (skb_valid_dst (skb)) +skb_dst_drop (skb); +return skb->len; }
@@ -353,6 +356,9 @@ static int iptunnel_pmtud_build_icmpv6(seth_header (skb, skb->dev,htons (eh.h_proto), eh.h_source, eh.h_dest,0 );skb_reset_mac_header (skb); +if (skb_valid_dst (skb)) +skb_dst_drop (skb); +return skb->len; }
tools/testing/selftests/net/pmtu.sh +1 -1
@@ -1105,7 +1105,7 @@ test_pmtu_ipvX_over_bridged_vxlanY_or_ge mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000)) run_cmd ${ns_c} ${ping} -q -M want -i 0.1 -c 10 -s $((${ll_mtu} + 500)) ${dst} || return 1 - run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst} || return 1 + run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -c 10 -s $((${ll_mtu} + 500)) ${dst} || return 1 # Check that exceptions were created pmtu="$(route_get_dst_pmtu_from_exception "${ns_c}" ${dst})"
Greg Kroah-Hartman
maintainerPATCH 295/595 tracing: Free histogram the var ref when its initialization fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
commit 516001d53e6b2ea95a251ee2ef54a1a689a3fd58 upstream.
create_var_ref() allocates a VAR_REF hist_field and then calls init_var_ref() to fill it in. When that fails the field is leaked.
commit 656fe2ba85e8 ("tracing: Use hist trigger's var_ref array to destroy var_refs") made destroy_hist_field() return early for HIST_FIELD_FL_VAR_REF, since var refs are freed by walking the trigger's var_refs[] array instead. create_var_ref() adds the field to that array only after init_var_ref() has succeeded, so on this path the field is in neither place and nothing frees it. The call was correct when it was written, before var refs were taken out of destroy_hist_field().
init_var_ref() cannot free it either. The caller owns the field, so init_var_ref() undoes only its own string allocations and leaves the field alone. Freeing it there would leave create_var_ref() passing freed memory to destroy_hist_field(), which reads its flags.
Call __destroy_hist_field(), which frees the field without consulting the flag.
--- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
@@ -1853,7 +1853,7 @@ static struct hist_field *create_var_ref ref_field =create_hist_field (var_field->hist_data,NULL , flags,NULL );if (ref_field) {if (init_var_ref (ref_field, var_field, system, event_name)) { -destroy_hist_field (ref_field,0 ); +__destroy_hist_field (ref_field);return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 296/595 ASoC: sprd: validate compress buffer sizes against fixed allocations
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchu Chen <[email protected]>
commit 7a4ce92d150b9e7ecf1a710a34d8cdeb590d3751 upstream.
sprd_platform_compr_open() allocates the stage 0 IRAM buffer (32K data area) and the stage 1 DDR buffer (2M data area) with fixed sizes, but sprd_platform_compr_copy() derives all copy lengths from the user controlled runtime->fragment_size and the write() count, never comparing them against the physical buffer sizes. The compress core only checks fragment_size * fragments for an u32 overflow in snd_compress_check_input(), so a local user can configure a logical buffer of up to ~4GB via SNDRV_COMPRESS_SET_PARAMS, far exceeding the fixed allocations.
A fragment_size larger than the 32K IRAM data area makes the stage 0 copy_from_user() overflow past the IRAM allocation, and a buffer_size larger than the 2M DDR buffer makes the wrapping copy at the end of sprd_platform_compr_copy() write fully user controlled data past the buffer. No SNDRV_PCM_TRIGGER_START is needed, a write() in SETUP state reaches the copy callback directly.
Reject parameters that do not fit into the fixed buffers in set_params(), and fix the advertised max fragment size: 128K never fitted into the 32K IRAM buffer. The caps values may have been carried over from the qdsp6 driver, which allocates its buffers according to the advertised maxima, unlike this driver. With 32K as max fragment size the advertised limits are self-consistent: 32K * 64 = 2M equals the DDR buffer size.
Discovered by Atuin - Automated Vulnerability Discovery Engine.
--- sound/soc/sprd/sprd-pcm-compress.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
sound/soc/sprd/sprd-pcm-compress.c +14 -1
@@ -17,7 +17,7 @@/* Default values if userspace does not set */ #define SPRD_COMPR_MIN_FRAGMENT_SIZE SZ_8K -#define SPRD_COMPR_MAX_FRAGMENT_SIZE SZ_128K +#define SPRD_COMPR_MAX_FRAGMENT_SIZE SZ_32K#define SPRD_COMPR_MIN_NUM_FRAGMENTS 4#define SPRD_COMPR_MAX_NUM_FRAGMENTS 64
@@ -272,6 +272,19 @@ static int sprd_platform_compr_set_paramint ret;/* +* The stage 0 IRAM buffer and the stage 1 DDR buffer are allocated +* with fixed sizes at open time, so the requested fragment size and +* fragments must fit into them, otherwise sprd_platform_compr_copy() +* would overflow the buffers. Note the compress core only checks the +* fragment size and fragments against an u32 overflow, not against +* the buffer sizes advertised by get_caps. +*/ +if (params->buffer.fragment_size >SPRD_COMPR_IRAM_BUF_SIZE || + (u64 )params->buffer.fragment_size * params->buffer.fragments > +SPRD_COMPR_AREA_BUF_SIZE ) +return -EINVAL ; + +/* * Configure the DMA engine 2-stage transfer mode. Channel 1 set as the * destination channel, and channel 0 set as the source channel, that * means once the source channel's transaction is done, it will trigger
Greg Kroah-Hartman
maintainerPATCH 297/595 ASoC: sti: initialize IRQ lock before requesting IRQ
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 04405aeef4f8d7bcac6dcb1947acafdb4420c2c3 upstream.
uni_reader_init() registers the shared IRQ before initializing reader->irq_lock. A pending interrupt can invoke the handler while the lock is still uninitialized.
Initialize the lock before registering the IRQ so the interrupt path always sees valid lock state.
--- sound/soc/sti/uniperif_reader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sti/uniperif_reader.c +2 -2
@@ -421,6 +421,8 @@ int uni_reader_init(struct platform_devielse reader->hw = &uni_reader_pcm_hw; +spin_lock_init (&reader->irq_lock); + ret =devm_request_irq (&pdev->dev, reader->irq, uni_reader_irq_handler,IRQF_SHARED ,dev_name (&pdev->dev), reader);
@@ -429,8 +431,6 @@ int uni_reader_init(struct platform_devireturn -EBUSY ; } -spin_lock_init (&reader->irq_lock); -return 0 ; }EXPORT_SYMBOL_GPL (uni_reader_init);
Greg Kroah-Hartman
maintainerPATCH 298/595 cpufreq: zero-initialize policy cpumask before sysfs publication
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhongqiu Han <[email protected]>
commit 54d37bcf2f497140b9207968557ddb484058e749 upstream.
cpufreq_policy_alloc() allocates policy->cpus with alloc_cpumask_var(), i.e. without __GFP_ZERO, unlike the sibling related_cpus and real_cpus masks. With CONFIG_CPUMASK_OFFSTACK=y the mask is a separate kmalloc_node() allocation, so its bitmap holds whatever the slab allocator left behind:
cpufreq_online()
cpufreq_policy_alloc()
alloc_cpumask_var(&policy->cpus) /* bitmap is uninitialized */
kobject_init_and_add() /* policy%u/ appears in sysfs */
cpufreq_policy_online()
cpumask_copy(policy->cpus, cpumask_of(cpu)) /* first valid value */This leaves a window in which the sysfs attributes are already reachable while policy->cpus is still garbage. show()/store() gate on policy_is_inactive(), i.e. cpumask_empty(policy->cpus), so a non-zero bitmap makes them run the attribute callbacks on a policy that is not initialized yet.
Fix this by using zalloc_cpumask_var() for policy->cpus.
--- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -1
@@ -1204,7 +1204,7 @@ static struct cpufreq_policy *cpufreq_poif (!policy)return NULL ; -if (!alloc_cpumask_var (&policy->cpus,GFP_KERNEL )) +if (!zalloc_cpumask_var (&policy->cpus,GFP_KERNEL )) goto err_free_policy;if (!zalloc_cpumask_var (&policy->related_cpus,GFP_KERNEL ))
Greg Kroah-Hartman
maintainerPATCH 299/595 cpufreq: initialize policy rwsem before sysfs publication
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 3e5d1bf4bd687beb2cb4e32a07af695455925588 upstream.
cpufreq_policy_alloc() initializes policy->rwsem after kobject_init_and_add() has created the policy sysfs directory and its default attributes. A sysfs access can therefore reach a policy callback before the semaphore has been initialized.
Initialize policy->rwsem before publishing the policy kobject so sysfs callbacks always see an initialized semaphore.
--- drivers/cpufreq/cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +2 -2
@@ -1213,6 +1213,8 @@ static struct cpufreq_policy *cpufreq_poif (!zalloc_cpumask_var (&policy->real_cpus,GFP_KERNEL )) goto err_free_rcpumask; +init_rwsem (&policy->rwsem); +init_completion (&policy->kobj_unregister); ret =kobject_init_and_add (&policy->kobj, &ktype_cpufreq, cpufreq_global_kobject,"policy%u" , cpu);
@@ -1227,8 +1229,6 @@ static struct cpufreq_policy *cpufreq_po goto err_free_real_cpus; } -init_rwsem (&policy->rwsem); -freq_constraints_init (&policy->constraints); policy->nb_min.notifier_call = cpufreq_notifier_min;
Greg Kroah-Hartman
maintainerPATCH 300/595 exec: do_close_on_exec() before taking exec_update_lock
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit e780259b54e618ceb4763fbc21314acf3565e813 upstream.
do_close_on_exec() currently happens while holding the exec_update_lock, which is used in a lot of places that access process state to synchronize access checks.
I recently added another such use of exec_update_lock, causing a regression.
do_close_on_exec() can block waiting for a reply from a filesystem. That means a hung filesystem can block codepaths that use exec_update_lock; and it also means that a FUSE filesystem which attempts to inspect the calling process can deadlock.
To avoid such problems, move do_close_on_exec() before the exec_update_lock is taken, but after the FD table has been copied if necessary.
I have looked through all the calls between the old and new position of the do_close_on_exec() call; there seems to be no file descriptor table access in between.
--- fs/exec.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
fs/exec.c +14 -8
@@ -1268,6 +1268,20 @@ int begin_new_exec(struct linux_binprm * goto out;/* +* We have to apply CLOEXEC before we change whether the process is +* dumpable (in setup_new_exec) to avoid a race with a process in userspace +* trying to access the should-be-closed file descriptors of a process +* undergoing exec(2). +* +* This can block on filesystem ->flush() handlers, including waiting +* for FUSE daemons, so do it before exec_mmap takes the +* exec_update_lock. +* This must happen after the point of no return, and after unsharing +* the FD table. +*/ +do_close_on_exec (me->files); + +/* * Must be called _before_ exec_mmap() as bprm->mm is * not visibile until then. This also enables the update * to be lockless.
@@ -1315,14 +1329,6 @@ int begin_new_exec(struct linux_binprm *flush_thread (); me->personality &= ~bprm->per_clear; -/* -* We have to apply CLOEXEC before we change whether the process is -* dumpable (in setup_new_exec) to avoid a race with a process in userspace -* trying to access the should-be-closed file descriptors of a process -* undergoing exec(2). -*/ -do_close_on_exec (me->files); -if (bprm->secureexec) {/* Make sure parent cannot signal privileged process. */ me->pdeath_signal =0 ;
Greg Kroah-Hartman
maintainerPATCH 301/595 drm/i915: Fix memory leak in query_perf_config_list()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit cbd3dafc2003db679ccd2f6c6a2551db79657049 upstream.
When krealloc() fails, free the original oa_config_ids before returning to avoid a memory leak.
--- drivers/gpu/drm/i915/i915_query.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_query.c +3 -1
@@ -364,8 +364,10 @@ static int query_perf_config_list(struct ids =krealloc (oa_config_ids, n_configs *sizeof (*oa_config_ids),GFP_KERNEL ); -if (!ids) +if (!ids) { +kfree (oa_config_ids);return -ENOMEM ; + } alloc =fetch_and_zero (&n_configs);
Greg Kroah-Hartman
maintainerPATCH 302/595 net: hso: fix TIOCMIWAIT race
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 00f9fbc12320253bfc576fb7539d860029c82d0f upstream.
The task state must be updated before checking the wakeup condition to avoid missing a racing modem status update.
--- drivers/net/usb/hso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/hso.c +1 -1
@@ -1557,10 +1557,10 @@ hso_wait_modem_status(struct hso_serialspin_unlock_irq (&serial->serial_lock);add_wait_queue (&tiocmget->waitq, &wait);for (;;) { +set_current_state (TASK_INTERRUPTIBLE );spin_lock_irq (&serial->serial_lock);memcpy (&cnow, &tiocmget->icount,sizeof (struct uart_icount ));spin_unlock_irq (&serial->serial_lock); -set_current_state (TASK_INTERRUPTIBLE );if (((arg &TIOCM_RNG ) && (cnow.rng != cprev.rng)) || ((arg &TIOCM_DSR ) && (cnow.dsr != cprev.dsr)) || ((arg &TIOCM_CD ) && (cnow.dcd != cprev.dcd))) {
Greg Kroah-Hartman
maintainerPATCH 303/595 net: mpls: clear inner_protocol when the last label is popped
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fourie Zhang <[email protected]>
commit 78a86d75a70e1e227711c72865c59b1422d0a5ae upstream.
skb_mpls_push() records the pre-encapsulation network header once, gated on !skb->inner_protocol. skb_mpls_pop() never clears that record, so it outlives the encapsulation it describes.
Open vSwitch can then re-push MPLS onto a packet whose inner_network_header still points at the older, deeper offset: push a label, pop every label, recirculate (ovs_flow_key_update() re-derives key->eth.type and resets network_header, but leaves inner_*), then push again. ovs_fragment() trusts the record:
skb->network_header = skb->inner_network_header;
so skb_network_offset() goes negative. The bound check is signed:
if (skb_network_offset(skb) > MAX_L2_LEN)
a negative offset passes it, and prepare_frag() widens the value:
unsigned int hlen = skb_network_offset(skb); memcpy(&data->l2_data, skb->data, hlen);
which is a ~4GiB memcpy out of a 30-byte per-CPU buffer.
Reproduced on v7.3-rc1. RDX is the truncated length, (unsigned int)(-8):
BUG: unable to handle page fault for address: ffffe8ffffc16000 #PF: supervisor write access in kernel mode Oops: 0002 [#1] SMP KASAN NOPTI RIP: 0010:memcpy+0x8/0x20 RDX: 00000000fffffff8 RSI: ffff888105d732db RDI: ffffe8ffffc16000 prepare_frag+0x3df/0x4e0 ovs_fragment+0x589/0x7e0 do_output+0x4ce/0x5e0 do_execute_actions+0x55d2/0x7b30 ovs_execute_actions+0xea/0x450
Same root-cause shape as commit 975b5b067f52 ("ipv6: sr: restore network header before routing and forwarding"): a stale network header offset reaching a consumer that widens it. Here it originates in the MPLS push/pop path.
Clear inner_protocol once the packet is no longer MPLS, so a later push re-records the current header. net/sched/act_mpls.c is the only other skb_mpls_pop() caller and gets the same fix; sch_frag.c saves and restores inner_protocol around fragmentation in the same way OVS does.
--- net/core/skbuff.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/skbuff.c +7 -0
@@ -5924,6 +5924,13 @@ int skb_mpls_pop(struct sk_buff *skb, __ } skb->protocol = next_proto; +/* The last label is gone, so the inner header recorded by +* skb_mpls_push() no longer describes this packet. Drop it, or a +* later push keeps the stale offset. +*/ +if (!eth_p_mpls (next_proto)) + skb->inner_protocol =0 ; +return 0 ; }EXPORT_SYMBOL_GPL (skb_mpls_pop);
Greg Kroah-Hartman
maintainerPATCH 304/595 net: openvswitch: fix use-after-free of the flow table mask array
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Norbert Szetei <[email protected]>
commit ba4ba11ed6eb8972c69070417fc27b48deb002e8 upstream.
tbl_mask_array_realloc() retires the old mask_array before it stops being reachable:
old = ovsl_dereference(tbl->mask_array);
if (old) {
...
call_rcu(&old->rcu, mask_array_rcu_cb);
}
rcu_assign_pointer(tbl->mask_array, new);call_rcu() only waits for read-side critical sections already in flight. tbl->mask_array still points at old between the call_rcu() and the rcu_assign_pointer(), so a reader entering ovs_flow_tbl_lookup_stats() in that window picks up old in a fresh critical section that the pending grace period does not cover.
tbl_mask_array_realloc() runs in process context under ovs_mutex, so the window is preemptible and can outlast the grace period. Then mask_array_rcu_cb() frees old before the swap runs:
BUG: KASAN: slab-use-after-free in flow_lookup.constprop.0+0x2bf/0x2f0 Read of size 8 at addr ffff888020b3e018 by task poc/741 flow_lookup.constprop.0+0x2bf/0x2f0 ovs_flow_tbl_lookup_stats+0x4a3/0x5c0 ovs_dp_process_packet+0x19c/0x710 ovs_vport_receive+0x243/0x390 internal_dev_xmit+0x81/0x170 Freed by task 728: kfree+0x16a/0x4e0 rcu_core+0x853/0x1030
Publish the new array before retiring the old one. The kfree_rcu() that call_rcu() replaced ran after the swap.
--- net/openvswitch/flow_table.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/openvswitch/flow_table.c +3 -1
@@ -261,11 +261,13 @@ static int tbl_mask_array_realloc(structif (ovsl_dereference (old->masks[i])) new->masks[new->count++] = old->masks[i]; } -call_rcu (&old->rcu, mask_array_rcu_cb); }rcu_assign_pointer (tbl->mask_array, new); +if (old) +call_rcu (&old->rcu, mask_array_rcu_cb); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 305/595 netfilter: report NLM_F_DUMP_FILTERED when all is filtered out
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
commit 7a099b347fef536a84068076e2d384f044e5cfc5 upstream.
NLM_F_DUMP_FILTERED is only set on data elements in the conntrack dump. But when everything is filtered out it is confusing for the user space, since the flag is not reported anymore and it looks like the table was empty, which may or may not be the case.
'answer_flags' were introduced precisely for this use case, and the conntrack dump should set the flag in there in case the filtering was applied.
This is important, for example, to be able to tell if the filters are supported or not by the kernel without modifying the kernel state.
With the proper reporting of NLM_F_DUMP_FILTERED on NLMSG_DONE, an application in user space can just try and dump with an arbitrary filter without worrying that there could be no matching entry. The reported flag will signal that the filtering was applied and therefore supported.
--- net/netfilter/nf_conntrack_netlink.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_conntrack_netlink.c +2 -0
@@ -989,6 +989,8 @@ static int ctnetlink_start(struct netlin } cb->data = filter; +if (filter) + cb->answer_flags =NLM_F_DUMP_FILTERED ;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 306/595 fbdev: vfb: defer cleanup until the last reference
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit a0a34a40ed299c9c7cff6af163a5b883ee9d6d73 upstream.
FBIOGETCMAP takes a shallow snapshot of info->cmap and performs the usercopy after dropping info->lock. vfb_remove() frees the colormap immediately after unregistering the framebuffer, even when an open file still holds a reference to fb_info. A concurrent driver unbind can therefore free the colormap while the ioctl copies it to userspace.
KASAN reports:
BUG: KASAN: slab-use-after-free in _copy_to_user Read of size 512 by task poc/125 _copy_to_user (./include/linux/instrumented.h:129 ./include/linux/uaccess.h:201 lib/usercopy.c:24) fb_cmap_to_user (./include/linux/uaccess.h:230 drivers/video/fbdev/core/fbcmap.c:211) do_fb_ioctl (drivers/video/fbdev/core/fb_chrdev.c:114) Allocated by task 1: fb_alloc_cmap_gfp (./include/linux/slab.h:973 ./include/linux/slab.h:1290 drivers/video/fbdev/core/fbcmap.c:108) vfb_probe (drivers/video/fbdev/vfb.c:459) Freed by task 124: fb_dealloc_cmap (drivers/video/fbdev/core/fbcmap.c:151) vfb_remove (drivers/video/fbdev/vfb.c:489)
unregister_framebuffer() drops the registration reference, and fbdev calls fb_destroy after the last put_fb_info(). Move the registered framebuffer's cleanup into an fb_destroy callback so its colormap and screen buffer stay alive until all file references have been released.
--- drivers/video/fbdev/vfb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/video/fbdev/vfb.c +8 -3
@@ -78,6 +78,13 @@ static int vfb_pan_display(struct fb_varstatic int vfb_mmap (struct fb_info *info,struct vm_area_struct *vma); +static void vfb_destroy (struct fb_info *info) +{ +vfree (info->screen_buffer); +fb_dealloc_cmap (&info->cmap); +framebuffer_release (info); +} +static const struct fb_ops vfb_ops = { .fb_read = fb_sys_read, .fb_write = fb_sys_write,
@@ -89,6 +96,7 @@ static const struct fb_ops vfb_ops = { .fb_copyarea = sys_copyarea, .fb_imageblit = sys_imageblit, .fb_mmap = vfb_mmap, + .fb_destroy = vfb_destroy, };/*
@@ -485,9 +493,6 @@ static int vfb_remove(struct platform_deif (info) {unregister_framebuffer (info); -vfree (videomemory); -fb_dealloc_cmap (&info->cmap); -framebuffer_release (info); }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 307/595 ieee802154: 6lowpan: fix NULL dereference in lowpan_newlink
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
commit bf79662bc85e820ac3b846e2f347da29fbf6ac95 upstream.
TUNSETLINK allows a TUN device to change its link-layer type to ARPHRD_IEEE802154 without initializing ieee802154_ptr. lowpan_newlink() checks only the device type before dereferencing the pointer, so an RTM_NEWLINK request can trigger a NULL pointer dereference.
Reject devices without ieee802154_ptr along with devices of the wrong type.
--- net/ieee802154/6lowpan/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ieee802154/6lowpan/core.c +1 -1
@@ -145,7 +145,7 @@ static int lowpan_newlink(struct net *sr wdev =dev_get_by_index (dev_net (ldev),nla_get_u32 (tb[IFLA_LINK ]));if (!wdev)return -ENODEV ; -if (wdev->type !=ARPHRD_IEEE802154 ) { +if (wdev->type !=ARPHRD_IEEE802154 || !wdev->ieee802154_ptr) {dev_put (wdev);return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 308/595 ipv4: fib: bound automatic table ID allocation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
commit efdfb1e27a3328085b79540dfe781d537b576ea1 upstream.
fib_empty_table() probes every table ID from 1 until it finds a free one. IPv4 tables are stored in a 256-bucket hash table, so a dense set of IDs makes each probe walk a growing hash chain while RTNL is held.
Automatic table assignment ("ip rule ... table 0") is an IPv4-only legacy path. Bound the automatically allocated ID to 4096 so the RTNL hold stays bounded, without changing lookups of explicitly specified table IDs.
This changes user-visible behavior. A table-0 rule previously received the lowest free ID in 1..RT_TABLE_MAX (0xFFFFFFFF). After this patch the search stops at 4096 and the rule add fails with ENOBUFS if that range is fully occupied. Explicit table IDs above 4096 remain usable.
The automatic path is unused in practice: it is IPv4-only, not documented by ip-rule, uncovered by kernel selftests, and both NetworkManager and systemd refuse table 0.
--- net/ipv4/fib_rules.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/fib_rules.c +3 -1
@@ -202,6 +202,8 @@ INDIRECT_CALLABLE_SCOPE int fib4_rule_mareturn 1 ; } +#define FIB_MAX_AUTO_TABLE_ID 4096 +static struct fib_table *fib_empty_table (struct net *net) {u32 id =1 ;
@@ -210,7 +212,7 @@ static struct fib_table *fib_empty_tableif (!fib_get_table (net, id))return fib_new_table (net, id); -if (id++ ==RT_TABLE_MAX ) +if (id++ ==FIB_MAX_AUTO_TABLE_ID )break ; }return NULL ;
Greg Kroah-Hartman
maintainerPATCH 309/595 ipvs: reject invalid states in connection template sync records
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
commit 74cb39735b6cd0aff4b5584158f09376fd97aadf upstream.
IPVS sync receivers validate protocol states before creating or updating a connection. For connection templates, however, they only log states outside the template state range and still store the value in the connection.
A template can be returned by ordinary connection lookup. TCP and SCTP then use the invalid state as an index into their transition tables.
Reject invalid template states in both sync protocol versions before looking up or modifying a connection. The version 1 path handles both IPv4 and IPv6 records.
--- net/netfilter/ipvs/ip_vs_sync.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +8 -8
@@ -1000,10 +1000,10 @@ static void ip_vs_process_message_v0(str pp->name, state);continue ; } - }else { -if (state >=IP_VS_CTPL_S_LAST ) -IP_VS_DBG (7 ,"BACKUP v0, Invalid tpl state %u\n" , - state); + }else if (state >=IP_VS_CTPL_S_LAST ) { +IP_VS_DBG (7 ,"BACKUP v0, Invalid tpl state %u\n" , + state); +continue ; } ip_vs_conn_fill_param(ipvs, AF_INET, s->protocol,
@@ -1160,10 +1160,10 @@ static inline int ip_vs_proc_sync_conn(s retc =40 ; goto out; } - }else { -if (state >=IP_VS_CTPL_S_LAST ) -IP_VS_DBG (7 ,"BACKUP, Invalid tpl state %u\n" , - state); + }else if (state >=IP_VS_CTPL_S_LAST ) { +IP_VS_DBG (7 ,"BACKUP, Invalid tpl state %u\n" , state); + retc =40 ; + goto out; }if (ip_vs_conn_fill_param_sync (ipvs, af, s, ¶m, pe_data, pe_data_len, pe_name, pe_name_len)) {
Greg Kroah-Hartman
maintainerPATCH 310/595 KVM: PPC: Book3S HV: Set irqfd->producer only on success
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: leixiang <[email protected]>
commit 1144454ea22290d7c6998a2af6239e5995476afc upstream.
Set irqfd->producer only after kvmppc_set_passthru_irq() succeeds to avoid leaving a dangling pointer on failure. The bypass manager does not register a failed producer, so the pointer is never cleared.
--- arch/powerpc/kvm/book3s_hv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_hv.c +2 -2
@@ -5286,12 +5286,12 @@ static int kvmppc_irq_bypass_add_producestruct kvm_kernel_irqfd *irqfd = container_of(cons, struct kvm_kernel_irqfd, consumer); - irqfd->producer = prod; - ret =kvmppc_set_passthru_irq (irqfd->kvm, prod->irq, irqfd->gsi);if (ret)pr_info ("kvmppc_set_passthru_irq (irq %d, gsi %d) fails: %d\n" , prod->irq, irqfd->gsi, ret); +else + irqfd->producer = prod;return ret; }
Greg Kroah-Hartman
maintainerPATCH 311/595 s390/qeth: allow bridgeport queries despite OS_MISMATCH
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nagamani PV <[email protected]>
commit 74f27fc8642b7e8d139796f8c18ee46df393c2b2 upstream.
When HiperSockets interfaces on the same VCHID span different OS families, reads of the sysfs attributes bridge_role and bridge_state fail with -EPERM if bridge port ownership belongs to another OS family.
As a result, userspace tools such as 'lszdev -ii' cannot retrieve bridge_role and bridge_state, even though firmware returns valid bridge port data for QUERY_BRIDGE_PORTS requests.
The firmware reports IPA_RC_SBP_IQD_OS_MISMATCH (0x0010) to indicate that bridge port ownership belongs to a different OS family. For QUERY_BRIDGE_PORTS operations, firmware still returns valid bridge port data (role=none, state=inactive) together with a primary return code of 0x0000 (success).
Allow QUERY_BRIDGE_PORTS requests to return the bridge port data provided by the firmware despite OS_MISMATCH. To make the OS family mismatch visible to userspace, represent the firmware-reported role "none" as "none (OS family mismatch)" while preserving the reported bridge_state.
The behavior for non-QUERY bridge port commands is unchanged; SET operations continue to return -EPERM when another OS family owns the bridge port.
This restores readability of bridge_role and bridge_state.
--- drivers/s390/net/qeth_l2.h | 3 ++- drivers/s390/net/qeth_l2_main.c | 26 ++++++++++++++++++++++---- drivers/s390/net/qeth_l2_sys.c | 7 ++++++- 3 files changed, 30 insertions(+), 6 deletions(-)
drivers/s390/net/qeth_l2.h +2 -1
@@ -15,7 +15,8 @@ int qeth_l2_create_device_attributes(strvoid qeth_l2_remove_device_attributes (struct device *);int qeth_bridgeport_query_ports (struct qeth_card *card,enum qeth_sbp_roles *role, -enum qeth_sbp_states *state); +enum qeth_sbp_states *state, +bool *os_mismatch);int qeth_bridgeport_setrole (struct qeth_card *card,enum qeth_sbp_roles role);int qeth_bridgeport_an_set (struct qeth_card *card,int enable);
drivers/s390/net/qeth_l2_main.c +22 -4
@@ -971,7 +971,7 @@ static void qeth_l2_setup_bridgeport_attqeth_bridgeport_setrole (card, card->options.sbp.role);/* Let the callback function refresh the stored role value. */ qeth_bridgeport_query_ports (card, &card->options.sbp.role, -NULL ); +NULL ,NULL ); }if (card->options.sbp.hostnotification) {if (qeth_bridgeport_an_set (card,1 ))
@@ -1433,6 +1433,7 @@ struct _qeth_sbp_cbctl {struct {enum qeth_sbp_roles *role;enum qeth_sbp_states *state; +bool *os_mismatch; } qports; } data; };
@@ -1609,10 +1610,19 @@ static int qeth_bridgeport_query_ports_cstruct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;struct qeth_sbp_port_data *qports; +u16 sbp_rc;int rc;QETH_CARD_TEXT (card,2 ,"brqprtcb" ); - rc =qeth_bridgeport_makerc (card, cmd); + sbp_rc = cmd->data.sbp.hdr.return_code; + +/* on OS family mismatch, query still returns valid port data; +* treat as success +*/ +if (sbp_rc ==IPA_RC_SBP_IQD_OS_MISMATCH && !cmd->hdr.return_code) + rc =0 ; +else + rc =qeth_bridgeport_makerc (card, cmd);if (rc)return rc;
@@ -1628,6 +1638,9 @@ static int qeth_bridgeport_query_ports_cif (cbctl->data.qports.state) *cbctl->data.qports.state = qports->entry[0 ].state; } +if (cbctl->data.qports.os_mismatch) + *cbctl->data.qports.os_mismatch = + (sbp_rc ==IPA_RC_SBP_IQD_OS_MISMATCH );return 0 ; }
@@ -1636,13 +1649,17 @@ static int qeth_bridgeport_query_ports_c* @card: qeth_card structure pointer. * @role: Role of the port: 0-none, 1-primary, 2-secondary. * @state: State of the port: 0-inactive, 1-standby, 2-active. +* @os_mismatch: if non-NULL, set to true when firmware reports +* OS family mismatch. * * Returns negative errno-compatible error indication or 0 on success. * -* 'role' and 'state' are not updated in case of hardware operation failure. +* 'role', 'state' and 'os_mismatch' are not updated in case of +* hardware operation failure. */ int qeth_bridgeport_query_ports (struct qeth_card *card, -enum qeth_sbp_roles *role,enum qeth_sbp_states *state) +enum qeth_sbp_roles *role,enum qeth_sbp_states *state, +bool *os_mismatch) {struct qeth_cmd_buffer *iob;struct _qeth_sbp_cbctl cbctl = {
@@ -1650,6 +1667,7 @@ int qeth_bridgeport_query_ports(struct q .qports = { .role = role, .state = state, + .os_mismatch = os_mismatch, }, }, };
drivers/s390/net/qeth_l2_sys.c +6 -1
@@ -15,6 +15,7 @@ static ssize_t qeth_bridge_port_role_sta {struct qeth_card *card =dev_get_drvdata (dev);enum qeth_sbp_states state =QETH_SBP_STATE_INACTIVE ; +bool os_mismatch = false;int rc =0 ;char *word;
@@ -25,7 +26,7 @@ static ssize_t qeth_bridge_port_role_staif (qeth_card_hw_is_reachable (card) && card->options.sbp.supported_funcs) rc =qeth_bridgeport_query_ports (card, - &card->options.sbp.role, &state); + &card->options.sbp.role, &state, &os_mismatch);if (!rc) {if (show_state)switch (state) {
@@ -52,6 +53,10 @@ static ssize_t qeth_bridge_port_role_staif (rc)QETH_CARD_TEXT_ (card,2 ,"SBP%02x:%02x" , card->options.sbp.role, state); +else if (!show_state && + card->options.sbp.role ==QETH_SBP_ROLE_NONE && + os_mismatch) + rc =sysfs_emit (buf,"%s (OS family mismatch)\n" , word);else rc =sprintf (buf,"%s\n" , word); }
Greg Kroah-Hartman
maintainerPATCH 312/595 s390/crypto: Fix missing scrub of temp buffers with AES ctr and gcm algorithm
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Freudenberger <[email protected]>
commit 8b7c3b6914f19caf648d05726a86af6326d3c2c6 upstream.
In function ctr_aes_crypt() there is a buffer used to process remaining bytes < AES_BLOCK_SIZE. This buffer was not scrubbed and thus could lead to expose of unwanted data. When the buffer is used explicitly scrub it at the end of the code block to avoid exposure of maybe sensitive data.
In a similar way the function gcm_aes_crypt() hat an error path where the CPACF param block was not scrubbed. Instead of return early now these error paths go to end of function where explicit scrubbing is done. Similar with the buffers which are part of the gcm_sg_walk structs from the variables gw_in and gw_out.
--- arch/s390/crypto/aes_s390.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
arch/s390/crypto/aes_s390.c +12 -4
@@ -607,6 +607,7 @@ static int ctr_aes_crypt(struct skciphermemcpy (walk.dst.virt.addr, buf, nbytes);crypto_inc (walk.iv,AES_BLOCK_SIZE ); ret =skcipher_walk_done (&walk,0 ); +memzero_explicit (buf,sizeof (buf)); }return ret;
@@ -908,10 +909,14 @@ static int gcm_aes_crypt(struct aead_req gw_in.ptr, aad_bytes); n = aad_bytes + pc_bytes; -if (gcm_in_walk_done (&gw_in, n) != n) -return -ENOMEM ; -if (gcm_out_walk_done (&gw_out, n) != n) -return -ENOMEM ; +if (gcm_in_walk_done (&gw_in, n) != n) { + ret = -ENOMEM ; + goto out; + } +if (gcm_out_walk_done (&gw_out, n) != n) { + ret = -ENOMEM ; + goto out; + } aadlen -= aad_bytes; pclen -= pc_bytes; }while (aadlen + pclen >0 );
@@ -923,7 +928,10 @@ static int gcm_aes_crypt(struct aead_req }else scatterwalk_map_and_copy (param.t, req->dst, len, taglen,1 ); +out:memzero_explicit (¶m,sizeof (param)); +memzero_explicit (gw_in.buf,sizeof (gw_in.buf)); +memzero_explicit (gw_out.buf,sizeof (gw_out.buf));return ret; }
Greg Kroah-Hartman
maintainerPATCH 313/595 hwmon: (applesmc) fix key backlight workqueue leak on register failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
commit 5a0aacaa2d593d7582ecfe289529b937b6dc5d3c upstream.
applesmc_create_key_backlight() allocates applesmc_led_wq before calling led_classdev_register(). When register fails, the error is returned to applesmc_init(), which jumps to out_light_sysfs and skips applesmc_release_key_backlight(), leaking the workqueue.
Destroy the workqueue on the register failure path. The bug was introduced when the inline init block was refactored into a helper that returns errors directly, dropping the old out_light_wq unwind label.
--- drivers/hwmon/applesmc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hwmon/applesmc.c +6 -1
@@ -1249,12 +1249,17 @@ static void applesmc_release_light_sensostatic int applesmc_create_key_backlight (void ) { +int ret; +if (!smcreg.has_key_backlight)return 0 ; applesmc_led_wq =create_singlethread_workqueue ("applesmc-led" );if (!applesmc_led_wq)return -ENOMEM ; -return led_classdev_register (&pdev->dev, &applesmc_backlight); + ret =led_classdev_register (&pdev->dev, &applesmc_backlight); +if (ret) +destroy_workqueue (applesmc_led_wq); +return ret; }static void applesmc_release_key_backlight (void )
Greg Kroah-Hartman
maintainerPATCH 314/595 hwmon: (pmbus) Clear generic status alarms with CLEAR_FAULTS
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Razdan <[email protected]>
commit 6d760f8b41aed74de4402440e4db663d261478bd upstream.
Some hwmon alarms fall back to STATUS_WORD summary bits when no individual limit alarm is available. On PMBus 1.2 and newer devices, pmbus_get_boolean() acknowledges these alarms with the same byte-data write used for detailed status registers. For example, PB_STATUS_INPUT is 0x2000, so it is truncated to zero when passed to _pmbus_write_byte_data(). The resulting write cannot acknowledge the input alarm.
PMBus 1.3 Part II, sections 10.2.4 and 10.2.5, excludes ordinary STATUS_BYTE and STATUS_WORD summary bits from individual clearing. Their summary bits clear when the underlying status bits clear, so changing this to a word-data write would not fix the generic input alarm either.
Use the existing page CLEAR_FAULTS path for generic STATUS_WORD alarms, including devices whose status accessor uses STATUS_BYTE. Keep individual byte writes for detailed status registers on PMBus 1.2 and newer devices. As with the existing older-device fallback, CLEAR_FAULTS can clear other latched status; an active condition can reassert its status.
--- drivers/hwmon/pmbus/pmbus_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/pmbus/pmbus_core.c +3 -1
@@ -919,7 +919,9 @@ static int pmbus_get_boolean(struct i2c_ regval = status & mask;if (regval) { -if (data->revision >=PMBUS_REV_12 ) { +/* Generic STATUS_WORD alarms are not individually clearable. */ +if (data->revision >=PMBUS_REV_12 && + reg !=PMBUS_STATUS_WORD ) { ret =_pmbus_write_byte_data (client, page, reg, regval);if (ret) goto unlock;
Greg Kroah-Hartman
maintainerPATCH 315/595 media: hevc: add bounded tile-count helpers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 592dd4f8442a13bed6e946d73d3164ba38b33bbd upstream.
The stateless HEVC decoders compute the number of tile columns and rows from num_tile_columns_minus1 / num_tile_rows_minus1 and clamp it to the column_width_minus1[] / row_height_minus1[] capacity before using it as a loop bound. Add shared helpers in a new <media/v4l2-hevc.h> so the rkvdec and hantro drivers do not each open-code the min_t() clamp.
--- include/media/v4l2-hevc.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/media/v4l2-hevc.h
include/media/v4l2-hevc.h new file +41 -0
@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Helper functions for HEVC stateless codecs. +*/ + +#ifndef _MEDIA_V4L2_HEVC_H +#define _MEDIA_V4L2_HEVC_H + +#include <linux/minmax.h> +#include <media/v4l2-ctrls.h> + +/** +* v4l2_hevc_pps_num_tile_columns - number of HEVC tile columns, bounded +* @pps: the V4L2 HEVC PPS control +* +* Return the number of tile columns (num_tile_columns_minus1 + 1) clamped to +* the capacity of column_width_minus1[]. The control validation already +* rejects out-of-range counts; this keeps the consuming drivers bounded too. +*/ +static inline unsigned int +v4l2_hevc_pps_num_tile_columns (const struct v4l2_ctrl_hevc_pps *pps) +{ + return min_t(unsigned int, pps->num_tile_columns_minus1 + 1, +ARRAY_SIZE (pps->column_width_minus1)); +} + +/** +* v4l2_hevc_pps_num_tile_rows - number of HEVC tile rows, bounded +* @pps: the V4L2 HEVC PPS control +* +* Return the number of tile rows (num_tile_rows_minus1 + 1) clamped to the +* capacity of row_height_minus1[]. +*/ +static inline unsigned int +v4l2_hevc_pps_num_tile_rows (const struct v4l2_ctrl_hevc_pps *pps) +{ + return min_t(unsigned int, pps->num_tile_rows_minus1 + 1, +ARRAY_SIZE (pps->row_height_minus1)); +} + +#endif /* _MEDIA_V4L2_HEVC_H */
Greg Kroah-Hartman
maintainerPATCH 316/595 media: v4l2-h264: Fix memcmp() size in B1 reference list comparison
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
commit 10e59fbdef13597836bd6459095caa02c80af3d7 upstream.
In v4l2_h264_build_b_ref_lists(), the B0/B1 list equality check passes the entry count builder->num_valid to memcmp() instead of a byte size. Since struct v4l2_h264_reference is two bytes (fields and index), only half of each list is compared, so distinct lists can be wrongly treated as equal and trigger an incorrect swap(b1_reflist[0], b1_reflist[1]).
Change the memcmp() size argument to sizeof(b1_reflist[0]) * builder->num_valid so that the full byte length of both reference lists is compared.
--- drivers/media/v4l2-core/v4l2-h264.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-h264.c +2 -1
@@ -258,7 +258,8 @@ v4l2_h264_build_b_ref_lists(const struct v4l2_h264_b1_ref_list_cmp, NULL, builder);if (builder->num_valid >1 && - !memcmp (b1_reflist, b0_reflist, builder->num_valid)) + !memcmp (b1_reflist, b0_reflist, +sizeof (b1_reflist[0 ]) * builder->num_valid))swap (b1_reflist[0 ], b1_reflist[1 ]); }EXPORT_SYMBOL_GPL (v4l2_h264_build_b_ref_lists);
Greg Kroah-Hartman
maintainerPATCH 317/595 bnxt_en: Handle buffer allocation failure in bnxt_rx_ring_reset()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Damato <[email protected]>
commit 961e2a17c5e3559b3f8654d2daabdd25a42e770a upstream.
bnxt_rx_ring_reset() frees the ring buffers and then reallocates them, ignoring the result.
bnxt_alloc_one_rx_ring() can fail in bnxt_alloc_one_tpa_info_data(), which returns -ENOMEM on the first failed allocation and leaves the remaining rxr->rx_tpa[] entries zeroed.
The error isn't propagated up, so the loop in bnxt_rx_ring_reset continues and at the end the code re-enables TPA with partially unallocated rx_tpa array.
This means that when the agg_id from hardware is mapped to a SW index in rxr->rx_tpa[], an uninitialized slot can be chosen which would hand a zero DMA address to the device.
Fix this by falling back to a global reset, which is what the existing code already does when other functions fail, but unlike the other failure cases this particular failure has to return because TPA can't be re-enabled since the allocation failed.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -1
@@ -10923,7 +10923,14 @@ static void bnxt_rx_ring_reset(struct bn rxr->rx_sw_agg_prod =0 ; rxr->rx_next_cons =0 ; rxr->bnapi->in_reset = false; -bnxt_alloc_one_rx_ring (bp, i); + rc =bnxt_alloc_one_rx_ring (bp, i); +if (rc) { +netdev_warn (bp->dev,"RX ring reset failed to allocate buffers, rc = %d, falling back to global reset\n" , + rc); +bnxt_reset_task (bp, true); +bnxt_rtnl_unlock_sp (bp); +return ; + } cpr = &rxr->bnapi->cp_ring; cpr->sw_stats.rx.rx_resets++;if (bp->flags &BNXT_FLAG_AGG_RINGS )
Greg Kroah-Hartman
maintainerPATCH 318/595 bnxt_en: Propagate RX ring init failures in bnxt_init_nic()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Damato <[email protected]>
commit 8e6a850c0746bb4be167aedf1ee57469fcda09a9 upstream.
bnxt_init_rx_rings() returns an error when bnxt_alloc_one_rx_ring() fails, but bnxt_init_nic() discards that return value and calls bnxt_init_chip(), which enables TPA.
If an allocation fails, this could leave rxr->rx_tpa[] partially zeroed and TPA would be enabled over an array with zeroed entries. This would lead to a zeroed DMA address being handed out if the agg_idx is translated to a SW index at a zeroed entry.
Fix this by propagating the error out of bnxt_init_nic(). Both callers already check its return value and unwind with bnxt_free_skbs() and bnxt_free_mem(), which tolerate a partially initialized RX ring.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -1
@@ -8448,8 +8448,13 @@ static int bnxt_shutdown_nic(struct bnxtstatic int bnxt_init_nic (struct bnxt *bp,bool irq_re_init) { +int rc; +bnxt_init_cp_rings (bp); -bnxt_init_rx_rings (bp); + rc =bnxt_init_rx_rings (bp); +if (rc) +return rc; +bnxt_init_tx_rings (bp);bnxt_init_ring_grps (bp, irq_re_init);bnxt_init_vnics (bp);
Greg Kroah-Hartman
maintainerPATCH 319/595 mptcp: syncookies: remember the request backup flag
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit b76c0e28b392620dfbaf92cdeedbf115820b44cb upstream.
Instead of using an uninitialised bit when copying the info in subflow_ulp_clone().
To fix this, no need to extend the join_entry structure: backup is coming from struct mptcp_subflow_request_sock, only one bit. Do the same here by using one bit for both.
--- net/mptcp/syncookies.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/mptcp/syncookies.c +4 -1
@@ -26,7 +26,8 @@ struct join_entry {u32 local_nonce;u8 join_id;u8 local_id; -u8 backup; + u8 backup:1, + request_bkup:1;u8 valid; };
@@ -63,6 +64,7 @@ static void mptcp_join_store_state(struc entry->remote_nonce = subflow_req->remote_nonce; entry->local_nonce = subflow_req->local_nonce; entry->backup = subflow_req->backup; + entry->request_bkup = subflow_req->request_bkup; entry->join_id = subflow_req->remote_id; entry->local_id = subflow_req->local_id; entry->valid =1 ;
@@ -117,6 +119,7 @@ bool mptcp_token_join_cookie_init_state( subflow_req->remote_nonce = e->remote_nonce; subflow_req->local_nonce = e->local_nonce; subflow_req->backup = e->backup; + subflow_req->request_bkup = e->request_bkup; subflow_req->remote_id = e->join_id; subflow_req->local_id = e->local_id; subflow_req->token = e->token;
Greg Kroah-Hartman
maintainerPATCH 320/595 ipv6: mcast: extend RCU protection in igmp6_send()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 087c1faa594fa07a66933d750c0b2610aa1a2946 ]
igmp6_send() can be called without RTNL or RCU being held.
Extend RCU protection so that we can safely fetch the net pointer and avoid a potential UAF.
Note that we no longer can use sock_alloc_send_skb() because ipv6.igmp_sk uses GFP_KERNEL allocations which can sleep.
Instead use alloc_skb() and charge the net->ipv6.igmp_sk socket under RCU protection.
[ use IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUT, full_len)
instead of upstream's IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTPKTS). Older LTS kernels do not have commit b4a11b2033b7 ("net: fix IPSTATS_MIB_OUTPKGS increment in OutForwDatagrams"), so the legacy byte-based counter logic must be preserved. ]
--- net/ipv6/mcast.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
net/ipv6/mcast.c +15 -17
@@ -2146,21 +2146,21 @@ static void mld_send_cr(struct inet6_dev *idev)static void igmp6_send (struct in6_addr *addr,struct net_device *dev,int type) { -struct net *net =dev_net (dev); -struct sock *sk = net->ipv6.igmp_sk; +const struct in6_addr *snd_addr, *saddr; +int err, len, payload_len, full_len; +struct in6_addr addr_buf;struct inet6_dev *idev;struct sk_buff *skb;struct mld_msg *hdr; -const struct in6_addr *snd_addr, *saddr; -struct in6_addr addr_buf;int hlen =LL_RESERVED_SPACE (dev);int tlen = dev->needed_tailroom; -int err, len, payload_len, full_len;u8 ra[8 ] = {IPPROTO_ICMPV6 ,0 ,IPV6_TLV_ROUTERALERT ,2 ,0 ,0 ,IPV6_TLV_PADN ,0 }; -struct flowi6 fl6;struct dst_entry *dst; +struct flowi6 fl6; +struct net *net; +struct sock *sk;if (type ==ICMPV6_MGM_REDUCTION ) snd_addr = &in6addr_linklocal_allrouters;
@@ -2171,20 +2171,21 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type) payload_len = len +sizeof (ra); full_len =sizeof (struct ipv6hdr ) + payload_len; -rcu_read_lock (); -IP6_UPD_PO_STATS (net,__in6_dev_get (dev), -IPSTATS_MIB_OUT , full_len); -rcu_read_unlock (); + skb =alloc_skb (hlen + tlen + full_len,GFP_KERNEL ); - skb =sock_alloc_send_skb (sk, hlen + tlen + full_len,1 , &err); +rcu_read_lock (); + net =dev_net_rcu (dev); + idev =__in6_dev_get (dev); +IP6_UPD_PO_STATS (net, idev,IPSTATS_MIB_OUT , full_len);if (!skb) { -rcu_read_lock (); -IP6_INC_STATS (net,__in6_dev_get (dev), -IPSTATS_MIB_OUTDISCARDS ); +IP6_INC_STATS (net, idev,IPSTATS_MIB_OUTDISCARDS );rcu_read_unlock ();return ; } + sk = net->ipv6.igmp_sk; +skb_set_owner_w (skb, sk); + skb->priority =TC_PRIO_CONTROL ;skb_reserve (skb, hlen);
@@ -2209,9 +2210,6 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)IPPROTO_ICMPV6 , csum_partial(hdr, len, 0)); -rcu_read_lock (); - idev =__in6_dev_get (skb->dev); -icmpv6_flow_init (sk, &fl6, type, &ipv6_hdr (skb)->saddr, &ipv6_hdr (skb)->daddr, skb->dev->ifindex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 321/595 ALSA: us122l: Prevent write upgrades for read mappings
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kazuki Hanai <[email protected]>
[ Upstream commit 71c610aeb1770302ac9c9e0b9a4ecd37f1311928 ]
The hwdep mmap callback rejects read-buffer mappings that are initially writable, but leaves VM_MAYWRITE set on mappings created with PROT_READ. A process that can open the hwdep node O_RDWR can later use mprotect() to make the mapping writable.
The read allocation begins with struct usb_stream. Its read_size member is used by the fault handler to decide which pages belong to the read buffer. The read VMA intentionally remains expandable because pcm_usb_stream uses mremap() after reading that size. Changing read_size first can therefore map and access pages beyond the allocation. The same member is also consumed by usb_stream_free(), where changing it can make free_pages_exact() release pages outside the allocation.
Clear VM_MAYWRITE for read-buffer mappings after rejecting an initially writable VMA. This keeps the separate output-buffer mapping writable while preventing later permission upgrades.
--- sound/usb/usx2y/us122l.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/usb/usx2y/us122l.c +6 -3
@@ -209,9 +209,12 @@ static int usb_stream_hwdep_mmap(struct snd_hwdep *hw,mutex_lock (&us122l->mutex); s = us122l->sk.s; read = offset < s->read_size; -if (read && area->vm_flags &VM_WRITE ) { - err = -EPERM ; - goto out; +if (read) { +if (area->vm_flags &VM_WRITE ) { + err = -EPERM ; + goto out; + } + area->vm_flags &= ~VM_MAYWRITE ; }snd_printdd (KERN_DEBUG "%lu %u\n" , size, read ? s->read_size : s->write_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 322/595 i2c: smbus: reject oversized block transfers in the common path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit 3051cd060fa496df42954291fa2306ed2eab4ecc upstream.
The SMBus block transfer length data->block[0] is validated in i2c_smbus_xfer_emulated() but that check runs too late for tracepoints and is skipped entirely when the adapter provides a native smbus_xfer implementation. This allows user-controlled oversized block lengths to reach tracepoint memcpy calls and driver callbacks unchecked.
Add an early validation in __i2c_smbus_xfer() that rejects block transfers whose caller-supplied length is zero or exceeds I2C_SMBUS_BLOCK_MAX before any tracepoint fires or driver callback runs. data->block[0] is filled in by the device on SMBus block reads, so the check is scoped to operations where the length is actually supplied by the caller. This is consistent with the existing -EINVAL convention in the emulated path and protects all downstream consumers at once: the smbus_write tracepoint, all native smbus_xfer driver implementations, and the emulated path.
Two distinct bugs are fixed by this change:
Bug 1: smbus_write tracepoint OOB (include/trace/events/smbus.h)
trace_smbus_write() fires before any validation and copies data->block[0]+1 bytes into a 34-byte event buffer. With block[0]=0xfe the tracepoint copies 255 bytes, overflowing by 221.
BUG: KASAN: stack-out-of-bounds in trace_event_raw_event_smbus_write+0x27c/0x530 Read of size 255 at addr ffff88800d98fcf8 by task poc_smbus/91 Call Trace: <TASK> __asan_memcpy+0x23/0x80 trace_event_raw_event_smbus_write+0x27c/0x530 __i2c_smbus_xfer+0x43a/0xa40 i2c_smbus_xfer+0x19e/0x340 i2cdev_ioctl_smbus+0x38f/0x7f0 i2cdev_ioctl+0x35e/0x680 __x64_sys_ioctl+0x147/0x1e0 do_syscall_64+0xcf/0x15a0 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK>
Bug 2: i2c-stub I2C_SMBUS_I2C_BLOCK_DATA OOB (drivers/i2c/i2c-stub.c)
stub_xfer() implements .smbus_xfer directly and only clamps block[0] against 256-command, not I2C_SMBUS_BLOCK_MAX. With block[0]=0xff and command=0 the loop accesses block[1+i] for i up to 254, far past the 34-byte union.
UBSAN: array-index-out-of-bounds in drivers/i2c/i2c-stub.c:223:44 index 34 is out of range for type '__u8 [34]' Call Trace: <TASK> __ubsan_handle_out_of_bounds+0xd7/0x120 stub_xfer+0x1971/0x198f [i2c_stub] __i2c_smbus_xfer+0x306/0xa40 i2c_smbus_xfer+0x19e/0x340 i2cdev_ioctl_smbus+0x38f/0x7f0 i2cdev_ioctl+0x35e/0x680 __x64_sys_ioctl+0x147/0x1e0 do_syscall_64+0xcf/0x15a0 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK>
Both traces reproduced on v7.0-rc6+i2c/for-current with KASAN+UBSAN.
--- drivers/i2c/i2c-core-smbus.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/i2c/i2c-core-smbus.c +12 -0
@@ -563,6 +563,18 @@ s32 __i2c_smbus_xfer(struct i2c_adapterif (res)return res; +/* Reject invalid caller-supplied block lengths before any +* tracepoint or native smbus_xfer callback runs. +*/ +if (data && + (protocol ==I2C_SMBUS_I2C_BLOCK_DATA || + protocol ==I2C_SMBUS_BLOCK_PROC_CALL || + (protocol ==I2C_SMBUS_BLOCK_DATA && + read_write ==I2C_SMBUS_WRITE )) && + (data->block[0 ] ==0 || + data->block[0 ] >I2C_SMBUS_BLOCK_MAX )) +return -EINVAL ; +/* If enabled, the following two tracepoints are conditional on * read_write and protocol. */
Greg Kroah-Hartman
maintainerPATCH 323/595 net: appletalk: fix NULL pointer dereference in aarp_send_ddp()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit 9e7f36ab5b7bf68463faa5f7b926fea8f35597bb upstream.
aarp_send_ddp() calls atalk_find_dev_addr(dev) in the LocalTalk fast path without checking for NULL. When the device has no AppleTalk interface configured (dev->atalk_ptr == NULL), this leads to a NULL pointer dereference at the at->s_net access.
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:aarp_send_ddp (net/appletalk/aarp.c:552 (discriminator 2)) Call Trace: <TASK> atalk_sendmsg (net/appletalk/ddp.c:1715) __sys_sendto (net/socket.c:2265 (discriminator 1)) __x64_sys_sendto (net/socket.c:2272) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
Add a NULL check consistent with the other callers of atalk_find_dev_addr().
--- net/appletalk/aarp.c | 5 +++++ 1 file changed, 5 insertions(+)
net/appletalk/aarp.c +5 -0
@@ -573,6 +573,11 @@ int aarp_send_ddp(struct net_device *devstruct ddpehdr *ddp = (struct ddpehdr *)skb->data;int ft =2 ; +if (!at) { +kfree_skb (skb); +return NET_XMIT_DROP ; + } +/* * Compressible ? *
Greg Kroah-Hartman
maintainerPATCH 324/595 fou: Fix use-after-free in fou_create()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuanqiang Luo <[email protected]>
commit b14361aca6350ff7907b0e9903c7b94dc7d5d4a0 upstream.
fou_create() publishes struct fou through sk_user_data before adding the new FOU port to the per-netns list. If fou_add_to_port_list() fails, the error path frees fou while it is still reachable through sk_user_data. A concurrent receive can then dereference the freed object in fou_from_sock().
This ordering issue was previously noted in the linked discussion.
The failure is reachable when local port 0 is requested. Each socket binds to a different ephemeral port, but fou_cfg_cmp() compares the requested port 0 and reports -EALREADY once an entry already exists.
Release the tunnel socket before freeing fou so sk_user_data is cleared first, and defer reclamation with kfree_rcu() to protect concurrent RCU readers. This matches the lifetime handling in fou_release().
--- net/ipv4/fou_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/fou_core.c +1 -1
@@ -639,9 +639,9 @@ static int fou_create(struct net *net, sreturn 0 ; error: -kfree (fou);if (sock)udp_tunnel_sock_release (sock); +kfree_rcu (fou, rcu);return err; }
Greg Kroah-Hartman
maintainerPATCH 325/595 crypto: sun8i-ss - Remove crypto_rng interface
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit a78446ee6fae86ac8733f120e3ffce2e5d9384f5 upstream.
Since the crypto_rng interface for hardware PRNGs is unused and is redundant with hwrng and the actual Linux RNG, it's being phased out. Most drivers for it were already removed. Go ahead and remove the sun8i-ss support which is one of the only remaining ones.
As usual for crypto_rng, this driver was also buggy: its ->generate() function had a use-after-free vulnerability due to using wait_for_completion_interruptible_timeout() without handling shutting down the DMA operation if a signal is sent. Also, it had a buffer overread bug in the line 'memcpy(ctx->seed, d + dlen, ctx->slen);'. There's no point in fixing these bugs separately only to remove the code anyway, so this commit is marked with Fixes and Cc stable.
--- drivers/crypto/allwinner/Kconfig | 8 - drivers/crypto/allwinner/sun8i-ss/Makefile | 1 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 39 ---- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-prng.c | 175 ---------------------- drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h | 23 -- 5 files changed, 246 deletions(-) delete mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-prng.c
drivers/crypto/allwinner/Kconfig +0 -8
@@ -112,14 +112,6 @@ config CRYPTO_DEV_SUN8I_SS_DEBUG This will create /sys/kernel/debug/sun8i-ss/stats for displaying the number of requests per flow and per algorithm. -config CRYPTO_DEV_SUN8I_SS_PRNG - bool "Support for Allwinner Security System PRNG" - depends on CRYPTO_DEV_SUN8I_SS - select CRYPTO_RNG - help - Select this option if you want to provide kernel-side support for - the Pseudo-Random Number Generator found in the Security System. - config CRYPTO_DEV_SUN8I_SS_HASH bool "Enable support for hash on sun8i-ss" depends on CRYPTO_DEV_SUN8I_SS
drivers/crypto/allwinner/sun8i-ss/Makefile +0 -1
@@ -1,4 +1,3 @@ obj-$(CONFIG_CRYPTO_DEV_SUN8I_SS) += sun8i-ss.o sun8i-ss-y += sun8i-ss-core.o sun8i-ss-cipher.o -sun8i-ss-$(CONFIG_CRYPTO_DEV_SUN8I_SS_PRNG) += sun8i-ss-prng.o sun8i-ss-$(CONFIG_CRYPTO_DEV_SUN8I_SS_HASH) += sun8i-ss-hash.o
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c +0 -39
@@ -22,7 +22,6 @@#include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/reset.h> -#include <crypto/internal/rng.h> #include <crypto/internal/skcipher.h> #include "sun8i-ss.h"
@@ -269,25 +268,6 @@ static struct sun8i_ss_alg_template ss_a .decrypt = sun8i_ss_skdecrypt, } }, -#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_PRNG -{ - .type = CRYPTO_ALG_TYPE_RNG, - .alg.rng = { - .base = { - .cra_name = "stdrng", - .cra_driver_name = "sun8i-ss-prng", - .cra_priority = 300, - .cra_ctxsize = sizeof(struct sun8i_ss_rng_tfm_ctx), - .cra_module = THIS_MODULE, - .cra_init = sun8i_ss_prng_init, - .cra_exit = sun8i_ss_prng_exit, - }, - .generate = sun8i_ss_prng_generate, - .seed = sun8i_ss_prng_seed, - .seedsize =PRNG_SEED_SIZE , - } -}, -#endif#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_HASH { .type = CRYPTO_ALG_TYPE_AHASH, .ss_algo_id = SS_ID_HASH_MD5,
@@ -431,12 +411,6 @@ static int sun8i_ss_debugfs_show(struct ss_algs[i].alg.skcipher.base.cra_name, ss_algs[i].stat_req, ss_algs[i].stat_fb);break ; -case CRYPTO_ALG_TYPE_RNG : -seq_printf (seq,"%s %s reqs=%lu tsize=%lu\n" , - ss_algs[i].alg.rng.base.cra_driver_name, - ss_algs[i].alg.rng.base.cra_name, - ss_algs[i].stat_req, ss_algs[i].stat_bytes); -break ;case CRYPTO_ALG_TYPE_AHASH : seq_printf(seq, "%s %s reqs=%lu fallback=%lu\n", ss_algs[i].alg.hash.halg.base.cra_driver_name,
@@ -626,14 +600,6 @@ static int sun8i_ss_register_algs(structreturn err; }break ; -case CRYPTO_ALG_TYPE_RNG : - err =crypto_register_rng (&ss_algs[i].alg.rng); -if (err) { -dev_err (ss->dev,"Fail to register %s\n" , - ss_algs[i].alg.rng.base.cra_name); - ss_algs[i].ss =NULL ; - } -break ;case CRYPTO_ALG_TYPE_AHASH : id = ss_algs[i].ss_algo_id; ss_method = ss->variant->alg_hash[id];
@@ -675,11 +641,6 @@ static void sun8i_ss_unregister_algs(str ss_algs[i].alg.skcipher.base.cra_name);crypto_unregister_skcipher (&ss_algs[i].alg.skcipher);break ; -case CRYPTO_ALG_TYPE_RNG : -dev_info (ss->dev,"Unregister %d %s\n" , i, - ss_algs[i].alg.rng.base.cra_name); -crypto_unregister_rng (&ss_algs[i].alg.rng); -break ;case CRYPTO_ALG_TYPE_AHASH :dev_info (ss->dev,"Unregister %d %s\n" , i, ss_algs[i].alg.hash.halg.base.cra_name);
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-prng.c deleted +0 -175
175 lines not on this page · raw message
drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h +0 -23
@@ -8,7 +8,6 @@#include <crypto/aes.h> #include <crypto/des.h> #include <crypto/engine.h> -#include <crypto/rng.h> #include <crypto/skcipher.h> #include <linux/atomic.h> #include <linux/debugfs.h>
@@ -26,7 +25,6 @@#define SS_ALG_DES (1 << 2)#define SS_ALG_3DES (2 << 2)#define SS_ALG_MD5 (3 << 2) -#define SS_ALG_PRNG (4 << 2)#define SS_ALG_SHA1 (6 << 2)#define SS_ALG_SHA224 (7 << 2)#define SS_ALG_SHA256 (8 << 2)
@@ -67,8 +65,6 @@#define SS_FLOW0 BIT(30)#define SS_FLOW1 BIT(31) -#define SS_PRNG_CONTINUE BIT(18) -#define MAX_SG 8#define MAXFLOW 2
@@ -78,9 +74,6 @@#define SS_DIE_ID_SHIFT 20#define SS_DIE_ID_MASK 0x07 -#define PRNG_DATA_SIZE (160 / 8) -#define PRNG_SEED_SIZE DIV_ROUND_UP(175, 8) -/* * struct ss_clock - Describe clocks used by sun8i-ss * @name: Name of clock needed by this variant
@@ -215,16 +208,6 @@ struct sun8i_cipher_tfm_ctx { };/* -* struct sun8i_ss_prng_ctx - context for PRNG TFM -* @seed: The seed to use -* @slen: The size of the seed -*/ -struct sun8i_ss_rng_tfm_ctx { -void *seed; -unsigned int slen; -}; - -/* * struct sun8i_ss_hash_tfm_ctx - context for an ahash TFM * @enginectx: crypto_engine used by this TFM * @fallback_tfm: pointer to the fallback TFM
@@ -273,7 +256,6 @@ struct sun8i_ss_alg_template {struct sun8i_ss_dev *ss;union {struct skcipher_alg skcipher; -struct rng_alg rng;struct ahash_alg hash; } alg;#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_DEBUG
@@ -297,11 +279,6 @@ int sun8i_ss_skencrypt(struct skcipher_rint sun8i_ss_get_engine_number (struct sun8i_ss_dev *ss);int sun8i_ss_run_task (struct sun8i_ss_dev *ss,struct sun8i_cipher_req_ctx *rctx,const char *name); -int sun8i_ss_prng_generate (struct crypto_rng *tfm,const u8 *src, -unsigned int slen,u8 *dst,unsigned int dlen); -int sun8i_ss_prng_seed (struct crypto_rng *tfm,const u8 *seed,unsigned int slen); -int sun8i_ss_prng_init (struct crypto_tfm *tfm); -void sun8i_ss_prng_exit (struct crypto_tfm *tfm);int sun8i_ss_hash_crainit (struct crypto_tfm *tfm);void sun8i_ss_hash_craexit (struct crypto_tfm *tfm);
Greg Kroah-Hartman
maintainerPATCH 326/595 crypto: sun8i-ce - Remove crypto_rng interface
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 011556f71d094da61379ae3672692cae2795304e upstream.
Since the crypto_rng interface for hardware PRNGs is unused and is redundant with hwrng and the actual Linux RNG, it's being phased out. Most drivers for it were already removed. Go ahead and remove the sun8i-ce support which is one of the only remaining ones.
Note that the sun8i-ce support for hwrng remains in place. That is the interface that actually matters.
As usual for crypto_rng, this driver was also buggy: its ->generate() function had a use-after-free vulnerability due to using wait_for_completion_interruptible_timeout() without handling shutting down the DMA operation if a signal is sent. There's no point in fixing this separately only to remove the code anyway, so this commit is marked with Fixes and Cc stable.
--- drivers/crypto/allwinner/Kconfig | 8 - drivers/crypto/allwinner/sun8i-ce/Makefile | 1 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 54 ------- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c | 164 ---------------------- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 29 --- 5 files changed, 256 deletions(-) delete mode 100644 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c
drivers/crypto/allwinner/Kconfig +0 -8
@@ -69,14 +69,6 @@ config CRYPTO_DEV_SUN8I_CE_HASH help Say y to enable support for hash algorithms. -config CRYPTO_DEV_SUN8I_CE_PRNG - bool "Support for Allwinner Crypto Engine PRNG" - depends on CRYPTO_DEV_SUN8I_CE - select CRYPTO_RNG - help - Select this option if you want to provide kernel-side support for - the Pseudo-Random Number Generator found in the Crypto Engine. - config CRYPTO_DEV_SUN8I_CE_TRNG bool "Support for Allwinner Crypto Engine TRNG" depends on CRYPTO_DEV_SUN8I_CE
drivers/crypto/allwinner/sun8i-ce/Makefile +0 -1
@@ -1,5 +1,4 @@ obj-$(CONFIG_CRYPTO_DEV_SUN8I_CE) += sun8i-ce.o sun8i-ce-y += sun8i-ce-core.o sun8i-ce-cipher.o sun8i-ce-$(CONFIG_CRYPTO_DEV_SUN8I_CE_HASH) += sun8i-ce-hash.o -sun8i-ce-$(CONFIG_CRYPTO_DEV_SUN8I_CE_PRNG) += sun8i-ce-prng.o sun8i-ce-$(CONFIG_CRYPTO_DEV_SUN8I_CE_TRNG) += sun8i-ce-trng.o
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +0 -54
120 lines not on this page · raw message
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c deleted +0 -164
164 lines not on this page · raw message
drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +0 -29
@@ -15,7 +15,6 @@#include <linux/hw_random.h> #include <crypto/internal/hash.h> #include <crypto/md5.h> -#include <crypto/rng.h> #include <crypto/sha.h> /* CE Registers */
@@ -57,9 +56,7 @@#define CE_ALG_SHA384 20#define CE_ALG_SHA512 21#define CE_ALG_TRNG 48 -#define CE_ALG_PRNG 49#define CE_ALG_TRNG_V2 0x1c -#define CE_ALG_PRNG_V2 0x1d/* Used in ce_variant */ #define CE_ID_NOTSUPP 0xFF
@@ -94,10 +91,6 @@#define ESR_H5 3#define ESR_H6 4 -#define PRNG_DATA_SIZE (160 / 8) -#define PRNG_SEED_SIZE DIV_ROUND_UP(175, 8) -#define PRNG_LD BIT(17) -#define CE_DIE_ID_SHIFT 16#define CE_DIE_ID_MASK 0x07
@@ -130,13 +123,10 @@ struct ce_clock {* bytes or words * @hash_t_dlen_in_bytes: Does the request size for hash is in * bits or words -* @prng_t_dlen_in_bytes: Does the request size for PRNG is in -* bytes or words * @trng_t_dlen_in_bytes: Does the request size for TRNG is in * bytes or words * @ce_clks: list of clocks needed by this variant * @esr: The type of error register -* @prng: The CE_ALG_XXX value for the PRNG * @trng: The CE_ALG_XXX value for the TRNG */ struct ce_variant {
@@ -145,11 +135,9 @@ struct ce_variant {u32 op_mode[CE_ID_OP_MAX ];bool cipher_t_dlen_in_bytes;bool hash_t_dlen_in_bits; -bool prng_t_dlen_in_bytes;bool trng_t_dlen_in_bytes;struct ce_clock ce_clks[CE_MAX_CLOCKS ];int esr; -unsigned char prng;unsigned char trng; };
@@ -300,16 +288,6 @@ struct sun8i_ce_hash_reqctx { };/* -* struct sun8i_ce_prng_ctx - context for PRNG TFM -* @seed: The seed to use -* @slen: The size of the seed -*/ -struct sun8i_ce_rng_tfm_ctx { -void *seed; -unsigned int slen; -}; - -/* * struct sun8i_ce_alg_template - crypto_alg template * @type: the CRYPTO_ALG_TYPE for this template * @ce_algo_id: the CE_ID for this template
@@ -329,7 +307,6 @@ struct sun8i_ce_alg_template {union {struct skcipher_alg skcipher;struct ahash_alg hash; -struct rng_alg rng; } alg;#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG unsigned long stat_req;
@@ -365,11 +342,5 @@ int sun8i_ce_hash_finup(struct ahash_reqint sun8i_ce_hash_digest (struct ahash_request *areq);int sun8i_ce_hash_run (struct crypto_engine *engine,void *breq); -int sun8i_ce_prng_generate (struct crypto_rng *tfm,const u8 *src, -unsigned int slen,u8 *dst,unsigned int dlen); -int sun8i_ce_prng_seed (struct crypto_rng *tfm,const u8 *seed,unsigned int slen); -void sun8i_ce_prng_exit (struct crypto_tfm *tfm); -int sun8i_ce_prng_init (struct crypto_tfm *tfm); -int sun8i_ce_hwrng_register (struct sun8i_ce_dev *ce);void sun8i_ce_hwrng_unregister (struct sun8i_ce_dev *ce);
Greg Kroah-Hartman
maintainerPATCH 327/595 netfilter: nft_set_pipapo_avx2: add missing vzeroupper
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 55dd20f0f4b1be5c9c8a0275d8d763c86563eac2 upstream.
Since pipapo_get_avx2() uses YMM registers, execute vzeroupper before returning from it. This is needed to avoid degrading the performance of any later SSE code that may happen to be executed.
--- net/netfilter/nft_set_pipapo_avx2.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nft_set_pipapo_avx2.c +1 -0
@@ -1248,6 +1248,7 @@ next_match: out:if (i %2 ) scratch->map_index = !map_index; + asmvolatile ("vzeroupper" );kernel_fpu_end ();local_bh_enable ();
Greg Kroah-Hartman
maintainerPATCH 328/595 mptcp: hold mptcp socket before calling tcp_done
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit ab82e996a1fa1b9ae514fa357d9ce8df62321157 upstream.
When processing options from tcp reset path its possible that tcp_done(ssk) drops the last reference on the mptcp socket which results in use-after-free.
Stable-dep-of: 2b0f561f21b2 ("mptcp: avoid unneeded actions on subflow reset") [ Conflicts in subflow.c, because commit 3ba14528684f ("mptcp: avoid
setting TCP_CLOSE state twice") has already been backported and also had the same conflict: this commit here should have been backported first. Fixed now! ]
--- net/mptcp/subflow.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/mptcp/subflow.c +6 -1
@@ -279,11 +279,16 @@ void mptcp_subflow_reset(struct sock *ssstruct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk);struct sock *sk = subflow->conn; +/* must hold: tcp_done() could drop last reference on parent */ +sock_hold (sk); +tcp_send_active_reset (ssk,GFP_ATOMIC );tcp_done (ssk);if (!test_and_set_bit (MPTCP_WORK_CLOSE_SUBFLOW , &mptcp_sk (sk)->flags) &&schedule_work (&mptcp_sk (sk)->work)) -sock_hold (sk); +return ;/* worker will put sk for us */ + +sock_put (sk); }static void subflow_finish_connect (struct sock *sk,const struct sk_buff *skb)
Greg Kroah-Hartman
maintainerPATCH 329/595 mptcp: avoid unneeded actions on subflow reset
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 2b0f561f21b27c40c91ea4975268a06092bd7e9c upstream.
Once in a blue moon, the mptcp receive path can recursively call mptcp_data_ready() via state change under unlucky error conditions, and then try to hold the data lock again.
Break the recursion loop explicitly checking for the exceptional condition.
Add a new flag instead of using an existing one like 'closing', to exit early in subflow_state_change(), and explicitly flush the RX queue at reset time.
This avoids unneeded processing to check for available data -- calling get_mapping_status() and more on a dying subflow -- but also in error reporting and worker scheduling.
Note that we must consume the currently peeked skb before invoking mptcp_dss_corruption to avoid consuming it again after the eventual reset has freed it.
[ Note: conflict in protocol.c, because commit e0ca4057e0ec ("mptcp:
micro-optimize __mptcp_move_skb()") is not in this version, and is part of a consequent rx path refactor. The conflict is in the context, and is easy to resolve, "done = true" can be moved along without consequences. Also, the context is slightly different because there is no DEBUG_NET_WARN_ON_ONCE in this version, see the backport commit 12c1676d598e ("mptcp: handle consistently DSS corruption"). Also a conflict in protocol.h, because __unused is at a different number. Decrement the one from this version and add the new flag above. The context is also a bit different with data_avail being an enum, but that's without consequences here.
Also a conflict in subflow.c, because commit 71154bbe4942 ("mptcp:
fallback earlier on simult connection") was not needed in this version, and cause conflicts in the context, but that's without consequences here. Also, a conflict in the context, because commit 81c1d0290160 ("mptcp: consolidate fallback and non fallback state machine") was not needed in this version. ]
--- net/mptcp/protocol.c | 6 +++--- net/mptcp/protocol.h | 3 ++- net/mptcp/subflow.c | 11 +++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-)
net/mptcp/protocol.c +3 -3
@@ -581,11 +581,11 @@ static bool __mptcp_move_skbs_from_subflif (unlikely (map_remaining < len))mptcp_dss_corruption (msk, ssk); }else { -if (unlikely (!fin)) -mptcp_dss_corruption (msk, ssk); -sk_eat_skb (ssk, skb); done = true; + +if (unlikely (!fin)) +mptcp_dss_corruption (msk, ssk); }WRITE_ONCE (tp->copied_seq, seq);
net/mptcp/protocol.h +2 -1
@@ -314,7 +314,8 @@ struct mptcp_subflow_context { mpc_map : 1, backup : 1, rx_eof : 1, - can_ack : 1; /* only after processing the remote a key */ + can_ack : 1, /* only after processing the remote a key */ + resetting : 1; /* subflow is resetting */enum mptcp_data_avail data_avail;u32 remote_nonce;u64 thmac;
net/mptcp/subflow.c +11 -0
@@ -282,6 +282,10 @@ void mptcp_subflow_reset(struct sock *ss/* must hold: tcp_done() could drop last reference on parent */ sock_hold (sk); + subflow->resetting =1 ; + +/* No need to delay the actual close for to-be discarded data. */ +__skb_queue_purge (&ssk->sk_receive_queue);tcp_send_active_reset (ssk,GFP_ATOMIC );tcp_done (ssk); if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags) &&
@@ -1302,6 +1306,13 @@ static void subflow_state_change(struct__subflow_state_change (sk); +/* Rx queue processing is unneeded, error reporting will take place at +* __mptcp_close_ssk() time and subflow reset can't happen in case of +* fallback: subflow_sched_work_if_closed() would be a no-op. +*/ +if (subflow->resetting) +return ; +if (subflow_simultaneous_connect (sk)) {mptcp_do_fallback (sk);mptcp_rcv_space_init (mptcp_sk (parent), sk);
Greg Kroah-Hartman
maintainerPATCH 330/595 mptcp: close race between scheduler and state change
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 42064de57fb83231fcc89663a94885f228a1ee53 upstream.
The mptcp scheduler may race with subflow sockets state change: data transmission on the selected socket may fail and a later release could try to use mss_now reset to 0 for a divide operation.
Address the issue by explicitly checking for the critical scenario.
[ Note: moved the mss_now check in previous places before commit
d9ca1de8c0cd ("mptcp: move page frag allocation in mptcp_sendmsg()") which is not in this version. ]
--- net/mptcp/protocol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +2 -2
@@ -1381,7 +1381,7 @@ restart: }mptcp_set_timeout (sk, ssk); -if (copied) { +if (copied && mss_now) {tcp_push (ssk, msg->msg_flags, mss_now,tcp_sk (ssk)->nonagle, size_goal);
@@ -1891,7 +1891,7 @@ static void mptcp_worker(struct work_strif (!mptcp_ext_cache_refill (msk))break ; } -if (copied) { +if (copied && mss_now) {tcp_push (ssk, msg.msg_flags, mss_now,tcp_sk (ssk)->nonagle, size_goal);WRITE_ONCE (msk->allow_infinite_fallback, false);
Greg Kroah-Hartman
maintainerPATCH 331/595 iomap: iomap: fix memory corruption when recording errors during writeback
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 3d5f3ba1ac28059bdf7000cae2403e4e984308d2 ]
Every now and then I see this crash on arm64:
Unable to handle kernel NULL pointer dereference at virtual address 00000000000000f8
Buffer I/O error on dev dm-0, logical block 8733687, async page read
Mem abort info:
ESR = 0x0000000096000006
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x06: level 2 translation fault
Data abort info:
ISV = 0, ISS = 0x00000006
CM = 0, WnR = 0
user pgtable: 64k pages, 42-bit VAs, pgdp=0000000139750000
[00000000000000f8] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000, pmd=0000000000000000
Internal error: Oops: 96000006 [#1] PREEMPT SMP
Buffer I/O error on dev dm-0, logical block 8733688, async page read Dumping ftrace buffer:
Buffer I/O error on dev dm-0, logical block 8733689, async page read
(ftrace buffer empty)
XFS (dm-0): log I/O error -5
Modules linked in: dm_thin_pool dm_persistent_data XFS (dm-0): Metadata I/O Error (0x1) detected at xfs_trans_read_buf_map+0x1ec/0x590 [xfs] (fs/xfs/xfs_trans_buf.c:296). dm_bio_prison
XFS (dm-0): Please unmount the filesystem and rectify the problem(s)
XFS (dm-0): xfs_imap_lookup: xfs_ialloc_read_agi() returned error -5, agno 0
dm_bufio dm_log_writes xfs nft_chain_nat xt_REDIRECT nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip6t_REJECT
potentially unexpected fatal signal 6.
nf_reject_ipv6
potentially unexpected fatal signal 6.
ipt_REJECT nf_reject_ipv4
CPU: 1 PID: 122166 Comm: fsstress Tainted: G W 6.0.0-rc5-djwa #rc5 3004c9f1de887ebae86015f2677638ce51ee7 rpcsec_gss_krb5 auth_rpcgss xt_tcpudp ip_set_hash_ip ip_set_hash_net xt_set nft_compat ip_set_hash_mac ip_set nf_tables Hardware name: QEMU KVM Virtual Machine, BIOS 1.5.1 06/16/2021 pstate: 60001000 (nZCv daif -PAN -UAO -TCO -DIT +SSBS BTYPE=--) ip_tables pc : 000003fd6d7df200 x_tables lr : 000003fd6d7df1ec overlay nfsv4 CPU: 0 PID: 54031 Comm: u4:3 Tainted: G W 6.0.0-rc5-djwa #rc5 3004c9f1de887ebae86015f2677638ce51ee7405 Hardware name: QEMU KVM Virtual Machine, BIOS 1.5.1 06/16/2021 Workqueue: writeback wb_workfn sp : 000003ffd9522fd0 (flush-253:0) pstate: 60401005 (nZCv daif +PAN -UAO -TCO -DIT +SSBS BTYPE=--) pc : errseq_set+0x1c/0x100 x29: 000003ffd9522fd0 x28: 0000000000000023 x27: 000002acefeb6780 x26: 0000000000000005 x25: 0000000000000001 x24: 0000000000000000 x23: 00000000ffffffff x22: 0000000000000005 lr : __filemap_set_wb_err+0x24/0xe0 x21: 0000000000000006
sp : fffffe000f80f760
x29: fffffe000f80f760 x28: 0000000000000003 x27: fffffe000f80f9f8
x26: 0000000002523000 x25: 00000000fffffffb x24: fffffe000f80f868
x23: fffffe000f80fbb0 x22: fffffc0180c26a78 x21: 0000000002530000
x20: 0000000000000000 x19: 0000000000000000 x18: 0000000000000000
x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
x14: 0000000000000001 x13: 0000000000470af3 x12: fffffc0058f70000
x11: 0000000000000040 x10: 0000000000001b20 x9 : fffffe000836b288 x8 : fffffc00eb9fd480 x7 : 0000000000f83659 x6 : 0000000000000000 x5 : 0000000000000869 x4 : 0000000000000005 x3 : 00000000000000f8
x20: 000003fd6d740020 x19: 000000000001dd36 x18: 0000000000000001
x17: 000003fd6d78704c x16: 0000000000000001 x15: 000002acfac87668 x2 : 0000000000000ffa x1 : 00000000fffffffb x0 : 00000000000000f8
Call trace: errseq_set+0x1c/0x100 __filemap_set_wb_err+0x24/0xe0 iomap_do_writepage+0x5e4/0xd5c write_cache_pages+0x208/0x674 iomap_writepages+0x34/0x60 xfs_vm_writepages+0x8c/0xcc [xfs 7a861f39c43631f15d3a5884246ba5035d4ca78b] x14: 0000000000000000 x13: 2064656e72757465 x12: 0000000000002180 x11: 000003fd6d8a82d0 x10: 0000000000000000 x9 : 000003fd6d8ae288 x8 : 0000000000000083 x7 : 00000000ffffffff x6 : 00000000ffffffee x5 : 00000000fbad2887 x4 : 000003fd6d9abb58 x3 : 000003fd6d740020 x2 : 0000000000000006 x1 : 000000000001dd36 x0 : 0000000000000000 CPU: 1 PID: 122167 Comm: fsstress Tainted: G W 6.0.0-rc5-djwa #rc5 3004c9f1de887ebae86015f2677638ce51ee7 do_writepages+0x90/0x1c4 __writeback_single_inode+0x4c/0x4ac Hardware name: QEMU KVM Virtual Machine, BIOS 1.5.1 06/16/2021 writeback_sb_inodes+0x214/0x4ac wb_writeback+0xf4/0x3b0 pstate: 60001000 (nZCv daif -PAN -UAO -TCO -DIT +SSBS BTYPE=--) wb_workfn+0xfc/0x580 process_one_work+0x1e8/0x480 pc : 000003fd6d7df200 worker_thread+0x78/0x430
This crash is a result of iomap_writepage_map encountering some sort of error during writeback and wanting to set that error code in the file mapping so that fsync will report it. Unfortunately, the code dereferences folio->mapping after unlocking the folio, which means that another thread could have removed the page from the page cache (writeback doesn't hold the invalidation lock) and give it to somebody else.
At best we crash the system like above; at worst, we corrupt memory or set an error on some other unsuspecting file while failing to record the problems with *this* file. Regardless, fix the problem by reporting the error to the inode mapping.
NOTE: Commit 598ecfbaa742 lifted the XFS writeback code to iomap, so this fix should be backported to XFS in the 4.6-5.4 kernels in addition to iomap in the 5.5-5.19 kernels.
--- fs/iomap/buffered-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/iomap/buffered-io.c +1 -1
@@ -1434,7 +1434,7 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,if (!count)end_page_writeback (page); done: -mapping_set_error (page->mapping, error); +mapping_set_error (inode->i_mapping, error);return error; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 332/595 Reapply "bluetooth/l2cap: sync sock recv cb and release"
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 89e856e124f9ae548572c56b1b70c2255705f8fe ]
This reverts commit 6ecdf922fb6bf92b6942edfa3f1aa874f1fd7c4d.
--- net/bluetooth/l2cap_sock.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
net/bluetooth/l2cap_sock.c +22 -3
@@ -1258,6 +1258,10 @@ static void l2cap_sock_kill(struct sock *sk)BT_DBG ("sk %p state %s" , sk,state_to_string (sk->sk_state)); +/* Sock is dead, so set chan data to NULL, avoid other task use invalid +* sock pointer. +*/ +l2cap_pi (sk)->chan->data =NULL ;/* Kill poor orphan */ l2cap_chan_put (l2cap_pi (sk)->chan);
@@ -1540,12 +1544,25 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)static int l2cap_sock_recv_cb (struct l2cap_chan *chan,struct sk_buff *skb) { -struct sock *sk = chan->data; -struct l2cap_pinfo *pi =l2cap_pi (sk); +struct sock *sk; +struct l2cap_pinfo *pi;int err; -lock_sock (sk); +/* To avoid race with sock_release, a chan lock needs to be added here +* to synchronize the sock. +*/ +l2cap_chan_hold (chan); +l2cap_chan_lock (chan); + sk = chan->data; +if (!sk) { +l2cap_chan_unlock (chan); +l2cap_chan_put (chan); +return -ENXIO ; + } + + pi =l2cap_pi (sk); +lock_sock (sk);if (chan->mode ==L2CAP_MODE_ERTM && !list_empty (&pi->rx_busy)) { err = -ENOMEM ; goto done;
@@ -1594,6 +1611,8 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) done:release_sock (sk); +l2cap_chan_unlock (chan); +l2cap_chan_put (chan);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 333/595 Bluetooth: L2CAP: Fix deadlock
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f1a8f402f13f94263cf349216c257b2985100927 ]
This fixes the following deadlock introduced by 39a92a55be13 ("bluetooth/l2cap: sync sock recv cb and release")
============================================
WARNING: possible recursive locking detected 6.10.0-rc3-g4029dba6b6f1 #6823 Not tainted
--------------------------------------------
kworker/u5:0/35 is trying to acquire lock:ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:l2cap_sock_recv_cb+0x44/0x1e0
but task is already holding lock:ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:l2cap_get_chan_by_scid+0xaf/0xd0
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&chan->lock#2/1);
lock(&chan->lock#2/1);
*** DEADLOCK ***
May be due to missing lock nesting notation
3 locks held by kworker/u5:0/35:
#0: ffff888002b8a940 ((wq_completion)hci0#2){+.+.}-{0:0}, at:
process_one_work+0x750/0x930
#1: ffff888002c67dd0 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0},
at: process_one_work+0x44e/0x930
#2: ffff888002ec2510 (&chan->lock#2/1){+.+.}-{3:3}, at:
l2cap_get_chan_by_scid+0xaf/0xd0To fix the original problem this introduces l2cap_chan_lock at l2cap_conless_channel to ensure that l2cap_sock_recv_cb is called with chan->lock held.
[ Karl Mehltretter: only the l2cap_core.c and l2cap_sock.c hunks apply
to this tree. hci_sync.c and hci_sync.h do not exist here, and the hci_core.c change is an unrelated conversion of hci_dev_cmd() off the old hci_request API. The changes to both L2CAP files apply unmodified.
The lock this adds to l2cap_conless_channel() is also the one that commit c531e63871c0 ("Bluetooth: l2cap: always unlock channel in l2cap_conless_channel()") was backported without, so it additionally pairs the l2cap_chan_unlock() that function currently calls on a mutex it never acquired. ]
--- net/bluetooth/l2cap_core.c | 3 +++ net/bluetooth/l2cap_sock.c | 13 +------------ 2 files changed, 4 insertions(+), 12 deletions(-)
net/bluetooth/l2cap_core.c +3 -0
@@ -8055,6 +8055,8 @@ static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm,BT_DBG ("chan %p, len %d" , chan, skb->len); +l2cap_chan_lock (chan); +if (chan->state !=BT_BOUND && chan->state !=BT_CONNECTED ) goto drop;
@@ -8072,6 +8074,7 @@ static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, } drop: +l2cap_chan_unlock (chan);l2cap_chan_put (chan); free_skb:kfree_skb (skb);
net/bluetooth/l2cap_sock.c +1 -12
@@ -1548,18 +1548,9 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)struct l2cap_pinfo *pi;int err; -/* To avoid race with sock_release, a chan lock needs to be added here -* to synchronize the sock. -*/ -l2cap_chan_hold (chan); -l2cap_chan_lock (chan); sk = chan->data; - -if (!sk) { -l2cap_chan_unlock (chan); -l2cap_chan_put (chan); +if (!sk)return -ENXIO ; - } pi =l2cap_pi (sk);lock_sock (sk);
@@ -1611,8 +1602,6 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) done:release_sock (sk); -l2cap_chan_unlock (chan); -l2cap_chan_put (chan);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 334/595 ARM: fix hash_name() fault
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King (Oracle) <[email protected]>
[ Upstream commit 7733bc7d299d682f2723dc38fc7f370b9bf973e9 ]
Zizhi Wo reports:
"During the execution of hash_name()->load_unaligned_zeropad(), a
potential memory access beyond the PAGE boundary may occur. For example, when the filename length is near the PAGE_SIZE boundary. This triggers a page fault, which leads to a call to do_page_fault()->mmap_read_trylock(). If we can't acquire the lock, we have to fall back to the mmap_read_lock() path, which calls might_sleep(). This breaks RCU semantics because path lookup occurs under an RCU read-side critical section."
This is seen with CONFIG_DEBUG_ATOMIC_SLEEP=y and CONFIG_KFENCE=y.
Kernel addresses (with the exception of the vectors/kuser helper page) do not have VMAs associated with them. If the vectors/kuser helper page faults, then there are two possibilities:
1. if the fault happened while in kernel mode, then we're basically dead, because the CPU won't be able to vector through this page to handle the fault.
2. if the fault happened while in user mode, that means the page was protected from user access, and we want to fault anyway.
Thus, we can handle kernel addresses from any context entirely separately without going anywhere near the mmap lock. This gives us an entirely non-sleeping path for all kernel mode kernel address faults.
As we handle the kernel address faults before interrupts are enabled, this change has the side effect of improving the branch predictor hardening, but does not completely solve the issue.
[ Xie Yuanbin: At the upstream, the following patches are a patch set:
1. commit dea20281ac8822661576 ("ARM: group is_permission_fault() with is_translation_fault()")
2. commit 40b466db1dffb41f0529 ("ARM: allow __do_kernel_fault() to report execution of memory faults")
3. commit 7733bc7d299d682f2723 ("ARM: fix hash_name() fault")
4. commit fd2dee1c6e2256f726ba ("ARM: fix branch predictor hardening") patch 1. and 2. is unneeded for 5.10.y and 5.15.y . This patch backports patch 3. and simply adapts to the context differences. ]
--- arch/arm/mm/fault.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/arm/mm/fault.c +35 -0
@@ -247,6 +247,35 @@ __do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,return fault; } +static int __kprobes +do_kernel_address_page_fault (struct mm_struct *mm,unsigned long addr, +unsigned int fsr,struct pt_regs *regs) +{ +if (user_mode (regs)) { +/* +* Fault from user mode for a kernel space address. User mode +* should not be faulting in kernel space, which includes the +* vector/khelper page. Send a SIGSEGV. +*/ +__do_user_fault (addr, fsr,SIGSEGV ,SEGV_MAPERR , regs); + }else { +/* +* Fault from kernel mode. Enable interrupts if they were +* enabled in the parent context. Section (upper page table) +* translation faults are handled via do_translation_fault(), +* so we will only get here for a non-present kernel space +* PTE or PTE permission fault. This may happen in exceptional +* circumstances and need the fixup tables to be walked. +*/ +if (interrupts_enabled (regs)) +local_irq_enable (); + +__do_kernel_fault (mm, addr, fsr, regs); + } + +return 0 ; +} +static int __kprobes do_page_fault (unsigned long addr,unsigned int fsr,struct pt_regs *regs) {
@@ -261,6 +290,12 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) tsk = current; mm = tsk->mm; +/* +* Handle kernel addresses faults separately, which avoids touching +* the mmap lock from contexts that are not able to sleep. +*/ +if (addr >=TASK_SIZE ) +return do_kernel_address_page_fault (mm, addr, fsr, regs);/* Enable interrupts if they were enabled in the parent context. */ if (interrupts_enabled (regs))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 335/595 ARM: fix branch predictor hardening
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King (Oracle) <[email protected]>
[ Upstream commit fd2dee1c6e2256f726ba33fd3083a7be0efc80d3 ]
__do_user_fault() may be called with indeterminent interrupt enable state, which means we may be preemptive at this point. This causes problems when calling harden_branch_predictor(). For example, when called from a data abort, do_alignment_fault()->do_bad_area().
Move harden_branch_predictor() out of __do_user_fault() and into the calling contexts.
Moving it into do_kernel_address_page_fault(), we can be sure that interrupts will be disabled here.
Converting do_translation_fault() to use do_kernel_address_page_fault() rather than do_bad_area() means that we keep branch predictor handling for translation faults. Interrupts will also be disabled at this call site.
do_sect_fault() needs special handling, so detect user mode accesses to kernel-addresses, and add an explicit call to branch predictor hardening.
Finally, add branch predictor hardening to do_alignment() for the faulting case (user mode accessing kernel addresses) before interrupts are enabled.
This should cover all cases where harden_branch_predictor() is called, ensuring that it is always has interrupts disabled, also ensuring that it is called early in each call path.
[ Xie Yuanbin: At the upstream, the following patches are a patch set:
1. commit dea20281ac8822661576 ("ARM: group is_permission_fault() with is_translation_fault()")
2. commit 40b466db1dffb41f0529 ("ARM: allow __do_kernel_fault() to report execution of memory faults")
3. commit 7733bc7d299d682f2723 ("ARM: fix hash_name() fault")
4. commit fd2dee1c6e2256f726ba ("ARM: fix branch predictor hardening") patch 1. and 2. is unneeded for 5.10.y and 5.15.y . This patch backports patch 4. and simply adapts to the context differences. ]
--- arch/arm/mm/alignment.c | 4 ++++ arch/arm/mm/fault.c | 39 ++++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 13 deletions(-)
arch/arm/mm/alignment.c +4 -0
@@ -23,6 +23,7 @@#include <asm/cp15.h> #include <asm/system_info.h> #include <asm/unaligned.h> +#include <asm/system_misc.h> #include <asm/opcodes.h> #include "fault.h"
@@ -809,6 +810,9 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)int thumb2_32b =0 ;int fault; +if (addr >=TASK_SIZE &&user_mode (regs)) +harden_branch_predictor (); +if (interrupts_enabled (regs))local_irq_enable ();
arch/arm/mm/fault.c +26 -13
@@ -145,9 +145,6 @@ __do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig, {struct task_struct *tsk = current; -if (addr >TASK_SIZE ) -harden_branch_predictor (); -#ifdef CONFIG_DEBUG_USER if (((user_debug &UDBG_SEGV ) && (sig ==SIGSEGV )) || ((user_debug &UDBG_BUS ) && (sig ==SIGBUS ))) {
@@ -255,8 +252,10 @@ do_kernel_address_page_fault(struct mm_struct *mm, unsigned long addr,/* * Fault from user mode for a kernel space address. User mode * should not be faulting in kernel space, which includes the -* vector/khelper page. Send a SIGSEGV. +* vector/khelper page. Handle the branch predictor hardening +* while interrupts are still disabled, then send a SIGSEGV. */ +harden_branch_predictor ();__do_user_fault (addr, fsr,SIGSEGV ,SEGV_MAPERR , regs); }else {/*
@@ -421,16 +420,20 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)* We enter here because the first level page table doesn't contain * a valid entry for the address. * -* If the address is in kernel space (>= TASK_SIZE), then we are -* probably faulting in the vmalloc() area. +* If this is a user address (addr < TASK_SIZE), we handle this as a +* normal page fault. This leaves the remainder of the function to handle +* kernel address translation faults. * -* If the init_task's first level page tables contains the relevant -* entry, we copy the it to this task. If not, we send the process -* a signal, fixup the exception, or oops the kernel. +* Since user mode is not permitted to access kernel addresses, pass these +* directly to do_kernel_address_page_fault() to handle. * -* NOTE! We MUST NOT take any locks for this case. We may be in an -* interrupt or a critical region, and should only copy the information -* from the master page table, nothing more. +* Otherwise, we're probably faulting in the vmalloc() area, so try to fix +* that up. Note that we must not take any locks or enable interrupts in +* this case. +* +* If vmalloc() fixup fails, that means the non-leaf page tables did not +* contain an entry for this address, so handle this via +* do_kernel_address_page_fault(). */ #ifdef CONFIG_MMU static int __kprobes
@@ -496,7 +499,8 @@ do_translation_fault(unsigned long addr, unsigned int fsr,return 0 ; bad_area: -do_bad_area (addr, fsr, regs); +do_kernel_address_page_fault (current->mm, addr, fsr, regs); + return 0; }#else /* CONFIG_MMU */
@@ -516,7 +520,16 @@ do_translation_fault(unsigned long addr, unsigned int fsr,static int do_sect_fault (unsigned long addr,unsigned int fsr,struct pt_regs *regs) { +/* +* If this is a kernel address, but from user mode, then userspace +* is trying bad stuff. Invoke the branch predictor handling. +* Interrupts are disabled here. +*/ +if (addr >=TASK_SIZE &&user_mode (regs)) +harden_branch_predictor (); +do_bad_area (addr, fsr, regs); +return 0 ; }#endif /* CONFIG_ARM_LPAE */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 336/595 ARM: ensure interrupts are enabled in __do_user_fault()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King (Oracle) <[email protected]>
[ Upstream commit 59e4f3b45b96a24fc9b7a89e5f8a2168b30f95af ]
__do_user_fault() may be called from fault handling paths where the interrupts are enabled or disabled. E.g. do_page_fault() calls this with interrupts enabled, whereas do_sect_fault()->do_bad_area() will call this with interrupts disabled. Since this is a userspace fault, we know that interrupts were enabled in the parent context, so call local_irq_enable() here to give a consistent interrupt state.
This is necessary for force_sig_info() when PREEMPT_RT is enabled.
--- arch/arm/mm/fault.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mm/fault.c +5 -1
@@ -137,7 +137,8 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,/* * Something tried to access memory that isn't in our memory map.. -* User mode accesses just cause a SIGSEGV +* User mode accesses just cause a SIGSEGV. Ensure interrupts are enabled +* for preempt RT. */ static void __do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig,
@@ -145,6 +146,8 @@ __do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig, {struct task_struct *tsk = current; +local_irq_enable (); +#ifdef CONFIG_DEBUG_USER if (((user_debug &UDBG_SEGV ) && (sig ==SIGSEGV )) || ((user_debug &UDBG_BUS ) && (sig ==SIGBUS ))) {
@@ -254,6 +257,7 @@ do_kernel_address_page_fault(struct mm_struct *mm, unsigned long addr,* should not be faulting in kernel space, which includes the * vector/khelper page. Handle the branch predictor hardening * while interrupts are still disabled, then send a SIGSEGV. +* Note that __do_user_fault() will enable interrupts. */ harden_branch_predictor ();__do_user_fault (addr, fsr,SIGSEGV ,SEGV_MAPERR , regs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 337/595 sunvdc: fix -EIO issue due to lack of retries
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit 5067d4ba713961d8ccea1e06cd4c453793f3121e ]
John reports that since commit:
a11f6ca9aef9 ("sunvdc: Do not spin in an infinite loop when vio_ldc_send() returns EAGAIN")
users of Linux inside Solaris ldom see occasional -EIO errors because the request send loop now times out. The current loop does 10 retries, and inside vio_ldc_send() a further 1000 1usec retries are done as well. Even with 10.5 msec of busy loop retries that's apparently not enough to always succeed.
Rather than introduce continued busy looping, requeue the request and have the delayed queue kicking retry the request after another 10ms. This obviously isn't ideal, but there's seemingly no way to wait for this type of event. And if 10ms of busy looping was not enough to make progress, then presumably this is an edge condition and we just need to guarantee to make forward progress at some later point in time. That's more suitably done through letting the CPU tend to other work, rather than sitting in a tight loop retrying.
[stian: rebased on top of the cookie-unmap fix, without which every
requeued attempt leaks LDC map table entries; tested on an UltraSPARC T4 LDOM where the vdc_tx_trigger failure condition was reproduced and absorbed by the requeue with no I/O error]
--- drivers/block/sunvdc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/block/sunvdc.c +8 -1
@@ -555,6 +555,7 @@ static blk_status_t vdc_queue_rq(struct blk_mq_hw_ctx *hctx,struct vdc_port *port = hctx->queue->queuedata;struct vio_dring_state *dr;unsigned long flags; +int ret; dr = &port->vio.drings[VIO_DRIVER_TX_RING ];
@@ -576,7 +577,13 @@ static blk_status_t vdc_queue_rq(struct blk_mq_hw_ctx *hctx,return BLK_STS_DEV_RESOURCE ; } -if (__send_request (bd->rq) <0 ) { + ret =__send_request (bd->rq); +if (ret == -EAGAIN ) { +spin_unlock_irqrestore (&port->vio.lock, flags); +/* already spun for 10msec, defer 10msec and retry */ +blk_mq_delay_kick_requeue_list (hctx->queue,10 ); +return BLK_STS_DEV_RESOURCE ; + }else if (ret <0 ) {spin_unlock_irqrestore (&port->vio.lock, flags);return BLK_STS_IOERR ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 338/595 net/smc: check smcd_v2_ext_offset when receiving proposal msg
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangguan Wang <[email protected]>
commit 9ab332deb671d8f7e66d82a2ff2b3f715bc3a4ad upstream.
When receiving proposal msg in server, the field smcd_v2_ext_offset in proposal msg is from the remote client and can not be fully trusted. Once the value of smcd_v2_ext_offset exceed the max value, there has the chance to access wrong address, and crash may happen.
This patch checks the value of smcd_v2_ext_offset before using it.
[ jcao: drop the af_smc.c hunk, the !smcd_v2_ext test already there
covers it; result matches the 5.15.y backport a36364d8d4fab ]
--- net/smc/smc_clc.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/smc/smc_clc.h +7 -1
@@ -306,9 +306,15 @@ smc_get_clc_v2_ext(struct smc_clc_msg_proposal *prop)static inline struct smc_clc_smcd_v2_extension *smc_get_clc_smcd_v2_ext (struct smc_clc_v2_extension *prop_v2ext) { +u16 max_offset = offsetof(struct smc_clc_msg_proposal_area , pclc_smcd_v2_ext) - + offsetof(struct smc_clc_msg_proposal_area , pclc_v2_ext) - + offsetof(struct smc_clc_v2_extension , hdr) - + offsetofend(struct smc_clnt_opts_area_hdr, smcd_v2_ext_offset); +if (!prop_v2ext)return NULL ; -if (!ntohs (prop_v2ext->hdr.smcd_v2_ext_offset)) +if (!ntohs (prop_v2ext->hdr.smcd_v2_ext_offset) || +ntohs (prop_v2ext->hdr.smcd_v2_ext_offset) > max_offset)return NULL ; return (struct smc_clc_smcd_v2_extension *)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 339/595 net/smc: check v2_ext_offset/eid_cnt/ism_gid_cnt when receiving proposal msg
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangguan Wang <[email protected]>
commit 7863c9f3d24ba49dbead7e03dfbe40deb5888fdf upstream.
When receiving proposal msg in server, the fields v2_ext_offset/ eid_cnt/ism_gid_cnt in proposal msg are from the remote client and can not be fully trusted. Especially the field v2_ext_offset, once exceed the max value, there has the chance to access wrong address, and crash may happen.
This patch checks the fields v2_ext_offset/eid_cnt/ism_gid_cnt before using them.
[ jcao: drop the af_smc.c hunk, smc_find_rdma_v2_device_serv() came
with SMC-Rv2 in e49300a6bf62 (v5.16); take SMC_CLC_MAX_UEID from fa0866625543 (v5.16); SMC_MAX_ISM_DEVS is the pre-b40584d14570 name of SMCD_CLC_MAX_V2_GID_ENTRIES ]
--- net/smc/smc_clc.c | 8 +++++++- net/smc/smc_clc.h | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-)
net/smc/smc_clc.c +7 -1
@@ -47,7 +47,6 @@ static bool smc_clc_msg_prop_valid(struct smc_clc_msg_proposal *pclc)struct smc_clc_msg_hdr *hdr = &pclc->hdr;struct smc_clc_v2_extension *v2_ext; - v2_ext =smc_get_clc_v2_ext (pclc); pclc_prfx =smc_clc_proposal_get_prefix (pclc);if (!pclc_prfx || pclc_prfx->ipv6_prefixes_cnt >SMC_CLC_MAX_V6_PREFIX )
@@ -64,6 +63,13 @@ static bool smc_clc_msg_prop_valid(struct smc_clc_msg_proposal *pclc) sizeof(struct smc_clc_msg_trail))return false; } else { + v2_ext =smc_get_clc_v2_ext (pclc); +if ((hdr->typev2 !=SMC_TYPE_N && + (!v2_ext || v2_ext->hdr.eid_cnt >SMC_CLC_MAX_UEID )) || + (smcd_indicated (hdr->typev2) && + v2_ext->hdr.ism_gid_cnt >SMC_MAX_ISM_DEVS )) +return false; + if (ntohs(hdr->length) != sizeof(*pclc) + sizeof(struct smc_clc_msg_smcd) +
net/smc/smc_clc.h +8 -1
@@ -153,6 +153,7 @@ struct smc_clc_msg_proposal { /* clc proposal message sent by Linux */ }__aligned(4) ;#define SMC_CLC_MAX_V6_PREFIX 8 +#define SMC_CLC_MAX_UEID 8struct smc_clc_msg_proposal_area {struct smc_clc_msg_proposal pclc_base;
@@ -292,8 +293,14 @@ static inline struct smc_clc_v2_extension * smc_get_clc_v2_ext(struct smc_clc_msg_proposal *prop) {struct smc_clc_msg_smcd *prop_smcd =smc_get_clc_msg_smcd (prop); +u16 max_offset; -if (!prop_smcd || !ntohs (prop_smcd->v2_ext_offset)) + max_offset = offsetof(struct smc_clc_msg_proposal_area , pclc_v2_ext) - + offsetof(struct smc_clc_msg_proposal_area , pclc_smcd) - + offsetofend(struct smc_clc_msg_smcd, v2_ext_offset); + +if (!prop_smcd || !ntohs (prop_smcd->v2_ext_offset) || +ntohs (prop_smcd->v2_ext_offset) > max_offset)return NULL ; return (struct smc_clc_v2_extension *)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 340/595 Revert "perf cs-etm: Avoid truncating AUX buffer sizes to int"
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 23893444447675e4e0701e24eb31163c8540438d.
--- tools/perf/util/cs-etm.c | 46 +++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 26 deletions(-)
tools/perf/util/cs-etm.c +20 -26
@@ -1065,7 +1065,8 @@ cs_etm__get_trace(struct cs_etm_queue *etmq) etmq->buf_used =0 ; etmq->buf_len = aux_buffer->size; etmq->buf = aux_buffer->data; -return 0 ; + +return etmq->buf_len; } static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm,
@@ -1658,33 +1659,26 @@ static int cs_etm__get_data_block(struct cs_etm_queue *etmq) {int ret; -/* The current block is not finished */ -if (etmq->buf_len) -return 1 ; - - ret =cs_etm__get_trace (etmq); -if (ret <0 ) -return ret; - -/* No more buffer to read */ -if (!etmq->buf_len) -return 0 ; - -/* -* We cannot assume consecutive blocks in the data file -* are contiguous, reset the decoder to force re-sync. -*/ - ret =cs_etm_decoder__reset (etmq->decoder); -if (ret) -return ret; +if (!etmq->buf_len) { + ret =cs_etm__get_trace (etmq); +if (ret <=0 ) +return ret; +/* +* We cannot assume consecutive blocks in the data file +* are contiguous, reset the decoder to force re-sync. +*/ + ret =cs_etm_decoder__reset (etmq->decoder); +if (ret) +return ret; -/* -* Since the decoder is reset, this causes a global trace -* discontinuity. Flush all thread stacks. -*/ -cs_etm__flush_all_stack (etmq); +/* +* Since the decoder is reset, this causes a global trace +* discontinuity. Flush all thread stacks. +*/ +cs_etm__flush_all_stack (etmq); + } -return 1 ; +return etmq->buf_len; } static bool cs_etm__is_svc_instr(struct cs_etm_queue *etmq, u8 trace_chan_id,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 341/595 Revert "perf cs-etm: Flush thread stacks after decoder reset"
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit e7e168699270235880344e3a0c9b8ce5c947ff3a.
--- tools/perf/util/cs-etm.c | 45 ---------------------------------------- 1 file changed, 45 deletions(-)
tools/perf/util/cs-etm.c +0 -45
@@ -1609,45 +1609,6 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq,return 0 ; } - -static int cs_etm__flush_stack_cb (struct thread *thread, -void *data__maybe_unused ) -{ -thread_stack__flush (thread); -return 0 ; -} - -static void cs_etm__flush_machine_stack (struct cs_etm_queue *etmq,pid_t pid) -{ -struct machine *machine; - - machine =machines__find (&etmq->etm->session->machines, pid); -if (machine) -machine__for_each_thread (machine, cs_etm__flush_stack_cb,NULL ); -} - -static void cs_etm__flush_all_stack (struct cs_etm_queue *etmq) -{ -enum cs_etm_pid_fmt pid_fmt =cs_etm__get_pid_fmt (etmq); - -if (!etmq->etm->synth_opts.last_branch) -return ; - -switch (pid_fmt) { -case CS_ETM_PIDFMT_CTXTID2 : -/* Clear the guest stack if virtualization is supported */ -cs_etm__flush_machine_stack (etmq,DEFAULT_GUEST_KERNEL_ID ); - fallthrough; -case CS_ETM_PIDFMT_CTXTID : -cs_etm__flush_machine_stack (etmq,HOST_KERNEL_ID ); -break ; -case CS_ETM_PIDFMT_NONE : -default : -break ; - - } -} -/* * cs_etm__get_data_block: Fetch a block from the auxtrace_buffer queue * if need be.
@@ -1670,12 +1631,6 @@ static int cs_etm__get_data_block(struct cs_etm_queue *etmq) ret =cs_etm_decoder__reset (etmq->decoder);if (ret)return ret; - -/* -* Since the decoder is reset, this causes a global trace -* discontinuity. Flush all thread stacks. -*/ -cs_etm__flush_all_stack (etmq); }return etmq->buf_len;
Signature · 1 line
2.53.0
PATCH 342/595 media: video-i2c: fix buffer queue ordering
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arash Golgol <[email protected]>
[ Upstream commit bc4574c265ed738849e46d942617100580fcedd2 ]
Queued buffers are added to the tail of vid_cap_active in buffer_queue(), but the capture kthread also retrieves buffers from the tail of the list.
This makes the queue behave as LIFO instead of FIFO when multiple buffers are queued.
Fix this by retrieving buffers from the head of the list.
--- drivers/media/i2c/video-i2c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/i2c/video-i2c.c +3 -2
@@ -458,8 +458,9 @@ static int video_i2c_thread_vid_cap(void *priv)spin_lock (&data->slock);if (!list_empty (&data->vid_cap_active)) { - vid_cap_buf =list_last_entry (&data->vid_cap_active, - struct video_i2c_buffer, list); + vid_cap_buf =list_first_entry (&data->vid_cap_active, + struct video_i2c_buffer, + list);list_del (&vid_cap_buf->list); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 343/595 ipv6: Select best matching nexthop object in fib6_table_lookup()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 484bb9d164df397a53e0f533b262b27b1590efcb ]
Currently, when using multipath routes without nexthop objects, fib6_table_lookup() selects the nexthop with the highest score. This means that when both a source address and an oif are specified, the nexthop that is chosen is the one that matches in terms of oif:
# sysctl -wq net.ipv6.conf.all.forwarding=1 # ip address add 2001:db8:2::1/64 dev lo # ip route add 2001:db8:10::/64 nexthop via fe80::1 dev dummy1 nexthop via fe80::2 dev dummy2
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy1; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy1
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy2When using nexthop objects, fib6_table_lookup() selects the first matching nexthop and not necessarily the one with the highest score:
# ip nexthop add id 1 via fe80::1 dev dummy1 # ip nexthop add id 2 via fe80::2 dev dummy2 # ip nexthop add id 3 group 1/2 # ip route add 2001:db8:20::/64 nhid 3
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:20::${i} from 2001:db8:2::1 oif dummy1; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy1
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:20::${i} from 2001:db8:2::1 oif dummy2; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy1This is not very significant right now because the nexthop is later overwritten during path selection in fib6_select_path(). However, the next patch is going to skip path selection when we have an oif match during output route lookup.
As a preparation for this change, align the nexthop object behavior with the legacy one and make sure that fib6_table_lookup() always selects the best matching nexthop. Do that by always returning 0 from rt6_nh_find_match() in order not to terminate the loop in nexthop_for_each_fib6_nh() and storing in arg->nh the best matching nexthop so far.
Behavior after the change:
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:20::${i} from 2001:db8:2::1 oif dummy1; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy1
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:20::${i} from 2001:db8:2::1 oif dummy2; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy2--- net/ipv6/route.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
net/ipv6/route.c +9 -8
@@ -775,9 +775,11 @@ static int rt6_nh_find_match(struct fib6_nh *nh, void *_arg) {struct fib6_nh_frl_arg *arg = _arg; - arg->nh = nh; -return find_match (nh, arg->flags, arg->oif, arg->strict, - arg->mpri, arg->do_rr); +if (find_match (nh, arg->flags, arg->oif, arg->strict, arg->mpri, + arg->do_rr)) + arg->nh = nh; + +return 0 ; } static void __find_rr_leaf(struct fib6_info *f6i_start,
@@ -817,11 +819,10 @@ static void __find_rr_leaf(struct fib6_info *f6i_start, res->nh =nexthop_fib6_nh (f6i->nh);return ; } -if (nexthop_for_each_fib6_nh (f6i->nh, rt6_nh_find_match, - &arg)) { - matched = true; - nh = arg.nh; - } +nexthop_for_each_fib6_nh (f6i->nh, rt6_nh_find_match, + &arg); + matched = !!arg.nh; + nh = arg.nh; }else { nh = f6i->fib6_nh; if (find_match(nh, f6i->fib6_flags, oif, strict,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 344/595 ipv6: Honor oif when choosing nexthop for locally generated traffic
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit d25e7e9d8a6c1e2afb854613e417c6aa1a28ce6f ]
Commit 741a11d9e410 ("net: ipv6: Add RT6_LOOKUP_F_IFACE flag if oif is set") made the kernel honor the oif parameter when specified as part of output route lookup:
# ip route add 2001:db8:1::/64 dev dummy1 # ip route add ::/0 dev dummy2 # ip route get 2001:db8:1::1 oif dummy2 fibmatch default dev dummy2 metric 1024 pref medium
Due to regression reports, the behavior was partially reverted in commit d46a9d678e4c ("net: ipv6: Dont add RT6_LOOKUP_F_IFACE flag if saddr set") to only honor the oif if source address is not specified:
# ip route get 2001:db8:1::1 from 2001:db8:2::1 oif dummy2 fibmatch 2001:db8:1::/64 dev dummy1 metric 1024 pref medium
That is, when source address is specified, the kernel will choose the most specific route even if its nexthop device does not match the specified oif.
This creates a problem for multipath routes. After looking up a route, when source address is not specified, the kernel will choose a nexthop whose nexthop device matches the specified oif:
# sysctl -wq net.ipv6.conf.all.forwarding=1
# ip route add 2001:db8:10::/64 nexthop via fe80::1 dev dummy1 nexthop via fe80::2 dev dummy2
# for i in {1..100}; do ip route get 2001:db8:10::${i} oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
100 dummy2But will disregard the oif when source address is specified despite the fact that a matching nexthop exists:
# for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
53 dummy1
47 dummy2This behavior differs from IPv4:
# ip address add 192.0.2.1/32 dev lo
# ip route add 198.51.100.0/24 nexthop via inet6 fe80::1 dev dummy1 nexthop via inet6 fe80::2 dev dummy2
# for i in {1..100}; do ip route get 198.51.100.${i} from 192.0.2.1 oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
100 dummy2What happens is that fib6_table_lookup() returns a route with a matching nexthop device (assuming it exists):
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy2But it is later overwritten during path selection in fib6_select_path() which instead chooses a nexthop according to the calculated hash.
Solve this by telling fib6_select_path() to skip path selection if we have an oif match during output route lookup (iif being LOOPBACK_IFINDEX).
Behavior after the change:
# sysctl -wq net.ipv6.conf.all.forwarding=1
# ip route add 2001:db8:10::/64 nexthop via fe80::1 dev dummy1 nexthop via fe80::2 dev dummy2
# for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
100 dummy2Note that enabling forwarding is only needed because we did not add neighbor entries for the gateway addresses. When forwarding is disabled and CONFIG_IPV6_ROUTER_PREF is not enabled in kernel config, the kernel will treat non-existing neighbor entries as errors and perform round-robin between the nexthops:
# sysctl -wq net.ipv6.conf.all.forwarding=0
# for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
50 dummy1
50 dummy2--- net/ipv6/route.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv6/route.c +4 -1
@@ -2207,6 +2207,7 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, {struct fib6_result res = {};struct rt6_info *rt =NULL ; +bool have_oif_match;int strict =0 ; WARN_ON_ONCE((flags & RT6_LOOKUP_F_DST_NOREF) &&
@@ -2223,7 +2224,9 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,if (res.f6i == net->ipv6.fib6_null_entry) goto out; -fib6_select_path (net, &res, fl6, oif, false, skb, strict); + have_oif_match = fl6->flowi6_iif ==LOOPBACK_IFINDEX && + oif == res.nh->fib_nh_dev->ifindex; +fib6_select_path (net, &res, fl6, oif, have_oif_match, skb, strict);/*Search through exception table */ rt =rt6_find_cached_rt (&res, &fl6->daddr, &fl6->saddr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 345/595 xfrm: propagate extack to all netlink doit handlers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 3bec6c3e83b5c125ff35e3dae3127c8d62046a1d ]
xfrm_user_rcv_msg() already handles extack, we just need to pass it down.
Stable-dep-of: d1ebd9081879 ("xfrm: fix compat ALLOCSPI request use-after-free")
--- net/xfrm/xfrm_user.c | 56 +++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 22 deletions(-)
net/xfrm/xfrm_user.c +34 -22
@@ -681,7 +681,7 @@ static struct xfrm_state *xfrm_state_construct(struct net *net, }static int xfrm_add_sa (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs,struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_usersa_info *p =nlmsg_data (nlh);
@@ -760,7 +760,7 @@ static struct xfrm_state *xfrm_user_state_lookup(struct net *net, }static int xfrm_del_sa (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs,struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_state *x;
@@ -1206,7 +1206,8 @@ static int build_spdinfo(struct sk_buff *skb, struct net *net, }static int xfrm_set_spdinfo (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrmu_spdhthresh *thresh4 =NULL ;
@@ -1251,7 +1252,8 @@ static int xfrm_set_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_get_spdinfo (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct sk_buff *r_skb;
@@ -1310,7 +1312,8 @@ static int build_sadinfo(struct sk_buff *skb, struct net *net, }static int xfrm_get_sadinfo (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct sk_buff *r_skb;
@@ -1330,7 +1333,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_get_sa (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs,struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_usersa_id *p =nlmsg_data (nlh);
@@ -1354,7 +1357,8 @@ static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_alloc_userspi (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_state *x;
@@ -1706,7 +1710,8 @@ static struct xfrm_policy *xfrm_policy_construct(struct net *net, struct xfrm_us }static int xfrm_add_policy (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_userpolicy_info *p =nlmsg_data (nlh);
@@ -1970,7 +1975,7 @@ static bool xfrm_userpolicy_is_valid(__u8 policy) }static int xfrm_set_default (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs,struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_userpolicy_default *up =nlmsg_data (nlh);
@@ -1991,7 +1996,7 @@ static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_get_default (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs,struct netlink_ext_ack *extack) {struct sk_buff *r_skb;struct nlmsghdr *r_nlh;
@@ -2021,7 +2026,8 @@ static int xfrm_get_default(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_get_policy (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_policy *xp;
@@ -2104,7 +2110,8 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_flush_sa (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct km_event c;
@@ -2204,7 +2211,7 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, const struct }static int xfrm_get_ae (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs,struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_state *x;
@@ -2248,7 +2255,7 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_new_ae (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs,struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_state *x;
@@ -2299,7 +2306,8 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_flush_policy (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct km_event c;
@@ -2327,7 +2335,8 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_add_pol_expire (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_policy *xp;
@@ -2393,7 +2402,8 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_add_sa_expire (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_state *x;
@@ -2427,7 +2437,8 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh, }static int xfrm_add_acquire (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk);struct xfrm_policy *xp;
@@ -2532,7 +2543,7 @@ static int copy_from_user_migrate(struct xfrm_migrate *ma, }static int xfrm_do_migrate (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs,struct netlink_ext_ack *extack) {struct xfrm_userpolicy_id *pi =nlmsg_data (nlh);struct xfrm_migrate m[XFRM_MAX_DEPTH ];
@@ -2578,7 +2589,7 @@ static int xfrm_do_migrate(struct sk_buff *skb, struct nlmsghdr *nlh, }#else static int xfrm_do_migrate (struct sk_buff *skb,struct nlmsghdr *nlh, -struct nlattr **attrs) +struct nlattr **attrs,struct netlink_ext_ack *extack) {return -ENOPROTOOPT ; }
@@ -2775,7 +2786,8 @@ static const struct nla_policy xfrma_spd_policy[XFRMA_SPD_MAX+1] = { }; static const struct xfrm_link { - int (*doit)(struct sk_buff *, struct nlmsghdr *, struct nlattr **); + int (*doit)(struct sk_buff *, struct nlmsghdr *, struct nlattr **, + struct netlink_ext_ack *); int (*start)(struct netlink_callback *); int (*dump)(struct sk_buff *, struct netlink_callback *); int (*done)(struct netlink_callback *);
@@ -2877,7 +2889,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, goto err; } - err = link->doit (skb, nlh, attrs); + err = link->doit (skb, nlh, attrs, extack);/* We need to free skb allocated in xfrm_alloc_compat() before * returning from this function, because consume_skb() won't take
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 346/595 xfrm: add extack to verify_sec_ctx_len
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 08a717e4803798e066aa6b69ebf69da9fc8e1758 ]
Stable-dep-of: d1ebd9081879 ("xfrm: fix compat ALLOCSPI request use-after-free")
--- net/xfrm/xfrm_user.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
net/xfrm/xfrm_user.c +9 -7
@@ -101,7 +101,7 @@ static void verify_one_addr(struct nlattr **attrs, enum xfrm_attr_type_t type, *addrp =nla_data (rt); } -static inline int verify_sec_ctx_len (struct nlattr **attrs) +static inline int verify_sec_ctx_len (struct nlattr **attrs,struct netlink_ext_ack *extack) {struct nlattr *rt = attrs[XFRMA_SEC_CTX ];struct xfrm_user_sec_ctx *uctx;
@@ -111,8 +111,10 @@ static inline int verify_sec_ctx_len(struct nlattr **attrs) uctx =nla_data (rt);if (uctx->len >nla_len (rt) || - uctx->len != (sizeof (struct xfrm_user_sec_ctx ) + uctx->ctx_len)) + uctx->len != (sizeof (struct xfrm_user_sec_ctx ) + uctx->ctx_len)) { +NL_SET_ERR_MSG (extack,"Invalid security context length" );return -EINVAL ; + }return 0 ; }
@@ -267,7 +269,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, goto out;if ((err =verify_one_alg (attrs,XFRMA_ALG_COMP ))) goto out; -if ((err =verify_sec_ctx_len (attrs))) +if ((err =verify_sec_ctx_len (attrs,NULL ))) goto out;if ((err =verify_replay (p, attrs))) goto out;
@@ -1723,7 +1725,7 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, err =verify_newpolicy_info (p);if (err)return err; - err =verify_sec_ctx_len (attrs); + err =verify_sec_ctx_len (attrs, extack);if (err)return err;
@@ -2062,7 +2064,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,struct nlattr *rt = attrs[XFRMA_SEC_CTX ];struct xfrm_sec_ctx *ctx; - err =verify_sec_ctx_len (attrs); + err =verify_sec_ctx_len (attrs, extack);if (err)return err;
@@ -2367,7 +2369,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,struct nlattr *rt = attrs[XFRMA_SEC_CTX ];struct xfrm_sec_ctx *ctx; - err =verify_sec_ctx_len (attrs); + err =verify_sec_ctx_len (attrs, extack);if (err)return err;
@@ -2459,7 +2461,7 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh, err =verify_newpolicy_info (&ua->policy);if (err) goto free_state; - err =verify_sec_ctx_len (attrs); + err =verify_sec_ctx_len (attrs, extack);if (err) goto free_state;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 347/595 xfrm: add extack support to verify_newsa_info
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 6999aae17a7b66c56e6cc8e05b3cd51718c3bfe3 ]
Stable-dep-of: d1ebd9081879 ("xfrm: fix compat ALLOCSPI request use-after-free")
--- net/xfrm/xfrm_user.c | 90 +++++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 21 deletions(-)
net/xfrm/xfrm_user.c +69 -21
@@ -148,7 +148,8 @@ static inline int verify_replay(struct xfrm_usersa_info *p, }static int verify_newsa_info (struct xfrm_usersa_info *p, -struct nlattr **attrs) +struct nlattr **attrs, +struct netlink_ext_ack *extack) {int err;u16 family = p->sel.family;
@@ -163,10 +164,12 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,break ;#else err = -EAFNOSUPPORT ; +NL_SET_ERR_MSG (extack,"IPv6 support disabled" ); goto out;#endif default : +NL_SET_ERR_MSG (extack,"Invalid address family" ); goto out; }
@@ -178,65 +181,98 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,break ;case AF_INET : -if (p->sel.prefixlen_d >32 || p->sel.prefixlen_s >32 ) +if (p->sel.prefixlen_d >32 || p->sel.prefixlen_s >32 ) { +NL_SET_ERR_MSG (extack,"Invalid prefix length in selector (must be <= 32 for IPv4)" ); goto out; + }break ;case AF_INET6 :#if IS_ENABLED (CONFIG_IPV6 ) -if (p->sel.prefixlen_d >128 || p->sel.prefixlen_s >128 ) +if (p->sel.prefixlen_d >128 || p->sel.prefixlen_s >128 ) { +NL_SET_ERR_MSG (extack,"Invalid prefix length in selector (must be <= 128 for IPv6)" ); goto out; + }break ;#else +NL_SET_ERR_MSG (extack,"IPv6 support disabled" ); err = -EAFNOSUPPORT ; goto out;#endif default : +NL_SET_ERR_MSG (extack,"Invalid address family in selector" ); goto out; } err = -EINVAL ;switch (p->id.proto) {case IPPROTO_AH : -if ((!attrs[XFRMA_ALG_AUTH ] && - !attrs[XFRMA_ALG_AUTH_TRUNC ]) || - attrs[XFRMA_ALG_AEAD ] || +if (!attrs[XFRMA_ALG_AUTH ] && + !attrs[XFRMA_ALG_AUTH_TRUNC ]) { +NL_SET_ERR_MSG (extack,"Missing required attribute for AH: AUTH_TRUNC or AUTH" ); + goto out; + } + +if (attrs[XFRMA_ALG_AEAD ] || attrs[XFRMA_ALG_CRYPT ] || attrs[XFRMA_ALG_COMP ] || - attrs[XFRMA_TFCPAD ]) + attrs[XFRMA_TFCPAD ]) { +NL_SET_ERR_MSG (extack,"Invalid attributes for AH: AEAD, CRYPT, COMP, TFCPAD" ); goto out; + }break ;case IPPROTO_ESP : -if (attrs[XFRMA_ALG_COMP ]) +if (attrs[XFRMA_ALG_COMP ]) { +NL_SET_ERR_MSG (extack,"Invalid attribute for ESP: COMP" ); goto out; + } +if (!attrs[XFRMA_ALG_AUTH ] && !attrs[XFRMA_ALG_AUTH_TRUNC ] && !attrs[XFRMA_ALG_CRYPT ] && - !attrs[XFRMA_ALG_AEAD ]) + !attrs[XFRMA_ALG_AEAD ]) { +NL_SET_ERR_MSG (extack,"Missing required attribute for ESP: at least one of AUTH, AUTH_TRUNC, CRYPT, AEAD" ); goto out; + } +if ((attrs[XFRMA_ALG_AUTH ] || attrs[XFRMA_ALG_AUTH_TRUNC ] || attrs[XFRMA_ALG_CRYPT ]) && - attrs[XFRMA_ALG_AEAD ]) + attrs[XFRMA_ALG_AEAD ]) { +NL_SET_ERR_MSG (extack,"Invalid attribute combination for ESP: AEAD can't be used with AUTH, AUTH_TRUNC, CRYPT" ); goto out; + } +if (attrs[XFRMA_TFCPAD ] && - p->mode !=XFRM_MODE_TUNNEL ) + p->mode !=XFRM_MODE_TUNNEL ) { +NL_SET_ERR_MSG (extack,"TFC padding can only be used in tunnel mode" ); goto out; + }break ;case IPPROTO_COMP : -if (!attrs[XFRMA_ALG_COMP ] || - attrs[XFRMA_ALG_AEAD ] || +if (!attrs[XFRMA_ALG_COMP ]) { +NL_SET_ERR_MSG (extack,"Missing required attribute for COMP: COMP" ); + goto out; + } + +if (attrs[XFRMA_ALG_AEAD ] || attrs[XFRMA_ALG_AUTH ] || attrs[XFRMA_ALG_AUTH_TRUNC ] || attrs[XFRMA_ALG_CRYPT ] || - attrs[XFRMA_TFCPAD ] || - (ntohl (p->id.spi) >=0x10000 )) + attrs[XFRMA_TFCPAD ]) { +NL_SET_ERR_MSG (extack,"Invalid attributes for COMP: AEAD, AUTH, AUTH_TRUNC, CRYPT, TFCPAD" ); + goto out; + } + +if (ntohl (p->id.spi) >=0x10000 ) { +NL_SET_ERR_MSG (extack,"SPI is too large for COMP (must be < 0x10000)" ); goto out; + }break ;#if IS_ENABLED (CONFIG_IPV6 )
@@ -249,13 +285,20 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, attrs[XFRMA_ALG_CRYPT] || attrs[XFRMA_ENCAP] || attrs[XFRMA_SEC_CTX] || - attrs[XFRMA_TFCPAD ] || - !attrs[XFRMA_COADDR]) + attrs[XFRMA_TFCPAD]) { +NL_SET_ERR_MSG (extack,"Invalid attributes for DSTOPTS/ROUTING" ); + goto out; + } + +if (!attrs[XFRMA_COADDR ]) { +NL_SET_ERR_MSG (extack,"Missing required COADDR attribute for DSTOPTS/ROUTING" ); goto out; + }break ;#endif default : +NL_SET_ERR_MSG (extack,"Unsupported protocol" ); goto out; }
@@ -269,7 +312,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, goto out;if ((err =verify_one_alg (attrs,XFRMA_ALG_COMP ))) goto out; -if ((err =verify_sec_ctx_len (attrs,NULL ))) +if ((err =verify_sec_ctx_len (attrs, extack))) goto out;if ((err =verify_replay (p, attrs))) goto out;
@@ -283,14 +326,19 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,break ;default : +NL_SET_ERR_MSG (extack,"Unsupported mode" ); goto out; } err =0 ; -if (attrs[XFRMA_MTIMER_THRESH ]) -if (!attrs[XFRMA_ENCAP ]) +if (attrs[XFRMA_MTIMER_THRESH ]) { +if (!attrs[XFRMA_ENCAP ]) { +NL_SET_ERR_MSG (extack,"MTIMER_THRESH attribute can only be set on ENCAP states" ); err = -EINVAL ; + goto out; + } + } out:return err;
@@ -691,7 +739,7 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh,int err;struct km_event c; - err =verify_newsa_info (p, attrs); + err =verify_newsa_info (p, attrs, extack);if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 348/595 xfrm: add extack to verify_one_alg, verify_auth_trunc, verify_aead
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 1fc8fde553917bca7c9b65fafb045a2a5c97e683 ]
Stable-dep-of: d1ebd9081879 ("xfrm: fix compat ALLOCSPI request use-after-free")
--- net/xfrm/xfrm_user.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
net/xfrm/xfrm_user.c +20 -11
@@ -34,7 +34,8 @@#endif #include <asm/unaligned.h> -static int verify_one_alg (struct nlattr **attrs,enum xfrm_attr_type_t type) +static int verify_one_alg (struct nlattr **attrs,enum xfrm_attr_type_t type, +struct netlink_ext_ack *extack) {struct nlattr *rt = attrs[type];struct xfrm_algo *algp;
@@ -43,8 +44,10 @@ static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)return 0 ; algp =nla_data (rt); -if (nla_len (rt) < (int )xfrm_alg_len (algp)) +if (nla_len (rt) < (int )xfrm_alg_len (algp)) { +NL_SET_ERR_MSG (extack,"Invalid AUTH/CRYPT/COMP attribute length" );return -EINVAL ; + }switch (type) {case XFRMA_ALG_AUTH :
@@ -53,6 +56,7 @@ static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)break ;default : +NL_SET_ERR_MSG (extack,"Invalid algorithm attribute type" );return -EINVAL ; }
@@ -60,7 +64,8 @@ static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)return 0 ; } -static int verify_auth_trunc (struct nlattr **attrs) +static int verify_auth_trunc (struct nlattr **attrs, +struct netlink_ext_ack *extack) {struct nlattr *rt = attrs[XFRMA_ALG_AUTH_TRUNC ];struct xfrm_algo_auth *algp;
@@ -69,14 +74,16 @@ static int verify_auth_trunc(struct nlattr **attrs)return 0 ; algp =nla_data (rt); -if (nla_len (rt) < (int )xfrm_alg_auth_len (algp)) +if (nla_len (rt) < (int )xfrm_alg_auth_len (algp)) { +NL_SET_ERR_MSG (extack,"Invalid AUTH_TRUNC attribute length" );return -EINVAL ; + } algp->alg_name[sizeof (algp->alg_name) -1 ] ='\0' ;return 0 ; } -static int verify_aead (struct nlattr **attrs) +static int verify_aead (struct nlattr **attrs,struct netlink_ext_ack *extack) {struct nlattr *rt = attrs[XFRMA_ALG_AEAD ];struct xfrm_algo_aead *algp;
@@ -85,8 +92,10 @@ static int verify_aead(struct nlattr **attrs)return 0 ; algp =nla_data (rt); -if (nla_len (rt) < (int )aead_len (algp)) +if (nla_len (rt) < (int )aead_len (algp)) { +NL_SET_ERR_MSG (extack,"Invalid AEAD attribute length" );return -EINVAL ; + } algp->alg_name[sizeof (algp->alg_name) -1 ] ='\0' ;return 0 ;
@@ -302,15 +311,15 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, goto out; } -if ((err =verify_aead (attrs))) +if ((err =verify_aead (attrs, extack))) goto out; -if ((err =verify_auth_trunc (attrs))) +if ((err =verify_auth_trunc (attrs, extack))) goto out; -if ((err =verify_one_alg (attrs,XFRMA_ALG_AUTH ))) +if ((err =verify_one_alg (attrs,XFRMA_ALG_AUTH , extack))) goto out; -if ((err =verify_one_alg (attrs,XFRMA_ALG_CRYPT ))) +if ((err =verify_one_alg (attrs,XFRMA_ALG_CRYPT , extack))) goto out; -if ((err =verify_one_alg (attrs,XFRMA_ALG_COMP ))) +if ((err =verify_one_alg (attrs,XFRMA_ALG_COMP , extack))) goto out;if ((err =verify_sec_ctx_len (attrs, extack))) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 349/595 xfrm: avoid RCU warnings around the per-netns netlink socket
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit d87f8bc47fbf012a7f115e311d0603d97e47c34c ]
net->xfrm.nlsk is used in 2 types of contexts:
- fully under RCU, with rcu_read_lock + rcu_dereference and a NULL check
- in the netlink handlers, with requests coming from a userspace socket
In the 2nd case, net->xfrm.nlsk is guaranteed to stay non-NULL and the object is alive, since we can't enter the netns destruction path while the user socket holds a reference on the netns.
After adding the __rcu annotation to netns_xfrm.nlsk (which silences sparse warnings in the RCU users and __net_init code), we need to tell sparse that the 2nd case is safe. Add a helper for that.
Stable-dep-of: d1ebd9081879 ("xfrm: fix compat ALLOCSPI request use-after-free")
--- include/net/netns/xfrm.h | 2 +- net/xfrm/xfrm_user.c | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-)
include/net/netns/xfrm.h +1 -1
@@ -58,7 +58,7 @@ struct netns_xfrm {struct list_head inexact_bins; -struct sock *nlsk; +struct sock __rcu *nlsk;struct sock *nlsk_stash;u32 sysctl_aevent_etime;
net/xfrm/xfrm_user.c +17 -8
@@ -34,6 +34,15 @@#endif #include <asm/unaligned.h> +static struct sock *xfrm_net_nlsk (const struct net *net,const struct sk_buff *skb) +{ +/* get the source of this request, see netlink_unicast_kernel */ +const struct sock *sk =NETLINK_CB (skb).sk; + +/* sk is refcounted, the netns stays alive and nlsk with it */ +return rcu_dereference_protected (net->xfrm.nlsk, sk->sk_net_refcnt); +} +static int verify_one_alg (struct nlattr **attrs,enum xfrm_attr_type_t type,struct netlink_ext_ack *extack) {
@@ -1328,7 +1337,7 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, err =build_spdinfo (r_skb, net, sportid, seq, *flags);BUG_ON (err <0 ); -return nlmsg_unicast (net->xfrm.nlsk, r_skb, sportid); +return nlmsg_unicast (xfrm_net_nlsk (net, skb), r_skb, sportid); }static inline unsigned int xfrm_sadinfo_msgsize (void )
@@ -1388,7 +1397,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, err =build_sadinfo (r_skb, net, sportid, seq, *flags);BUG_ON (err <0 ); -return nlmsg_unicast (net->xfrm.nlsk, r_skb, sportid); +return nlmsg_unicast (xfrm_net_nlsk (net, skb), r_skb, sportid); } static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -1408,7 +1417,7 @@ static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,if (IS_ERR (resp_skb)) { err =PTR_ERR (resp_skb); }else { - err =nlmsg_unicast (net->xfrm.nlsk, resp_skb,NETLINK_CB (skb).portid); + err =nlmsg_unicast (xfrm_net_nlsk (net, skb), resp_skb,NETLINK_CB (skb).portid); }xfrm_state_put (x); out_noput:
@@ -1484,7 +1493,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, } } - err =nlmsg_unicast (net->xfrm.nlsk, resp_skb,NETLINK_CB (skb).portid); + err =nlmsg_unicast (xfrm_net_nlsk (net, skb), resp_skb,NETLINK_CB (skb).portid); out:xfrm_state_put (x);
@@ -2081,7 +2090,7 @@ static int xfrm_get_default(struct sk_buff *skb, struct nlmsghdr *nlh, r_up->out = net->xfrm.policy_default[XFRM_POLICY_OUT ];nlmsg_end (r_skb, r_nlh); -return nlmsg_unicast (net->xfrm.nlsk, r_skb, portid); +return nlmsg_unicast (xfrm_net_nlsk (net, skb), r_skb, portid); } static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -2147,7 +2156,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,if (IS_ERR (resp_skb)) { err =PTR_ERR (resp_skb); }else { - err =nlmsg_unicast (net->xfrm.nlsk, resp_skb, + err =nlmsg_unicast (xfrm_net_nlsk (net, skb), resp_skb,NETLINK_CB (skb).portid); } }else {
@@ -2307,7 +2316,7 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh, err =build_aevent (r_skb, x, &c);BUG_ON (err <0 ); - err =nlmsg_unicast (net->xfrm.nlsk, r_skb,NETLINK_CB (skb).portid); + err =nlmsg_unicast (xfrm_net_nlsk (net, skb), r_skb,NETLINK_CB (skb).portid);spin_unlock_bh (&x->lock);xfrm_state_put (x);return err;
@@ -2933,7 +2942,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, goto err; } - err =netlink_dump_start (net->xfrm.nlsk, skb, nlh, &c); + err =netlink_dump_start (xfrm_net_nlsk (net, skb), skb, nlh, &c); goto err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 350/595 xfrm: fix compat ALLOCSPI request use-after-free
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit d1ebd9081879fd9ae9c8fb7e8928f19cc88ae320 ]
xfrm_state_netlink() builds the ALLOCSPI response with dump_one_state(), which already calls alloc_compat() with the response skb and header.
xfrm_alloc_userspi() then calls alloc_compat() again, but passes the original request skb and its header. For a compat request, the translator therefore interprets the 228-byte compat xfrm_userspi_info as the 232-byte native layout and reads four bytes past the declared payload. It also publishes the translated child through the request's frag_list.
A multicast clone of the request shares skb_shared_info and can observe that child. xfrm_user_rcv_msg() frees it after the request handler returns, racing a compat receiver which may still be copying from it and resulting in a use-after-free.
Remove the redundant conversion. The response keeps its correct compat translation from dump_one_state(), and no child is attached to the inbound request.
--- net/xfrm/xfrm_user.c | 12 ------------ 1 file changed, 12 deletions(-)
net/xfrm/xfrm_user.c +0 -12
@@ -1431,7 +1431,6 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh,struct net *net =sock_net (skb->sk);struct xfrm_state *x;struct xfrm_userspi_info *p; -struct xfrm_translator *xtr;struct sk_buff *resp_skb;xfrm_address_t *daddr;int family;
@@ -1482,17 +1481,6 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, goto out; } - xtr =xfrm_get_translator (); -if (xtr) { - err = xtr->alloc_compat (skb,nlmsg_hdr (skb)); - -xfrm_put_translator (xtr); -if (err) { -kfree_skb (resp_skb); - goto out; - } - } - err =nlmsg_unicast (xfrm_net_nlsk (net, skb), resp_skb,NETLINK_CB (skb).portid); out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 351/595 ARM: socfpga: select the PL310 erratum 753970 workaround
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit cfc1e9a543e3589ba200795b6e7fd8ef4314efdf ]
ARCH_INTEL_SOCFPGA selects CACHE_L2X0 and several PL310 erratum workarounds. The 753970 workaround is still conditioned on PL310, but that Kconfig symbol no longer exists, so this one selection is always disabled.
Select PL310_ERRATA_753970 directly, consistently with the other PL310 workarounds required by the platform.
--- arch/arm/mach-socfpga/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/Kconfig +1 -1
@@ -17,7 +17,7 @@ menuconfig ARCH_SOCFPGA select ARM_ERRATA_775420 select PL310_ERRATA_588369 select PL310_ERRATA_727915 - select PL310_ERRATA_753970 if PL310 + select PL310_ERRATA_753970 select PL310_ERRATA_769419 select RESET_CONTROLLER
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 352/595 RDMA/siw: Introduce siw_cep_set_free_and_put
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guoqing Jiang <[email protected]>
[ Upstream commit b5c91543204c345f1b28af573854c4b7e699cc91 ]
Add the helper which can be used in some places.
Stable-dep-of: 32cd87f54dd1 ("RDMA/siw: Clear association under lock if siw_qp_modify fails in siw_accept")
--- drivers/infiniband/sw/siw/siw_cm.c | 31 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +14 -17
@@ -450,6 +450,12 @@ void siw_cep_put(struct siw_cep *cep)kref_put (&cep->ref, __siw_cep_dealloc); } +static void siw_cep_set_free_and_put (struct siw_cep *cep) +{ +siw_cep_set_free (cep); +siw_cep_put (cep); +} +void siw_cep_get (struct siw_cep *cep) {kref_get (&cep->ref);
@@ -1511,9 +1517,7 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params) cep->state =SIW_EPSTATE_CLOSED ; -siw_cep_set_free (cep); - -siw_cep_put (cep); +siw_cep_set_free_and_put (cep); }else if (s) {sock_release (s);
@@ -1561,16 +1565,14 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)if (cep->state !=SIW_EPSTATE_RECVD_MPAREQ ) {siw_dbg_cep (cep,"out of state\n" ); -siw_cep_set_free (cep); -siw_cep_put (cep); +siw_cep_set_free_and_put (cep);return -ECONNRESET ; } qp =siw_qp_id2obj (sdev, params->qpn);if (!qp) {WARN (1 ,"[QP %d] does not exist\n" , params->qpn); -siw_cep_set_free (cep); -siw_cep_put (cep); +siw_cep_set_free_and_put (cep);return -EINVAL ; }
@@ -1713,8 +1715,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) cep->qp =NULL ;siw_qp_put (qp); -siw_cep_set_free (cep); -siw_cep_put (cep); +siw_cep_set_free_and_put (cep);return rv; }
@@ -1737,8 +1738,7 @@ int siw_reject(struct iw_cm_id *id, const void *pdata, u8 pd_len)if (cep->state !=SIW_EPSTATE_RECVD_MPAREQ ) {siw_dbg_cep (cep,"out of state\n" ); -siw_cep_set_free (cep); -siw_cep_put (cep);/* put last reference */ +siw_cep_set_free_and_put (cep);/* put last reference */ return -ECONNRESET ; }
@@ -1755,8 +1755,7 @@ int siw_reject(struct iw_cm_id *id, const void *pdata, u8 pd_len) cep->state =SIW_EPSTATE_CLOSED ; -siw_cep_set_free (cep); -siw_cep_put (cep); +siw_cep_set_free_and_put (cep);return 0 ; }
@@ -1879,8 +1878,7 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)siw_socket_disassoc (s); cep->state =SIW_EPSTATE_CLOSED ; -siw_cep_set_free (cep); -siw_cep_put (cep); +siw_cep_set_free_and_put (cep); }sock_release (s);
@@ -1911,8 +1909,7 @@ static void siw_drop_listeners(struct iw_cm_id *id) cep->sock =NULL ; } cep->state =SIW_EPSTATE_CLOSED ; -siw_cep_set_free (cep); -siw_cep_put (cep); +siw_cep_set_free_and_put (cep); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 353/595 RDMA/siw: Cleanup siw_accept
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guoqing Jiang <[email protected]>
[ Upstream commit 77b59bd932a026b64303d313d966decb0e9225fa ]
With the initialization of rv and the two added label, we can simplifiy code a bit.
Stable-dep-of: 32cd87f54dd1 ("RDMA/siw: Clear association under lock if siw_qp_modify fails in siw_accept")
--- drivers/infiniband/sw/siw/siw_cm.c | 41 ++++++++++-------------------- 1 file changed, 14 insertions(+), 27 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +14 -27
@@ -1548,7 +1548,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)struct siw_cep *cep = (struct siw_cep *)id->provider_data;struct siw_qp *qp;struct siw_qp_attrs qp_attrs; -int rv, max_priv_data =MPA_MAX_PRIVDATA ; +int rv = -EINVAL , max_priv_data =MPA_MAX_PRIVDATA ;bool wait_for_peer_rts = false;siw_cep_set_inuse (cep);
@@ -1564,24 +1564,17 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)if (cep->state !=SIW_EPSTATE_RECVD_MPAREQ ) {siw_dbg_cep (cep,"out of state\n" ); - -siw_cep_set_free_and_put (cep); - -return -ECONNRESET ; + rv = -ECONNRESET ; + goto free_cep; } qp =siw_qp_id2obj (sdev, params->qpn);if (!qp) {WARN (1 ,"[QP %d] does not exist\n" , params->qpn); -siw_cep_set_free_and_put (cep); - -return -EINVAL ; + goto free_cep; }down_write (&qp->state_lock); -if (qp->attrs.state >SIW_QP_STATE_RTR ) { - rv = -EINVAL ; -up_write (&qp->state_lock); - goto error; - } +if (qp->attrs.state >SIW_QP_STATE_RTR ) + goto error_unlock;siw_dbg_cep (cep,"[QP %d]\n" , params->qpn);if (try_gso && cep->mpa.hdr.params.bits &MPA_RR_FLAG_GSO_EXP ) {
@@ -1595,9 +1588,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)"[QP %u]: ord %d (max %d), ird %d (max %d)\n" ,qp_id (qp), params->ord, sdev->attrs.max_ord, params->ird, sdev->attrs.max_ird); - rv = -EINVAL ; -up_write (&qp->state_lock); - goto error; + goto error_unlock; }if (cep->enhanced_rdma_conn_est) max_priv_data -=sizeof (struct mpa_v2_data );
@@ -1607,9 +1598,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) cep,"[QP %u]: private data length: %d (max %d)\n" , qp_id(qp), params->private_data_len, max_priv_data); - rv = -EINVAL ; -up_write (&qp->state_lock); - goto error; + goto error_unlock; }if (cep->enhanced_rdma_conn_est) {if (params->ord > cep->ord) {
@@ -1618,9 +1607,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) }else { cep->ird = params->ird; cep->ord = params->ord; - rv = -EINVAL ; -up_write (&qp->state_lock); - goto error; + goto error_unlock; } }if (params->ird < cep->ird) {
@@ -1629,8 +1616,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) params->ird = cep->ird; else { rv = -ENOMEM ; -up_write (&qp->state_lock); - goto error; + goto error_unlock; } } if (cep->mpa.v2_ctrl.ord &
@@ -1677,7 +1663,6 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)SIW_QP_ATTR_ORD |SIW_QP_ATTR_IRD | SIW_QP_ATTR_MPA);up_write (&qp->state_lock); -if (rv) goto error;
@@ -1700,6 +1685,9 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)siw_cep_set_free (cep);return 0 ; + +error_unlock: +up_write (&qp->state_lock); error:siw_socket_disassoc (cep->sock);sock_release (cep->sock);
@@ -1714,9 +1702,8 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) } cep->qp =NULL ;siw_qp_put (qp); - +free_cep:siw_cep_set_free_and_put (cep); -return rv; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 354/595 RDMA/siw: Clear association under lock if siw_qp_modify fails in siw_accept
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guoqing Jiang <[email protected]>
[ Upstream commit 32cd87f54dd1070020e664ccb0312a9f0fea79b4 ]
We need to clear cep before release state_lock as siw_qp_llp_close and siw_qp_modify->siw_qp_llp_close did.
Otherwise if siw_qp_modify() fails in siw_accept(), the QP's state_lock is released before the error path cleanup. A concurrent ibv_modify_qp() transitioning the QP to ERROR can race in this window:
siw_accept() ibv_modify_qp(ERROR)
---------------------- ----------------------
siw_qp_modify() fails
up_write(&qp->state_lock)
down_write(&qp->state_lock)
nextstate_from_idle():
if (qp->cep)
siw_cep_put(qp->cep) <- frees cep
qp->cep = NULL
goto error
cep->qp = NULL <- UAFClear qp->cep and drop the association reference taken by siw_cep_get(), all under the write lock held from the initial down_write(&qp->state_lock). Thread B therefore sees qp->cep == NULL, skips its own put, and cannot free the cep before siw_accept() is done with it.
--- drivers/infiniband/sw/siw/siw_cm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +5 -2
@@ -1662,9 +1662,12 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)SIW_QP_ATTR_STATE |SIW_QP_ATTR_LLP_HANDLE |SIW_QP_ATTR_ORD |SIW_QP_ATTR_IRD | SIW_QP_ATTR_MPA); +if (rv) { + qp->cep =NULL ; +siw_cep_put (cep); + goto error_unlock; + }up_write (&qp->state_lock); -if (rv) - goto error;siw_dbg_cep (cep,"[QP %u]: send mpa reply, %d byte pdata\n" ,qp_id (qp), params->private_data_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 355/595 firmware: arm_scpi: reject DVFS OPP count above MAX_DVFS_OPPS
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xixin Liu <[email protected]>
[ Upstream commit 32471d84a487c7fd74532bc96be56f8028cf4a3f ]
scpi_dvfs_get_info() already rejected a zero opp_count, but still trusted any larger value from the SCP firmware. The shared-memory reply only holds MAX_DVFS_OPPS entries in buf.opps[]; a bigger count over-reads that array and then sizes the allocated OPP table incorrectly (garbage OPPs / OOB). The missing upper bound dates back to the original SCPI DVFS support.
Reject zero and out-of-range counts in one check and return -EINVAL.
--- drivers/firmware/arm_scpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/arm_scpi.c +2 -2
@@ -627,8 +627,8 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain)if (ret)return ERR_PTR (ret); -if (!buf.opp_count) -return ERR_PTR (-ENOENT ); +if (!buf.opp_count || buf.opp_count >MAX_DVFS_OPPS ) +return ERR_PTR (-EINVAL ); info =kmalloc (sizeof (*info),GFP_KERNEL );if (!info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 356/595 clk: scpi: bound-check DVFS index in scpi_dvfs_recalc_rate
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xixin Liu <[email protected]>
[ Upstream commit 70f4b78d560e592cbf3325b162424737d032fc1d ]
dvfs_get_idx() may return an out-of-range index if the SCP firmware is buggy or returns a stale value. Only negative indexes were rejected, so a large index walked past info->opps and could treat garbage as a clock rate (KASAN OOB / wrong frequency to consumers). The missing upper bound dates back to the original SCPI clock driver.
Treat indexes >= opp count as invalid and return 0, same as idx < 0.
--- drivers/clk/clk-scpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-scpi.c +1 -1
@@ -86,7 +86,7 @@ static unsigned long scpi_dvfs_recalc_rate(struct clk_hw *hw,int idx = clk->scpi_ops->dvfs_get_idx (clk->id);const struct scpi_opp *opp; -if (idx <0 ) +if (idx <0 || idx >= clk->info->count)return 0 ; opp = clk->info->opps + idx;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 357/595 IB/iser: Align coding style across driver
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Gurtovoy <[email protected]>
[ Upstream commit ca2770c65b56374374fa00c349883e67c16943de ]
The following changes were made:
1. Align function signatures to 80 characters per line.
2. Remove tabs for variable assignment and use 1 space instead.
3. Don't compare to NULL in "if" clause.
4. Remove strange indentations.
This will ease on the maintenance of the driver for the future.
Stable-dep-of: d85f0f0a7c85 ("IB/iser: reject a remote invalidation of an unregistered direction")
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 72 ++++++++------------ drivers/infiniband/ulp/iser/iser_initiator.c | 29 +++----- drivers/infiniband/ulp/iser/iser_memory.c | 58 +++++++--------- drivers/infiniband/ulp/iser/iser_verbs.c | 54 +++++++-------- 4 files changed, 87 insertions(+), 126 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +28 -44
@@ -120,9 +120,8 @@ MODULE_PARM_DESC(pi_guard, "T10-PI guard_type [deprecated]");* Notes: In case of data length errors or iscsi PDU completion failures * this routine will signal iscsi layer of connection failure. */ -void -iscsi_iser_recv (struct iscsi_conn *conn,struct iscsi_hdr *hdr, -char *rx_data,int rx_data_len) +void iscsi_iser_recv (struct iscsi_conn *conn,struct iscsi_hdr *hdr, +char *rx_data,int rx_data_len) {int rc =0 ;int datalen;
@@ -157,8 +156,7 @@ iscsi_iser_recv(struct iscsi_conn *conn, struct iscsi_hdr *hdr,* Netes: This routine can't fail, just assign iscsi task * hdr and max hdr size. */ -static int -iscsi_iser_pdu_alloc (struct iscsi_task *task,uint8_t opcode) +static int iscsi_iser_pdu_alloc (struct iscsi_task *task,uint8_t opcode) {struct iscsi_iser_task *iser_task = task->dd_data;
@@ -179,9 +177,8 @@ iscsi_iser_pdu_alloc(struct iscsi_task *task, uint8_t opcode)* state mutex to avoid dereferencing the IB device which * may have already been terminated. */ -int -iser_initialize_task_headers (struct iscsi_task *task, -struct iser_tx_desc *tx_desc) +int iser_initialize_task_headers (struct iscsi_task *task, +struct iser_tx_desc *tx_desc) {struct iser_conn *iser_conn = task->conn->dd_data;struct iser_device *device = iser_conn->ib_conn.device;
@@ -230,8 +227,7 @@ iser_initialize_task_headers(struct iscsi_task *task,* Return: Returns zero on success or -ENOMEM when failing * to init task headers (dma mapping error). */ -static int -iscsi_iser_task_init (struct iscsi_task *task) +static int iscsi_iser_task_init (struct iscsi_task *task) {struct iscsi_iser_task *iser_task = task->dd_data;int ret;
@@ -265,8 +261,8 @@ iscsi_iser_task_init(struct iscsi_task *task)* xmit. * **/ -static int -iscsi_iser_mtask_xmit (struct iscsi_conn *conn,struct iscsi_task *task) +static int iscsi_iser_mtask_xmit (struct iscsi_conn *conn, +struct iscsi_task *task) {int error =0 ;
@@ -283,9 +279,8 @@ iscsi_iser_mtask_xmit(struct iscsi_conn *conn, struct iscsi_task *task)return error; } -static int -iscsi_iser_task_xmit_unsol_data (struct iscsi_conn *conn, -struct iscsi_task *task) +static int iscsi_iser_task_xmit_unsol_data (struct iscsi_conn *conn, +struct iscsi_task *task) {struct iscsi_r2t_info *r2t = &task->unsol_r2t;struct iscsi_data hdr;
@@ -319,8 +314,7 @@ iscsi_iser_task_xmit_unsol_data(struct iscsi_conn *conn,* * Return: zero on success or escalates $error on failure. */ -static int -iscsi_iser_task_xmit (struct iscsi_task *task) +static int iscsi_iser_task_xmit (struct iscsi_task *task) {struct iscsi_conn *conn = task->conn;struct iscsi_iser_task *iser_task = task->dd_data;
@@ -403,8 +397,7 @@ static void iscsi_iser_cleanup_task(struct iscsi_task *task)* * In addition the error sector is marked. */ -static u8 -iscsi_iser_check_protection (struct iscsi_task *task,sector_t *sector) +static u8 iscsi_iser_check_protection (struct iscsi_task *task,sector_t *sector) {struct iscsi_iser_task *iser_task = task->dd_data; enum iser_data_dir dir = iser_task->dir[ISER_DIR_IN] ?
@@ -453,11 +446,9 @@ iscsi_iser_conn_create(struct iscsi_cls_session *cls_session,* -EINVAL in case end-point doesn't exsits anymore or iser connection * state is not UP (teardown already started). */ -static int -iscsi_iser_conn_bind (struct iscsi_cls_session *cls_session, -struct iscsi_cls_conn *cls_conn, -uint64_t transport_eph, -int is_leading) +static int iscsi_iser_conn_bind (struct iscsi_cls_session *cls_session, +struct iscsi_cls_conn *cls_conn, +uint64_t transport_eph,int is_leading) {struct iscsi_conn *conn = cls_conn->dd_data;struct iser_conn *iser_conn;
@@ -512,8 +503,7 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,* from this point iscsi must call conn_stop in session/connection * teardown so iser transport must wait for it. */ -static int -iscsi_iser_conn_start (struct iscsi_cls_conn *cls_conn) +static int iscsi_iser_conn_start (struct iscsi_cls_conn *cls_conn) {struct iscsi_conn *iscsi_conn;struct iser_conn *iser_conn;
@@ -535,8 +525,7 @@ iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)* handle, so we call it under iser the state lock to protect against * this kind of race. */ -static void -iscsi_iser_conn_stop (struct iscsi_cls_conn *cls_conn,int flag) +static void iscsi_iser_conn_stop (struct iscsi_cls_conn *cls_conn,int flag) {struct iscsi_conn *conn = cls_conn->dd_data;struct iser_conn *iser_conn = conn->dd_data;
@@ -571,8 +560,7 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)* * Removes and free iscsi host. */ -static void -iscsi_iser_session_destroy (struct iscsi_cls_session *cls_session) +static void iscsi_iser_session_destroy (struct iscsi_cls_session *cls_session) {struct Scsi_Host *shost =iscsi_session_to_shost (cls_session);
@@ -581,8 +569,7 @@ iscsi_iser_session_destroy(struct iscsi_cls_session *cls_session)iscsi_host_free (shost); } -static inline unsigned int -iser_dif_prot_caps (int prot_caps) +static inline unsigned int iser_dif_prot_caps (int prot_caps) { return ((prot_caps & IB_PROT_T10DIF_TYPE_1) ? SHOST_DIF_TYPE1_PROTECTION | SHOST_DIX_TYPE0_PROTECTION |
@@ -694,9 +681,8 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,return NULL ; } -static int -iscsi_iser_set_param (struct iscsi_cls_conn *cls_conn, -enum iscsi_param param,char *buf,int buflen) +static int iscsi_iser_set_param (struct iscsi_cls_conn *cls_conn, +enum iscsi_param param,char *buf,int buflen) {int value;
@@ -746,8 +732,8 @@ iscsi_iser_set_param(struct iscsi_cls_conn *cls_conn,* * Output connection statistics. */ -static void -iscsi_iser_conn_get_stats (struct iscsi_cls_conn *cls_conn,struct iscsi_stats *stats) +static void iscsi_iser_conn_get_stats (struct iscsi_cls_conn *cls_conn, +struct iscsi_stats *stats) {struct iscsi_conn *conn = cls_conn->dd_data;
@@ -798,9 +784,9 @@ static int iscsi_iser_get_ep_param(struct iscsi_endpoint *ep,* Return: iscsi_endpoint created by iscsi layer or ERR_PTR(error) * if fails. */ -static struct iscsi_endpoint * -iscsi_iser_ep_connect (struct Scsi_Host *shost,struct sockaddr *dst_addr, -int non_blocking) +static struct iscsi_endpoint *iscsi_iser_ep_connect (struct Scsi_Host *shost, +struct sockaddr *dst_addr, +int non_blocking) {int err;struct iser_conn *iser_conn;
@@ -843,8 +829,7 @@ iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,* or more likely iser connection state transitioned to TEMINATING or * DOWN during the wait period. */ -static int -iscsi_iser_ep_poll (struct iscsi_endpoint *ep,int timeout_ms) +static int iscsi_iser_ep_poll (struct iscsi_endpoint *ep,int timeout_ms) {struct iser_conn *iser_conn = ep->dd_data;int rc;
@@ -879,8 +864,7 @@ iscsi_iser_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)* and cleanup or actually call it immediately in case we didn't pass * iscsi conn bind/start stage, thus it is safe. */ -static void -iscsi_iser_ep_disconnect (struct iscsi_endpoint *ep) +static void iscsi_iser_ep_disconnect (struct iscsi_endpoint *ep) {struct iser_conn *iser_conn = ep->dd_data;
drivers/infiniband/ulp/iser/iser_initiator.c +10 -19
@@ -95,11 +95,8 @@ static int iser_prepare_read_cmd(struct iscsi_task *task)* task->data[ISER_DIR_OUT].data_len, Protection size * is stored at task->prot[ISER_DIR_OUT].data_len */ -static int -iser_prepare_write_cmd (struct iscsi_task *task, -unsigned int imm_sz, -unsigned int unsol_sz, -unsigned int edtl) +static int iser_prepare_write_cmd (struct iscsi_task *task,unsigned int imm_sz, +unsigned int unsol_sz,unsigned int edtl) {struct iscsi_iser_task *iser_task = task->dd_data;struct iser_mem_reg *mem_reg;
@@ -160,8 +157,8 @@ iser_prepare_write_cmd(struct iscsi_task *task, }/* creates a new tx descriptor and adds header regd buffer */ -static void iser_create_send_desc (struct iser_conn *iser_conn, -struct iser_tx_desc *tx_desc) +static void iser_create_send_desc (struct iser_conn *iser_conn, +struct iser_tx_desc *tx_desc) {struct iser_device *device = iser_conn->ib_conn.device;
@@ -360,8 +357,7 @@ static inline bool iser_signal_comp(u8 sig_count)* @conn: link to matching iscsi connection * @task: SCSI command task */ -int iser_send_command (struct iscsi_conn *conn, -struct iscsi_task *task) +int iser_send_command (struct iscsi_conn *conn,struct iscsi_task *task) {struct iser_conn *iser_conn = conn->dd_data;struct iscsi_iser_task *iser_task = task->dd_data;
@@ -434,8 +430,7 @@ int iser_send_command(struct iscsi_conn *conn,* @task: SCSI command task * @hdr: pointer to the LLD's iSCSI message header */ -int iser_send_data_out (struct iscsi_conn *conn, -struct iscsi_task *task, +int iser_send_data_out (struct iscsi_conn *conn,struct iscsi_task *task,struct iscsi_data *hdr) {struct iser_conn *iser_conn = conn->dd_data;
@@ -497,8 +492,7 @@ int iser_send_data_out(struct iscsi_conn *conn,return err; } -int iser_send_control (struct iscsi_conn *conn, -struct iscsi_task *task) +int iser_send_control (struct iscsi_conn *conn,struct iscsi_task *task) {struct iser_conn *iser_conn = conn->dd_data;struct iscsi_iser_task *iser_task = task->dd_data;
@@ -593,8 +587,7 @@ void iser_login_rsp(struct ib_cq *cq, struct ib_wc *wc) ib_conn->post_recv_buf_count--; } -static inline int -iser_inv_desc (struct iser_fr_desc *desc,u32 rkey) +static inline int iser_inv_desc (struct iser_fr_desc *desc,u32 rkey) {if (unlikely ((!desc->sig_protected && rkey != desc->rsc.mr->rkey) || (desc->sig_protected && rkey != desc->rsc.sig_mr->rkey))) {
@@ -610,10 +603,8 @@ iser_inv_desc(struct iser_fr_desc *desc, u32 rkey)return 0 ; } -static int -iser_check_remote_inv (struct iser_conn *iser_conn, -struct ib_wc *wc, -struct iscsi_hdr *hdr) +static int iser_check_remote_inv (struct iser_conn *iser_conn,struct ib_wc *wc, +struct iscsi_hdr *hdr) {if (wc->wc_flags &IB_WC_WITH_INVALIDATE ) {struct iscsi_task *task;
drivers/infiniband/ulp/iser/iser_memory.c +24 -34
118 lines not on this page · raw message
drivers/infiniband/ulp/iser/iser_verbs.c +25 -29
134 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 358/595 IB/iser: Remove iser_reg_data_sg helper function
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Gurtovoy <[email protected]>
[ Upstream commit 7f68d7493ff07a0ad63f63c4a1a4e0781cec0dd2 ]
Open coding it makes the code more readable and simple.
Stable-dep-of: d85f0f0a7c85 ("IB/iser: reject a remote invalidation of an unregistered direction")
--- drivers/infiniband/ulp/iser/iser_memory.c | 31 +++++++---------------- 1 file changed, 9 insertions(+), 22 deletions(-)
drivers/infiniband/ulp/iser/iser_memory.c +9 -22
@@ -327,40 +327,26 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task,return 0 ; } -static int iser_reg_data_sg (struct iscsi_iser_task *task, -struct iser_data_buf *mem, -struct iser_fr_desc *desc,bool use_dma_key, -struct iser_mem_reg *reg) -{ -struct iser_device *device = task->iser_conn->ib_conn.device; - -if (use_dma_key) -return iser_reg_dma (device, mem, reg); - -return iser_fast_reg_mr (task, mem, &desc->rsc, reg); -} -int iser_reg_mem_fastreg (struct iscsi_iser_task *task,enum iser_data_dir dir,bool all_imm) {struct ib_conn *ib_conn = &task->iser_conn->ib_conn; +struct iser_device *device = ib_conn->device;struct iser_data_buf *mem = &task->data[dir];struct iser_mem_reg *reg = &task->rdma_reg[dir]; -struct iser_fr_desc *desc =NULL ; +struct iser_fr_desc *desc;bool use_dma_key;int err; use_dma_key = mem->dma_nents ==1 && (all_imm || !iser_always_reg) &&scsi_get_prot_op (task->sc) ==SCSI_PROT_NORMAL ; +if (use_dma_key) +return iser_reg_dma (device, mem, reg); -if (!use_dma_key) { - desc =iser_reg_desc_get_fr (ib_conn); - reg->mem_h = desc; - } - + desc =iser_reg_desc_get_fr (ib_conn);if (scsi_get_prot_op (task->sc) ==SCSI_PROT_NORMAL ) { - err =iser_reg_data_sg (task, mem, desc, use_dma_key, reg); + err =iser_fast_reg_mr (task, mem, &desc->rsc, reg);if (unlikely (err)) goto err_reg; }else {
@@ -372,11 +358,12 @@ int iser_reg_mem_fastreg(struct iscsi_iser_task *task, desc->sig_protected = true; } + reg->mem_h = desc; +return 0 ; err_reg: -if (desc) -iser_reg_desc_put_fr (ib_conn, desc); +iser_reg_desc_put_fr (ib_conn, desc);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 359/595 IB/iser: Use iser_fr_desc as registration context
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Gurtovoy <[email protected]>
[ Upstream commit ee4efeaea8837bb7018d188a9eb8837c7ff79561 ]
After removing the FMR support in iSER, there is only one type of registration context. Replace the void pointer with the explicit structure for registration (struct iser_fr_desc).
Stable-dep-of: d85f0f0a7c85 ("IB/iser: reject a remote invalidation of an unregistered direction")
--- drivers/infiniband/ulp/iser/iscsi_iser.h | 8 ++++---- drivers/infiniband/ulp/iser/iser_initiator.c | 4 ++-- drivers/infiniband/ulp/iser/iser_memory.c | 8 ++++---- drivers/infiniband/ulp/iser/iser_verbs.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.h +4 -4
@@ -207,12 +207,12 @@ struct iser_reg_resources;* * @sge: memory region sg element * @rkey: memory region remote key -* @mem_h: pointer to registration context (FMR/Fastreg) +* @desc: pointer to fast registration context */ struct iser_mem_reg { -struct ib_sge sge; -u32 rkey; -void *mem_h; +struct ib_sge sge; +u32 rkey; +struct iser_fr_desc *desc; };enum iser_desc_type {
drivers/infiniband/ulp/iser/iser_initiator.c +2 -2
@@ -625,13 +625,13 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc,struct iser_fr_desc *desc;if (iser_task->dir[ISER_DIR_IN ]) { - desc = iser_task->rdma_reg[ISER_DIR_IN ].mem_h; + desc = iser_task->rdma_reg[ISER_DIR_IN ].desc;if (unlikely (iser_inv_desc (desc, rkey)))return -EINVAL ; }if (iser_task->dir[ISER_DIR_OUT ]) { - desc = iser_task->rdma_reg[ISER_DIR_OUT ].mem_h; + desc = iser_task->rdma_reg[ISER_DIR_OUT ].desc;if (unlikely (iser_inv_desc (desc, rkey)))return -EINVAL ; }
drivers/infiniband/ulp/iser/iser_memory.c +4 -4
@@ -130,7 +130,7 @@ void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task,struct iser_fr_desc *desc;struct ib_mr_status mr_status; - desc = reg->mem_h; + desc = reg->desc;if (!desc)return ;
@@ -147,8 +147,8 @@ void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task,ib_check_mr_status (desc->rsc.sig_mr,IB_MR_CHECK_SIG_STATUS , &mr_status); } -iser_reg_desc_put_fr (&iser_task->iser_conn->ib_conn, reg->mem_h); - reg->mem_h =NULL ; +iser_reg_desc_put_fr (&iser_task->iser_conn->ib_conn, reg->desc); + reg->desc =NULL ; } static void iser_set_dif_domain(struct scsi_cmnd *sc,
@@ -358,7 +358,7 @@ int iser_reg_mem_fastreg(struct iscsi_iser_task *task, desc->sig_protected = true; } - reg->mem_h = desc; + reg->desc = desc;return 0 ;
drivers/infiniband/ulp/iser/iser_verbs.c +1 -1
@@ -924,7 +924,7 @@ u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task, enum iser_data_dir cmd_dir, sector_t *sector) { struct iser_mem_reg *reg = &iser_task->rdma_reg[cmd_dir]; -struct iser_fr_desc *desc = reg->mem_h; +struct iser_fr_desc *desc = reg->desc;unsigned long sector_size = iser_task->sc->device->sector_size;struct ib_mr_status mr_status;int ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 360/595 IB/iser: reject a remote invalidation of an unregistered direction
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit d85f0f0a7c85756fc992c70d869706f19dac9259 ]
A write command whose data is sent entirely as immediate data is not registered. iser_reg_mem_fastreg() takes the DMA key path and leaves rdma_reg[ISER_DIR_OUT].desc at NULL, while iser_dma_map_task_data() has already set dir[ISER_DIR_OUT].
iser_check_remote_inv() looks at dir[] alone and hands the descriptor to iser_inv_desc(), which reads desc->sig_protected. A target that answers such a command with IB_WR_SEND_WITH_INV faults the initiator. Leaving those commands unregistered is deliberate.
The same function already terminates the connection when a target sends a remote invalidation the initiator did not ask for. A target that invalidates a direction that was never registered is in the same class, so give it the same answer.
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000004: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027] CPU: 0 UID: 0 PID: 40 Comm: kworker/u8:2 Not tainted 7.2.0-rc5-ISERHOST-gf5098b6bae76-dirty #3 PREEMPT(lazy) Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Workqueue: rxe_wq do_work RIP: 0010:iser_task_rsp+0x6d6/0xec0 Code: 48 c1 ea 03 80 3c 02 00 0f 85 ba 06 00 00 48 8b 9b 78 01 00 00 48 b8 00 00 00 00 00 fc ff df 48 8d 7b 20 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 06 0f 8e 76 06 00 00 80 7b 20 00 0f 84 3d 04 RSP: 0018:ffff88811b008db8 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000001848 RDX: 0000000000000004 RSI: 1ffff11021587b12 RDI: 0000000000000020 RBP: ffff88810adc1ae4 R08: ffff888109b7f860 R09: ffffffff90a922c0 R10: ffff88810adc1a1c R11: 000000000000003c R12: ffff888109b7f800 R13: ffff88810adc1acc R14: ffff888109b7f820 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff88818a676000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000005afe2b CR3: 000000010af23005 CR4: 0000000000770ef0 PKRU: 55555554 Call Trace: <IRQ> __ib_process_cq+0xe1/0x390 ib_poll_handler+0x6e/0x200 irq_poll_softirq+0x1df/0x480 ? clockevents_program_event+0x2ba/0x860 ? __pfx_irq_poll_softirq+0x10/0x10 handle_softirqs+0x18e/0x590 ? __pfx_handle_softirqs+0x10/0x10 ? __hrtimer_rearm_deferred+0x156/0x450 do_softirq+0x3b/0x60 </IRQ> <TASK> __local_bh_enable_ip+0x61/0x70 __alloc_skb+0x732/0x890 ? _raw_spin_lock_irqsave+0x85/0xe0 ? __pfx___alloc_skb+0x10/0x10 ? _raw_read_unlock_irqrestore+0x16/0x50 rxe_init_packet+0x16b/0x4f0 prepare_ack_packet+0xb8/0x830 rxe_receiver+0x499/0x9980 ? __pfx_rxe_receiver+0x10/0x10 ? rxe_completer+0x29e5/0x38c0 ? hrtimer_start_range_ns_common+0x75f/0x1730 ? hrtimer_start_range_ns+0xa6/0x2c0 ? __pfx__raw_spin_lock_irqsave+0x10/0x10 ? __pfx_rxe_receiver+0x10/0x10 do_work+0x144/0x470 process_one_work+0x633/0x1030 ? assign_work+0x11d/0x370 worker_thread+0x45b/0xd10 ? __pfx_worker_thread+0x10/0x10 kthread+0x2c6/0x3b0 ? recalc_sigpending+0x15c/0x1e0 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x36e/0x5a0 ? __pfx_ret_from_fork+0x10/0x10 ? __switch_to+0x572/0xdd0 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]---
--- drivers/infiniband/ulp/iser/iser_initiator.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/infiniband/ulp/iser/iser_initiator.c +11 -5
@@ -613,11 +613,8 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc,iser_dbg ("conn %p: remote invalidation for rkey %#x\n" , iser_conn, rkey); -if (unlikely (!iser_conn->snd_w_inv)) { -iser_err ("conn %p: unexpected remote invalidation, terminating connection\n" , - iser_conn); -return -EPROTO ; - } +if (unlikely (!iser_conn->snd_w_inv)) + goto bad_inv; task =iscsi_itt_to_ctask (iser_conn->iscsi_conn, hdr->itt);if (likely (task)) {
@@ -626,12 +623,16 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc,if (iser_task->dir[ISER_DIR_IN ]) { desc = iser_task->rdma_reg[ISER_DIR_IN ].desc; +if (unlikely (!desc)) + goto bad_inv;if (unlikely (iser_inv_desc (desc, rkey)))return -EINVAL ; }if (iser_task->dir[ISER_DIR_OUT ]) { desc = iser_task->rdma_reg[ISER_DIR_OUT ].desc; +if (unlikely (!desc)) + goto bad_inv;if (unlikely (iser_inv_desc (desc, rkey)))return -EINVAL ; }
@@ -642,6 +643,11 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc, }return 0 ; + +bad_inv: +iser_err ("conn %p: unexpected remote invalidation, terminating connection\n" , + iser_conn); +return -EPROTO ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 361/595 scsi: target: iscsi: Avoid in_interrupt() usage in iscsit_close_session()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 433675486af4635416f8ece70b92b020a5b91005 ]
iscsit_close_session() uses in_interrupt() to decide if it needs to check the return value of iscsit_check_session_usage_count() if it was not able to sleep.
The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context.
iscsit_close_session() has two callers:
- iscsit_handle_time2retain_timeout()
A timer_list callback.
- iscsit_close_connection()
Runs in preemptible context, acquires a mutex.
Add an argument to iscsit_close_session() indicating if sleeping is possible.
Stable-dep-of: a8fe3dfce8c0 ("IB/isert: wait for deferred control PDU completions before releasing the connection")
--- drivers/target/iscsi/iscsi_target.c | 10 +++++----- drivers/target/iscsi/iscsi_target.h | 2 +- drivers/target/iscsi/iscsi_target_erl0.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/target/iscsi/iscsi_target.c +5 -5
@@ -4343,7 +4343,7 @@ int iscsit_close_connection( atomic_read(&sess->session_fall_back_to_erl0)) {spin_unlock_bh (&sess->conn_lock);complete_all (&sess->session_wait_comp); -iscsit_close_session (sess); +iscsit_close_session (sess, true);return 0 ; } else if (atomic_read(&sess->session_logout)) {
@@ -4353,7 +4353,7 @@ int iscsit_close_connection(if (atomic_read (&sess->session_close)) {spin_unlock_bh (&sess->conn_lock);complete_all (&sess->session_wait_comp); -iscsit_close_session (sess); +iscsit_close_session (sess, true); }else {spin_unlock_bh (&sess->conn_lock); }
@@ -4369,7 +4369,7 @@ int iscsit_close_connection(if (atomic_read (&sess->session_close)) {spin_unlock_bh (&sess->conn_lock);complete_all (&sess->session_wait_comp); -iscsit_close_session (sess); +iscsit_close_session (sess, true); }else {spin_unlock_bh (&sess->conn_lock); }
@@ -4382,7 +4382,7 @@ int iscsit_close_connection(* If the iSCSI Session for the iSCSI Initiator Node exists, * forcefully shutdown the iSCSI NEXUS. */ -int iscsit_close_session (struct iscsi_session *sess) +int iscsit_close_session (struct iscsi_session *sess,bool can_sleep) {struct iscsi_portal_group *tpg = sess->tpg;struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
@@ -4418,7 +4418,7 @@ int iscsit_close_session(struct iscsi_session *sess)* time2retain handler) and contain and active session usage count we * restart the timer and exit. */ -if (!in_interrupt ()) { +if (can_sleep) {iscsit_check_session_usage_count (sess); }else {if (iscsit_check_session_usage_count (sess) ==2 ) {
drivers/target/iscsi/iscsi_target.h +1 -1
@@ -41,7 +41,7 @@ extern void iscsit_thread_get_cpumask(struct iscsi_conn *);extern int iscsi_target_tx_thread (void *);extern int iscsi_target_rx_thread (void *);extern int iscsit_close_connection (struct iscsi_conn *); -extern int iscsit_close_session (struct iscsi_session *); +extern int iscsit_close_session (struct iscsi_session *,bool can_sleep);extern void iscsit_fail_session (struct iscsi_session *);extern void iscsit_stop_session (struct iscsi_session *,int ,int );extern int iscsit_release_sessions_for_tpg (struct iscsi_portal_group *,int );
drivers/target/iscsi/iscsi_target_erl0.c +1 -1
@@ -765,7 +765,7 @@ void iscsit_handle_time2retain_timeout(struct timer_list *t)iscsit_fill_cxn_timeout_err_stats (sess);spin_unlock_bh (&se_tpg->session_lock); -iscsit_close_session (sess); +iscsit_close_session (sess, false); }void iscsit_start_time2retain_handler (struct iscsi_session *sess)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 362/595 scsi: target: iscsi: Avoid in_interrupt() usage in iscsit_check_session_usage_count()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit efc9d73063c15f1aba8920b9f9ceaba4f3fb8ed9 ]
iscsit_check_session_usage_count() uses in_interrupt() to find out if it is safe to invoke wait_for_completion().
The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context.
There is only one caller of iscsit_check_session_usage_count() which already has an argument indicating if it is safe to sleep.
Extend iscsit_check_session_usage_count() by an argument indicating if it may sleep.
Stable-dep-of: a8fe3dfce8c0 ("IB/isert: wait for deferred control PDU completions before releasing the connection")
--- drivers/target/iscsi/iscsi_target.c | 4 ++-- drivers/target/iscsi/iscsi_target_util.c | 4 ++-- drivers/target/iscsi/iscsi_target_util.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/target/iscsi/iscsi_target.c +2 -2
@@ -4419,9 +4419,9 @@ int iscsit_close_session(struct iscsi_session *sess, bool can_sleep)* restart the timer and exit. */ if (can_sleep) { -iscsit_check_session_usage_count (sess); +iscsit_check_session_usage_count (sess, can_sleep); }else { -if (iscsit_check_session_usage_count (sess) ==2 ) { +if (iscsit_check_session_usage_count (sess, can_sleep) ==2 ) {atomic_set (&sess->session_logout,0 );iscsit_start_time2retain_handler (sess);return 0 ;
drivers/target/iscsi/iscsi_target_util.c +2 -2
@@ -779,13 +779,13 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) }EXPORT_SYMBOL (iscsit_free_cmd); -int iscsit_check_session_usage_count (struct iscsi_session *sess) +int iscsit_check_session_usage_count (struct iscsi_session *sess,bool can_sleep) {spin_lock_bh (&sess->session_usage_lock);if (sess->session_usage_count !=0 ) { sess->session_waiting_on_uc =1 ;spin_unlock_bh (&sess->session_usage_lock); -if (in_interrupt ()) +if (!can_sleep)return 2 ;wait_for_completion (&sess->session_waiting_on_uc_comp);
drivers/target/iscsi/iscsi_target_util.h +1 -1
@@ -40,7 +40,7 @@ extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *);extern void iscsit_release_cmd (struct iscsi_cmd *);extern void __iscsit_free_cmd (struct iscsi_cmd *,bool );extern void iscsit_free_cmd (struct iscsi_cmd *,bool ); -extern int iscsit_check_session_usage_count (struct iscsi_session *); +extern int iscsit_check_session_usage_count (struct iscsi_session *sess,bool can_sleep);extern void iscsit_dec_session_usage_count (struct iscsi_session *);extern void iscsit_inc_session_usage_count (struct iscsi_session *);extern struct iscsi_conn *iscsit_get_conn_from_cid (struct iscsi_session *,u16 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 363/595 scsi: target: iscsi: Redo iscsit_check_session_usage_count() return code
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit f88a10f80da9ed1ab1ba7496b70e9a0cdd8f7cf8 ]
The return value of iscsit_check_session_usage_count() is only checked if it was not allowed to sleep. If it returns `2' then a timer is prepared. If it returns something else or if it was allowed to sleep then it is ignored.
Let iscsit_check_session_usage_count() return true if it needs to arm the timer - otherwise false. This simplifies the code flow of the only caller.
Stable-dep-of: a8fe3dfce8c0 ("IB/isert: wait for deferred control PDU completions before releasing the connection")
--- drivers/target/iscsi/iscsi_target.c | 12 ++++-------- drivers/target/iscsi/iscsi_target_util.c | 9 +++++---- drivers/target/iscsi/iscsi_target_util.h | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-)
drivers/target/iscsi/iscsi_target.c +4 -8
@@ -4418,14 +4418,10 @@ int iscsit_close_session(struct iscsi_session *sess, bool can_sleep)* time2retain handler) and contain and active session usage count we * restart the timer and exit. */ -if (can_sleep) { -iscsit_check_session_usage_count (sess, can_sleep); - }else { -if (iscsit_check_session_usage_count (sess, can_sleep) ==2 ) { -atomic_set (&sess->session_logout,0 ); -iscsit_start_time2retain_handler (sess); -return 0 ; - } +if (iscsit_check_session_usage_count (sess, can_sleep)) { +atomic_set (&sess->session_logout,0 ); +iscsit_start_time2retain_handler (sess); +return 0 ; }transport_deregister_session (sess->se_sess);
drivers/target/iscsi/iscsi_target_util.c +5 -4
@@ -779,21 +779,22 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) }EXPORT_SYMBOL (iscsit_free_cmd); -int iscsit_check_session_usage_count (struct iscsi_session *sess,bool can_sleep) +bool iscsit_check_session_usage_count (struct iscsi_session *sess, +bool can_sleep) {spin_lock_bh (&sess->session_usage_lock);if (sess->session_usage_count !=0 ) { sess->session_waiting_on_uc =1 ;spin_unlock_bh (&sess->session_usage_lock);if (!can_sleep) -return 2 ; +return true;wait_for_completion (&sess->session_waiting_on_uc_comp); -return 1 ; +return false; }spin_unlock_bh (&sess->session_usage_lock); -return 0 ; +return false; }void iscsit_dec_session_usage_count (struct iscsi_session *sess)
drivers/target/iscsi/iscsi_target_util.h +1 -1
@@ -40,7 +40,7 @@ extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *);extern void iscsit_release_cmd (struct iscsi_cmd *);extern void __iscsit_free_cmd (struct iscsi_cmd *,bool );extern void iscsit_free_cmd (struct iscsi_cmd *,bool ); -extern int iscsit_check_session_usage_count (struct iscsi_session *sess,bool can_sleep); +extern bool iscsit_check_session_usage_count (struct iscsi_session *sess,bool can_sleep);extern void iscsit_dec_session_usage_count (struct iscsi_session *);extern void iscsit_inc_session_usage_count (struct iscsi_session *);extern struct iscsi_conn *iscsit_get_conn_from_cid (struct iscsi_session *,u16 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 364/595 scsi: target: iscsi: Rename iscsi_cmd to iscsit_cmd
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Gurtovoy <[email protected]>
[ Upstream commit 66cd9d4ef74ae1ad459e3db3a3280182275c2ce9 ]
The structure iscsi_cmd naming is used by the iSCSI initiator driver. Rename the target cmd to iscsit_cmd to have more readable code.
Stable-dep-of: a8fe3dfce8c0 ("IB/isert: wait for deferred control PDU completions before releasing the connection")
--- drivers/infiniband/ulp/isert/ib_isert.c | 64 ++++---- drivers/infiniband/ulp/isert/ib_isert.h | 2 +- drivers/target/iscsi/cxgbit/cxgbit.h | 8 +- drivers/target/iscsi/cxgbit/cxgbit_ddp.c | 4 +- drivers/target/iscsi/cxgbit/cxgbit_target.c | 34 ++-- drivers/target/iscsi/iscsi_target.c | 150 +++++++++--------- drivers/target/iscsi/iscsi_target.h | 14 +- drivers/target/iscsi/iscsi_target_configfs.c | 14 +- .../target/iscsi/iscsi_target_datain_values.c | 18 +-- .../target/iscsi/iscsi_target_datain_values.h | 12 +- drivers/target/iscsi/iscsi_target_device.c | 2 +- drivers/target/iscsi/iscsi_target_device.h | 4 +- drivers/target/iscsi/iscsi_target_erl0.c | 30 ++-- drivers/target/iscsi/iscsi_target_erl0.h | 8 +- drivers/target/iscsi/iscsi_target_erl1.c | 42 ++--- drivers/target/iscsi/iscsi_target_erl1.h | 20 +-- drivers/target/iscsi/iscsi_target_erl2.c | 20 +-- drivers/target/iscsi/iscsi_target_erl2.h | 8 +- drivers/target/iscsi/iscsi_target_nego.c | 2 +- .../target/iscsi/iscsi_target_seq_pdu_list.c | 34 ++-- .../target/iscsi/iscsi_target_seq_pdu_list.h | 10 +- drivers/target/iscsi/iscsi_target_tmr.c | 38 ++--- drivers/target/iscsi/iscsi_target_tmr.h | 8 +- drivers/target/iscsi/iscsi_target_util.c | 66 ++++---- drivers/target/iscsi/iscsi_target_util.h | 48 +++--- include/target/iscsi/iscsi_target_core.h | 34 ++-- include/target/iscsi/iscsi_transport.h | 92 +++++------ 27 files changed, 393 insertions(+), 393 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +32 -32
@@ -46,7 +46,7 @@ static struct workqueue_struct *isert_comp_wq;static struct workqueue_struct *isert_release_wq;static int -isert_put_response (struct iscsi_conn *conn,struct iscsi_cmd *cmd); +isert_put_response (struct iscsi_conn *conn,struct iscsit_cmd *cmd);static int isert_login_post_recv (struct isert_conn *isert_conn); static int
@@ -1032,21 +1032,21 @@ isert_rx_login_req(struct isert_conn *isert_conn)schedule_delayed_work (&conn->login_work,0 ); } -static struct iscsi_cmd +static struct iscsit_cmd *isert_allocate_cmd (struct iscsi_conn *conn,struct iser_rx_desc *rx_desc) {struct isert_conn *isert_conn = conn->context;struct isert_cmd *isert_cmd; -struct iscsi_cmd *cmd; +struct iscsit_cmd *cmd; cmd =iscsit_allocate_cmd (conn,TASK_INTERRUPTIBLE );if (!cmd) { -isert_err ("Unable to allocate iscsi_cmd + isert_cmd\n" ); +isert_err ("Unable to allocate iscsit_cmd + isert_cmd\n" );return NULL ; } isert_cmd =iscsit_priv_cmd (cmd); isert_cmd->conn = isert_conn; - isert_cmd->iscsi_cmd = cmd; + isert_cmd->iscsit_cmd = cmd; isert_cmd->rx_desc = rx_desc;return cmd;
@@ -1054,7 +1054,7 @@ static struct iscsi_cmdstatic int isert_handle_scsi_cmd (struct isert_conn *isert_conn, -struct isert_cmd *isert_cmd,struct iscsi_cmd *cmd, +struct isert_cmd *isert_cmd,struct iscsit_cmd *cmd,struct iser_rx_desc *rx_desc,unsigned char *buf) {struct iscsi_conn *conn = isert_conn->conn;
@@ -1127,7 +1127,7 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, {struct scatterlist *sg_start;struct iscsi_conn *conn = isert_conn->conn; -struct iscsi_cmd *cmd =NULL ; +struct iscsit_cmd *cmd =NULL ;struct iscsi_data *hdr = (struct iscsi_data *)buf;u32 unsol_data_len =ntoh24 (hdr->dlength);int rc, sg_nents, sg_off, page_off;
@@ -1183,7 +1183,7 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn,static int isert_handle_nop_out (struct isert_conn *isert_conn,struct isert_cmd *isert_cmd, -struct iscsi_cmd *cmd,struct iser_rx_desc *rx_desc, +struct iscsit_cmd *cmd,struct iser_rx_desc *rx_desc,unsigned char *buf) {struct iscsi_conn *conn = isert_conn->conn;
@@ -1202,7 +1202,7 @@ isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,static int isert_handle_text_cmd (struct isert_conn *isert_conn,struct isert_cmd *isert_cmd, -struct iscsi_cmd *cmd,struct iser_rx_desc *rx_desc, +struct iscsit_cmd *cmd,struct iser_rx_desc *rx_desc,struct iscsi_text *hdr) {struct iscsi_conn *conn = isert_conn->conn;
@@ -1233,7 +1233,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, {struct iscsi_hdr *hdr =isert_get_iscsi_hdr (rx_desc);struct iscsi_conn *conn = isert_conn->conn; -struct iscsi_cmd *cmd; +struct iscsit_cmd *cmd;struct isert_cmd *isert_cmd;int ret = -EINVAL ;u8 opcode = (hdr->opcode &ISCSI_OPCODE_MASK );
@@ -1441,7 +1441,7 @@ isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc)static void isert_rdma_rw_ctx_destroy (struct isert_cmd *cmd,struct isert_conn *conn) { -struct se_cmd *se_cmd = &cmd->iscsi_cmd->se_cmd; +struct se_cmd *se_cmd = &cmd->iscsit_cmd->se_cmd;enum dma_data_direction dir =target_reverse_dma_direction (se_cmd);if (!cmd->rw.nr_ops)
@@ -1463,7 +1463,7 @@ isert_rdma_rw_ctx_destroy(struct isert_cmd *cmd, struct isert_conn *conn)static void isert_put_cmd (struct isert_cmd *isert_cmd,bool comp_err) { -struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; +struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd;struct isert_conn *isert_conn = isert_cmd->conn;struct iscsi_conn *conn = isert_conn->conn;struct iscsi_text_rsp *hdr;
@@ -1612,7 +1612,7 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc)struct isert_device *device = isert_conn->device;struct iser_tx_desc *desc =cqe_to_tx_desc (wc->wr_cqe);struct isert_cmd *isert_cmd =tx_desc_to_cmd (desc); -struct se_cmd *cmd = &isert_cmd->iscsi_cmd->se_cmd; +struct se_cmd *cmd = &isert_cmd->iscsit_cmd->se_cmd;int ret =0 ;if (unlikely (wc->status !=IB_WC_SUCCESS )) {
@@ -1641,7 +1641,7 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc)/* * XXX: isert_put_response() failure is not retried. */ - ret =isert_put_response (isert_conn->conn, isert_cmd->iscsi_cmd); + ret =isert_put_response (isert_conn->conn, isert_cmd->iscsit_cmd);if (ret)pr_warn_ratelimited ("isert_put_response() ret: %d\n" , ret); }
@@ -1654,7 +1654,7 @@ isert_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc)struct isert_device *device = isert_conn->device;struct iser_tx_desc *desc =cqe_to_tx_desc (wc->wr_cqe);struct isert_cmd *isert_cmd =tx_desc_to_cmd (desc); -struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; +struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd;struct se_cmd *se_cmd = &cmd->se_cmd;int ret =0 ;
@@ -1699,7 +1699,7 @@ isert_do_control_comp(struct work_struct *work) struct isert_cmd, comp_work);struct isert_conn *isert_conn = isert_cmd->conn;struct ib_device *ib_dev = isert_conn->cm_id->device; -struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; +struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd;isert_dbg ("Cmd %p i_state %d\n" , isert_cmd, cmd->i_state);
@@ -1757,7 +1757,7 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc)isert_dbg ("Cmd %p\n" , isert_cmd); -switch (isert_cmd->iscsi_cmd->i_state) { +switch (isert_cmd->iscsit_cmd->i_state) {case ISTATE_SEND_TASKMGTRSP :case ISTATE_SEND_LOGOUTRSP :case ISTATE_SEND_REJECT :
@@ -1768,7 +1768,7 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc)queue_work (isert_comp_wq, &isert_cmd->comp_work);return ;default : - isert_cmd->iscsi_cmd->i_state =ISTATE_SENT_STATUS ; + isert_cmd->iscsit_cmd->i_state =ISTATE_SENT_STATUS ;isert_completion_put (tx_desc, isert_cmd, ib_dev, false);break ; }
@@ -1792,7 +1792,7 @@ isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd) }static int -isert_put_response (struct iscsi_conn *conn,struct iscsi_cmd *cmd) +isert_put_response (struct iscsi_conn *conn,struct iscsit_cmd *cmd) {struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);struct isert_conn *isert_conn = conn->context;
@@ -1843,7 +1843,7 @@ isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd) }static void -isert_aborted_task (struct iscsi_conn *conn,struct iscsi_cmd *cmd) +isert_aborted_task (struct iscsi_conn *conn,struct iscsit_cmd *cmd) {struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);struct isert_conn *isert_conn = conn->context;
@@ -1879,7 +1879,7 @@ isert_get_sup_prot_ops(struct iscsi_conn *conn) }static int -isert_put_nopin (struct iscsi_cmd *cmd,struct iscsi_conn *conn, +isert_put_nopin (struct iscsit_cmd *cmd,struct iscsi_conn *conn,bool nopout_response) {struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);
@@ -1899,7 +1899,7 @@ isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, }static int -isert_put_logout_rsp (struct iscsi_cmd *cmd,struct iscsi_conn *conn) +isert_put_logout_rsp (struct iscsit_cmd *cmd,struct iscsi_conn *conn) {struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);struct isert_conn *isert_conn = conn->context;
@@ -1917,7 +1917,7 @@ isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) }static int -isert_put_tm_rsp (struct iscsi_cmd *cmd,struct iscsi_conn *conn) +isert_put_tm_rsp (struct iscsit_cmd *cmd,struct iscsi_conn *conn) {struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);struct isert_conn *isert_conn = conn->context;
@@ -1935,7 +1935,7 @@ isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) }static int -isert_put_reject (struct iscsi_cmd *cmd,struct iscsi_conn *conn) +isert_put_reject (struct iscsit_cmd *cmd,struct iscsi_conn *conn) {struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);struct isert_conn *isert_conn = conn->context;
@@ -1970,7 +1970,7 @@ isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn) }static int -isert_put_text_rsp (struct iscsi_cmd *cmd,struct iscsi_conn *conn) +isert_put_text_rsp (struct iscsit_cmd *cmd,struct iscsi_conn *conn) {struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);struct isert_conn *isert_conn = conn->context;
@@ -2072,7 +2072,7 @@ static int isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn, struct ib_cqe *cqe, struct ib_send_wr *chain_wr) { - struct se_cmd *se_cmd = &cmd->iscsi_cmd->se_cmd; + struct se_cmd *se_cmd = &cmd->iscsit_cmd->se_cmd;enum dma_data_direction dir =target_reverse_dma_direction (se_cmd);u8 port_num = conn->cm_id->port_num;u64 addr;
@@ -2085,7 +2085,7 @@ isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn,if (dir ==DMA_FROM_DEVICE ) { addr = cmd->write_va; rkey = cmd->write_stag; - offset = cmd->iscsi_cmd->write_data_done; + offset = cmd->iscsit_cmd->write_data_done; }else { addr = cmd->read_va; rkey = cmd->read_stag;
@@ -2125,7 +2125,7 @@ isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn, }static int -isert_put_datain (struct iscsi_conn *conn,struct iscsi_cmd *cmd) +isert_put_datain (struct iscsi_conn *conn,struct iscsit_cmd *cmd) {struct se_cmd *se_cmd = &cmd->se_cmd;struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);
@@ -2166,7 +2166,7 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) }static int -isert_get_dataout (struct iscsi_conn *conn,struct iscsi_cmd *cmd,bool recovery) +isert_get_dataout (struct iscsi_conn *conn,struct iscsit_cmd *cmd,bool recovery) {struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);int ret;
@@ -2184,7 +2184,7 @@ isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) }static int -isert_immediate_queue (struct iscsi_conn *conn,struct iscsi_cmd *cmd,int state) +isert_immediate_queue (struct iscsi_conn *conn,struct iscsit_cmd *cmd,int state) {struct isert_cmd *isert_cmd =iscsit_priv_cmd (cmd);int ret =0 ;
@@ -2209,7 +2209,7 @@ isert_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state) }static int -isert_response_queue (struct iscsi_conn *conn,struct iscsi_cmd *cmd,int state) +isert_response_queue (struct iscsi_conn *conn,struct iscsit_cmd *cmd,int state) {struct isert_conn *isert_conn = conn->context;int ret;
@@ -2560,7 +2560,7 @@ isert_wait4cmds(struct iscsi_conn *conn)static void isert_put_unsol_pending_cmds (struct iscsi_conn *conn) { -struct iscsi_cmd *cmd, *tmp; +struct iscsit_cmd *cmd, *tmp;static LIST_HEAD (drop_cmd_list);spin_lock_bh (&conn->cmd_lock);
drivers/infiniband/ulp/isert/ib_isert.h +1 -1
@@ -146,7 +146,7 @@ struct isert_cmd {u64 pdu_buf_dma;u32 pdu_buf_len;struct isert_conn *conn; -struct iscsi_cmd *iscsi_cmd; +struct iscsit_cmd *iscsit_cmd;struct iser_tx_desc tx_desc;struct iser_rx_desc *rx_desc;struct rdma_rw_ctx rw;
drivers/target/iscsi/cxgbit/cxgbit.h +4 -4
@@ -327,9 +327,9 @@ int cxgbit_l2t_send(struct cxgbit_device *, struct sk_buff *, struct l2t_entry *);void cxgbit_push_tx_frames (struct cxgbit_sock *);int cxgbit_put_login_tx (struct iscsi_conn *,struct iscsi_login *,u32 ); -int cxgbit_xmit_pdu (struct iscsi_conn *,struct iscsi_cmd *, +int cxgbit_xmit_pdu (struct iscsi_conn *,struct iscsit_cmd *,struct iscsi_datain_req *,const void *,u32 ); -void cxgbit_get_r2t_ttt (struct iscsi_conn *,struct iscsi_cmd *, +void cxgbit_get_r2t_ttt (struct iscsi_conn *,struct iscsit_cmd *,struct iscsi_r2t *);u32 cxgbit_send_tx_flowc_wr (struct cxgbit_sock *);int cxgbit_ofld_send (struct cxgbit_device *,struct sk_buff *);
@@ -340,8 +340,8 @@ struct cxgbit_device *cxgbit_find_device(struct net_device *, u8 *);/* DDP */ int cxgbit_ddp_init (struct cxgbit_device *);int cxgbit_setup_conn_pgidx (struct cxgbit_sock *,u32 ); -int cxgbit_reserve_ttt (struct cxgbit_sock *,struct iscsi_cmd *); -void cxgbit_unmap_cmd (struct iscsi_conn *,struct iscsi_cmd *); +int cxgbit_reserve_ttt (struct cxgbit_sock *,struct iscsit_cmd *); +void cxgbit_unmap_cmd (struct iscsi_conn *,struct iscsit_cmd *);static inline struct cxgbi_ppm *cdev2ppm (struct cxgbit_device *cdev)
drivers/target/iscsi/cxgbit/cxgbit_ddp.c +2 -2
@@ -227,7 +227,7 @@ cxgbit_ddp_reserve(struct cxgbit_sock *csk, struct cxgbi_task_tag_info *ttinfo, }void -cxgbit_get_r2t_ttt (struct iscsi_conn *conn,struct iscsi_cmd *cmd, +cxgbit_get_r2t_ttt (struct iscsi_conn *conn,struct iscsit_cmd *cmd,struct iscsi_r2t *r2t) {struct cxgbit_sock *csk = conn->context;
@@ -260,7 +260,7 @@ cxgbit_get_r2t_ttt(struct iscsi_conn *conn, struct iscsi_cmd *cmd, r2t->targ_xfer_tag = ttinfo->tag; } -void cxgbit_unmap_cmd (struct iscsi_conn *conn,struct iscsi_cmd *cmd) +void cxgbit_unmap_cmd (struct iscsi_conn *conn,struct iscsit_cmd *cmd) {struct cxgbit_cmd *ccmd =iscsit_priv_cmd (cmd);
drivers/target/iscsi/cxgbit/cxgbit_target.c +17 -17
@@ -337,7 +337,7 @@ static int cxgbit_queue_skb(struct cxgbit_sock *csk, struct sk_buff *skb) }static int -cxgbit_map_skb (struct iscsi_cmd *cmd,struct sk_buff *skb,u32 data_offset, +cxgbit_map_skb (struct iscsit_cmd *cmd,struct sk_buff *skb,u32 data_offset,u32 data_length) {u32 i =0 , nr_frags =MAX_SKB_FRAGS ;
@@ -390,7 +390,7 @@ cxgbit_map_skb(struct iscsi_cmd *cmd, struct sk_buff *skb, u32 data_offset, }static int -cxgbit_tx_datain_iso (struct cxgbit_sock *csk,struct iscsi_cmd *cmd, +cxgbit_tx_datain_iso (struct cxgbit_sock *csk,struct iscsit_cmd *cmd,struct iscsi_datain_req *dr) {struct iscsi_conn *conn = csk->conn;
@@ -481,7 +481,7 @@ cxgbit_tx_datain_iso(struct cxgbit_sock *csk, struct iscsi_cmd *cmd, }static int -cxgbit_tx_datain (struct cxgbit_sock *csk,struct iscsi_cmd *cmd, +cxgbit_tx_datain (struct cxgbit_sock *csk,struct iscsit_cmd *cmd,const struct iscsi_datain *datain) {struct sk_buff *skb;
@@ -510,7 +510,7 @@ cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsi_cmd *cmd, }static int -cxgbit_xmit_datain_pdu (struct iscsi_conn *conn,struct iscsi_cmd *cmd, +cxgbit_xmit_datain_pdu (struct iscsi_conn *conn,struct iscsit_cmd *cmd,struct iscsi_datain_req *dr,const struct iscsi_datain *datain) {
@@ -530,7 +530,7 @@ cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, }static int -cxgbit_xmit_nondatain_pdu (struct iscsi_conn *conn,struct iscsi_cmd *cmd, +cxgbit_xmit_nondatain_pdu (struct iscsi_conn *conn,struct iscsit_cmd *cmd,const void *data_buf,u32 data_buf_len) {struct cxgbit_sock *csk = conn->context;
@@ -560,7 +560,7 @@ cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, }int -cxgbit_xmit_pdu (struct iscsi_conn *conn,struct iscsi_cmd *cmd, +cxgbit_xmit_pdu (struct iscsi_conn *conn,struct iscsit_cmd *cmd,struct iscsi_datain_req *dr,const void *buf,u32 buf_len) {if (dr)
@@ -832,16 +832,16 @@ cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg, } } -static struct iscsi_cmd *cxgbit_allocate_cmd (struct cxgbit_sock *csk) +static struct iscsit_cmd *cxgbit_allocate_cmd (struct cxgbit_sock *csk) {struct iscsi_conn *conn = csk->conn;struct cxgbi_ppm *ppm =cdev2ppm (csk->com.cdev);struct cxgbit_cmd *ccmd; -struct iscsi_cmd *cmd; +struct iscsit_cmd *cmd; cmd =iscsit_allocate_cmd (conn,TASK_INTERRUPTIBLE );if (!cmd) { -pr_err ("Unable to allocate iscsi_cmd + cxgbit_cmd\n" ); +pr_err ("Unable to allocate iscsit_cmd + cxgbit_cmd\n" );return NULL ; }
@@ -853,7 +853,7 @@ static struct iscsi_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk) }static int -cxgbit_handle_immediate_data (struct iscsi_cmd *cmd,struct iscsi_scsi_req *hdr, +cxgbit_handle_immediate_data (struct iscsit_cmd *cmd,struct iscsi_scsi_req *hdr,u32 length) {struct iscsi_conn *conn = cmd->conn;
@@ -910,7 +910,7 @@ cxgbit_handle_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, }static int -cxgbit_get_immediate_data (struct iscsi_cmd *cmd,struct iscsi_scsi_req *hdr, +cxgbit_get_immediate_data (struct iscsit_cmd *cmd,struct iscsi_scsi_req *hdr,bool dump_payload) {struct iscsi_conn *conn = cmd->conn;
@@ -964,7 +964,7 @@ cxgbit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, }static int -cxgbit_handle_scsi_cmd (struct cxgbit_sock *csk,struct iscsi_cmd *cmd) +cxgbit_handle_scsi_cmd (struct cxgbit_sock *csk,struct iscsit_cmd *cmd) {struct iscsi_conn *conn = csk->conn;struct cxgbit_lro_pdu_cb *pdu_cb =cxgbit_rx_pdu_cb (csk->skb);
@@ -996,7 +996,7 @@ static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk) {struct scatterlist *sg_start;struct iscsi_conn *conn = csk->conn; -struct iscsi_cmd *cmd =NULL ; +struct iscsit_cmd *cmd =NULL ;struct cxgbit_cmd *ccmd;struct cxgbi_task_tag_info *ttinfo;struct cxgbit_lro_pdu_cb *pdu_cb =cxgbit_rx_pdu_cb (csk->skb);
@@ -1084,7 +1084,7 @@ static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk)return 0 ; } -static int cxgbit_handle_nop_out (struct cxgbit_sock *csk,struct iscsi_cmd *cmd) +static int cxgbit_handle_nop_out (struct cxgbit_sock *csk,struct iscsit_cmd *cmd) {struct iscsi_conn *conn = csk->conn;struct cxgbit_lro_pdu_cb *pdu_cb =cxgbit_rx_pdu_cb (csk->skb);
@@ -1134,7 +1134,7 @@ static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) ping_data[payload_length] ='\0' ;/* -* Attach ping data to struct iscsi_cmd->buf_ptr. +* Attach ping data to struct iscsit_cmd->buf_ptr. */ cmd->buf_ptr = ping_data; cmd->buf_ptr_size = payload_length;
@@ -1152,7 +1152,7 @@ static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) }static int -cxgbit_handle_text_cmd (struct cxgbit_sock *csk,struct iscsi_cmd *cmd) +cxgbit_handle_text_cmd (struct cxgbit_sock *csk,struct iscsit_cmd *cmd) {struct iscsi_conn *conn = csk->conn;struct cxgbit_lro_pdu_cb *pdu_cb =cxgbit_rx_pdu_cb (csk->skb);
@@ -1210,7 +1210,7 @@ static int cxgbit_target_rx_opcode(struct cxgbit_sock *csk)struct cxgbit_lro_pdu_cb *pdu_cb =cxgbit_rx_pdu_cb (csk->skb);struct iscsi_hdr *hdr = (struct iscsi_hdr *)pdu_cb->hdr;struct iscsi_conn *conn = csk->conn; -struct iscsi_cmd *cmd =NULL ; +struct iscsit_cmd *cmd =NULL ;u8 opcode = (hdr->opcode &ISCSI_OPCODE_MASK );int ret = -EINVAL ;
drivers/target/iscsi/iscsi_target.c +75 -75
569 lines not on this page · raw message
drivers/target/iscsi/iscsi_target.h +7 -7
@@ -5,7 +5,7 @@#include <linux/types.h> #include <linux/spinlock.h> -struct iscsi_cmd ; +struct iscsit_cmd ;struct iscsi_conn ;struct iscsi_np ;struct iscsi_portal_group ;
@@ -30,13 +30,13 @@ extern struct iscsi_np *iscsit_add_np(struct sockaddr_storage *,extern int iscsit_reset_np_thread (struct iscsi_np *,struct iscsi_tpg_np *,struct iscsi_portal_group *,bool );extern int iscsit_del_np (struct iscsi_np *); -extern int iscsit_reject_cmd (struct iscsi_cmd *cmd,u8 ,unsigned char *); -extern void iscsit_set_unsolicited_dataout (struct iscsi_cmd *); -extern int iscsit_logout_closesession (struct iscsi_cmd *,struct iscsi_conn *); -extern int iscsit_logout_closeconnection (struct iscsi_cmd *,struct iscsi_conn *); -extern int iscsit_logout_removeconnforrecovery (struct iscsi_cmd *,struct iscsi_conn *); +extern int iscsit_reject_cmd (struct iscsit_cmd *cmd,u8 ,unsigned char *); +extern void iscsit_set_unsolicited_dataout (struct iscsit_cmd *); +extern int iscsit_logout_closesession (struct iscsit_cmd *,struct iscsi_conn *); +extern int iscsit_logout_closeconnection (struct iscsit_cmd *,struct iscsi_conn *); +extern int iscsit_logout_removeconnforrecovery (struct iscsit_cmd *,struct iscsi_conn *);extern int iscsit_send_async_msg (struct iscsi_conn *,u16 ,u8 ,u8 ); -extern int iscsit_build_r2ts_for_cmd (struct iscsi_conn *,struct iscsi_cmd *,bool recovery); +extern int iscsit_build_r2ts_for_cmd (struct iscsi_conn *,struct iscsit_cmd *,bool recovery);extern void iscsit_thread_get_cpumask (struct iscsi_conn *);extern int iscsi_target_tx_thread (void *);extern int iscsi_target_rx_thread (void *);
drivers/target/iscsi/iscsi_target_configfs.c +7 -7
@@ -1337,7 +1337,7 @@ static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {static int iscsi_get_cmd_state (struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);return cmd->i_state; }
@@ -1363,7 +1363,7 @@ static u32 lio_sess_get_initiator_sid(static int lio_queue_data_in (struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);struct iscsi_conn *conn = cmd->conn; cmd->i_state =ISTATE_SEND_DATAIN ;
@@ -1372,7 +1372,7 @@ static int lio_queue_data_in(struct se_cmd *se_cmd)static int lio_write_pending (struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);struct iscsi_conn *conn = cmd->conn;if (!cmd->immediate_data && !cmd->unsolicited_data)
@@ -1383,7 +1383,7 @@ static int lio_write_pending(struct se_cmd *se_cmd)static int lio_queue_status (struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);struct iscsi_conn *conn = cmd->conn; cmd->i_state =ISTATE_SEND_STATUS ;
@@ -1396,7 +1396,7 @@ static int lio_queue_status(struct se_cmd *se_cmd)static void lio_queue_tm_rsp (struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); cmd->i_state =ISTATE_SEND_TASKMGTRSP ;iscsit_add_cmd_to_response_queue (cmd, cmd->conn, cmd->i_state);
@@ -1404,7 +1404,7 @@ static void lio_queue_tm_rsp(struct se_cmd *se_cmd)static void lio_aborted_task (struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); cmd->conn->conn_transport->iscsit_aborted_task (cmd->conn, cmd); }
@@ -1519,7 +1519,7 @@ static int lio_check_stop_free(struct se_cmd *se_cmd)static void lio_release_cmd (struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);pr_debug ("Entering lio_release_cmd for se_cmd: %p\n" , se_cmd);iscsit_release_cmd (cmd);
drivers/target/iscsi/iscsi_target_datain_values.c +9 -9
@@ -32,14 +32,14 @@ struct iscsi_datain_req *iscsit_allocate_datain_req(void)return dr; } -void iscsit_attach_datain_req (struct iscsi_cmd *cmd,struct iscsi_datain_req *dr) +void iscsit_attach_datain_req (struct iscsit_cmd *cmd,struct iscsi_datain_req *dr) {spin_lock (&cmd->datain_lock);list_add_tail (&dr->cmd_datain_node, &cmd->datain_list);spin_unlock (&cmd->datain_lock); } -void iscsit_free_datain_req (struct iscsi_cmd *cmd,struct iscsi_datain_req *dr) +void iscsit_free_datain_req (struct iscsit_cmd *cmd,struct iscsi_datain_req *dr) {spin_lock (&cmd->datain_lock);list_del (&dr->cmd_datain_node);
@@ -48,7 +48,7 @@ void iscsit_free_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr)kmem_cache_free (lio_dr_cache, dr); } -void iscsit_free_all_datain_reqs (struct iscsi_cmd *cmd) +void iscsit_free_all_datain_reqs (struct iscsit_cmd *cmd) {struct iscsi_datain_req *dr, *dr_tmp;
@@ -60,7 +60,7 @@ void iscsit_free_all_datain_reqs(struct iscsi_cmd *cmd)spin_unlock (&cmd->datain_lock); } -struct iscsi_datain_req *iscsit_get_datain_req (struct iscsi_cmd *cmd) +struct iscsi_datain_req *iscsit_get_datain_req (struct iscsit_cmd *cmd) {if (list_empty (&cmd->datain_list)) { pr_err("cmd->datain_list is empty for ITT:"
@@ -76,7 +76,7 @@ struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd)* For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=Yes. */ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_datain *datain) {u32 next_burst_len, read_data_done, read_data_left;
@@ -174,7 +174,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes(* For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=Yes. */ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_datain *datain) {u32 offset, read_data_done, read_data_left, seq_send_order;
@@ -295,7 +295,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes(* For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=No. */ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_datain *datain) {u32 next_burst_len, read_data_done, read_data_left;
@@ -394,7 +394,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no(* For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=No. */ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_datain *datain) {u32 read_data_done, read_data_left, seq_send_order;
@@ -496,7 +496,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no( }struct iscsi_datain_req *iscsit_get_datain_values ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_datain *datain) {struct iscsi_conn *conn = cmd->conn;
drivers/target/iscsi/iscsi_target_datain_values.h +6 -6
@@ -2,15 +2,15 @@#ifndef ISCSI_TARGET_DATAIN_VALUES_H #define ISCSI_TARGET_DATAIN_VALUES_H -struct iscsi_cmd ; +struct iscsit_cmd ;struct iscsi_datain ;extern struct iscsi_datain_req *iscsit_allocate_datain_req (void ); -extern void iscsit_attach_datain_req (struct iscsi_cmd *,struct iscsi_datain_req *); -extern void iscsit_free_datain_req (struct iscsi_cmd *,struct iscsi_datain_req *); -extern void iscsit_free_all_datain_reqs (struct iscsi_cmd *); -extern struct iscsi_datain_req *iscsit_get_datain_req (struct iscsi_cmd *); -extern struct iscsi_datain_req *iscsit_get_datain_values (struct iscsi_cmd *, +extern void iscsit_attach_datain_req (struct iscsit_cmd *,struct iscsi_datain_req *); +extern void iscsit_free_datain_req (struct iscsit_cmd *,struct iscsi_datain_req *); +extern void iscsit_free_all_datain_reqs (struct iscsit_cmd *); +extern struct iscsi_datain_req *iscsit_get_datain_req (struct iscsit_cmd *); +extern struct iscsi_datain_req *iscsit_get_datain_values (struct iscsit_cmd *,struct iscsi_datain *);#endif /*** ISCSI_TARGET_DATAIN_VALUES_H ***/
drivers/target/iscsi/iscsi_target_device.c +1 -1
@@ -42,7 +42,7 @@ void iscsit_determine_maxcmdsn(struct iscsi_session *sess)atomic_add (se_nacl->queue_depth -1 , &sess->max_cmd_sn); } -void iscsit_increment_maxcmdsn (struct iscsi_cmd *cmd,struct iscsi_session *sess) +void iscsit_increment_maxcmdsn (struct iscsit_cmd *cmd,struct iscsi_session *sess) {u32 max_cmd_sn;
drivers/target/iscsi/iscsi_target_device.h +2 -2
@@ -2,10 +2,10 @@#ifndef ISCSI_TARGET_DEVICE_H #define ISCSI_TARGET_DEVICE_H -struct iscsi_cmd ; +struct iscsit_cmd ;struct iscsi_session ;extern void iscsit_determine_maxcmdsn (struct iscsi_session *); -extern void iscsit_increment_maxcmdsn (struct iscsi_cmd *,struct iscsi_session *); +extern void iscsit_increment_maxcmdsn (struct iscsit_cmd *,struct iscsi_session *);#endif /* ISCSI_TARGET_DEVICE_H */
drivers/target/iscsi/iscsi_target_erl0.c +15 -15
@@ -24,12 +24,12 @@#include "iscsi_target.h" /* -* Used to set values in struct iscsi_cmd that iscsit_dataout_check_sequence() +* Used to set values in struct iscsit_cmd that iscsit_dataout_check_sequence() * checks against to determine a PDU's Offset+Length is within the current * DataOUT Sequence. Used for DataSequenceInOrder=Yes only. */ void iscsit_set_dataout_sequence_values ( -struct iscsi_cmd *cmd) +struct iscsit_cmd *cmd) {struct iscsi_conn *conn = cmd->conn;/*
@@ -63,7 +63,7 @@ void iscsit_set_dataout_sequence_values( }static int iscsit_dataout_within_command_recovery_check ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) {struct iscsi_conn *conn = cmd->conn;
@@ -129,7 +129,7 @@ static int iscsit_dataout_within_command_recovery_check( }static int iscsit_dataout_check_unsolicited_sequence ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) {u32 first_burst_len;
@@ -204,7 +204,7 @@ static int iscsit_dataout_check_unsolicited_sequence( }static int iscsit_dataout_check_sequence ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) {u32 next_burst_len;
@@ -333,7 +333,7 @@ static int iscsit_dataout_check_sequence( }static int iscsit_dataout_check_datasn ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) {u32 data_sn =0 ;
@@ -384,7 +384,7 @@ static int iscsit_dataout_check_datasn( }static int iscsit_dataout_pre_datapduinorder_yes ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) {int dump =0 , recovery =0 ;
@@ -394,7 +394,7 @@ static int iscsit_dataout_pre_datapduinorder_yes(/* * For DataSequenceInOrder=Yes: If the offset is greater than the global -* DataPDUInOrder=Yes offset counter in struct iscsi_cmd a protcol error has +* DataPDUInOrder=Yes offset counter in struct iscsit_cmd a protcol error has * occurred and fail the connection. * * For DataSequenceInOrder=No: If the offset is greater than the per
@@ -446,7 +446,7 @@ static int iscsit_dataout_pre_datapduinorder_yes( }static int iscsit_dataout_pre_datapduinorder_no ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) {struct iscsi_pdu *pdu;
@@ -477,7 +477,7 @@ static int iscsit_dataout_pre_datapduinorder_no(return DATAOUT_NORMAL ; } -static int iscsit_dataout_update_r2t (struct iscsi_cmd *cmd,u32 offset,u32 length) +static int iscsit_dataout_update_r2t (struct iscsit_cmd *cmd,u32 offset,u32 length) {struct iscsi_r2t *r2t;
@@ -497,7 +497,7 @@ static int iscsit_dataout_update_r2t(struct iscsi_cmd *cmd, u32 offset, u32 leng }static int iscsit_dataout_update_datapduinorder_no ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,u32 data_sn,int f_bit) {
@@ -530,7 +530,7 @@ static int iscsit_dataout_update_datapduinorder_no( }static int iscsit_dataout_post_crc_passed ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) {int ret, send_r2t =0 ;
@@ -641,7 +641,7 @@ static int iscsit_dataout_post_crc_passed( }static int iscsit_dataout_post_crc_failed ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) {struct iscsi_conn *conn = cmd->conn;
@@ -679,7 +679,7 @@ static int iscsit_dataout_post_crc_failed(* and CRC computed. */ int iscsit_check_pre_dataout ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) {int ret;
@@ -717,7 +717,7 @@ int iscsit_check_pre_dataout(* and CRC computed. */ int iscsit_check_post_dataout ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf,u8 data_crc_failed) {
drivers/target/iscsi/iscsi_target_erl0.h +4 -4
@@ -4,13 +4,13 @@#include <linux/types.h> -struct iscsi_cmd ; +struct iscsit_cmd ;struct iscsi_conn ;struct iscsi_session ; -extern void iscsit_set_dataout_sequence_values (struct iscsi_cmd *); -extern int iscsit_check_pre_dataout (struct iscsi_cmd *,unsigned char *); -extern int iscsit_check_post_dataout (struct iscsi_cmd *,unsigned char *,u8 ); +extern void iscsit_set_dataout_sequence_values (struct iscsit_cmd *); +extern int iscsit_check_pre_dataout (struct iscsit_cmd *,unsigned char *); +extern int iscsit_check_post_dataout (struct iscsit_cmd *,unsigned char *,u8 );extern void iscsit_start_time2retain_handler (struct iscsi_session *);extern void iscsit_handle_time2retain_timeout (struct timer_list *t);extern int iscsit_stop_time2retain_timer (struct iscsi_session *);
drivers/target/iscsi/iscsi_target_erl1.c +21 -21
168 lines not on this page · raw message
drivers/target/iscsi/iscsi_target_erl1.h +10 -10
@@ -5,7 +5,7 @@#include <linux/types.h> #include <scsi/iscsi_proto.h> /* itt_t */ -struct iscsi_cmd ; +struct iscsit_cmd ;struct iscsi_conn ;struct iscsi_datain_req ;struct iscsi_ooo_cmdsn ;
@@ -14,25 +14,25 @@ struct iscsi_session;extern int iscsit_dump_data_payload (struct iscsi_conn *,u32 ,int );extern int iscsit_create_recovery_datain_values_datasequenceinorder_yes ( -struct iscsi_cmd *,struct iscsi_datain_req *); +struct iscsit_cmd *,struct iscsi_datain_req *);extern int iscsit_create_recovery_datain_values_datasequenceinorder_no ( -struct iscsi_cmd *,struct iscsi_datain_req *); +struct iscsit_cmd *,struct iscsi_datain_req *);extern int iscsit_handle_recovery_datain_or_r2t (struct iscsi_conn *,unsigned char *,itt_t ,u32 ,u32 ,u32 );extern int iscsit_handle_status_snack (struct iscsi_conn *,itt_t ,u32 ,u32 ,u32 );extern int iscsit_handle_data_ack (struct iscsi_conn *,u32 ,u32 ,u32 ); -extern int iscsit_dataout_datapduinorder_no_fbit (struct iscsi_cmd *,struct iscsi_pdu *); -extern int iscsit_recover_dataout_sequence (struct iscsi_cmd *,u32 ,u32 ); +extern int iscsit_dataout_datapduinorder_no_fbit (struct iscsit_cmd *,struct iscsi_pdu *); +extern int iscsit_recover_dataout_sequence (struct iscsit_cmd *,u32 ,u32 );extern void iscsit_clear_ooo_cmdsns_for_conn (struct iscsi_conn *);extern void iscsit_free_all_ooo_cmdsns (struct iscsi_session *);extern int iscsit_execute_ooo_cmdsns (struct iscsi_session *); -extern int iscsit_execute_cmd (struct iscsi_cmd *,int ); -extern int iscsit_handle_ooo_cmdsn (struct iscsi_session *,struct iscsi_cmd *,u32 ); +extern int iscsit_execute_cmd (struct iscsit_cmd *,int ); +extern int iscsit_handle_ooo_cmdsn (struct iscsi_session *,struct iscsit_cmd *,u32 );extern void iscsit_remove_ooo_cmdsn (struct iscsi_session *,struct iscsi_ooo_cmdsn *);extern void iscsit_handle_dataout_timeout (struct timer_list *t); -extern void iscsit_mod_dataout_timer (struct iscsi_cmd *); -extern void iscsit_start_dataout_timer (struct iscsi_cmd *,struct iscsi_conn *); -extern void iscsit_stop_dataout_timer (struct iscsi_cmd *); +extern void iscsit_mod_dataout_timer (struct iscsit_cmd *); +extern void iscsit_start_dataout_timer (struct iscsit_cmd *,struct iscsi_conn *); +extern void iscsit_stop_dataout_timer (struct iscsit_cmd *);#endif /* ISCSI_TARGET_ERL1_H */
drivers/target/iscsi/iscsi_target_erl2.c +10 -10
@@ -26,7 +26,7 @@* FIXME: Does RData SNACK apply here as well? */ void iscsit_create_conn_recovery_datain_values ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,__be32 exp_data_sn) {u32 data_sn =0 ;
@@ -54,7 +54,7 @@ void iscsit_create_conn_recovery_datain_values( }void iscsit_create_conn_recovery_dataout_values ( -struct iscsi_cmd *cmd) +struct iscsit_cmd *cmd) {u32 write_data_done =0 ;struct iscsi_conn *conn = cmd->conn;
@@ -119,7 +119,7 @@ struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry(void iscsit_free_connection_recovery_entries (struct iscsi_session *sess) { -struct iscsi_cmd *cmd, *cmd_tmp; +struct iscsit_cmd *cmd, *cmd_tmp;struct iscsi_conn_recovery *cr, *cr_tmp;spin_lock (&sess->cr_a_lock);
@@ -197,7 +197,7 @@ static void iscsit_remove_inactive_connection_recovery_entry(* Called with cr->conn_recovery_cmd_lock help. */ int iscsit_remove_cmd_from_connection_recovery ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_session *sess) {struct iscsi_conn_recovery *cr;
@@ -218,7 +218,7 @@ void iscsit_discard_cr_cmds_by_expstatsn( u32 exp_statsn) {u32 dropped_count =0 ; -struct iscsi_cmd *cmd, *cmd_tmp; +struct iscsit_cmd *cmd, *cmd_tmp;struct iscsi_session *sess = cr->sess;spin_lock (&cr->conn_recovery_cmd_lock);
@@ -266,7 +266,7 @@ void iscsit_discard_cr_cmds_by_expstatsn(int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn (struct iscsi_conn *conn) {u32 dropped_count =0 ; -struct iscsi_cmd *cmd, *cmd_tmp; +struct iscsit_cmd *cmd, *cmd_tmp;struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;struct iscsi_session *sess = conn->sess;
@@ -307,13 +307,13 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn)int iscsit_prepare_cmds_for_reallegiance (struct iscsi_conn *conn) {u32 cmd_count =0 ; -struct iscsi_cmd *cmd, *cmd_tmp; +struct iscsit_cmd *cmd, *cmd_tmp;struct iscsi_conn_recovery *cr;/* * Allocate an struct iscsi_conn_recovery for this connection. -* Each struct iscsi_cmd contains an struct iscsi_conn_recovery pointer -* (struct iscsi_cmd->cr) so we need to allocate this before preparing the +* Each struct iscsit_cmd contains an struct iscsi_conn_recovery pointer +* (struct iscsit_cmd->cr) so we need to allocate this before preparing the * connection's command list for connection recovery. */ cr =kzalloc (sizeof (struct iscsi_conn_recovery ),GFP_KERNEL );
@@ -393,7 +393,7 @@ int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn)transport_wait_for_tasks (&cmd->se_cmd);/* -* Add the struct iscsi_cmd to the connection recovery cmd list +* Add the struct iscsit_cmd to the connection recovery cmd list */ spin_lock (&cr->conn_recovery_cmd_lock);list_add_tail (&cmd->i_conn_node, &cr->conn_recovery_cmd_list);
drivers/target/iscsi/iscsi_target_erl2.h +4 -4
@@ -4,19 +4,19 @@#include <linux/types.h> -struct iscsi_cmd ; +struct iscsit_cmd ;struct iscsi_conn ;struct iscsi_conn_recovery ;struct iscsi_session ; -extern void iscsit_create_conn_recovery_datain_values (struct iscsi_cmd *,__be32 ); -extern void iscsit_create_conn_recovery_dataout_values (struct iscsi_cmd *); +extern void iscsit_create_conn_recovery_datain_values (struct iscsit_cmd *,__be32 ); +extern void iscsit_create_conn_recovery_dataout_values (struct iscsit_cmd *);extern struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry (struct iscsi_session *,u16 );extern void iscsit_free_connection_recovery_entries (struct iscsi_session *);extern int iscsit_remove_active_connection_recovery_entry (struct iscsi_conn_recovery *,struct iscsi_session *); -extern int iscsit_remove_cmd_from_connection_recovery (struct iscsi_cmd *, +extern int iscsit_remove_cmd_from_connection_recovery (struct iscsit_cmd *,struct iscsi_session *);extern void iscsit_discard_cr_cmds_by_expstatsn (struct iscsi_conn_recovery *,u32 );extern int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn (struct iscsi_conn *);
drivers/target/iscsi/iscsi_target_nego.c +1 -1
@@ -1289,7 +1289,7 @@ int iscsi_target_locate_portal( alloc_tags: tag_num =max_t (u32,ISCSIT_MIN_TAGS , queue_depth); tag_num = (tag_num *2 ) +ISCSIT_EXTRA_TAGS ; - tag_size =sizeof (struct iscsi_cmd ) + conn->conn_transport->priv_size; + tag_size =sizeof (struct iscsit_cmd ) + conn->conn_transport->priv_size; ret =transport_alloc_session_tags (sess->se_sess, tag_num, tag_size);if (ret <0 ) {
drivers/target/iscsi/iscsi_target_seq_pdu_list.c +17 -17
@@ -18,7 +18,7 @@#include "iscsi_target_seq_pdu_list.h" #ifdef DEBUG -static void iscsit_dump_seq_list (struct iscsi_cmd *cmd) +static void iscsit_dump_seq_list (struct iscsit_cmd *cmd) {int i;struct iscsi_seq *seq;
@@ -36,7 +36,7 @@ static void iscsit_dump_seq_list(struct iscsi_cmd *cmd) } } -static void iscsit_dump_pdu_list (struct iscsi_cmd *cmd) +static void iscsit_dump_pdu_list (struct iscsit_cmd *cmd) {int i;struct iscsi_pdu *pdu;
@@ -52,12 +52,12 @@ static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd) } }#else -static void iscsit_dump_seq_list (struct iscsi_cmd *cmd) {} -static void iscsit_dump_pdu_list (struct iscsi_cmd *cmd) {} +static void iscsit_dump_seq_list (struct iscsit_cmd *cmd) {} +static void iscsit_dump_pdu_list (struct iscsit_cmd *cmd) {}#endif static void iscsit_ordered_seq_lists ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,u8 type) {u32 i, seq_count =0 ;
@@ -70,7 +70,7 @@ static void iscsit_ordered_seq_lists( }static void iscsit_ordered_pdu_lists ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,u8 type) {u32 i, pdu_send_order =0 , seq_no =0 ;
@@ -117,7 +117,7 @@ static void iscsit_create_random_array(u32 *array, u32 count) }static int iscsit_randomize_pdu_lists ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,u8 type) {int i =0 ;
@@ -167,7 +167,7 @@ static int iscsit_randomize_pdu_lists( }static int iscsit_randomize_seq_lists ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,u8 type) {int i, j =0 ;
@@ -199,7 +199,7 @@ static int iscsit_randomize_seq_lists( }static void iscsit_determine_counts_for_list ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_build_list *bl,u32 *seq_count,u32 *pdu_count)
@@ -283,7 +283,7 @@ static void iscsit_determine_counts_for_list(* or DataPDUInOrder=No. */ static int iscsit_do_build_pdu_and_seq_lists ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_build_list *bl) {int check_immediate =0 , datapduinorder, datasequenceinorder;
@@ -484,7 +484,7 @@ static int iscsit_do_build_pdu_and_seq_lists( }int iscsit_build_pdu_and_seq_lists ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,u32 immediate_data_length) {struct iscsi_build_list bl;
@@ -559,7 +559,7 @@ int iscsit_build_pdu_and_seq_lists( }struct iscsi_pdu *iscsit_get_pdu_holder ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,u32 offset,u32 length) {
@@ -567,7 +567,7 @@ struct iscsi_pdu *iscsit_get_pdu_holder(struct iscsi_pdu *pdu =NULL ;if (!cmd->pdu_list) { -pr_err ("struct iscsi_cmd->pdu_list is NULL!\n" ); +pr_err ("struct iscsit_cmd->pdu_list is NULL!\n" );return NULL ; }
@@ -583,7 +583,7 @@ struct iscsi_pdu *iscsit_get_pdu_holder( }struct iscsi_pdu *iscsit_get_pdu_holder_for_seq ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_seq *seq) {u32 i;
@@ -591,7 +591,7 @@ struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(struct iscsi_pdu *pdu =NULL ;if (!cmd->pdu_list) { -pr_err ("struct iscsi_cmd->pdu_list is NULL!\n" ); +pr_err ("struct iscsit_cmd->pdu_list is NULL!\n" );return NULL ; }
@@ -660,14 +660,14 @@ struct iscsi_pdu *iscsit_get_pdu_holder_for_seq( }struct iscsi_seq *iscsit_get_seq_holder ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,u32 offset,u32 length) {u32 i;if (!cmd->seq_list) { -pr_err ("struct iscsi_cmd->seq_list is NULL!\n" ); +pr_err ("struct iscsit_cmd->seq_list is NULL!\n" );return NULL ; }
drivers/target/iscsi/iscsi_target_seq_pdu_list.h +5 -5
@@ -82,11 +82,11 @@ struct iscsi_seq { u32 xfer_len; }____cacheline_aligned ; -struct iscsi_cmd ; +struct iscsit_cmd ; -extern int iscsit_build_pdu_and_seq_lists (struct iscsi_cmd *,u32 ); -extern struct iscsi_pdu *iscsit_get_pdu_holder (struct iscsi_cmd *,u32 ,u32 ); -extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq (struct iscsi_cmd *,struct iscsi_seq *); -extern struct iscsi_seq *iscsit_get_seq_holder (struct iscsi_cmd *,u32 ,u32 ); +extern int iscsit_build_pdu_and_seq_lists (struct iscsit_cmd *,u32 ); +extern struct iscsi_pdu *iscsit_get_pdu_holder (struct iscsit_cmd *,u32 ,u32 ); +extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq (struct iscsit_cmd *,struct iscsi_seq *); +extern struct iscsi_seq *iscsit_get_seq_holder (struct iscsit_cmd *,u32 ,u32 );#endif /* ISCSI_SEQ_AND_PDU_LIST_H */
drivers/target/iscsi/iscsi_target_tmr.c +19 -19
@@ -28,10 +28,10 @@#include "iscsi_target.h" u8 iscsit_tmr_abort_task ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) { -struct iscsi_cmd *ref_cmd; +struct iscsit_cmd *ref_cmd;struct iscsi_conn *conn = cmd->conn;struct iscsi_tmr_req *tmr_req = cmd->tmr_req;struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
@@ -103,10 +103,10 @@ int iscsit_tmr_task_cold_reset( }u8 iscsit_tmr_task_reassign ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,unsigned char *buf) { -struct iscsi_cmd *ref_cmd =NULL ; +struct iscsit_cmd *ref_cmd =NULL ;struct iscsi_conn *conn = cmd->conn;struct iscsi_conn_recovery *cr =NULL ;struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
@@ -175,7 +175,7 @@ u8 iscsit_tmr_task_reassign( }static void iscsit_task_reassign_remove_cmd ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_conn_recovery *cr,struct iscsi_session *sess) {
@@ -195,7 +195,7 @@ static int iscsit_task_reassign_complete_nop_out(struct iscsi_tmr_req *tmr_req, struct iscsi_conn *conn) { - struct iscsi_cmd *cmd = tmr_req->ref_cmd; + struct iscsit_cmd *cmd = tmr_req->ref_cmd;struct iscsi_conn_recovery *cr;if (!cmd->cr) {
@@ -224,7 +224,7 @@ static int iscsit_task_reassign_complete_nop_out( }static int iscsit_task_reassign_complete_write ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_tmr_req *tmr_req) {int no_build_r2ts =0 ;
@@ -296,7 +296,7 @@ static int iscsit_task_reassign_complete_write( }static int iscsit_task_reassign_complete_read ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_tmr_req *tmr_req) {struct iscsi_conn *conn = cmd->conn;
@@ -349,7 +349,7 @@ static int iscsit_task_reassign_complete_read( }static int iscsit_task_reassign_complete_none ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_tmr_req *tmr_req) {struct iscsi_conn *conn = cmd->conn;
@@ -363,7 +363,7 @@ static int iscsit_task_reassign_complete_scsi_cmnd(struct iscsi_tmr_req *tmr_req, struct iscsi_conn *conn) { - struct iscsi_cmd *cmd = tmr_req->ref_cmd; + struct iscsit_cmd *cmd = tmr_req->ref_cmd;struct iscsi_conn_recovery *cr;if (!cmd->cr) {
@@ -412,11 +412,11 @@ static int iscsit_task_reassign_complete(struct iscsi_tmr_req *tmr_req, struct iscsi_conn *conn) { - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd;int ret =0 ;if (!tmr_req->ref_cmd) { -pr_err ("TMR Request is missing a RefCmd struct iscsi_cmd.\n" ); +pr_err ("TMR Request is missing a RefCmd struct iscsit_cmd.\n" );return -1 ; } cmd = tmr_req->ref_cmd;
@@ -451,7 +451,7 @@ static int iscsit_task_reassign_complete(* Right now the only one that its really needed for is * connection recovery releated TASK_REASSIGN. */ -int iscsit_tmr_post_handler (struct iscsi_cmd *cmd,struct iscsi_conn *conn) +int iscsit_tmr_post_handler (struct iscsit_cmd *cmd,struct iscsi_conn *conn) {struct iscsi_tmr_req *tmr_req = cmd->tmr_req;struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
@@ -475,7 +475,7 @@ static int iscsit_task_reassign_prepare_read( }static void iscsit_task_reassign_prepare_unsolicited_dataout ( -struct iscsi_cmd *cmd, +struct iscsit_cmd *cmd,struct iscsi_conn *conn) {int i, j;
@@ -546,7 +546,7 @@ static int iscsit_task_reassign_prepare_write(struct iscsi_tmr_req *tmr_req, struct iscsi_conn *conn) { - struct iscsi_cmd *cmd = tmr_req->ref_cmd; + struct iscsit_cmd *cmd = tmr_req->ref_cmd;struct iscsi_pdu *pdu =NULL ;struct iscsi_r2t *r2t =NULL , *r2t_tmp;int first_incomplete_r2t =1 , i =0 ;
@@ -575,7 +575,7 @@ static int iscsit_task_reassign_prepare_write(* * If we have not received all DataOUT in question, we must * make sure to make the appropriate changes to values in -* struct iscsi_cmd (and elsewhere depending on session parameters) +* struct iscsit_cmd (and elsewhere depending on session parameters) * so iscsit_build_r2ts_for_cmd() in iscsit_task_reassign_complete_write() * will resend a new R2T for the DataOUT sequences in question. */
@@ -708,7 +708,7 @@ static int iscsit_task_reassign_prepare_write(* to check that the Initiator is not requesting R2Ts for DataOUT * sequences it has already completed. * -* Free each R2T in question and adjust values in struct iscsi_cmd +* Free each R2T in question and adjust values in struct iscsit_cmd * accordingly so iscsit_build_r2ts_for_cmd() do the rest of * the work after the TMR TASK_REASSIGN Response is sent. */
@@ -773,13 +773,13 @@ static int iscsit_task_reassign_prepare_write(/* * Performs sanity checks TMR TASK_REASSIGN's ExpDataSN for -* a given struct iscsi_cmd. +* a given struct iscsit_cmd. */ int iscsit_check_task_reassign_expdatasn (struct iscsi_tmr_req *tmr_req,struct iscsi_conn *conn) { -struct iscsi_cmd *ref_cmd = tmr_req->ref_cmd; +struct iscsit_cmd *ref_cmd = tmr_req->ref_cmd;if (ref_cmd->iscsi_opcode !=ISCSI_OP_SCSI_CMD )return 0 ;
drivers/target/iscsi/iscsi_target_tmr.h +4 -4
@@ -4,17 +4,17 @@#include <linux/types.h> -struct iscsi_cmd ; +struct iscsit_cmd ;struct iscsi_conn ;struct iscsi_tmr_req ; -extern u8 iscsit_tmr_abort_task (struct iscsi_cmd *,unsigned char *); +extern u8 iscsit_tmr_abort_task (struct iscsit_cmd *,unsigned char *);extern int iscsit_tmr_task_warm_reset (struct iscsi_conn *,struct iscsi_tmr_req *,unsigned char *);extern int iscsit_tmr_task_cold_reset (struct iscsi_conn *,struct iscsi_tmr_req *,unsigned char *); -extern u8 iscsit_tmr_task_reassign (struct iscsi_cmd *,unsigned char *); -extern int iscsit_tmr_post_handler (struct iscsi_cmd *,struct iscsi_conn *); +extern u8 iscsit_tmr_task_reassign (struct iscsit_cmd *,unsigned char *); +extern int iscsit_tmr_post_handler (struct iscsit_cmd *,struct iscsi_conn *);extern int iscsit_check_task_reassign_expdatasn (struct iscsi_tmr_req *,struct iscsi_conn *);
drivers/target/iscsi/iscsi_target_util.c +33 -33
240 lines not on this page · raw message
drivers/target/iscsi/iscsi_target_util.h +24 -24
71 lines not on this page · raw message
include/target/iscsi/iscsi_target_core.h +17 -17
@@ -143,7 +143,7 @@ enum tiqn_state_table { TIQN_STATE_SHUTDOWN = 2, }; -/* struct iscsi_cmd->cmd_flags */ +/* struct iscsit_cmd->cmd_flags */ enum cmd_flags_table {ICF_GOT_LAST_DATAOUT =0x00000001 ,ICF_GOT_DATACK_SNACK =0x00000002 ,
@@ -157,7 +157,7 @@ enum cmd_flags_table { ICF_SENDTARGETS_SINGLE = 0x00000200, }; -/* struct iscsi_cmd->i_state */ +/* struct iscsit_cmd->i_state */ enum cmd_i_state_table {ISTATE_NO_STATE =0 ,ISTATE_NEW_CMD =1 ,
@@ -297,7 +297,7 @@ struct iscsi_sess_ops {struct iscsi_queue_req {int state; -struct iscsi_cmd *cmd; +struct iscsit_cmd *cmd;struct list_head qr_list; };
@@ -327,7 +327,7 @@ struct iscsi_ooo_cmdsn {u32 batch_count;u32 cmdsn;u32 exp_cmdsn; -struct iscsi_cmd *cmd; +struct iscsit_cmd *cmd;struct list_head ooo_list; }____cacheline_aligned ;
@@ -349,7 +349,7 @@ struct iscsi_r2t {struct list_head r2t_list; }____cacheline_aligned ; -struct iscsi_cmd { +struct iscsit_cmd {enum iscsi_timer_flags_table dataout_timer_flags;/* DataOUT timeout retries */ u8 dataout_timeout_retries;
@@ -405,22 +405,22 @@ struct iscsi_cmd {u32 outstanding_r2ts;/* Next R2T Offset when DataSequenceInOrder=Yes */ u32 r2t_offset; -/* Iovec current and orig count for iscsi_cmd->iov_data */ +/* Iovec current and orig count for iscsit_cmd->iov_data */ u32 iov_data_count;u32 orig_iov_data_count;/* Number of miscellaneous iovecs used for IP stack calls */ u32 iov_misc_count; -/* Number of struct iscsi_pdu in struct iscsi_cmd->pdu_list */ +/* Number of struct iscsi_pdu in struct iscsit_cmd->pdu_list */ u32 pdu_count; -/* Next struct iscsi_pdu to send in struct iscsi_cmd->pdu_list */ +/* Next struct iscsi_pdu to send in struct iscsit_cmd->pdu_list */ u32 pdu_send_order; -/* Current struct iscsi_pdu in struct iscsi_cmd->pdu_list */ +/* Current struct iscsi_pdu in struct iscsit_cmd->pdu_list */ u32 pdu_start; -/* Next struct iscsi_seq to send in struct iscsi_cmd->seq_list */ +/* Next struct iscsi_seq to send in struct iscsit_cmd->seq_list */ u32 seq_send_order; -/* Number of struct iscsi_seq in struct iscsi_cmd->seq_list */ +/* Number of struct iscsi_seq in struct iscsit_cmd->seq_list */ u32 seq_count; -/* Current struct iscsi_seq in struct iscsi_cmd->seq_list */ +/* Current struct iscsi_seq in struct iscsit_cmd->seq_list */ u32 seq_no;/* Lowest offset in current DataOUT sequence */ u32 seq_start_offset;
@@ -444,12 +444,12 @@ struct iscsi_cmd {enum dma_data_direction data_direction;/* iSCSI PDU Header + CRC */ unsigned char pdu[ISCSI_HDR_LEN +ISCSI_CRC_LEN ]; -/* Number of times struct iscsi_cmd is present in immediate queue */ +/* Number of times struct iscsit_cmd is present in immediate queue */ atomic_t immed_queue_count;atomic_t response_queue_count;spinlock_t datain_lock;spinlock_t dataout_timeout_lock; -/* spinlock for protecting struct iscsi_cmd->i_state */ +/* spinlock for protecting struct iscsit_cmd->i_state */ spinlock_t istate_lock;/* spinlock for adding within command recovery entries */ spinlock_t error_lock;
@@ -503,7 +503,7 @@ struct iscsi_cmd {struct iscsi_tmr_req {bool task_reassign:1 ;u32 exp_data_sn; -struct iscsi_cmd *ref_cmd; +struct iscsit_cmd *ref_cmd;struct iscsi_conn_recovery *conn_recovery;struct se_tmr_req *se_tmr_req; };
@@ -582,7 +582,7 @@ struct iscsi_conn {cpumask_var_t conn_cpumask; unsigned int conn_rx_reset_cpumask:1; unsigned int conn_tx_reset_cpumask:1; -/* list_head of struct iscsi_cmd for this connection */ +/* list_head of struct iscsit_cmd for this connection */ struct list_head conn_cmd_list;struct list_head immed_queue_list;struct list_head response_queue_list;
@@ -896,7 +896,7 @@ static inline u32 session_get_next_ttt(struct iscsi_session *session)return ttt; } -extern struct iscsi_cmd *iscsit_find_cmd_from_itt (struct iscsi_conn *,itt_t ); +extern struct iscsit_cmd *iscsit_find_cmd_from_itt (struct iscsi_conn *,itt_t ); static inline void iscsit_thread_check_cpumask( struct iscsi_conn *conn,
include/target/iscsi/iscsi_transport.h +46 -46
159 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 365/595 IB/isert: wait for deferred control PDU completions before releasing the connection
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit a8fe3dfce8c0d8a76dc3d8486a5bff5feebe156f ]
isert_send_done() hands ISTATE_SEND_TASKMGTRSP, ISTATE_SEND_REJECT and ISTATE_SEND_TEXTRSP completions off to isert_comp_wq and returns. The work item then runs isert_completion_put() -> isert_put_cmd(), which reads isert_conn->conn and takes conn->cmd_lock.
Nothing orders that work item against teardown. isert_wait_conn() queues isert_release_work, which frees isert_conn, and iscsit_close_connection() frees the iscsit_conn right after it returns, so the queued work can run against freed memory.
Count the deferred control PDU completions per connection and let isert_wait_conn() wait for them before the release work is queued.
ISTATE_SEND_LOGOUTRSP is deliberately not counted: that branch runs iscsit_logout_post_handler(), which ends up waiting for conn->conn_wait_comp, and that completion is only sent by iscsit_close_connection() after it has called iscsit_wait_conn(). Waiting for it here would deadlock. Its wait stays the existing isert_wait4logout().
The splat below is from a kernel with tracing printk()s and an msleep(200) injected into isert_do_control_comp() to widen the window:
BUG: KASAN: slab-use-after-free in isert_put_cmd+0x53d/0x620 Read of size 8 at addr ffff8881054f1038 by task kworker/u17:1/182 CPU: 0 UID: 0 PID: 182 Comm: kworker/u17:1 Tainted: G B 7.2.0-rc5-TWIDE-gb8babf08acc7 #1 PREEMPT(lazy) Tainted: [B]=BAD_PAGE Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Workqueue: isert_comp_wq isert_do_control_comp Call Trace: <TASK> dump_stack_lvl+0x53/0x70 print_report+0xd0/0x630 ? __pfx__raw_spin_lock_irqsave+0x10/0x10 ? _raw_spin_unlock_irqrestore+0x3e/0x70 ? isert_put_cmd+0x53d/0x620 kasan_report+0xce/0x100 ? isert_put_cmd+0x53d/0x620 isert_put_cmd+0x53d/0x620 ? isert_completion_put+0x305/0x330 ? isert_do_control_comp+0x2ef/0x310 process_one_work+0x633/0x1030 ? assign_work+0x11d/0x370 worker_thread+0x45b/0xd10 ? __pfx_worker_thread+0x10/0x10 ? __pfx_worker_thread+0x10/0x10 kthread+0x2c6/0x3b0 ? recalc_sigpending+0x15c/0x1e0 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x36e/0x5a0 ? __pfx_ret_from_fork+0x10/0x10 ? __switch_to+0x572/0xdd0 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Allocated by task 48: kasan_save_stack+0x33/0x60 kasan_save_track+0x14/0x30 __kasan_kmalloc+0x8f/0xa0 __kmalloc_cache_noprof+0x158/0x370 isert_cma_handler+0x1e3/0x2ae0 cma_cm_event_handler+0x3e/0x240 cma_ib_req_handler+0x17d9/0x4490 cm_process_work+0x41/0x330 cm_work_handler+0x5727/0xc160 process_one_work+0x633/0x1030 worker_thread+0x45b/0xd10 kthread+0x2c6/0x3b0 ret_from_fork+0x36e/0x5a0 ret_from_fork_asm+0x1a/0x30 Freed by task 184: kasan_save_stack+0x33/0x60 kasan_save_track+0x14/0x30 kasan_save_free_info+0x3b/0x60 __kasan_slab_free+0x43/0x70 kfree+0x121/0x380 iscsit_close_connection+0x7cf/0x1e60 iscsit_take_action_for_connection_exit+0x1b6/0x360 iscsi_target_tx_thread+0x472/0x690 kthread+0x2c6/0x3b0 ret_from_fork+0x36e/0x5a0 ret_from_fork_asm+0x1a/0x30
--- drivers/infiniband/ulp/isert/ib_isert.c | 22 ++++++++++++++++++++++ drivers/infiniband/ulp/isert/ib_isert.h | 2 ++ 2 files changed, 24 insertions(+)
drivers/infiniband/ulp/isert/ib_isert.c +22 -0
@@ -21,6 +21,7 @@#include <target/target_core_fabric.h> #include <target/iscsi/iscsi_transport.h> #include <linux/semaphore.h> +#include <linux/wait_bit.h> #include "ib_isert.h"
@@ -313,6 +314,7 @@ isert_init_conn(struct isert_conn *isert_conn)init_completion (&isert_conn->login_req_comp);init_waitqueue_head (&isert_conn->rem_wait);kref_init (&isert_conn->kref); +atomic_set (&isert_conn->ctrl_comp_cnt,0 );mutex_init (&isert_conn->mutex);INIT_WORK (&isert_conn->release_work, isert_release_work); }
@@ -1700,6 +1702,8 @@ isert_do_control_comp(struct work_struct *work)struct isert_conn *isert_conn = isert_cmd->conn;struct ib_device *ib_dev = isert_conn->cm_id->device;struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd; +/* The switch below may free isert_cmd. */ +bool counted = isert_cmd->ctrl_counted;isert_dbg ("Cmd %p i_state %d\n" , isert_cmd, cmd->i_state);
@@ -1721,6 +1725,14 @@ isert_do_control_comp(struct work_struct *work)dump_stack ();break ; } + +/* +* The count is what keeps isert_conn alive, so drop it last. The wait +* queue lives in the global hash table, not in isert_conn, so this is +* safe even if the waiter has already freed the connection. +*/ +if (counted &&atomic_dec_and_test (&isert_conn->ctrl_comp_cnt)) +wake_up_var (&isert_conn->ctrl_comp_cnt); } static void
@@ -1764,6 +1776,12 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc)case ISTATE_SEND_TEXTRSP :isert_unmap_tx_desc (tx_desc, ib_dev); +/* Paired with the wait in isert_wait_conn(). */ + isert_cmd->ctrl_counted = + isert_cmd->iscsit_cmd->i_state !=ISTATE_SEND_LOGOUTRSP ; +if (isert_cmd->ctrl_counted) +atomic_inc (&isert_conn->ctrl_comp_cnt); +INIT_WORK (&isert_cmd->comp_work, isert_do_control_comp);queue_work (isert_comp_wq, &isert_cmd->comp_work);return ;
@@ -2598,6 +2616,10 @@ static void isert_wait_conn(struct iscsi_conn *conn)isert_wait4cmds (conn);isert_wait4logout (isert_conn); +/* Paired with the count taken in isert_send_done(). */ +wait_var_event (&isert_conn->ctrl_comp_cnt, + !atomic_read (&isert_conn->ctrl_comp_cnt)); +queue_work (isert_release_wq, &isert_conn->release_work); }
drivers/infiniband/ulp/isert/ib_isert.h +2 -0
@@ -153,6 +153,7 @@ struct isert_cmd {struct work_struct comp_work;struct scatterlist sg;bool ctx_init_done; +bool ctrl_counted; };static inline struct isert_cmd *tx_desc_to_cmd (struct iser_tx_desc *desc)
@@ -187,6 +188,7 @@ struct isert_conn {struct mutex mutex;struct kref kref;struct work_struct release_work; +atomic_t ctrl_comp_cnt;bool logout_posted;bool snd_w_inv;wait_queue_head_t rem_wait;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 366/595 RDMA/mad: Fix receive buffer leak when PKey enforcement fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 3476c28c9addfa253f505e6bd87f1f5598b961d0 ]
ib_mad_complete_recv() initializes mad_recv_wc->rmpp_list and then runs ib_mad_enforce_security() before linking recv_buf onto that list. On failure it calls ib_free_recv_mad(), which only walks rmpp_list and frees the ib_mad_private of every buffer found there. As the list is still empty at that point, nothing is freed at all.
The caller cannot clean up either: ib_mad_recv_done() sets recv to NULL right after ib_mad_complete_recv() returns, assuming the MAD layer took ownership of the buffer. Every MAD that fails the PKey check therefore leaks one ib_mad_private (about 300 bytes per IB port MAD, ~2K for OPA), and a remote node can trigger this repeatedly by sending MADs with a wrong PKey.
Link recv_buf onto rmpp_list right after the list is initialized, so the error path has something to free.
--- drivers/infiniband/core/mad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/mad.c +2 -1
@@ -1810,6 +1810,8 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,int ret;INIT_LIST_HEAD (&mad_recv_wc->rmpp_list); +list_add (&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list); + ret =ib_mad_enforce_security (mad_agent_priv, mad_recv_wc->wc->pkey_index);if (ret) {
@@ -1818,7 +1820,6 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,return ; } -list_add (&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list);if (is_kernel_rmpp_data_response (mad_agent_priv, mad_recv_wc)) {spin_lock_irqsave (&mad_agent_priv->lock, flags); mad_send_wr =ib_find_send_mad (mad_agent_priv, mad_recv_wc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 367/595 dmaengine: sprd: Fix runtime PM reference leak in probe
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit a7df136ec529ee49a789c5029bc37b98b0d4bedd ]
pm_runtime_get_sync() increments a device's usage counter even when it fails. sprd_dma_probe() currently jumps directly to controller clock cleanup on that error, bypassing both pm_runtime_put_noidle() and pm_runtime_disable(). This can happen if the preceding unchecked pm_runtime_set_active() fails and the following runtime-resume attempt also returns an error.
Enter the existing runtime-PM unwind path instead. This drops the reference without idling the partially initialized device, disables runtime PM, and then releases the controller clocks. The success path and propagated error code are unchanged.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/dma/sprd-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/sprd-dma.c +1 -2
@@ -1205,7 +1205,7 @@ static int sprd_dma_probe(struct platform_device *pdev) ret =pm_runtime_get_sync (&pdev->dev);if (ret <0 ) - goto err_rpm; + goto err_register; ret =dma_async_device_register (&sdev->dma_dev);if (ret <0 ) {
@@ -1227,7 +1227,6 @@ static int sprd_dma_probe(struct platform_device *pdev) err_register:pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev); -err_rpm:sprd_dma_disable (sdev);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 368/595 wifi: virt_wifi: free skb when disconnected
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mariano Baragiola <[email protected]>
[ Upstream commit f9edf7cf63b96d2b776fca8d258d3c5256e40c8e ]
When the simulated link is disconnected, virt_wifi_start_xmit() returns NET_XMIT_DROP without freeing the skb. dev_hard_start_xmit() treats this return value as consumed, so every packet sent while disconnected leaks its skb.
Free the skb before returning the drop status.
--- drivers/net/wireless/virt_wifi.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/virt_wifi.c +1 -0
@@ -430,6 +430,7 @@ static netdev_tx_t virt_wifi_start_xmit(struct sk_buff *skb, priv->tx_packets++;if (!priv->is_connected) { priv->tx_failed++; +dev_kfree_skb_any (skb);return NET_XMIT_DROP ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 369/595 wifi: mwifiex: fix IRQ leak using wrong index in MSI-X error path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Hao <[email protected]>
[ Upstream commit a3d722190cdef18da4878b5efc27c3c386dda248 ]
mwifiex_pcie_request_irq() registers each MSI-X vector with a per-index dev_id (&card->msix_ctx[i]). On a request_irq() failure the cleanup loop "for (j = 0; j < i; j++)" frees msix_entries[j].vector but passes the failed index's &card->msix_ctx[i] as the dev_id. free_irq() matches on (irq, dev_id), so it fails to find the action registered with &card->msix_ctx[j]: the already-requested IRQ j is not freed (leaked) and free_irq() warns about freeing a non-existent IRQ. Use &card->msix_ctx[j].
--- drivers/net/wireless/marvell/mwifiex/pcie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/marvell/mwifiex/pcie.c +1 -1
@@ -3244,7 +3244,7 @@ static int mwifiex_pcie_request_irq(struct mwifiex_adapter *adapter) ret);for (j =0 ; j < i; j++)free_irq (card->msix_entries[j].vector, - &card->msix_ctx[i]); + &card->msix_ctx[j]);pci_disable_msix (pdev); }else {mwifiex_dbg (adapter,MSG ,"MSIx enabled!" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 370/595 wifi: libipw: reject too-short beacon and probe responses
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shmulik Cohen <[email protected]>
[ Upstream commit 5ce5721e8cbe3e80db8f43851cc2a2a92485ef4b ]
libipw_process_probe_response() and the libipw_network_init() call it makes assume the frame contains the full 36-byte beacon and probe response prefix, but the ipw2100 and ipw2200 receive paths only establish that a management frame carries the generic 24-byte three-address header.
libipw_network_init() then computes the information element length as
stats->len - sizeof(*beacon)
stats->len is a u16 and sizeof() has type size_t, so the subtraction is evaluated as size_t and wraps instead of going negative. Truncating that to the u16 length parameter of libipw_parse_info_param() yields 65524 for a 24-byte beacon, and the parser then walks the receive buffer as if it held almost 64 KiB of information elements, reading past the allocation.
Reject the frame before any fixed field is touched.
Found by an AI-assisted review of length arithmetic in management frame parsers. Verified with a KUnit case under Generic KASAN on arm64 under QEMU; I do not have the hardware, so it is not tested on a real device.
--- drivers/net/wireless/intel/ipw2x00/libipw_rx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/ipw2x00/libipw_rx.c +3 -0
@@ -1536,6 +1536,9 @@ static void libipw_process_probe_response(struct libipw_device#endif unsigned long flags; +if (stats->len <sizeof (*beacon)) +return ; + LIBIPW_DEBUG_SCAN("'%*pE' (%pM): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", info_element->len, info_element->data, beacon->header.addr3,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 371/595 wifi: libipw: reject too-short association responses
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shmulik Cohen <[email protected]>
[ Upstream commit adb7118b7d2cfd7e8213c17d7d2829f353017754 ]
libipw_handle_assoc_resp() reads the capability, status and aid fields of the 30-byte association response prefix and then computes the information element length as
stats->len - sizeof(*frame)
stats->len is a u16 and sizeof() has type size_t, so the subtraction is evaluated as size_t and wraps instead of going negative. Truncating that to the u16 length parameter of libipw_parse_info_param() turns a frame shorter than the fixed fields into a length near 64 KiB, and the parser then reads past the receive buffer.
Both the ipw2100 and ipw2200 management receive paths reach this function having established only that the frame carries the generic 24-byte three-address header.
Reject the frame before any fixed field is touched.
Found by an AI-assisted review of length arithmetic in management frame parsers. Verified with a KUnit case under Generic KASAN on arm64 under QEMU; I do not have the hardware, so it is not tested on a real device.
--- drivers/net/wireless/intel/ipw2x00/libipw_rx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/ipw2x00/libipw_rx.c +3 -0
@@ -1324,6 +1324,9 @@ static int libipw_handle_assoc_resp(struct libipw_device *ieee, struct libipw_asstruct libipw_network *network = &network_resp;struct net_device *dev = ieee->dev; +if (stats->len <sizeof (*frame)) +return 1 ; + network->flags =0 ; network->qos_data.active =0 ; network->qos_data.supported =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 372/595 IB/IPoIB: Avoid restoring OPER_UP after multicast flush
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit 9a141d3dc869d18b2eab35e999f4790a9b84e40f ]
ipoib_ib_dev_flush_light() temporarily clears IPOIB_FLAG_OPER_UP to prevent multicast joins while ipoib_mcast_dev_flush() is running, and restores the flag afterwards if it was previously set.
This restore races with ipoib_ib_dev_down(). If the interface is brought down while the flush is in progress, ipoib_ib_dev_down() clears IPOIB_FLAG_OPER_UP, but the flush path may set it again after the device has already gone down.
Since commit 894021a75291 ("IB/ipoib: Make the carrier_on_task race aware"), ipoib_mcast_carrier_on_task() relies on IPOIB_FLAG_OPER_UP being cleared to terminate its rtnl_trylock() retry loop. If the flag is left set after shutdown, the workqueue retries forever, causing teardown to deadlock when ipoib_ndo_uninit() waits in destroy_workqueue() while holding RTNL.
Instead of overloading IPOIB_FLAG_OPER_UP to block multicast joins during a light flush, introduce a dedicated IPOIB_FLAG_MCAST_FLUSH flag. Use it together with IPOIB_FLAG_OPER_UP to determine whether multicast joins are allowed, avoiding the race with device shutdown.
--- drivers/infiniband/ulp/ipoib/ipoib.h | 7 +++++++ drivers/infiniband/ulp/ipoib/ipoib_ib.c | 12 +++++++----- drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 16 ++++++++-------- 3 files changed, 22 insertions(+), 13 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib.h +7 -0
@@ -87,6 +87,7 @@ enum {IPOIB_FLAG_INITIALIZED =1 ,IPOIB_FLAG_ADMIN_UP =2 ,IPOIB_PKEY_ASSIGNED =3 , +IPOIB_FLAG_MCAST_FLUSH =4 ,IPOIB_FLAG_SUBINTERFACE =5 ,IPOIB_STOP_REAPER =7 , IPOIB_FLAG_ADMIN_CM = 9,
@@ -417,6 +418,12 @@ struct ipoib_dev_priv {const struct net_device_ops *rn_ops; }; +static inline bool ipoib_mcast_allowed (struct ipoib_dev_priv *priv) +{ +return test_bit (IPOIB_FLAG_OPER_UP , &priv->flags) && + !test_bit (IPOIB_FLAG_MCAST_FLUSH , &priv->flags); +} +struct ipoib_ah {struct net_device *dev;struct ib_ah *ah;
drivers/infiniband/ulp/ipoib/ipoib_ib.c +7 -5
@@ -1212,17 +1212,19 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, }if (level ==IPOIB_FLUSH_LIGHT ) { -int oper_up;ipoib_mark_paths_invalid (dev); -/* Set IPoIB operation as down to prevent races between: +/* Set MCAST_FLUSH to prevent races between: * the flush flow which leaves MCG and on the fly joins * which can happen during that time. mcast restart task * should deal with join requests we missed. +* +* Do not clear OPER_UP for this; restoring it races with +* ipoib_ib_dev_down() and can leave OPER_UP set after the +* device is down. */ - oper_up =test_and_clear_bit (IPOIB_FLAG_OPER_UP , &priv->flags); +set_bit (IPOIB_FLAG_MCAST_FLUSH , &priv->flags);ipoib_mcast_dev_flush (dev); -if (oper_up) -set_bit (IPOIB_FLAG_OPER_UP , &priv->flags); +clear_bit (IPOIB_FLAG_MCAST_FLUSH , &priv->flags);ipoib_reap_dead_ahs (priv); }
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +8 -8
@@ -74,7 +74,7 @@ static void __ipoib_mcast_schedule_join_thread(struct ipoib_dev_priv *priv, struct ipoib_mcast *mcast, bool delay) { -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) +if (!ipoib_mcast_allowed (priv))return ;/*
@@ -479,7 +479,7 @@ static int ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast)int ret =0 ;if (!priv->broadcast || - !test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) + !ipoib_mcast_allowed (priv))return -EINVAL ;init_completion (&mcast->done);
@@ -567,7 +567,7 @@ void ipoib_mcast_join_task(struct work_struct *work)unsigned long delay_until =0 ;struct ipoib_mcast *mcast =NULL ; -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) +if (!ipoib_mcast_allowed (priv))return ;if (ib_query_port (priv->ca, priv->port, &port_attr)) {
@@ -589,7 +589,7 @@ void ipoib_mcast_join_task(struct work_struct *work)netif_addr_unlock_bh (dev);spin_lock_irq (&priv->lock); -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) +if (!ipoib_mcast_allowed (priv)) goto out;if (!priv->broadcast) {
@@ -761,7 +761,7 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb)spin_lock_irqsave (&priv->lock, flags); -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags) || +if (!ipoib_mcast_allowed (priv) || !priv->broadcast || !test_bit (IPOIB_MCAST_FLAG_ATTACHED , &priv->broadcast->flags)) { ++dev->stats.tx_dropped;
@@ -883,7 +883,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)LIST_HEAD (remove_list);struct ib_sa_mcmember_rec rec; -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) +if (!ipoib_mcast_allowed (priv))/* * shortcut...on shutdown flush is called next, just * let it do all the work
@@ -977,9 +977,9 @@ void ipoib_mcast_restart_task(struct work_struct *work)ipoib_mcast_remove_list (&remove_list);/* -* Double check that we are still up +* Double check that we are still up and not flushing */ -if (test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) { +if (ipoib_mcast_allowed (priv)) {spin_lock_irq (&priv->lock);__ipoib_mcast_schedule_join_thread (priv,NULL ,0 );spin_unlock_irq (&priv->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 373/595 wifi: cfg80211: check IP header size in cfg80211_classify8021d()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 48b2c5c628b09cf36cbeca53e0432fc2a7518be7 ]
A frame that looks like IP can be transmitted, but be too short, so the DS field is read incorrectly:
BUG: KMSAN: uninit-value in cfg80211_classify8021d+0x99d/0x12b0 net/wireless/util.c:1027 cfg80211_classify8021d+0x99d/0x12b0 net/wireless/util.c:1027 ieee80211_select_queue+0x37a/0x9e0 net/mac80211/wme.c:180 __ieee80211_subif_start_xmit+0x60f/0x1d90 net/mac80211/tx.c:4304 ieee80211_subif_start_xmit+0xa8/0x6d0 net/mac80211/tx.c:4538 ... packet_sendmsg+0x9173/0xa2a0 net/packet/af_packet.c:3108
Use skb_header_pointer() like the MPLS case.
--- net/wireless/util.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
net/wireless/util.c +22 -4
@@ -856,12 +856,30 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb, }switch (skb->protocol) { -case htons (ETH_P_IP ): - dscp =ipv4_get_dsfield (ip_hdr (skb)) &0xfc ; +case htons (ETH_P_IP ): { +const struct iphdr *iph; +struct iphdr _iph; + + iph =skb_header_pointer (skb,sizeof (struct ethhdr ), +sizeof (*iph), &_iph); +if (!iph) +return 0 ; + + dscp =ipv4_get_dsfield (iph) &0xfc ;break ; -case htons (ETH_P_IPV6 ): - dscp =ipv6_get_dsfield (ipv6_hdr (skb)) &0xfc ; + } +case htons (ETH_P_IPV6 ): { +const struct ipv6hdr *ip6h; +struct ipv6hdr _ip6h; + + ip6h =skb_header_pointer (skb,sizeof (struct ethhdr ), +sizeof (*ip6h), &_ip6h); +if (!ip6h) +return 0 ; + + dscp =ipv6_get_dsfield (ip6h) &0xfc ;break ; + }case htons (ETH_P_MPLS_UC ):case htons (ETH_P_MPLS_MC ): {struct mpls_label mpls_tmp, *mpls;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 374/595 soundwire: cadence_master: wait and cancel cdns->work before clock stop
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bard Liao <[email protected]>
[ Upstream commit aba7b41faeecb7692458095ce6fafc341fe0b80e ]
A peripheral event could happen during the clock stop process. We need to wait for the event be handled before stopping the bus clock. Otherwise, we will get the IO transfer timed out issue.
--- drivers/soundwire/cadence_master.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/soundwire/cadence_master.c +7 -0
@@ -1416,6 +1416,13 @@ int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake)return 0 ; } +/* +* wait for any in-flight peripheral event handling to complete before stopping the clock. +* No need to disable peripheral interrupts before canceling the work, as the peripheral +* interrupts are already masked before the work is scheduled. +*/ +cancel_work_sync (&cdns->work); +/* * Before entering clock stop we mask the Slave * interrupts. This helps avoid having to deal with e.g. a
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 375/595 MIPS: Octeon: apply USB FDT fixups also when USB is modular
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit 126f16e0a1b353c2ba5c7e2c8626cfa865934f9f ]
The uctl/usbn device-tree fixups in octeon_prune_device_tree() - which set the board's USB reference-clock frequency and type from __cvmx_helper_board_usb_get_clock_type() - are guarded by "#ifdef CONFIG_USB", which is false when USB is built as a module. The fixups then silently disappear and octeon-hcd sees whatever default the DTS carries (12MHz crystal in octeon_3xxx.dts), leaving the PHY dead or the bus erroring on boards with a different reference clock.
Use IS_ENABLED() so USB=m gets the same fixups as USB=y.
--- arch/mips/cavium-octeon/octeon-platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +2 -2
@@ -15,7 +15,7 @@#include <asm/octeon/octeon.h> #include <asm/octeon/cvmx-helper-board.h> -#ifdef CONFIG_USB +#if IS_ENABLED (CONFIG_USB )#include <linux/usb/ehci_def.h> #include <linux/usb/ehci_pdriver.h> #include <linux/usb/ohci_pdriver.h>
@@ -1079,7 +1079,7 @@ int __init octeon_prune_device_tree(void) ; } -#ifdef CONFIG_USB +#if IS_ENABLED (CONFIG_USB )/* OHCI/UHCI USB */ alias_prop =fdt_getprop (initial_boot_params, aliases,"uctl" ,NULL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 376/595 dma-mapping: simplify dma_init_coherent_memory
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit a6933571f34a9aee843fff2aa4b96949c57d6274 ]
Return the allocated dma_coherent_mem structure, set the use_dma_pfn_offset and print the failure warning inside of dma_init_coherent_memory instead of leaving that to the callers.
Stable-dep-of: 504981db4f69 ("dma-coherent: report a failed reserved memory assignment")
--- kernel/dma/coherent.c | 78 ++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 45 deletions(-)
kernel/dma/coherent.c +33 -45
@@ -37,51 +37,44 @@ static inline dma_addr_t dma_get_device_base(struct device *dev,return mem->device_base; } -static int dma_init_coherent_memory (phys_addr_t phys_addr, -dma_addr_t device_addr,size_t size, -struct dma_coherent_mem **mem) +static struct dma_coherent_mem *dma_init_coherent_memory (phys_addr_t phys_addr, +dma_addr_t device_addr,size_t size,bool use_dma_pfn_offset) { -struct dma_coherent_mem *dma_mem =NULL ; -void *mem_base =NULL ; +struct dma_coherent_mem *dma_mem;int pages = size >>PAGE_SHIFT ;int bitmap_size =BITS_TO_LONGS (pages) *sizeof (long ); -int ret; +void *mem_base; -if (!size) { - ret = -EINVAL ; - goto out; - } +if (!size) +return ERR_PTR (-EINVAL ); mem_base =memremap (phys_addr, size,MEMREMAP_WC ); -if (!mem_base) { - ret = -EINVAL ; - goto out; - } +if (!mem_base) +return ERR_PTR (-EINVAL ); + dma_mem =kzalloc (sizeof (struct dma_coherent_mem ),GFP_KERNEL ); -if (!dma_mem) { - ret = -ENOMEM ; - goto out; - } +if (!dma_mem) + goto out_unmap_membase; dma_mem->bitmap =kzalloc (bitmap_size,GFP_KERNEL ); -if (!dma_mem->bitmap) { - ret = -ENOMEM ; - goto out; - } +if (!dma_mem->bitmap) + goto out_free_dma_mem; dma_mem->virt_base = mem_base; dma_mem->device_base = device_addr; dma_mem->pfn_base =PFN_DOWN (phys_addr); dma_mem->size = pages; + dma_mem->use_dev_dma_pfn_offset = use_dma_pfn_offset;spin_lock_init (&dma_mem->spinlock); - *mem = dma_mem; -return 0 ; +return dma_mem; -out: +out_free_dma_mem:kfree (dma_mem); -if (mem_base) -memunmap (mem_base); -return ret; +out_unmap_membase: +memunmap (mem_base); +pr_err ("Reserved memory: failed to init DMA memory pool at %pa, size %zd MiB\n" , + &phys_addr, size /SZ_1M ); +return ERR_PTR (-ENOMEM ); }static void _dma_release_coherent_memory (struct dma_coherent_mem *mem)
@@ -130,9 +123,9 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,struct dma_coherent_mem *mem;int ret; - ret =dma_init_coherent_memory (phys_addr, device_addr, size, &mem); -if (ret) -return ret; + mem =dma_init_coherent_memory (phys_addr, device_addr, size, false); +if (IS_ERR (mem)) +return PTR_ERR (mem); ret =dma_assign_coherent_memory (dev, mem);if (ret)
@@ -327,21 +320,16 @@ static struct reserved_mem *dma_reserved_default_memory __initdata;static int rmem_dma_device_init (struct reserved_mem *rmem,struct device *dev) { -struct dma_coherent_mem *mem = rmem->priv; -int ret; - -if (!mem) { - ret =dma_init_coherent_memory (rmem->base, rmem->base, - rmem->size, &mem); -if (ret) { -pr_err ("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n" , - &rmem->base, (unsigned long )rmem->size /SZ_1M ); -return ret; - } +if (!rmem->priv) { +struct dma_coherent_mem *mem; + + mem =dma_init_coherent_memory (rmem->base, rmem->base, + rmem->size, true); +if (IS_ERR (mem)) +return PTR_ERR (mem); + rmem->priv = mem; } - mem->use_dev_dma_pfn_offset = true; - rmem->priv = mem; -dma_assign_coherent_memory (dev, mem); +dma_assign_coherent_memory (dev, rmem->priv);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 377/595 dma-coherent: Warn if OF reserved memory is beyond current coherent DMA mask
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit 89461db349cc00816c01d55507d511466b3b7151 ]
When a reserved memory region described in the device tree is attached to a device, it is expected that the device's limitations are correctly included in that description.
However, if the device driver failed to implement DMA address masking or addressing beyond the default 32 bits (on arm64), then bad things could happen because the DMA address was truncated, such as playing back audio with no actual audio coming out, or DMA overwriting random blocks of kernel memory.
Check against the coherent DMA mask when the memory regions are attached to the device. Give a warning when the memory region can not be covered by the mask.
A warning instead of a hard error was chosen, because it is possible that existing drivers could be working fine even if they forgot to extend the coherent DMA mask.
Stable-dep-of: 504981db4f69 ("dma-coherent: report a failed reserved memory assignment")
--- kernel/dma/coherent.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
kernel/dma/coherent.c +9 -3
@@ -320,16 +320,22 @@ static struct reserved_mem *dma_reserved_default_memory __initdata;static int rmem_dma_device_init (struct reserved_mem *rmem,struct device *dev) { -if (!rmem->priv) { -struct dma_coherent_mem *mem; +struct dma_coherent_mem *mem = rmem->priv; +if (!mem) { mem =dma_init_coherent_memory (rmem->base, rmem->base, rmem->size, true);if (IS_ERR (mem))return PTR_ERR (mem); rmem->priv = mem; } -dma_assign_coherent_memory (dev, rmem->priv); + +/* Warn if the device potentially can't use the reserved memory */ +if (mem->device_base + rmem->size -1 > +min_not_zero (dev->coherent_dma_mask, dev->bus_dma_limit)) +dev_warn (dev,"reserved memory is beyond device's set DMA address range\n" ); + +dma_assign_coherent_memory (dev, mem);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 378/595 dma-coherent: report a failed reserved memory assignment
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
[ Upstream commit 504981db4f69bdd28054fb98c96a3a67f7248dde ]
rmem_dma_device_init() drops the return value of dma_assign_coherent_memory() and always reports success. That call fails with -EBUSY when the device already has a coherent pool, and the file allows only "*one* such region of memory" per device.
of_reserved_mem_device_init_by_idx() reads the zero as success. It logs "assigned reserved memory node" for a region that was not assigned and records the pairing, so of_reserved_mem_device_release() later runs rmem_dma_device_release() for it. That clears dev->dma_mem without looking at which region it was called for, dropping the pool the device did get and leaving it on ordinary memory.
dma_declare_coherent_memory() checks the same call and releases the memory on failure, and rmem_swiotlb_device_init() propagates its own errors. Return the error here as well, so a device tree that assigns two pools to one device fails the probe instead of half working.
--- kernel/dma/coherent.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/dma/coherent.c +1 -2
@@ -335,8 +335,7 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit))dev_warn (dev,"reserved memory is beyond device's set DMA address range\n" ); -dma_assign_coherent_memory (dev, mem); -return 0 ; +return dma_assign_coherent_memory (dev, mem); } static void rmem_dma_device_release(struct reserved_mem *rmem,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 379/595 dmaengine: Fix device kref underflow in dma_chan_put()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivank Garg <[email protected]>
[ Upstream commit 44dab659064eb5c10adb0306510eebe848ed592d ]
dma_chan_get() takes chan->device->ref only on the slow path:
/* no kref on fast path */
if (chan->client_count) {
__module_get(owner);
chan->client_count++;
return 0;
}
if (!try_module_get(owner))
return -ENODEV;
if (!dma_device_get(chan->device)) { // calls kref_get_unless_zero()dma_chan_put() drops the ref unconditionally, so every fast-path get/put pair drops one extra device reference.
The bug fires when two conditions hold together: a non-private provider has a persistent client holding chan->client_count > 0 and another client cycles dmaengine_get()/dmaengine_put(). When the kref hits zero, the subsequent dma_find_channel() returns NULL even though the provider module is still loaded.
Fix this by dropping device->ref only on the last put, matching the single slow-path get.
--- drivers/dma/dmaengine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/dmaengine.c +3 -1
@@ -513,7 +513,9 @@ static void dma_chan_put(struct dma_chan *chan) chan->route_data =NULL ; } -dma_device_put (chan->device); +/* This channel is not in use anymore, drop the device ref */ +if (!chan->client_count) +dma_device_put (chan->device);module_put (dma_chan_to_owner (chan)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 380/595 dmaengine: fix use-after-free in dma_chan_put() and dma_release_channel()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivank Garg <[email protected]>
[ Upstream commit e873c74132f0c5f1452816cd9bb26208f0bba1e1 ]
When dma_device_put() drops the last reference on chan->device->ref, dma_device_release() runs and may free the dma_device along with its channels.
dma_chan_put() then still reads chan->device->owner via dma_chan_to_owner() for the trailing module_put(). KASAN catches it:
slab-use-after-free in dma_chan_put+0x3e6/0x4c0 Read of size 8 by task insmod/6319 Freed by task 6319: kfree+0x225/0x470 dma_chan_put+0x395/0x4c0 dmaengine_put+0xf8/0x160
Cache the module owner in dma_chan_put() before the put so the trailing module_put() does not need chan->device.
--- drivers/dma/dmaengine.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/dmaengine.c +4 -1
@@ -493,10 +493,13 @@ static int dma_chan_get(struct dma_chan *chan)*/ static void dma_chan_put (struct dma_chan *chan) { +struct module *owner; +/* This channel is not in use, bail out */ if (!chan->client_count)return ; + owner =dma_chan_to_owner (chan); chan->client_count--;/* This channel is not in use anymore, free it */
@@ -516,7 +519,7 @@ static void dma_chan_put(struct dma_chan *chan)/* This channel is not in use anymore, drop the device ref */ if (!chan->client_count)dma_device_put (chan->device); -module_put (dma_chan_to_owner (chan)); +module_put (owner); }enum dma_status dma_sync_wait (struct dma_chan *chan,dma_cookie_t cookie)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 381/595 dmaengine: wait for RCU readers before releasing dma_device
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivank Garg <[email protected]>
[ Upstream commit dc750422170a563c7a81f6e49d36bb02c62ae37f ]
dma_issue_pending_all() walks the dma_device_list with list_for_each_entry_rcu() under rcu_read_lock(). dma_device_release() unlinks the device with list_del_rcu() and then calls device->device_release() (which in many drivers, such as plx_dma.c, directly calls kfree()).
Because there is no grace period between unlinking the device and freeing it, concurrent RCU readers in dma_issue_pending_all() can access the device after it has been freed.
The lockless walk originally relied on clients holding a dmaengine reference to pin the provider module, and therefore the device, for as long as they might traverse the list. Commit 8ad342a86359 ("dmaengine:
Add reference counting to dma_device struct") decoupled the dma_device lifetime from the module reference, so the device can now be released while a reader is still walking the list.
Add synchronize_rcu() before the device is freed, so RCU readers are guaranteed to have finished. Keep it unconditional: providers that do not implement device_release() free the device themselves once dma_async_device_unregister() returns. This call will delay for a grace period with dma_list_mutex held, which is safe and only teardown path is delayed.
--- drivers/dma/dmaengine.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/dmaengine.c +1 -0
@@ -426,6 +426,7 @@ static void dma_device_release(struct kref *ref)list_del_rcu (&device->global_node);dma_channel_rebalance (); +synchronize_rcu ();if (device->device_release) device->device_release (device);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 382/595 wifi: cfg80211: only group hidden BSSes with beacon entries
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 068843ed0902c552a13860c5ec6b2ca65b57a065 ]
When a probe response for an unknown BSS comes in, __cfg80211_bss_update() looks for an existing entry with the same BSSID and a hidden (zero-length or NUL-filled) SSID, and if it finds one it groups them, using the beacon IEs from the existing entry.
But that could find another entry without a beacon, if it was also from a probe response (with SSID), so there's a group without beacon elements.
If a beacon with a hidden SSID for that BSSID arrives later, cfg80211_combine_bsses() goes looking for the probe response entries that belong to it - i.e. entries with the same BSSID and channel that have no beacon IEs - and finds those two. They are already grouped with each other, so it hits its
WARN_ON_ONCE(bss->pub.hidden_beacon_bss)
WARN_ON_ONCE(!list_empty(&bss->hidden_list))
which are there because an entry without beacon elements is not supposed to be part of a group yet.
Only combine entries when a beacon was already received, ones that are kept separate will be combined when a beacon arrives.
--- net/wireless/scan.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/wireless/scan.c +7 -0
@@ -1860,6 +1860,13 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,if (!hidden) hidden =rb_find_bss (rdev, tmp,BSS_CMP_HIDE_NUL ); +/* +* Only group with an entry with beacon data, otherwise +* beacon data can never be filled/updated. +*/ +if (hidden && + !rcu_access_pointer (hidden->pub.beacon_ies)) + hidden =NULL ;if (hidden) { new->pub.hidden_beacon_bss = &hidden->pub; list_add(&new->hidden_list,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 383/595 wifi: cfg80211: dont filter by BSS type when removing stale entries
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit b377e1000d963e7182a987082b4b06580bd7ac84 ]
When an assoc AP switches to a channel that already has a BSS entry, cfg80211_update_assoc_bss_entry() removes that entry before rehashing the real one, since the two would otherwise collide in the BSS rbtree.
The lookup for that entry also required it to match the connection's BSS type, so an entry advertising e.g. the IBSS capability bit was left in place, and the following cfg80211_rehash_bss() then ran into it:
WARN_ON(!cmp)
Changing the type shouldn't really happen, but can be triggered by a rogue AP/device, so drop the check and remove any entries matching the comparison.
--- net/wireless/scan.c | 5 ----- 1 file changed, 5 deletions(-)
net/wireless/scan.c +0 -5
@@ -2740,11 +2740,6 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev, cbss->pub.channel = chan;list_for_each_entry (bss, &rdev->bss_list, list) { -if (!cfg80211_bss_type_match (bss->pub.capability, - bss->pub.channel->band, - wdev->conn_bss_type)) -continue ; -if (bss == cbss)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 384/595 wifi: mac80211: reset the AP_VLAN tailroom counter on ifdown
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 4504f3960dc4501c73be9f99eabda2e26e9db41e ]
On ifup, AP_VLAN interfaces get crypto_tx_tailroom_needed_cnt from the AP interface, but it's never decremented again unless the AP is also brought down. Thus, bringing the same AP_VLAN up again will increment the counter again and eventually hit the sanity check:
WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt !=
master->crypto_tx_tailroom_needed_cnt);
Reset it on ifdown to avoid that.
--- net/mac80211/iface.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/iface.c +2 -0
@@ -522,6 +522,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,RCU_INIT_POINTER (sdata->vif.chanctx_conf,NULL );/* see comment in the default case below */ ieee80211_free_keys (sdata, true); +/* increased by AP value on ifup, so reset on ifdown */ + sdata->crypto_tx_tailroom_needed_cnt =0 ;/* no need to tell driver */ break ;case NL80211_IFTYPE_MONITOR :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 385/595 wifi: mac80211: dont RCU-dereference the mesh CSA settings we just set
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit b481e64e4498e2c053d5954f546ee02338f6ab63 ]
In the error path of ieee80211_mesh_csa_beacon() the settings that were just assigned are read back with rcu_dereference(), which lockdep then complains about.
There's no need to read the pointer at all, tmp_csa_settings still is the right value anyway.
--- net/mac80211/mesh.c | 1 - 1 file changed, 1 deletion(-)
net/mac80211/mesh.c +0 -1
@@ -1379,7 +1379,6 @@ int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata, ret =ieee80211_mesh_rebuild_beacon (sdata);if (ret) { - tmp_csa_settings =rcu_dereference (ifmsh->csa);RCU_INIT_POINTER (ifmsh->csa,NULL );kfree_rcu (tmp_csa_settings, rcu_head);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 386/595 wifi: mac80211: dont access the TSF of a down interface
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 0b1de9feeb8651f7a3bb53ed7c9006e3b5298c01 ]
The tsf debugfs files call the driver even if the interface isn't up, tgriggering check-sdata-in-driver warnings.
Reject the access in that case.
--- net/mac80211/debugfs_netdev.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/mac80211/debugfs_netdev.c +6 -0
@@ -522,6 +522,9 @@ static ssize_t ieee80211_if_fmt_tsf(struct ieee80211_local *local = sdata->local;u64 tsf; +if (!ieee80211_sdata_running ((struct ieee80211_sub_if_data *)sdata)) +return -ENETDOWN ; + tsf =drv_get_tsf (local, (struct ieee80211_sub_if_data *)sdata);return scnprintf (buf, buflen,"0x%016llx\n" , (unsigned long long ) tsf);
@@ -535,6 +538,9 @@ static ssize_t ieee80211_if_parse_tsf(int ret;int tsf_is_delta =0 ; +if (!ieee80211_sdata_running (sdata)) +return -ENETDOWN ; +if (strncmp (buf,"reset" ,5 ) ==0 ) {if (local->ops->reset_tsf) {drv_reset_tsf (local, sdata);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 387/595 dmaengine: xilinx_dma: Fix hardware buffer descriptor reuse order
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Bereza <[email protected]>
[ Upstream commit cee9c863ee68cb27d66745eb03f60e357f4f8ad2 ]
xilinx_dma_alloc_chan_resources() builds a static ring of hardware buffer descriptors once and the driver uses this ring throughout the lifetime of a channel. This requires the allocation order of hardware buffer descriptors from chan->free_seg_list to stay in sync with the hardware buffer descriptor ring built at channel allocation time by returning oldest descriptors to chan->free_seg_list first.
When chan->pending_list is not empty e.g. during xilinx_dma_terminate_all() the chan->free_seg_list and the order of the static hardware buffer descriptor ring get out of sync. Descriptors age in this order: pending -> active -> done. So freeing pending_list first returns the newest buffer descriptors to the chan->free_seg_list first and thus breaks the order required by the static hardware buffer descriptor ring. Then when the channel is reused, after a wrap around of the free_seg_list the DMA will find a hardware buffer descriptor with a length field that is still zeroed and stop with something like this:
xilinx-vdma 86000000.dma: Channel 000000003a21d7b8 has errors 10, cdr 6de4c000 tdr 6de4c000
After this no more descriptors are completed and a consumer potentially blocks and waits forever. The only way to get out of this error state is to rebuild the static hardware buffer descriptor ring and the free_seg_list by releasing and re-acquiring the channel.
Fix the order in which hardware buffer descriptors are returned to free_seg_list to ensure the mentioned requirement holds.
--- drivers/dma/xilinx/xilinx_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/xilinx/xilinx_dma.c +1 -1
@@ -889,9 +889,9 @@ static void xilinx_dma_free_descriptors(struct xilinx_dma_chan *chan)spin_lock_irqsave (&chan->lock, flags); -xilinx_dma_free_desc_list (chan, &chan->pending_list);xilinx_dma_free_desc_list (chan, &chan->done_list);xilinx_dma_free_desc_list (chan, &chan->active_list); +xilinx_dma_free_desc_list (chan, &chan->pending_list);spin_unlock_irqrestore (&chan->lock, flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 388/595 dmaengine: xilinx_dma: Fix hardware buffer descriptor chain after cyclic DMA
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Bereza <[email protected]>
[ Upstream commit 7ed1e3070c9b4bbd67d5519e14711038dd53ab13 ]
Using the DMA in cyclic mode modifies the hardware buffer descriptor chain in xilinx_dma_prep_dma_cyclic so that the last descriptor used by the cyclic transfer points back to the first descriptor, but it never restores the original descriptor ring. This breaks using non-cyclic mode after cyclic mode with an error like:
xilinx-vdma 86000000.dma: Channel 00000000354d5c8d has errors 100, cdr 6de40000 tdr 6de40400
The only way to get out of this error state is to rebuild the hardware buffer descriptor ring by releasing and re-acquiring the channel.
Fix using non-cyclic mode after cyclic mode by always restoring the original buffer descriptor ring in the same manner as it is set up by xilinx_dma_alloc_chan_resources().
--- drivers/dma/xilinx/xilinx_dma.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/dma/xilinx/xilinx_dma.c +17 -7
@@ -725,15 +725,25 @@ xilinx_aximcdma_alloc_tx_segment(struct xilinx_dma_chan *chan)return segment; } -static void xilinx_dma_clean_hw_desc (struct xilinx_axidma_desc_hw *hw) +static void xilinx_dma_clean_hw_desc (struct xilinx_dma_chan *chan, +struct xilinx_axidma_tx_segment *segment) { -u32 next_desc = hw->next_desc; -u32 next_desc_msb = hw->next_desc_msb; +dma_addr_t next; +u32 i; -memset (hw,0 ,sizeof (struct xilinx_axidma_desc_hw )); +/* +* Restore the buffer descriptor's next descriptor pointer to the value +* set up in xilinx_dma_alloc_chan_resources(). Otherwise using the DMA +* in cyclic mode leaves the next descriptor pointer altered and +* prevents subsequent non-cyclic transfers. +*/ + i = segment - chan->seg_v; + next = chan->seg_p + +sizeof (*chan->seg_v) * ((i +1 ) %XILINX_DMA_NUM_DESCS ); - hw->next_desc = next_desc; - hw->next_desc_msb = next_desc_msb; +memset (&segment->hw,0 ,sizeof (segment->hw)); + segment->hw.next_desc =lower_32_bits (next); + segment->hw.next_desc_msb =upper_32_bits (next); }static void xilinx_mcdma_clean_hw_desc (struct xilinx_aximcdma_desc_hw *hw)
@@ -755,7 +765,7 @@ static void xilinx_mcdma_clean_hw_desc(struct xilinx_aximcdma_desc_hw *hw)static void xilinx_dma_free_tx_segment (struct xilinx_dma_chan *chan,struct xilinx_axidma_tx_segment *segment) { -xilinx_dma_clean_hw_desc (&segment->hw); +xilinx_dma_clean_hw_desc (chan, segment);list_add_tail (&segment->node, &chan->free_seg_list); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 389/595 RDMA/siw: Bound fragmented header copies by the remaining length
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 9ff797e516dbc1ecb73701ec4c24055712d44411 ]
siw_get_hdr() can receive an extended DDP/RDMAP header across more than one TCP callback. The first callback may receive most of the header, while the next one still limits the copy to hdrlen - MIN_DDP_HDR instead of the number of missing bytes. This makes the destination move past the end of the header and overwrite the receive state, including fpdu_part_rcvd. A later callback can then use a negative fpdu_part_rcvd value as a copy offset, which creates an OOB write.
Use the number of header bytes already received when calculating the next copy length.
--- drivers/infiniband/sw/siw/siw_qp_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_qp_rx.c +1 -1
@@ -1095,7 +1095,7 @@ static int siw_get_hdr(struct siw_rx_stream *srx)if (iwarp_pktinfo[opcode].hdr_len >sizeof (struct iwarp_ctrl_tagged )) {int hdrlen = iwarp_pktinfo[opcode].hdr_len; - bytes =min_t (int, hdrlen -MIN_DDP_HDR , srx->skb_new); + bytes =min_t (int, hdrlen - srx->fpdu_part_rcvd, srx->skb_new);skb_copy_bits (skb, srx->skb_offset, (char *)c_hdr + srx->fpdu_part_rcvd, bytes);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 390/595 netfilter: nft_nat: fully initialise new_addr in netmap setup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodor Arsenij Larionov Trichkine <[email protected]>
[ Upstream commit d313499df66159b4b7971d760d16729598ab7e5a ]
nft_nat_setup_netmap() builds the mapped address in an on-stack union nf_inet_addr. For an IPv4 mapping it writes only the 4-byte .ip member and the loop runs a single 32-bit iteration, but it then copies the whole 16-byte union into range->min_addr and range->max_addr, so the upper 12 bytes reach nf_nat_setup_info() uninitialised.
KMSAN reports an uninit-value in nf_nat_setup_info() reached from nft_nat_eval(). The IPv6 path fills all 16 bytes and is not affected.
Zero-initialise new_addr.
--- net/netfilter/nft_nat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_nat.c +1 -1
@@ -64,8 +64,8 @@ static void nft_nat_setup_netmap(struct nf_nat_range2 *range,const struct nft_pktinfo *pkt, const struct nft_nat *priv) { + union nf_inet_addr new_addr = {};struct sk_buff *skb = pkt->skb; -union nf_inet_addr new_addr;__be32 netmask;int i, len =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 391/595 netfilter: flowtable: hold reference on ct until flow is released
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit e75a9fa1d44bcbd66ea02e8781bcca6ea4076e0d ]
nf_ct_put() releases the ct->ext area inmediately, the rcu typesafe semantics also allow to refer to the wrong conntrack from the flowtable datapath. Hold reference on ct until flow is released after rcu grace period.
Add rcu_barrier() on module exit path, to ensure pending flow entries are release before module goes away.
--- net/netfilter/nf_flow_table_core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
net/netfilter/nf_flow_table_core.c +10 -2
@@ -173,6 +173,14 @@ static void flow_offload_route_release(struct flow_offload *flow)dst_release (flow->tuplehash[FLOW_OFFLOAD_DIR_REPLY ].tuple.dst_cache); } +static void flow_offload_free_rcu (struct rcu_head *rcu_head) +{ + struct flow_offload *flow = container_of(rcu_head, struct flow_offload, rcu_head); + +nf_ct_put (flow->ct); +kfree (flow); +} +void flow_offload_free (struct flow_offload *flow) {switch (flow->type) {
@@ -182,8 +190,7 @@ void flow_offload_free(struct flow_offload *flow)default :break ; } -nf_ct_put (flow->ct); -kfree_rcu (flow, rcu_head); +call_rcu (&flow->rcu_head, flow_offload_free_rcu); }EXPORT_SYMBOL_GPL (flow_offload_free);
@@ -584,6 +591,7 @@ static int __init nf_flow_table_module_init(void) static void __exit nf_flow_table_module_exit(void) { +rcu_barrier ();nf_flow_table_offload_exit (); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 392/595 drm: Fix drm_pending_vblank_event leak in error path for out_fence_ptr
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
[ Upstream commit 9eb1a393c89a79c4210230d23e7d88d239c61d7b ]
When an out_fence_ptr is provided but DRM_MODE_PAGE_FLIP_EVENT is not set, a drm_pending_vblank_event will be allocated. If later, there is an allocation failure or another failure at setup_out_fence(), that event will not have base.fence set and it will not be released at complete_signaling().
Release the event and set crtc_state->event to NULL just like in the DRM_MODE_PAGE_FLIP_EVENT case when there is a failure at drm_event_reserve_init(). That is, prepare_signaling() releases the event and there is nothing to be done at complete_signaling(). Use drm_event_cancel_free() as that will also undo drm_event_reserve_init() in case it has been called.
--- drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +10 -3
@@ -1163,10 +1163,12 @@ static int prepare_signaling(struct drm_device *dev,struct dma_fence *fence;struct drm_out_fence_state *f; + ret = -ENOMEM ; + f =krealloc (*fence_state,sizeof (**fence_state) * (*num_fences +1 ),GFP_KERNEL );if (!f) -return -ENOMEM ; + goto err_free_event;memset (&f[*num_fences],0 ,sizeof (*f));
@@ -1175,12 +1177,12 @@ static int prepare_signaling(struct drm_device *dev, fence =drm_crtc_create_fence (crtc);if (!fence) -return -ENOMEM ; + goto err_free_event; ret =setup_out_fence (&f[(*num_fences)++], fence);if (ret) {dma_fence_put (fence); -return ret; + goto err_free_event; } crtc_state->event->base.fence = fence;
@@ -1234,6 +1236,11 @@ static int prepare_signaling(struct drm_device *dev,return -EINVAL ;return 0 ; + +err_free_event: +drm_event_cancel_free (dev, &crtc_state->event->base); + crtc_state->event =NULL ; +return ret; } static void complete_signaling(struct drm_device *dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 393/595 keys: fix lost wakeup when reaping a dead key type
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 2725ab3f5ad1c5f375c7c9fee4af02a9b138f701 ]
clear_bit() is atomic with respect to the word it modifies, but it is an unordered operation: it implies no memory barrier on either side (Documentation/atomic_bitops.txt).
key_garbage_collector() clears KEY_GC_REAPING_KEYTYPE with clear_bit() and calls wake_up_bit() after reaping a dead key type. wake_up_bit() uses a lockless waitqueue check and requires a full barrier after the clear.
The existing smp_mb() is before clear_bit(), so nothing orders the clear against that check. The GC can see an empty waitqueue while unregister_key_type() still sees the bit set. The final wakeup is then lost, leaving module unload stuck in wait_on_bit().
Use clear_and_wake_up_bit(). Its clear_bit_unlock() has RELEASE semantics, so the completed GC work stays ordered before the clear, and its smp_mb__after_atomic() orders the clear before the waitqueue check.
--- security/keys/gc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
security/keys/gc.c +1 -3
@@ -324,9 +324,7 @@ static void key_garbage_collector(struct work_struct *work)if (unlikely (gc_state &KEY_GC_REAPING_DEAD_3 )) {kdebug ("dead wake" ); -smp_mb (); -clear_bit (KEY_GC_REAPING_KEYTYPE , &key_gc_flags); -wake_up_bit (&key_gc_flags,KEY_GC_REAPING_KEYTYPE ); +clear_and_wake_up_bit (KEY_GC_REAPING_KEYTYPE , &key_gc_flags); }if (gc_state &KEY_GC_REAP_AGAIN )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 394/595 ALSA: pcm: set timer->private_data before registering the PCM timer
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit 1e713f9bb2ac583521f06b0eb4e22440b1e3d078 ]
snd_pcm_timer_init() calls snd_device_register() to link the new struct snd_timer into the global timer list while it still carries hw.c_resolution = snd_pcm_timer_resolution (and hw.start/hw.stop), and only afterwards sets timer->private_data = substream.
Once the timer is on the list under register_mutex, a concurrent reader can already reach it through the same mutex and invoke these callbacks. /proc/asound/timers does this via c_resolution(), and snd_timer_open()+snd_timer_start() reach start()/stop() the same way. All three dereference timer->private_data, which for this brief window is NULL, giving a NULL-pointer dereference:
substream = timer->private_data; return substream->runtime ? ... // substream is NULL
Move the private_data/private_free assignment before snd_device_register() so the timer is never visible on the list without its private_data set. On the snd_device_register() failure path, private_free() (snd_pcm_timer_free()) can now run, but it only does substream->timer = NULL, which is already NULL at that point since substream->timer is set to the new timer just once, after a successful registration -- so the failure path stays safe.
--- sound/core/pcm_timer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/core/pcm_timer.c +5 -2
@@ -112,12 +112,15 @@ void snd_pcm_timer_init(struct snd_pcm_substream *substream) "capture" : "playback", tid.card, tid.device, tid.subdevice); timer->hw = snd_pcm_timer; +/* Set before registering: a concurrent reader can invoke our hw +* callbacks as soon as the timer is on the global list. +*/ + timer->private_data = substream; + timer->private_free = snd_pcm_timer_free;if (snd_device_register (timer->card, timer) <0 ) {snd_device_free (timer->card, timer);return ; } - timer->private_data = substream; - timer->private_free = snd_pcm_timer_free; substream->timer = timer; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 395/595 Input: trackpoint - fix the inertia attribute name in the ABI document
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 45b0037899704caf9078be2be4de69361ca7d933 ]
The attribute is created as "inertia" (TRACKPOINT_INT_ATTR(inertia, ...) in drivers/input/mouse/trackpoint.c); the ABI file spells the path "intertia". The description below it already says inertia.
Fix the spelling.
--- Documentation/ABI/testing/sysfs-devices-platform-trackpoint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-devices-platform-trackpoint +1 -1
@@ -5,7 +5,7 @@ Contact: [email protected] Description: (RW) Trackpoint sensitivity. -What: /sys/devices/platform/i8042/.../intertia +What: /sys/devices/platform/i8042/.../inertia Date: Aug, 2005 KernelVersion: 2.6.14 Contact: [email protected]
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 396/595 wifi: virt_wifi: dont transfer operstate before register
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit e5c8d7acd31b27057ea42cd405d0b3ece097bc89 ]
virt_wifi_newlink() calls netif_stacked_transfer_operstate() before register_netdevice(). If the lower device is dormant, that queues the new netdev on lweventlist while it is still uninitialized. If registration fails after that, for example because of an invalid name such as "bad/name", free_netdev() immediately frees the object. A later linkwatch_fire_event() then use-after-frees the list entry.
Move the transfer to after netdev_upper_dev_link(), as macvlan and ipvlan already do.
--- drivers/net/wireless/virt_wifi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/virt_wifi.c +2 -1
@@ -552,7 +552,6 @@ static int virt_wifi_newlink(struct net *src_net, struct net_device *dev, }eth_hw_addr_inherit (dev, priv->lowerdev); -netif_stacked_transfer_operstate (priv->lowerdev, dev);SET_NETDEV_DEV (dev, &priv->lowerdev->dev); dev->ieee80211_ptr =kzalloc (sizeof (*dev->ieee80211_ptr),GFP_KERNEL );
@@ -579,6 +578,8 @@ static int virt_wifi_newlink(struct net *src_net, struct net_device *dev, goto unregister_netdev; } +netif_stacked_transfer_operstate (priv->lowerdev, dev); + dev->priv_destructor = virt_wifi_net_device_destructor; priv->being_deleted = false; priv->is_connected = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 397/595 ALSA: hda: trace PCM open only after assigning a stream
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slavin Liu <[email protected]>
[ Upstream commit c9e6e5f38bf75276605f1952b22285f5f3abcaff ]
Stream assignment can fail when hardware streams are exhausted. Move the tracepoint after the NULL check because its payload accesses the assigned stream tag.
Detected by static analysis and reviewed with AI-assisted source auditing.
--- sound/pci/hda/hda_controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/hda_controller.c +1 -1
@@ -588,11 +588,11 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)snd_hda_codec_pcm_get (apcm->info);mutex_lock (&chip->open_mutex); azx_dev =azx_assign_device (chip, substream); -trace_azx_pcm_open (chip, azx_dev);if (azx_dev ==NULL ) { err = -EBUSY ; goto unlock; } +trace_azx_pcm_open (chip, azx_dev); runtime->private_data = azx_dev; runtime->hw = azx_pcm_hw;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/595 btrfs: tree-checker: print dev extent offset in error message
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit a1167d9420474ab9ed9efca99d86aeb6217c0265 ]
If a dev extent's offset is not sector size aligned, the error message is printing the dev extent's objectid instead of the offset. This is a copy paste error, as before this check we check the objectid field.
--- fs/btrfs/tree-checker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-checker.c +1 -1
@@ -1608,7 +1608,7 @@ static int check_dev_extent_item(const struct extent_buffer *leaf, sectorsize))) {generic_err (leaf, slot,"invalid dev extent chunk offset, has %llu not aligned to %u" , -btrfs_dev_extent_chunk_objectid (leaf, de), +btrfs_dev_extent_chunk_offset (leaf, de), sectorsize);return -EUCLEAN ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/595 seg6: set IPSKB_L3SLAVE from IP6SKB_L3SLAVE on IPIP decapsulation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Mayer <[email protected]>
[ Upstream commit 7616242a2b37883f7322aaa1d2bd6cd0fed28315 ]
When an SRv6 packet arrives on an interface enslaved to a VRF, vrf_ip6_rcv() sets IP6SKB_L3SLAVE in IP6CB, but decap_and_validate() has never set IPSKB_L3SLAVE in IPCB. The bit stayed clear in the common case, and with CONFIG_IPV6_MIP6 the leftover frag_max_size of a reassembled outer packet could even set it, with no VRF involved. Commit 44930446dde4 ("ipv6: seg6: clear IPv4 control block on IPIP decapsulation") then made the unreliable bit reliably clear.
The effect of the missing flag is visible with End.DX4 when a delivery to a local address of the node reaches the socket lookup. For example, a UDP socket bound to the enslaved ingress interface does not receive any of the decapsulated packets, while an unbound socket outside the VRF does.
This contradicts Documentation/networking/vrf.rst: by default the scope of an unbound UDP or TCP socket is limited to the default VRF.
Set IPSKB_L3SLAVE for IPv4 in decap_and_validate(), which already does the same for IPv6. The socket lookup then matches the decapsulated packet like any other packet received on that enslaved interface. Such a packet matches an unbound UDP or TCP socket only when udp_l3mdev_accept or tcp_l3mdev_accept is set.
--- net/ipv6/seg6_local.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/seg6_local.c +3 -0
@@ -140,10 +140,13 @@ static bool decap_and_validate(struct sk_buff *skb, int proto)return false;if (proto ==IPPROTO_IPIP ) { +bool l3slave =ipv6_l3mdev_skb (IP6CB (skb)->flags);int iif =IP6CB (skb)->iif;memset (IPCB (skb),0 ,sizeof (*IPCB (skb)));IPCB (skb)->iif = iif; +if (l3slave) +IPCB (skb)->flags |=IPSKB_L3SLAVE ; }else if (proto ==IPPROTO_IPV6 ) {bool l3slave =ipv6_l3mdev_skb (IP6CB (skb)->flags);int iif =IP6CB (skb)->iif;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/595 net: fddi: skfp: fix NULL deref when setting the MAC address while down
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hohyun Sim <[email protected]>
[ Upstream commit 7c8810c2e69c3d9ca6df870b40ae9218e50b4fb1 ]
skfp_ctl_set_mac_address() calls ResetAdapter() unconditionally, without checking netif_running(). ResetAdapter() first calls card_stop(), which sets smc->hw.hw_state to STOPPED, and then mac_drv_clear_tx_queue(), which walks the two transmit queues:
for (i = QUEUE_S; i <= QUEUE_A0; i++) {
queue = smc->hw.fp.tx[i] ;
...
t = queue->tx_curr_get ;smc->hw.fp.tx[] is only populated by init_tx(), which is reached from skfp_open() through init_smt() -> init_fddi_driver() -> init_fplus() -> init_mac() -> init_tx(). The private area is allocated and zeroed by alloc_fddidev(), so on an interface that has never been brought up both queue pointers are still NULL. The hw_state test at the top of mac_drv_clear_tx_queue() does not catch this, because card_stop() has just set STOPPED; the function proceeds into the loop and dereferences NULL. ResetAdapter() does call init_smt() itself, but only after the queues have been cleared.
Setting the MAC address on a down interface therefore oopses:
ip link set dev fddi0 address 02:00:00:00:00:01
BUG: KASAN: null-ptr-deref in mac_drv_clear_tx_queue+0x68/0x2c0 [skfp] Read of size 8 at addr 0000000000000010 by task ip/302 Call Trace: <TASK> mac_drv_clear_tx_queue+0x68/0x2c0 [skfp 6c01d4bab63c36978bd0a7d7e90837adb44cc37b] ResetAdapter+0x29/0x100 [skfp 6c01d4bab63c36978bd0a7d7e90837adb44cc37b] skfp_ctl_set_mac_address+0x57/0x80 [skfp 6c01d4bab63c36978bd0a7d7e90837adb44cc37b] netif_set_mac_address+0x1e4/0x2c0 do_setlink+0x684/0x2680 </TASK>
Address 0x10 is the offset of tx_curr_get, the third pointer in struct s_smt_tx_queue, on 64-bit. mac_drv_clear_rx_queue(), which ResetAdapter() calls immediately afterwards, dereferences smc->hw.fp.rx[QUEUE_R1] in the same way behind the same ineffective hw_state test; the transmit queue merely crashes first. Both are covered by the guard below.
Skip the adapter reset when the interface is down. dev_addr_set() is left unconditional, so the new address is still recorded in dev->dev_addr. Nothing is lost by not resetting the adapter here:skfp_open() deliberately re-reads the factory address on every open,
read_address(smc, NULL); eth_hw_addr_set(dev, smc->hw.fddi_canon_addr.a);
and the comment above it states this is done to discard exactly such an address override across a close/open cycle. An address set while the interface is down could not have survived the following open even before this change, so the guard removes no working behaviour. Guarding the hardware side of ndo_set_mac_address() with netif_running() is established practice; skge_set_mac_address() has done so since commit 2eb3e621c4e0 ("skge: set mac address bonding fix").
Guarding the reset as a whole, rather than NULL-checking the queues, is also what the rest of the driver expects. After a previous open/close the queue pointers are stale but non-NULL, so there is no crash, yet ResetAdapter() goes on to call smt_online() and STI_FBI() ("Enable Board Interrupts") while skfp_close() has already called free_irq() - the adapter would be brought back online with no handler installed. The only other ResetAdapter() caller is skfp_interrupt(), which by construction runs only while the device is open.
Found by automated driver testing against an emulated SysKonnect FDDI adapter under a KASAN-enabled 7.0.0 kernel. Triggering it requires CAP_NET_ADMIN.
--- drivers/net/fddi/skfp/skfddi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/fddi/skfp/skfddi.c +2 -1
@@ -924,7 +924,8 @@ static int skfp_ctl_set_mac_address(struct net_device *dev, void *addr)memcpy (dev->dev_addr, p_sockaddr->sa_data,FDDI_K_ALEN );spin_lock_irqsave (&bp->DriverLock, Flags); -ResetAdapter (smc); +if (netif_running (dev)) +ResetAdapter (smc);spin_unlock_irqrestore (&bp->DriverLock, Flags);return 0 ;/* always return zero */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/595 wifi: brcmfmac: fix lost 802.1x TX completion wakeup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 621d90169cef6c8da5b6134db5c0c4e23cdd09ce ]
brcmf_txfinalize() decrements pend_8021x_cnt before a lockless waitqueue_active() check. atomic_dec() does not order the decrement against the check.
The waiter can therefore observe a nonzero count while the waker observes an empty queue, losing the final wakeup and delaying key installation until the 950 ms timeout.
Add smp_mb__after_atomic() to order the decrement before the queue check. wait_event_timeout() provides the matching barrier. LKMM confirms that this forbids the lost-wakeup outcome.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +2 -0
@@ -555,6 +555,8 @@ void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff *txp, bool success)if (type ==ETH_P_PAE ) {atomic_dec (&ifp->pend_8021x_cnt); +/* Order the decrement before waitqueue_active() */ +smp_mb__after_atomic ();if (waitqueue_active (&ifp->pend_8021x_wait))wake_up (&ifp->pend_8021x_wait); }
Signature · 1 line
2.53.0