5.17.3-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 178/343 SUNRPC: remove scheduling boost for "SWAPPER" tasks.
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit a80a8461868905823609be97f91776a26befe839 ]
Currently, tasks marked as "swapper" tasks get put to the front of non-priority rpc_queues, and are sorted earlier than non-swapper tasks on the transport's ->xmit_queue.
This is pointless as currently *all* tasks for a mount that has swap enabled on *any* file are marked as "swapper" tasks. So the net result is that the non-priority rpc_queues are reverse-ordered (LIFO).
This scheduling boost is not necessary to avoid deadlocks, and hurts fairness, so remove it. If there were a need to expedite some requests, the tk_priority mechanism is a more appropriate tool.
--- net/sunrpc/sched.c | 7 ------- net/sunrpc/xprt.c | 11 ----------- 2 files changed, 18 deletions(-)
net/sunrpc/sched.c +0 -7
@@ -186,11 +186,6 @@ static void __rpc_add_wait_queue_priority(struct rpc_wait_queue *queue,/* * Add new request to wait queue. -* -* Swapper tasks always get inserted at the head of the queue. -* This should avoid many nasty memory deadlocks and hopefully -* improve overall performance. -* Everyone else gets appended to the queue to ensure proper FIFO behavior. */ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue, struct rpc_task *task,
@@ -199,8 +194,6 @@ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue,INIT_LIST_HEAD (&task->u.tk_wait.timer_list);if (RPC_IS_PRIORITY (queue))__rpc_add_wait_queue_priority (queue, task, queue_priority); -else if (RPC_IS_SWAPPER (task)) -list_add (&task->u.tk_wait.list, &queue->tasks[0 ]);else list_add_tail (&task->u.tk_wait.list, &queue->tasks[0 ]); task->tk_waitqueue = queue;
net/sunrpc/xprt.c +0 -11
@@ -1354,17 +1354,6 @@ xprt_request_enqueue_transmit(struct rpc_task *task)INIT_LIST_HEAD (&req->rq_xmit2); goto out; } - }else if (RPC_IS_SWAPPER (task)) { -list_for_each_entry (pos, &xprt->xmit_queue, rq_xmit) { -if (pos->rq_cong || pos->rq_bytes_sent) -continue ; -if (RPC_IS_SWAPPER (pos->rq_task)) -continue ; -/* Note: req is added _before_ pos */ -list_add_tail (&req->rq_xmit, &pos->rq_xmit); -INIT_LIST_HEAD (&req->rq_xmit2); - goto out; - } }else if (!req->rq_seqno) {list_for_each_entry (pos, &xprt->xmit_queue, rq_xmit) {if (pos->rq_task->tk_owner != task->tk_owner)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 148/343 Bluetooth: Fix use after free in hci_send_acl
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f63d24baff787e13b723d86fe036f84bdbc35045 ]
This fixes the following trace caused by receiving HCI_EV_DISCONN_PHY_LINK_COMPLETE which does call hci_conn_del without first checking if conn->type is in fact AMP_LINK and in case it is do properly cleanup upper layers with hci_disconn_cfm:
==================================================================
BUG: KASAN: use-after-free in hci_send_acl+0xaba/0xc50
Read of size 8 at addr ffff88800e404818 by task bluetoothd/142
CPU: 0 PID: 142 Comm: bluetoothd Not tainted
5.17.0-rc5-00006-gda4022eeac1a #7
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x45/0x59
print_address_description.constprop.0+0x1f/0x150
kasan_report.cold+0x7f/0x11b
hci_send_acl+0xaba/0xc50
l2cap_do_send+0x23f/0x3d0
l2cap_chan_send+0xc06/0x2cc0
l2cap_sock_sendmsg+0x201/0x2b0
sock_sendmsg+0xdc/0x110
sock_write_iter+0x20f/0x370
do_iter_readv_writev+0x343/0x690
do_iter_write+0x132/0x640
vfs_writev+0x198/0x570
do_writev+0x202/0x280
do_syscall_64+0x38/0x90
entry_SYSCALL_64_after_hwframe+0x44/0xae
RSP: 002b:00007ffce8a099b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
Code: 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3
0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 14 00 00 00 0f 05
<48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10
RDX: 0000000000000001 RSI: 00007ffce8a099e0 RDI: 0000000000000015
RAX: ffffffffffffffda RBX: 00007ffce8a099e0 RCX: 00007f788fc3cf77
R10: 00007ffce8af7080 R11: 0000000000000246 R12: 000055e4ccf75580
RBP: 0000000000000015 R08: 0000000000000002 R09: 0000000000000001
</TASK>
R13: 000055e4ccf754a0 R14: 000055e4ccf75cd0 R15: 000055e4ccf4a6b0
Allocated by task 45:
kasan_save_stack+0x1e/0x40
__kasan_kmalloc+0x81/0xa0
hci_chan_create+0x9a/0x2f0
l2cap_conn_add.part.0+0x1a/0xdc0
l2cap_connect_cfm+0x236/0x1000
le_conn_complete_evt+0x15a7/0x1db0
hci_le_conn_complete_evt+0x226/0x2c0
hci_le_meta_evt+0x247/0x450
hci_event_packet+0x61b/0xe90
hci_rx_work+0x4d5/0xc50
process_one_work+0x8fb/0x15a0
worker_thread+0x576/0x1240
kthread+0x29d/0x340
ret_from_fork+0x1f/0x30
Freed by task 45:
kasan_save_stack+0x1e/0x40
kasan_set_track+0x21/0x30
kasan_set_free_info+0x20/0x30
__kasan_slab_free+0xfb/0x130
kfree+0xac/0x350
hci_conn_cleanup+0x101/0x6a0
hci_conn_del+0x27e/0x6c0
hci_disconn_phylink_complete_evt+0xe0/0x120
hci_event_packet+0x812/0xe90
hci_rx_work+0x4d5/0xc50
process_one_work+0x8fb/0x15a0
worker_thread+0x576/0x1240
kthread+0x29d/0x340
ret_from_fork+0x1f/0x30
The buggy address belongs to the object at ffff88800c0f0500
The buggy address is located 24 bytes inside of
which belongs to the cache kmalloc-128 of size 128
The buggy address belongs to the page:
128-byte region [ffff88800c0f0500, ffff88800c0f0580)
flags: 0x100000000000200(slab|node=0|zone=1)
page:00000000fe45cd86 refcount:1 mapcount:0
mapping:0000000000000000 index:0x0 pfn:0xc0f0
raw: 0000000000000000 0000000080100010 00000001ffffffff
0000000000000000
raw: 0100000000000200 ffffea00003a2c80 dead000000000004
ffff8880078418c0
page dumped because: kasan: bad access detected
ffff88800c0f0400: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc
Memory state around the buggy address:
>ffff88800c0f0500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88800c0f0480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800c0f0580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
==================================================================
ffff88800c0f0600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb--- net/bluetooth/hci_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/hci_event.c +2 -1
@@ -5453,8 +5453,9 @@ static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev, void *data,hci_dev_lock (hdev); hcon =hci_conn_hash_lookup_handle (hdev, ev->phy_handle); -if (hcon) { +if (hcon && hcon->type ==AMP_LINK ) { hcon->state =BT_CLOSED ; +hci_disconn_cfm (hcon, ev->reason);hci_conn_del (hcon); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 152/343 ceph: fix memory leak in ceph_readdir when note_last_dentry returns error
In reply to Greg Kroah-HartmanFrom: Xiubo Li <[email protected]>
[ Upstream commit f639d9867eea647005dc824e0e24f39ffc50d4e4 ]
Reset the last_readdir at the same time, and add a comment explaining why we don't free last_readdir when dir_emit returns false.
--- fs/ceph/dir.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/ceph/dir.c +10 -1
@@ -478,8 +478,11 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx) 2 : (fpos_off(rde->offset) + 1); err =note_last_dentry (dfi, rde->name, rde->name_len, next_offset); -if (err) +if (err) { +ceph_mdsc_put_request (dfi->last_readdir); + dfi->last_readdir =NULL ;return err; + } }else if (req->r_reply_info.dir_end) { dfi->next_offset =2 ;/* keep last name */
@@ -520,6 +523,12 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)if (!dir_emit (ctx, rde->name, rde->name_len,ceph_present_ino (inode->i_sb,le64_to_cpu (rde->inode.in->ino)),le32_to_cpu (rde->inode.in->mode) >>12 )) { +/* +* NOTE: Here no need to put the 'dfi->last_readdir', +* because when dir_emit stops us it's most likely +* doesn't have enough memory, etc. So for next readdir +* it will continue. +*/ dout ("filldir stopping us...\n" );return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 153/343 lib/Kconfig.debug: add ARCH dependency for FUNCTION_ALIGN option
In reply to Greg Kroah-HartmanFrom: Feng Tang <[email protected]>
[ Upstream commit 1bf18da62106225dbc47aab41efee2aeb99caccd ]
0Day robots reported there is compiling issue for 'csky' ARCH when CONFIG_DEBUG_FORCE_DATA_SECTION_ALIGNED is enabled [1]:
All errors (new ones prefixed by >>):
{standard input}: Assembler messages:
Quoted 1 line
Quoted 1 line
{standard input}:2277: Error: pcrel offset for branch to .LS000B too far (
0x3c)
Which was discussed in [2]. And as there is no solution for csky yet, add some dependency for this config to limit it to several ARCHs which have no compiling issue so far.
[1]. https://lore.kernel.org/lkml/[email protected]/
[2]. https://www.spinics.net/lists/linux-kbuild/msg30298.html
--- lib/Kconfig.debug | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/Kconfig.debug +2 -1
@@ -416,7 +416,8 @@ config SECTION_MISMATCH_WARN_ONLY If unsure, say Y. config DEBUG_FORCE_FUNCTION_ALIGN_64B - bool "Force all function address 64B aligned" if EXPERT + bool "Force all function address 64B aligned" + depends on EXPERT && (X86_64 || ARM64 || PPC32 || PPC64 || ARC) help There are cases that a commit from one domain changes the function address alignment of other domains, and cause magic performance
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 154/343 init/main.c: return 1 from handled __setup() functions
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit f9a40b0890658330c83c95511f9d6b396610defc ]
initcall_blacklist() should return 1 to indicate that it handled its cmdline arguments.
set_debug_rodata() should return 1 to indicate that it handled its cmdline arguments. Print a warning if the option string is invalid.
This prevents these strings from being added to the 'init' program's environment as they are not init arguments/parameters.
--- init/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
init/main.c +4 -2
@@ -1192,7 +1192,7 @@ static int __init initcall_blacklist(char *str) } }while (str_entry); -return 0 ; +return 1 ; } static bool __init_or_module initcall_blacklisted(initcall_t fn)
@@ -1454,7 +1454,9 @@ static noinline void __init kernel_init_freeable(void);bool rodata_enabled__ro_after_init = true;static int __init set_debug_rodata (char *str) { -return strtobool (str, &rodata_enabled); +if (strtobool (str, &rodata_enabled)) +pr_warn ("Invalid option string for rodata: '%s'\n" , str); +return 1 ; }__setup ("rodata=" , set_debug_rodata);#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 188/343 NFS: Avoid writeback threads getting stuck in mempool_alloc()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 0bae835b63c53f86cdc524f5962e39409585b22c ]
In a low memory situation, allow the NFS writeback code to fail without getting stuck in infinite loops in mempool_alloc().
--- fs/nfs/pagelist.c | 10 +++++----- fs/nfs/write.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 7 deletions(-)
fs/nfs/pagelist.c +5 -5
@@ -90,10 +90,10 @@ void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos) } } -static inline struct nfs_page * -nfs_page_alloc (void ) +static inline struct nfs_page *nfs_page_alloc (void ) { -struct nfs_page *p =kmem_cache_zalloc (nfs_page_cachep,GFP_KERNEL ); +struct nfs_page *p = +kmem_cache_zalloc (nfs_page_cachep,nfs_io_gfp_mask ());if (p)INIT_LIST_HEAD (&p->wb_list);return p;
@@ -892,7 +892,7 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc,struct nfs_commit_info cinfo;struct nfs_page_array *pg_array = &hdr->page_array;unsigned int pagecount, pageused; -gfp_t gfp_flags =GFP_KERNEL ; +gfp_t gfp_flags =nfs_io_gfp_mask (); pagecount =nfs_page_array_len (mirror->pg_base, mirror->pg_count); pg_array->npages = pagecount;
@@ -979,7 +979,7 @@ nfs_pageio_alloc_mirrors(struct nfs_pageio_descriptor *desc, desc->pg_mirrors_dynamic =NULL ;if (mirror_count ==1 )return desc->pg_mirrors_static; - ret =kmalloc_array (mirror_count,sizeof (*ret),GFP_KERNEL ); + ret =kmalloc_array (mirror_count,sizeof (*ret),nfs_io_gfp_mask ());if (ret !=NULL ) {for (i =0 ; i < mirror_count; i++)nfs_pageio_mirror_init (&ret[i], desc->pg_bsize);
fs/nfs/write.c +8 -2
@@ -94,9 +94,15 @@ EXPORT_SYMBOL_GPL(nfs_commit_free);static struct nfs_pgio_header *nfs_writehdr_alloc (void ) { -struct nfs_pgio_header *p =mempool_alloc (nfs_wdata_mempool,GFP_KERNEL ); +struct nfs_pgio_header *p; -memset (p,0 ,sizeof (*p)); + p =kmem_cache_zalloc (nfs_wdata_cachep,nfs_io_gfp_mask ()); +if (!p) { + p =mempool_alloc (nfs_wdata_mempool,GFP_NOWAIT ); +if (!p) +return NULL ; +memset (p,0 ,sizeof (*p)); + } p->rw_mode =FMODE_WRITE ;return p; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 189/343 selftests: net: Add tls config dependency for tls selftests
In reply to Greg Kroah-HartmanFrom: Naresh Kamboju <[email protected]>
[ Upstream commit d9142e1cf3bbdaf21337767114ecab26fe702d47 ]
selftest net tls test cases need TLS=m without this the test hangs. Enabling config TLS solves this problem and runs to complete.
- CONFIG_TLS=m
--- tools/testing/selftests/net/config | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/net/config +1 -0
@@ -43,5 +43,6 @@ CONFIG_NET_ACT_TUNNEL_KEY=m CONFIG_NET_ACT_MIRRED=m CONFIG_BAREUDP=m CONFIG_IPV6_IOAM6_LWTUNNEL=y +CONFIG_TLS=m CONFIG_CRYPTO_SM4=y CONFIG_AMT=m
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 193/343 drm/amdgpu: fix off by one in amdgpu_gfx_kiq_acquire()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1647b54ed55d4d48c7199d439f8834626576cbe9 ]
This post-op should be a pre-op so that we do not pass -1 as the bit number to test_bit(). The current code will loop downwards from 63 to -1. After changing to a pre-op, it loops from 63 to 0.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
@@ -266,7 +266,7 @@ static int amdgpu_gfx_kiq_acquire(struct amdgpu_device *adev,* adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_queue_per_pipe; -while (queue_bit-- >= 0) { +while (--queue_bit >= 0) { if (test_bit(queue_bit, adev->gfx.mec.queue_bitmap)) continue;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 204/343 net: sfc: add missing xdp queue reinitialization
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit 059a47f1da93811d37533556d67e72f2261b1127 ]
After rx/tx ring buffer size is changed, kernel panic occurs when it acts XDP_TX or XDP_REDIRECT.
When tx/rx ring buffer size is changed(ethtool -G), sfc driver reallocates and reinitializes rx and tx queues and their buffer (tx_queue->buffer).
But it misses reinitializing xdp queues(efx->xdp_tx_queues). So, while it is acting XDP_TX or XDP_REDIRECT, it uses the uninitialized tx_queue->buffer.
A new function efx_set_xdp_channels() is separated from efx_set_channels() to handle only xdp queues.
Splat looks like:
BUG: kernel NULL pointer dereference, address: 000000000000002a
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
PGD 0 P4D 0
Oops: 0002 [#4] PREEMPT SMP NOPTI
RIP: 0010:efx_tx_map_chunk+0x54/0x90 [sfc]
CPU: 2 PID: 0 Comm: swapper/2 Tainted: G D 5.17.0+ #55 e8beeee8289528f11357029357cf
Code: 48 8b 8d a8 01 00 00 48 8d 14 52 4c 8d 2c d0 44 89 e0 48 85 c9 74 0e 44 89 e2 4c 89 f6 48 80
RSP: 0018:ffff92f121e45c60 EFLAGS: 00010297
RIP: 0010:efx_tx_map_chunk+0x54/0x90 [sfc]
RAX: 0000000000000040 RBX: ffff92ea506895c0 RCX: ffffffffc0330870
RDX: 0000000000000001 RSI: 00000001139b10ce RDI: ffff92ea506895c0
RBP: ffffffffc0358a80 R08: 00000001139b110d R09: 0000000000000000
R10: 0000000000000001 R11: ffff92ea414c0088 R12: 0000000000000040
R13: 0000000000000018 R14: 00000001139b10ce R15: ffff92ea506895c0
FS: 0000000000000000(0000) GS:ffff92f121ec0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Code: 48 8b 8d a8 01 00 00 48 8d 14 52 4c 8d 2c d0 44 89 e0 48 85 c9 74 0e 44 89 e2 4c 89 f6 48 80
CR2: 000000000000002a CR3: 00000003e6810004 CR4: 00000000007706e0
RSP: 0018:ffff92f121e85c60 EFLAGS: 00010297
PKRU: 55555554
RAX: 0000000000000040 RBX: ffff92ea50689700 RCX: ffffffffc0330870
RDX: 0000000000000001 RSI: 00000001145a90ce RDI: ffff92ea50689700
RBP: ffffffffc0358a80 R08: 00000001145a910d R09: 0000000000000000
R10: 0000000000000001 R11: ffff92ea414c0088 R12: 0000000000000040
R13: 0000000000000018 R14: 00000001145a90ce R15: ffff92ea50689700
FS: 0000000000000000(0000) GS:ffff92f121e80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000000002a CR3: 00000003e6810005 CR4: 00000000007706e0
PKRU: 55555554
Call Trace:
<IRQ>
efx_xdp_tx_buffers+0x12b/0x3d0 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]
__efx_rx_packet+0x5c3/0x930 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]
efx_rx_packet+0x28c/0x2e0 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]
efx_ef10_ev_process+0x5f8/0xf40 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]
? enqueue_task_fair+0x95/0x550
efx_poll+0xc4/0x360 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5]--- drivers/net/ethernet/sfc/efx_channels.c | 146 +++++++++++++----------- 1 file changed, 81 insertions(+), 65 deletions(-)
drivers/net/ethernet/sfc/efx_channels.c +81 -65
@@ -764,6 +764,85 @@ void efx_remove_channels(struct efx_nic *efx)kfree (efx->xdp_tx_queues); } +static int efx_set_xdp_tx_queue (struct efx_nic *efx,int xdp_queue_number, +struct efx_tx_queue *tx_queue) +{ +if (xdp_queue_number >= efx->xdp_tx_queue_count) +return -EINVAL ; + +netif_dbg (efx, drv, efx->net_dev, +"Channel %u TXQ %u is XDP %u, HW %u\n" , + tx_queue->channel->channel, tx_queue->label, + xdp_queue_number, tx_queue->queue); + efx->xdp_tx_queues[xdp_queue_number] = tx_queue; +return 0 ; +} + +static void efx_set_xdp_channels (struct efx_nic *efx) +{ +struct efx_tx_queue *tx_queue; +struct efx_channel *channel; +unsigned int next_queue =0 ; +int xdp_queue_number =0 ; +int rc; + +/* We need to mark which channels really have RX and TX +* queues, and adjust the TX queue numbers if we have separate +* RX-only and TX-only channels. +*/ +efx_for_each_channel (channel, efx) { +if (channel->channel < efx->tx_channel_offset) +continue ; + +if (efx_channel_is_xdp_tx (channel)) { +efx_for_each_channel_tx_queue (tx_queue, channel) { + tx_queue->queue = next_queue++; + rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, + tx_queue); +if (rc ==0 ) + xdp_queue_number++; + } + }else { +efx_for_each_channel_tx_queue (tx_queue, channel) { + tx_queue->queue = next_queue++; +netif_dbg (efx, drv, efx->net_dev, +"Channel %u TXQ %u is HW %u\n" , + channel->channel, tx_queue->label, + tx_queue->queue); + } + +/* If XDP is borrowing queues from net stack, it must +* use the queue with no csum offload, which is the +* first one of the channel +* (note: tx_queue_by_type is not initialized yet) +*/ +if (efx->xdp_txq_queues_mode == +EFX_XDP_TX_QUEUES_BORROWED ) { + tx_queue = &channel->tx_queue[0 ]; + rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, + tx_queue); +if (rc ==0 ) + xdp_queue_number++; + } + } + } +WARN_ON (efx->xdp_txq_queues_mode ==EFX_XDP_TX_QUEUES_DEDICATED && + xdp_queue_number != efx->xdp_tx_queue_count); +WARN_ON (efx->xdp_txq_queues_mode !=EFX_XDP_TX_QUEUES_DEDICATED && + xdp_queue_number > efx->xdp_tx_queue_count); + +/* If we have more CPUs than assigned XDP TX queues, assign the already +* existing queues to the exceeding CPUs +*/ + next_queue =0 ; +while (xdp_queue_number < efx->xdp_tx_queue_count) { + tx_queue = efx->xdp_tx_queues[next_queue++]; + rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, tx_queue); +if (rc ==0 ) + xdp_queue_number++; + } +} +int efx_realloc_channels (struct efx_nic *efx,u32 rxq_entries,u32 txq_entries) {struct efx_channel *other_channel[EFX_MAX_CHANNELS ], *channel;
@@ -835,6 +914,7 @@ int efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries)efx_init_napi_channel (efx->channel[i]); } +efx_set_xdp_channels (efx); out:/* Destroy unused channel structures */ for (i =0 ; i < efx->n_channels; i++) {
@@ -867,26 +947,9 @@ int efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) goto out; } -static inline int -efx_set_xdp_tx_queue (struct efx_nic *efx,int xdp_queue_number, -struct efx_tx_queue *tx_queue) -{ -if (xdp_queue_number >= efx->xdp_tx_queue_count) -return -EINVAL ; - -netif_dbg (efx, drv, efx->net_dev,"Channel %u TXQ %u is XDP %u, HW %u\n" , - tx_queue->channel->channel, tx_queue->label, - xdp_queue_number, tx_queue->queue); - efx->xdp_tx_queues[xdp_queue_number] = tx_queue; -return 0 ; -} -int efx_set_channels (struct efx_nic *efx) { -struct efx_tx_queue *tx_queue;struct efx_channel *channel; -unsigned int next_queue =0 ; -int xdp_queue_number;int rc; efx->tx_channel_offset =
@@ -904,61 +967,14 @@ int efx_set_channels(struct efx_nic *efx)return -ENOMEM ; } -/* We need to mark which channels really have RX and TX -* queues, and adjust the TX queue numbers if we have separate -* RX-only and TX-only channels. -*/ - xdp_queue_number =0 ;efx_for_each_channel (channel, efx) {if (channel->channel < efx->n_rx_channels) channel->rx_queue.core_index = channel->channel;else channel->rx_queue.core_index =-1 ; - -if (channel->channel >= efx->tx_channel_offset) { -if (efx_channel_is_xdp_tx (channel)) { -efx_for_each_channel_tx_queue (tx_queue, channel) { - tx_queue->queue = next_queue++; - rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, tx_queue); -if (rc ==0 ) - xdp_queue_number++; - } - }else { -efx_for_each_channel_tx_queue (tx_queue, channel) { - tx_queue->queue = next_queue++; -netif_dbg (efx, drv, efx->net_dev,"Channel %u TXQ %u is HW %u\n" , - channel->channel, tx_queue->label, - tx_queue->queue); - } - -/* If XDP is borrowing queues from net stack, it must use the queue -* with no csum offload, which is the first one of the channel -* (note: channel->tx_queue_by_type is not initialized yet) -*/ -if (efx->xdp_txq_queues_mode ==EFX_XDP_TX_QUEUES_BORROWED ) { - tx_queue = &channel->tx_queue[0 ]; - rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, tx_queue); -if (rc ==0 ) - xdp_queue_number++; - } - } - } } -WARN_ON (efx->xdp_txq_queues_mode ==EFX_XDP_TX_QUEUES_DEDICATED && - xdp_queue_number != efx->xdp_tx_queue_count); -WARN_ON (efx->xdp_txq_queues_mode !=EFX_XDP_TX_QUEUES_DEDICATED && - xdp_queue_number > efx->xdp_tx_queue_count); -/* If we have more CPUs than assigned XDP TX queues, assign the already -* existing queues to the exceeding CPUs -*/ - next_queue =0 ; -while (xdp_queue_number < efx->xdp_tx_queue_count) { - tx_queue = efx->xdp_tx_queues[next_queue++]; - rc =efx_set_xdp_tx_queue (efx, xdp_queue_number, tx_queue); -if (rc ==0 ) - xdp_queue_number++; - } +efx_set_xdp_channels (efx); rc =netif_set_real_num_tx_queues (efx->net_dev, efx->n_tx_channels);if (rc)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 208/343 Revert "net: dsa: stop updating master MTU from master.c"
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 066dfc4290406b1b0b014ae3267d4266a344efd1 ]
This reverts commit a1ff94c2973c43bc1e2677ac63ebb15b1d1ff846.
Switch drivers that don't implement ->port_change_mtu() will cause the DSA master to remain with an MTU of 1500, since we've deleted the other code path. In turn, this causes a regression for those systems, where MTU-sized traffic can no longer be terminated.
Revert the change taking into account the fact that rtnl_lock() is now taken top-level from the callers of dsa_master_setup() and dsa_master_teardown(). Also add a comment in order for it to be absolutely clear why it is still needed.
--- net/dsa/master.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
net/dsa/master.c +24 -1
@@ -337,11 +337,24 @@ static const struct attribute_group dsa_group = {static struct lock_class_key dsa_master_addr_list_lock_key; +static void dsa_master_reset_mtu (struct net_device *dev) +{ +int err; + + err =dev_set_mtu (dev,ETH_DATA_LEN ); +if (err) +netdev_dbg (dev, +"Unable to reset MTU to exclude DSA overheads\n" ); +} +int dsa_master_setup (struct net_device *dev,struct dsa_port *cpu_dp) { +const struct dsa_device_ops *tag_ops = cpu_dp->tag_ops;struct dsa_switch *ds = cpu_dp->ds;struct device_link *consumer_link; -int ret; +int mtu, ret; + + mtu =ETH_DATA_LEN +dsa_tag_protocol_overhead (tag_ops);/* The DSA master must use SET_NETDEV_DEV for this to work. */ consumer_link = device_link_add(ds->dev, dev->dev.parent,
@@ -351,6 +364,15 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)"Failed to create a device link to DSA switch %s\n" , dev_name(ds->dev)); +/* The switch driver may not implement ->port_change_mtu(), case in +* which dsa_slave_change_mtu() will not update the master MTU either, +* so we need to do that here. +*/ + ret =dev_set_mtu (dev, mtu); +if (ret) +netdev_warn (dev,"error %d setting MTU to %d to include DSA overhead\n" , + ret, mtu); +/* If we use a tagging format that doesn't have an ethertype * field, make sure that all packets from this point on get * sent to the tag format's receive function.
@@ -388,6 +410,7 @@ void dsa_master_teardown(struct net_device *dev)sysfs_remove_group (&dev->dev.kobj, &dsa_group);dsa_netdev_ops_set (dev,NULL );dsa_master_ethtool_teardown (dev); +dsa_master_reset_mtu (dev);dsa_master_set_promiscuity (dev,-1 ); dev->dsa_ptr =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 209/343 ice: Clear default forwarding VSI during VSI release
In reply to Greg Kroah-HartmanFrom: Ivan Vecera <[email protected]>
[ Upstream commit bd8c624c0cd59de0032752ba3001c107bba97f7b ]
VSI is set as default forwarding one when promisc mode is set for PF interface, when PF is switched to switchdev mode or when VF driver asks to enable allmulticast or promisc mode for the VF interface (when vf-true-promisc-support priv flag is off). The third case is buggy because in that case VSI associated with VF remains as default one after VF removal.
Reproducer:
1. Create VF
echo 1 > sys/class/net/ens7f0/device/sriov_numvfs
2. Enable allmulticast or promisc mode on VF ip link set ens7f0v0 allmulticast on
ip link set ens7f0v0 promisc on
3. Delete VF
echo 0 > sys/class/net/ens7f0/device/sriov_numvfs
4. Try to enable promisc mode on PF
ip link set ens7f0 promisc on
Although it looks that promisc mode on PF is enabled the opposite is true because ice_vsi_sync_fltr() responsible for IFF_PROMISC handling first checks if any other VSI is set as default forwarding one and if so the function does not do anything. At this point it is not possible to enable promisc mode on PF without re-probe device.
To resolve the issue this patch clear default forwarding VSI during ice_vsi_release() when the VSI to be released is the default one.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/ice/ice_lib.c +2 -0
@@ -3147,6 +3147,8 @@ int ice_vsi_release(struct ice_vsi *vsi) } } +if (ice_is_vsi_dflt_vsi (pf->first_sw, vsi)) +ice_clear_dflt_vsi (pf->first_sw);ice_fltr_remove_all (vsi);ice_rm_vsi_lan_cfg (vsi->port_info, vsi->idx); err =ice_rm_vsi_rdma_cfg (vsi->port_info, vsi->idx);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 216/343 drm/imx: Fix memory leak in imx_pd_connector_get_modes
In reply to Greg Kroah-HartmanFrom: José Expósito <[email protected]>
[ Upstream commit bce81feb03a20fca7bbdd1c4af16b4e9d5c0e1d3 ]
Avoid leaking the display mode variable if of_get_drm_display_mode fails.
Addresses-Coverity-ID: 1443943 ("Resource leak")
--- drivers/gpu/drm/imx/parallel-display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/parallel-display.c +3 -1
@@ -75,8 +75,10 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector) ret =of_get_drm_display_mode (np, &imxpd->mode, &imxpd->bus_flags,OF_USE_NATIVE_MODE ); -if (ret) +if (ret) { +drm_mode_destroy (connector->dev, mode);return ret; + }drm_mode_copy (mode, &imxpd->mode); mode->type |=DRM_MODE_TYPE_DRIVER |DRM_MODE_TYPE_PREFERRED ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 218/343 regulator: rtq2134: Fix missing active_discharge_on setting
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit 17049bf9de55a42ee96fd34520aff8a484677675 ]
The active_discharge_on setting was missed, so output discharge resistor is always disabled. Fix it.
--- drivers/regulator/rtq2134-regulator.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/rtq2134-regulator.c +1 -0
@@ -285,6 +285,7 @@ static const unsigned int rtq2134_buck_ramp_delay_table[] = { .enable_mask = RTQ2134_VOUTEN_MASK, \ .active_discharge_reg = RTQ2134_REG_BUCK##_id##_CFG0, \ .active_discharge_mask = RTQ2134_ACTDISCHG_MASK, \ + .active_discharge_on = RTQ2134_ACTDISCHG_MASK, \ .ramp_reg = RTQ2134_REG_BUCK##_id##_RSPCFG, \ .ramp_mask = RTQ2134_RSPUP_MASK, \ .ramp_delay_table = rtq2134_buck_ramp_delay_table, \
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 220/343 regulator: atc260x: Fix missing active_discharge_on setting
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit 2316f0fc0ad2aa87a568ceaf3d76be983ee555c3 ]
Without active_discharge_on setting, the SWITCH1 discharge enable control is always disabled. Fix it.
--- drivers/regulator/atc260x-regulator.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/atc260x-regulator.c +1 -0
@@ -292,6 +292,7 @@ enum atc2603c_reg_ids { .bypass_mask = BIT(5), \ .active_discharge_reg = ATC2603C_PMU_SWITCH_CTL, \ .active_discharge_mask = BIT(1), \ + .active_discharge_on = BIT(1), \ .owner = THIS_MODULE, \ }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 221/343 arch/arm64: Fix topology initialization for core scheduling
In reply to Greg Kroah-HartmanFrom: Phil Auld <[email protected]>
[ Upstream commit 5524cbb1bfcdff0cad0aaa9f94e6092002a07259 ]
Arm64 systems rely on store_cpu_topology() to call update_siblings_masks() to transfer the toplogy to the various cpu masks. This needs to be done before the call to notify_cpu_starting() which tells the scheduler about each cpu found, otherwise the core scheduling data structures are setup in a way that does not match the actual topology.
With smt_mask not setup correctly we bail on cpumask_weight(smt_mask) == 1 for !leaders in:
notify_cpu_starting()
cpuhp_invoke_callback_range()
sched_cpu_starting()
sched_core_cpu_starting()
which leads to rq->core not being correctly set for !leader-rq's.
Without this change stress-ng (which enables core scheduling in its prctl tests in newer versions -- i.e. with PR_SCHED_CORE support) causes a warning and then a crash (trimmed for legibility):
[ 1853.805168] ------------[ cut here ]------------ [ 1853.809784] task_rq(b)->core != rq->core [ 1853.809792] WARNING: CPU: 117 PID: 0 at kernel/sched/fair.c:11102 cfs_prio_less+0x1b4/0x1c4 ... [ 1854.015210] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 ... [ 1854.231256] Call trace: [ 1854.233689] pick_next_task+0x3dc/0x81c [ 1854.237512] __schedule+0x10c/0x4cc [ 1854.240988] schedule_idle+0x34/0x54
--- arch/arm64/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/smp.c +1 -1
@@ -234,6 +234,7 @@ asmlinkage notrace void secondary_start_kernel(void)* Log the CPU info before it is marked online and might get read. */ cpuinfo_store_cpu (); +store_cpu_topology (cpu);/* * Enable GIC and timers.
@@ -242,7 +243,6 @@ asmlinkage notrace void secondary_start_kernel(void)ipi_setup (cpu); -store_cpu_topology (cpu);numa_add_cpu (cpu);/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 225/343 sfc: Do not free an empty page_ring
In reply to Greg Kroah-HartmanFrom: Martin Habets <[email protected]>
[ Upstream commit 458f5d92df4807e2a7c803ed928369129996bf96 ]
When the page_ring is not used page_ptr_mask is 0. Do not dereference page_ring[0] in this case.
--- drivers/net/ethernet/sfc/rx_common.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/sfc/rx_common.c +3 -0
@@ -166,6 +166,9 @@ static void efx_fini_rx_recycle_ring(struct efx_rx_queue *rx_queue)struct efx_nic *efx = rx_queue->efx;int i; +if (unlikely (!rx_queue->page_ring)) +return ; +/* Unmap and release the pages in the recycle ring. Remove the ring. */ for (i =0 ; i <= rx_queue->page_ptr_mask; i++) {struct page *page = rx_queue->page_ring[i];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 226/343 RDMA/mlx5: Dont remove cache MRs when a delay is needed
In reply to Greg Kroah-HartmanFrom: Aharon Landau <[email protected]>
[ Upstream commit 84c2362fb65d69c721fec0974556378cbb36a62b ]
Don't remove MRs from the cache if need to delay the removal.
--- drivers/infiniband/hw/mlx5/mr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/mr.c +3 -1
@@ -541,8 +541,10 @@ static void __cache_work_func(struct mlx5_cache_ent *ent)spin_lock_irq (&ent->lock);if (ent->disabled) goto out; -if (need_delay) +if (need_delay) {queue_delayed_work (cache->wq, &ent->dwork,300 *HZ ); + goto out; + }remove_cache_mr_locked (ent);queue_adjust_cache_locked (ent); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 196/343 netfilter: bitwise: fix reduce comparisons
In reply to Greg Kroah-HartmanFrom: Jeremy Sowden <[email protected]>
[ Upstream commit 31818213170caa51d116eb5dc1167b88523b4fe1 ]
The nft_bitwise_reduce and nft_bitwise_fast_reduce functions should compare the bitwise operation in expr with the tracked operation associated with the destination register of expr. However, instead of being called on expr and track->regs[priv->dreg].selector, nft_expr_priv is called on expr twice, so both reduce functions return true even when the operations differ.
--- net/netfilter/nft_bitwise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nft_bitwise.c +2 -2
@@ -287,7 +287,7 @@ static bool nft_bitwise_reduce(struct nft_regs_track *track,if (!track->regs[priv->sreg].selector)return false; - bitwise =nft_expr_priv (expr); + bitwise =nft_expr_priv (track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops == expr->ops &&
@@ -434,7 +434,7 @@ static bool nft_bitwise_fast_reduce(struct nft_regs_track *track,if (!track->regs[priv->sreg].selector)return false; - bitwise =nft_expr_priv (expr); + bitwise =nft_expr_priv (track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector == track->regs[priv->dreg].selector && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops == expr->ops &&
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 197/343 Revert "NFSv4: Handle the special Linux file open access mode"
In reply to Greg Kroah-HartmanFrom: ChenXiaoSong <[email protected]>
[ Upstream commit ab0fc21bc7105b54bafd85bd8b82742f9e68898a ]
This reverts commit 44942b4e457beda00981f616402a1a791e8c616e.
After secondly opening a file with O_ACCMODE|O_DIRECT flags, nfs4_valid_open_stateid() will dereference NULL nfs4_state when lseek().
Reproducer:
1. mount -t nfs -o vers=4.2 $server_ip:/ /mnt/
2. fd = open("/mnt/file", O_ACCMODE|O_DIRECT|O_CREAT)
3. close(fd)
4. fd = open("/mnt/file", O_ACCMODE|O_DIRECT)
5. lseek(fd)
--- fs/nfs/inode.c | 1 - fs/nfs/nfs4file.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
fs/nfs/inode.c +0 -1
@@ -1180,7 +1180,6 @@ int nfs_open(struct inode *inode, struct file *filp)nfs_fscache_open_file (inode, filp);return 0 ; } -EXPORT_SYMBOL_GPL (nfs_open);/* * This function is called whenever some part of NFS notices that
fs/nfs/nfs4file.c +1 -1
@@ -51,7 +51,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)return err;if ((openflags &O_ACCMODE ) ==3 ) -return nfs_open (inode, filp); + openflags--;/* We can't create new files here */ openflags &= ~(O_CREAT |O_EXCL );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 230/343 IB/rdmavt: add lock to call to rvt_error_qp to prevent a race condition
In reply to Greg Kroah-HartmanFrom: Niels Dossche <[email protected]>
[ Upstream commit 4d809f69695d4e7d1378b3a072fa9aef23123018 ]
The documentation of the function rvt_error_qp says both r_lock and s_lock need to be held when calling that function. It also asserts using lockdep that both of those locks are held. However, the commit I referenced in Fixes accidentally makes the call to rvt_error_qp in rvt_ruc_loopback no longer covered by r_lock. This results in the lockdep assertion failing and also possibly in a race condition.
--- drivers/infiniband/sw/rdmavt/qp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rdmavt/qp.c +5 -1
@@ -3190,7 +3190,11 @@ void rvt_ruc_loopback(struct rvt_qp *sqp)spin_lock_irqsave (&sqp->s_lock, flags);rvt_send_complete (sqp, wqe, send_status);if (sqp->ibqp.qp_type ==IB_QPT_RC ) { -int lastwqe =rvt_error_qp (sqp,IB_WC_WR_FLUSH_ERR ); +int lastwqe; + +spin_lock (&sqp->r_lock); + lastwqe =rvt_error_qp (sqp,IB_WC_WR_FLUSH_ERR ); +spin_unlock (&sqp->r_lock); sqp->s_flags &= ~RVT_S_BUSY ;spin_unlock_irqrestore (&sqp->s_lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 231/343 sctp: count singleton chunks in assoc user stats
In reply to Greg Kroah-HartmanFrom: Jamie Bainbridge <[email protected]>
[ Upstream commit e3d37210df5c41c51147a2d5d465de1a4d77be7a ]
Singleton chunks (INIT, HEARTBEAT PMTU probes, and SHUTDOWN- COMPLETE) are not counted in SCTP_GET_ASOC_STATS "sas_octrlchunks" counter available to the assoc owner.
These are all control chunks so they should be counted as such.
Add counting of singleton chunks so they are properly accounted for.
--- net/sctp/outqueue.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sctp/outqueue.c +5 -1
@@ -914,6 +914,7 @@ static void sctp_outq_flush_ctrl(struct sctp_flush_ctx *ctx) ctx->asoc->base.sk->sk_err = -error;return ; } + ctx->asoc->stats.octrlchunks++;break ;case SCTP_CID_ABORT :
@@ -938,7 +939,10 @@ static void sctp_outq_flush_ctrl(struct sctp_flush_ctx *ctx)case SCTP_CID_HEARTBEAT :if (chunk->pmtu_probe) { -sctp_packet_singleton (ctx->transport, chunk, ctx->gfp); + error =sctp_packet_singleton (ctx->transport, + chunk, ctx->gfp); +if (!error) + ctx->asoc->stats.octrlchunks++;break ; } fallthrough;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 200/343 scsi: sr: Fix typo in CDROM(CLOSETRAY|EJECT) handling
In reply to Greg Kroah-HartmanFrom: Kevin Groeneveld <[email protected]>
[ Upstream commit bc5519c18a32ce855bb51b9f5eceb77a9489d080 ]
Commit 2e27f576abc6 ("scsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioctl()") seems to have a typo as it is checking ret instead of cmd in the if statement checking for CDROMCLOSETRAY and CDROMEJECT. This changes the behaviour of these ioctls as the cdrom_ioctl handling of these is more restrictive than the scsi_ioctl version.
--- drivers/scsi/sr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sr.c +1 -1
@@ -578,7 +578,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,scsi_autopm_get_device (sdev); -if (ret !=CDROMCLOSETRAY && ret !=CDROMEJECT ) { +if (cmd !=CDROMCLOSETRAY && cmd !=CDROMEJECT ) { ret =cdrom_ioctl (&cd->cdi, bdev, mode, cmd, arg);if (ret != -ENOSYS ) goto put;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 199/343 scsi: core: scsi_logging: Fix a BUG
In reply to Greg Kroah-HartmanFrom: Tomas Henzl <[email protected]>
[ Upstream commit f06aa52cb2723ec67e92df463827b800d6c477d1 ]
The request_queue may be NULL in a request, for example when it comes from scsi_ioctl_reset(). Check it before use.
--- drivers/scsi/scsi_logging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_logging.c +1 -1
@@ -30,7 +30,7 @@ static inline const char *scmd_name(const struct scsi_cmnd *scmd) {struct request *rq =scsi_cmd_to_rq ((struct scsi_cmnd *)scmd); -if (!rq->q->disk) +if (!rq->q || !rq->q->disk)return NULL ;return rq->q->disk->disk_name; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 201/343 scsi: core: Fix sbitmap depth in scsi_realloc_sdev_budget_map()
In reply to Greg Kroah-HartmanFrom: John Garry <[email protected]>
[ Upstream commit eaba83b5b8506bbc9ee7ca2f10aeab3fff3719e7 ]
In commit edb854a3680b ("scsi: core: Reallocate device's budget map on queue depth change"), the sbitmap for the device budget map may be reallocated after the slave device depth is configured.
When the sbitmap is reallocated we use the result from scsi_device_max_queue_depth() for the sbitmap size, but don't resize to match the actual device queue depth.
Fix by resizing the sbitmap after reallocating the budget sbitmap. We do this instead of init'ing the sbitmap to the device queue depth as the user may want to change the queue depth later via sysfs or other.
--- drivers/scsi/scsi_scan.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/scsi/scsi_scan.c +5 -0
@@ -223,6 +223,8 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,int ret;struct sbitmap sb_backup; + depth = min_t(unsigned int, depth, scsi_device_max_queue_depth(sdev)); +/* * realloc if new shift is calculated, which is caused by setting * up one new default queue depth after calling ->slave_configure
@@ -245,6 +247,9 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,scsi_device_max_queue_depth (sdev), new_shift,GFP_KERNEL , sdev->request_queue->node, false, true); +if (!ret) +sbitmap_resize (&sdev->budget_map, depth); +if (need_free) {if (ret) sdev->budget_map = sb_backup;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 192/343 mm: fix race between MADV_FREE reclaim and blkdev direct IO read
In reply to Greg Kroah-HartmanFrom: Mauricio Faria de Oliveira <[email protected]>
commit 6c8e2a256915a223f6289f651d6b926cd7135c9e upstream.
Problem:
=======
Userspace might read the zero-page instead of actual data from a direct IO read on a block device if the buffers have been called madvise(MADV_FREE) on earlier (this is discussed below) due to a race between page reclaim on MADV_FREE and blkdev direct IO read.
- Race condition:
==============
During page reclaim, the MADV_FREE page check in try_to_unmap_one() checks if the page is not dirty, then discards its rmap PTE(s) (vs. remap back if the page is dirty).
However, after try_to_unmap_one() returns to shrink_page_list(), it might keep the page _anyway_ if page_ref_freeze() fails (it expects exactly _one_ page reference, from the isolation for page reclaim).
Well, blkdev_direct_IO() gets references for all pages, and on READ operations it only sets them dirty _later_.
So, if MADV_FREE'd pages (i.e., not dirty) are used as buffers for direct IO read from block devices, and page reclaim happens during __blkdev_direct_IO[_simple]() exactly AFTER bio_iov_iter_get_pages() returns, but BEFORE the pages are set dirty, the situation happens.
The direct IO read eventually completes. Now, when userspace reads the buffers, the PTE is no longer there and the page fault handler do_anonymous_page() services that with the zero-page, NOT the data!
A synthetic reproducer is provided.
- Page faults:
===========
If page reclaim happens BEFORE bio_iov_iter_get_pages() the issue doesn't happen, because that faults-in all pages as writeable, so do_anonymous_page() sets up a new page/rmap/PTE, and that is used by direct IO. The userspace reads don't fault as the PTE is there (thus zero-page is not used/setup).
But if page reclaim happens AFTER it / BEFORE setting pages dirty, the PTE is no longer there; the subsequent page faults can't help:
The data-read from the block device probably won't generate faults due to DMA (no MMU) but even in the case it wouldn't use DMA, that happens on different virtual addresses (not user-mapped addresses) because struct bio_vec stores struct page to figure addresses out (which are different from user-mapped addresses) for the read.
Thus userspace reads (to user-mapped addresses) still fault, then do_anonymous_page() gets another struct page that would address/ map to other memory than the struct page used by struct bio_vec for the read. (The original struct page is not available, since it wasn't freed, as page_ref_freeze() failed due to more page refs. And even if it were available, its data cannot be trusted anymore.)
Solution:
========
One solution is to check for the expected page reference count in try_to_unmap_one().
There should be one reference from the isolation (that is also checked in shrink_page_list() with page_ref_freeze()) plus one or more references from page mapping(s) (put in discard: label). Further references mean that rmap/PTE cannot be unmapped/nuked.
(Note: there might be more than one reference from mapping due to fork()/clone() without CLONE_VM, which use the same struct page for references, until the copy-on-write page gets copied.)
So, additional page references (e.g., from direct IO read) now prevent the rmap/PTE from being unmapped/dropped; similarly to the page is not freed per shrink_page_list()/page_ref_freeze()).
- Races and Barriers:
==================
The new check in try_to_unmap_one() should be safe in races with bio_iov_iter_get_pages() in get_user_pages() fast and slow paths, as it's done under the PTE lock.
The fast path doesn't take the lock, but it checks if the PTE has changed and if so, it drops the reference and leaves the page for the slow path (which does take that lock).
The fast path requires synchronization w/ full memory barrier: it writes the page reference count first then it reads the PTE later, while try_to_unmap() writes PTE first then it reads page refcount.
And a second barrier is needed, as the page dirty flag should not be read before the page reference count (as in __remove_mapping()). (This can be a load memory barrier only; no writes are involved.)
Call stack/comments:
- try_to_unmap_one()
- page_vma_mapped_walk()
- map_pte() # see pte_offset_map_lock():
pte_offset_map()
spin_lock()
- ptep_get_and_clear() # write PTE
- smp_mb() # (new barrier) GUP fast path
- page_ref_count() # (new check) read refcount
- page_vma_mapped_walk_done() # see pte_unmap_unlock():
pte_unmap()
spin_unlock()- bio_iov_iter_get_pages()
- __bio_iov_iter_get_pages()
- iov_iter_get_pages()
- get_user_pages_fast()
- internal_get_user_pages_fast()
# fast path
- lockless_pages_from_mm()
- gup_{pgd,p4d,pud,pmd,pte}_range()
ptep = pte_offset_map() # not _lock()
pte = ptep_get_lockless(ptep)
page = pte_page(pte)
try_grab_compound_head(page) # inc refcount
# (RMW/barrier # on success)
if (pte_val(pte) != pte_val(*ptep)) # read PTE
put_compound_head(page) # dec refcount
# go slow path
# slow path
- __gup_longterm_unlocked()
- get_user_pages_unlocked()
- __get_user_pages_locked()
- __get_user_pages()
- follow_{page,p4d,pud,pmd}_mask()
- follow_page_pte()
ptep = pte_offset_map_lock() pte = *ptep
page = vm_normal_page(pte)
try_grab_page(page) # inc refcount
pte_unmap_unlock()
- Huge Pages:
==========
Regarding transparent hugepages, that logic shouldn't change, as MADV_FREE (aka lazyfree) pages are PageAnon() && !PageSwapBacked() (madvise_free_pte_range() -> mark_page_lazyfree() -> lru_lazyfree_fn()) thus should reach shrink_page_list() -> split_huge_page_to_list() before try_to_unmap[_one](), so it deals with normal pages only.
(And in case unlikely/TTU_SPLIT_HUGE_PMD/split_huge_pmd_address() happens, which should not or be rare, the page refcount should be greater than
mapcount: the head page is referenced by tail pages. That also prevents checking the head page then incorrectly call page_remove_rmap(subpage) for a tail page, that isn't even in the shrink_page_list()'s page_list (an effect of split huge pmd/pmvw), as it might happen today in this unlikely scenario.)
MADV_FREE'd buffers:
===================
So, back to the "if MADV_FREE pages are used as buffers" note. The case is arguable, and subject to multiple interpretations.
The madvise(2) manual page on the MADV_FREE advice value says:
1) 'After a successful MADV_FREE ... data will be lost when the kernel frees the pages.'
2) 'the free operation will be canceled if the caller writes into the page' / 'subsequent writes ... will succeed and then [the] kernel cannot free those dirtied pages'
3) 'If there is no subsequent write, the kernel can free the pages at any time.'
Thoughts, questions, considerations... respectively:
1) Since the kernel didn't actually free the page (page_ref_freeze() failed), should the data not have been lost? (on userspace read.)
2) Should writes performed by the direct IO read be able to cancel the free operation?
- Should the direct IO read be considered as 'the caller' too, as it's been requested by 'the caller'?
- Should the bio technique to dirty pages on return to userspace (bio_check_pages_dirty() is called/used by __blkdev_direct_IO()) be considered in another/special way here?
3) Should an upcoming write from a previously requested direct IO read be considered as a subsequent write, so the kernel should not free the pages? (as it's known at the time of page reclaim.)
And lastly:
Technically, the last point would seem a reasonable consideration and balance, as the madvise(2) manual page apparently (and fairly) seem to assume that 'writes' are memory access from the userspace process (not explicitly considering writes from the kernel or its corner cases; again, fairly).. plus the kernel fix implementation for the corner case of the largely 'non-atomic write' encompassed by a direct IO read operation, is relatively simple; and it helps.
Reproducer:
==========
@ test.c (simplified, but works)
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
int main() {
int fd, i;
char *buf;
fd = open(DEV, O_RDONLY | O_DIRECT);
buf = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
for (i = 0; i < BUF_SIZE; i += PAGE_SIZE)
buf[i] = 1; // init to non-zero
madvise(buf, BUF_SIZE, MADV_FREE);
read(fd, buf, BUF_SIZE);
for (i = 0; i < BUF_SIZE; i += PAGE_SIZE)
printf("%p: 0x%x\n", &buf[i], buf[i]);
return 0;
}@ block/fops.c (formerly fs/block_dev.c)
+#include <linux/swap.h>
...
... __blkdev_direct_IO[_simple](...)
{
...
+ if (!strcmp(current->comm, "good"))
+ shrink_all_memory(ULONG_MAX);
+
ret = bio_iov_iter_get_pages(...);
+
+ if (!strcmp(current->comm, "bad"))
+ shrink_all_memory(ULONG_MAX);
...
}@ shell
# NUM_PAGES=4
# PAGE_SIZE=$(getconf PAGE_SIZE)
# yes | dd of=test.img bs=${PAGE_SIZE} count=${NUM_PAGES}
# DEV=$(losetup -f --show test.img)
# gcc -DDEV=\"$DEV\" \
-DBUF_SIZE=$((PAGE_SIZE * NUM_PAGES)) \
-DPAGE_SIZE=${PAGE_SIZE} \
test.c -o test
# od -tx1 $DEV
0000000 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a
*
0040000
# mv test good
# ./good
0x7f7c10418000: 0x79
0x7f7c10419000: 0x79
0x7f7c1041a000: 0x79
0x7f7c1041b000: 0x79
# mv good bad
# ./bad
0x7fa1b8050000: 0x0
0x7fa1b8051000: 0x0
0x7fa1b8052000: 0x0
0x7fa1b8053000: 0x0Note: the issue is consistent on v5.17-rc3, but it's intermittent with the support of MADV_FREE on v4.5 (60%-70% error; needs swap). [wrap do_direct_IO() in do_blockdev_direct_IO() @ fs/direct-io.c].
- v5.17-rc3:
# for i in {1..1000}; do ./good; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79 # mv good bad
# for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
4000 0x0 # free | grep Swap
Swap: 0 0 0- v4.5:
# for i in {1..1000}; do ./good; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79 # mv good bad
# for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
2702 0x0
1298 0x79 # swapoff -av
swapoff /swap # for i in {1..1000}; do ./bad; done \
| cut -d: -f2 | sort | uniq -c
4000 0x79Ceph/TCMalloc:
=============
For documentation purposes, the use case driving the analysis/fix is Ceph on Ubuntu 18.04, as the TCMalloc library there still uses MADV_FREE to release unused memory to the system from the mmap'ed page heap (might be committed back/used again; it's not munmap'ed.) - PageHeap::DecommitSpan() -> TCMalloc_SystemRelease() -> madvise() - PageHeap::CommitSpan() -> TCMalloc_SystemCommit() -> do nothing.
Note: TCMalloc switched back to MADV_DONTNEED a few commits after the release in Ubuntu 18.04 (google-perftools/gperftools 2.5), so the issue just 'disappeared' on Ceph on later Ubuntu releases but is still present in the kernel, and can be hit by other use cases.
The observed issue seems to be the old Ceph bug #22464 [1], where checksum mismatches are observed (and instrumentation with buffer dumps shows zero-pages read from mmap'ed/MADV_FREE'd page ranges).
The issue in Ceph was reasonably deemed a kernel bug (comment #50) and mostly worked around with a retry mechanism, but other parts of Ceph could still hit that (rocksdb). Anyway, it's less likely to be hit again as TCMalloc switched out of MADV_FREE by default.
(Some kernel versions/reports from the Ceph bug, and relation with the MADV_FREE introduction/changes; TCMalloc versions not checked.)
- 4.4 good
- 4.5 (madv_free: introduction)
- 4.9 bad
- 4.10 good? maybe a swapless system
- 4.12 (madv_free: no longer free instantly on swapless systems)
- 4.13 bad
[1] https://tracker.ceph.com/issues/22464
Thanks:
======
Several people contributed to analysis/discussions/tests/reproducers in the first stages when drilling down on ceph/tcmalloc/linux kernel:
- Dan Hill
- Dan Streetman
- Dongdong Tao
- Gavin Guo
- Gerald Yang
- Heitor Alves de Siqueira
- Ioanna Alifieraki
- Jay Vosburgh
- Matthew Ruffell
- Ponnuvel Palaniyappan
Reviews, suggestions, corrections, comments:
- Minchan Kim
- Yu Zhao
- Huang, Ying
- John Hubbard
- Christoph Hellwig
[mfo: backport: replace folio/test_flag with page/flag equivalents;
real Fixes: 854e9ed09ded ("mm: support madvise(MADV_FREE)") in v4.]
--- mm/rmap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
mm/rmap.c +24 -1
@@ -1599,7 +1599,30 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,/* MADV_FREE page check */ if (!PageSwapBacked (page)) { -if (!PageDirty (page)) { +int ref_count, map_count; + +/* +* Synchronize with gup_pte_range(): +* - clear PTE; barrier; read refcount +* - inc refcount; barrier; read PTE +*/ +smp_mb (); + + ref_count =page_ref_count (page); + map_count =page_mapcount (page); + +/* +* Order reads for page refcount and dirty flag +* (see comments in __remove_mapping()). +*/ +smp_rmb (); + +/* +* The only page refs must be one from isolation +* plus the rmap(s) (dropped by discard:). +*/ +if (ref_count ==1 + map_count && + !PageDirty (page)) {/* Invalidate as we cleared the pte */ mmu_notifier_invalidate_range (mm, address, address +PAGE_SIZE );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 236/343 ice: synchronize_rcu() when terminating rings
In reply to Greg Kroah-HartmanFrom: Maciej Fijalkowski <[email protected]>
[ Upstream commit f9124c68f05ffdb87a47e3ea6d5fae9dad7cb6eb ]
Unfortunately, the ice driver doesn't respect the RCU critical section that XSK wakeup is surrounded with. To fix this, add synchronize_rcu() calls to paths that destroy resources that might be in use.
This was addressed in other AF_XDP ZC enabled drivers, for reference see for example commit b3873a5be757 ("net/i40e: Fix concurrency issues between config flow and XSK")
--- drivers/net/ethernet/intel/ice/ice.h | 2 +- drivers/net/ethernet/intel/ice/ice_main.c | 4 +++- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -1
@@ -674,7 +674,7 @@ static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev)static inline bool ice_is_xdp_ena_vsi (struct ice_vsi *vsi) { -return !!vsi->xdp_prog; +return !!READ_ONCE (vsi->xdp_prog); }static inline void ice_set_ring_xdp (struct ice_tx_ring *ring)
drivers/net/ethernet/intel/ice/ice_main.c +3 -1
@@ -2742,8 +2742,10 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi)ice_for_each_xdp_txq (vsi, i)if (vsi->xdp_rings[i]) { -if (vsi->xdp_rings[i]->desc) +if (vsi->xdp_rings[i]->desc) { +synchronize_rcu ();ice_free_tx_ring (vsi->xdp_rings[i]); + }kfree_rcu (vsi->xdp_rings[i], rcu); vsi->xdp_rings[i] =NULL ; }
drivers/net/ethernet/intel/ice/ice_xsk.c +3 -1
@@ -41,8 +41,10 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx)static void ice_qp_clean_rings (struct ice_vsi *vsi,u16 q_idx) {ice_clean_tx_ring (vsi->tx_rings[q_idx]); -if (ice_is_xdp_ena_vsi (vsi)) +if (ice_is_xdp_ena_vsi (vsi)) { +synchronize_rcu ();ice_clean_tx_ring (vsi->xdp_rings[q_idx]); + }ice_clean_rx_ring (vsi->rx_rings[q_idx]); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 249/343 bpf: Support dual-stack sockets in bpf_tcp_check_syncookie
In reply to Greg Kroah-HartmanFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit 2e8702cc0cfa1080f29fd64003c00a3e24ac38de ]
bpf_tcp_gen_syncookie looks at the IP version in the IP header and validates the address family of the socket. It supports IPv4 packets in AF_INET6 dual-stack sockets.
On the other hand, bpf_tcp_check_syncookie looks only at the address family of the socket, ignoring the real IP version in headers, and validates only the packet size. This implementation has some drawbacks:
1. Packets are not validated properly, allowing a BPF program to trick bpf_tcp_check_syncookie into handling an IPv6 packet on an IPv4 socket.
2. Dual-stack sockets fail the checks on IPv4 packets. IPv4 clients end up receiving a SYNACK with the cookie, but the following ACK gets dropped.
This patch fixes these issues by changing the checks in bpf_tcp_check_syncookie to match the ones in bpf_tcp_gen_syncookie. IP version from the header is taken into account, and it is validated properly with address family.
--- net/core/filter.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
net/core/filter.c +13 -4
@@ -6777,24 +6777,33 @@ BPF_CALL_5(bpf_tcp_check_syncookie, struct sock *, sk, void *, iph, u32, iph_lenif (!th->ack || th->rst || th->syn)return -ENOENT ; +if (unlikely (iph_len <sizeof (struct iphdr ))) +return -EINVAL ; +if (tcp_synq_no_recent_overflow (sk))return -ENOENT ; cookie =ntohl (th->ack_seq) -1 ; -switch (sk->sk_family) { -case AF_INET : -if (unlikely (iph_len <sizeof (struct iphdr ))) +/* Both struct iphdr and struct ipv6hdr have the version field at the +* same offset so we can cast to the shorter header (struct iphdr). +*/ +switch (((struct iphdr *)iph)->version) { +case 4 : +if (sk->sk_family ==AF_INET6 &&ipv6_only_sock (sk))return -EINVAL ; ret =__cookie_v4_check ((struct iphdr *)iph, th, cookie);break ;#if IS_BUILTIN (CONFIG_IPV6 ) -case AF_INET6 : +case 6 :if (unlikely (iph_len <sizeof (struct ipv6hdr )))return -EINVAL ; +if (sk->sk_family !=AF_INET6 ) +return -EINVAL ; + ret =__cookie_v6_check ((struct ipv6hdr *)iph, th, cookie);break ;#endif /* CONFIG_IPV6 */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 250/343 drbd: Fix five use after free bugs in get_initial_state
In reply to Greg Kroah-HartmanFrom: Lv Yunlong <[email protected]>
[ Upstream commit aadb22ba2f656581b2f733deb3a467c48cc618f6 ]
In get_initial_state, it calls notify_initial_state_done(skb,..) if cb->args[5]==1. If genlmsg_put() failed in notify_initial_state_done(), the skb will be freed by nlmsg_free(skb).
Then get_initial_state will goto out and the freed skb will be used by return value skb->len, which is a uaf bug.
What's worse, the same problem goes even further: skb can also be freed in the notify_*_state_change -> notify_*_state calls below. Thus 4 additional uaf bugs happened.
My patch lets the problem callee functions: notify_initial_state_done and notify_*_state_change return an error code if errors happen. So that the error codes could be propagated and the uaf bugs can be avoid.
v2 reports a compilation warning. This v3 fixed this warning and built successfully in my local environment with no additional warnings.
v2: https://lore.kernel.org/patchwork/patch/1435218/
--- drivers/block/drbd/drbd_int.h | 8 ++--- drivers/block/drbd/drbd_nl.c | 41 ++++++++++++++++---------- drivers/block/drbd/drbd_state.c | 18 +++++------ drivers/block/drbd/drbd_state_change.h | 8 ++--- 4 files changed, 42 insertions(+), 33 deletions(-)
drivers/block/drbd/drbd_int.h +4 -4
@@ -1642,22 +1642,22 @@ struct sib_info { };void drbd_bcast_event (struct drbd_device *device,const struct sib_info *sib); -extern void notify_resource_state (struct sk_buff *, +extern int notify_resource_state (struct sk_buff *,unsigned int ,struct drbd_resource *,struct resource_info *,enum drbd_notification_type ); -extern void notify_device_state (struct sk_buff *, +extern int notify_device_state (struct sk_buff *,unsigned int ,struct drbd_device *,struct device_info *,enum drbd_notification_type ); -extern void notify_connection_state (struct sk_buff *, +extern int notify_connection_state (struct sk_buff *,unsigned int ,struct drbd_connection *,struct connection_info *,enum drbd_notification_type ); -extern void notify_peer_device_state(struct sk_buff *, +extern int notify_peer_device_state(struct sk_buff *, unsigned int, struct drbd_peer_device *, struct peer_device_info *,
drivers/block/drbd/drbd_nl.c +25 -16
156 lines not on this page · raw message
drivers/block/drbd/drbd_state.c +9 -9
@@ -1537,7 +1537,7 @@ int drbd_bitmap_io_from_worker(struct drbd_device *device,return rv; } -void notify_resource_state_change (struct sk_buff *skb, +int notify_resource_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_resource_state_change *resource_state_change,enum drbd_notification_type type)
@@ -1550,10 +1550,10 @@ void notify_resource_state_change(struct sk_buff *skb, .res_susp_fen = resource_state_change->susp_fen[NEW], }; -notify_resource_state (skb, seq, resource, &resource_info, type); +return notify_resource_state (skb, seq, resource, &resource_info, type); } -void notify_connection_state_change (struct sk_buff *skb, +int notify_connection_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_connection_state_change *connection_state_change,enum drbd_notification_type type)
@@ -1564,10 +1564,10 @@ void notify_connection_state_change(struct sk_buff *skb, .conn_role = connection_state_change->peer_role[NEW], }; -notify_connection_state (skb, seq, connection, &connection_info, type); +return notify_connection_state (skb, seq, connection, &connection_info, type); } -void notify_device_state_change (struct sk_buff *skb, +int notify_device_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_device_state_change *device_state_change,enum drbd_notification_type type)
@@ -1577,10 +1577,10 @@ void notify_device_state_change(struct sk_buff *skb, .dev_disk_state = device_state_change->disk_state[NEW], }; -notify_device_state (skb, seq, device, &device_info, type); +return notify_device_state (skb, seq, device, &device_info, type); } -void notify_peer_device_state_change (struct sk_buff *skb, +int notify_peer_device_state_change (struct sk_buff *skb,unsigned int seq,struct drbd_peer_device_state_change *p,enum drbd_notification_type type)
@@ -1594,7 +1594,7 @@ void notify_peer_device_state_change(struct sk_buff *skb, .peer_resync_susp_dependency = p->resync_susp_dependency[NEW], }; -notify_peer_device_state (skb, seq, peer_device, &peer_device_info, type); +return notify_peer_device_state (skb, seq, peer_device, &peer_device_info, type); }static void broadcast_state_change (struct drbd_state_change *state_change)
@@ -1602,7 +1602,7 @@ static void broadcast_state_change(struct drbd_state_change *state_change)struct drbd_resource_state_change *resource_state_change = &state_change->resource[0 ];bool resource_state_has_changed;unsigned int n_device, n_connection, n_peer_device, n_peer_devices; -void (*last_func)(struct sk_buff *,unsigned int ,void *, +int (*last_func)(struct sk_buff *,unsigned int ,void *,enum drbd_notification_type ) =NULL ;void *last_arg =NULL ;
drivers/block/drbd/drbd_state_change.h +4 -4
@@ -44,19 +44,19 @@ extern struct drbd_state_change *remember_old_state(struct drbd_resource *, gfp_extern void copy_old_to_new_state_change (struct drbd_state_change *);extern void forget_state_change (struct drbd_state_change *); -extern void notify_resource_state_change (struct sk_buff *, +extern int notify_resource_state_change (struct sk_buff *,unsigned int ,struct drbd_resource_state_change *,enum drbd_notification_type type); -extern void notify_connection_state_change (struct sk_buff *, +extern int notify_connection_state_change (struct sk_buff *,unsigned int ,struct drbd_connection_state_change *,enum drbd_notification_type type); -extern void notify_device_state_change (struct sk_buff *, +extern int notify_device_state_change (struct sk_buff *,unsigned int ,struct drbd_device_state_change *,enum drbd_notification_type type); -extern void notify_peer_device_state_change (struct sk_buff *, +extern int notify_peer_device_state_change (struct sk_buff *,unsigned int ,struct drbd_peer_device_state_change *,enum drbd_notification_type type);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 251/343 scsi: sd: sd_read_cpr() requires VPD pages
In reply to Greg Kroah-HartmanFrom: Martin K. Petersen <[email protected]>
[ Upstream commit 1700714b1ff252b634db21186db4d91e7e006043 ]
As such it should be called inside the scsi_device_supports_vpd() conditional.
--- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd.c +1 -1
@@ -3320,6 +3320,7 @@ static int sd_revalidate_disk(struct gendisk *disk)sd_read_block_limits (sdkp);sd_read_block_characteristics (sdkp);sd_zbc_read_zones (sdkp, buffer); +sd_read_cpr (sdkp); }sd_print_capacity (sdkp, old_capacity);
@@ -3329,7 +3330,6 @@ static int sd_revalidate_disk(struct gendisk *disk)sd_read_app_tag_own (sdkp, buffer);sd_read_write_same (sdkp, buffer);sd_read_security (sdkp, buffer); -sd_read_cpr (sdkp); }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 252/343 scsi: ufs: ufshpb: Fix a NULL check on list iterator
In reply to Greg Kroah-HartmanFrom: Xiaomeng Tong <[email protected]>
[ Upstream commit bfb7789bcbd901caead43861461bc8f334c90d3b ]
The list iterator is always non-NULL so the check 'if (!rgn)' is always false and the dev_err() is never called. Move the check outside the loop and determine if 'victim_rgn' is NULL, to fix this bug.
--- drivers/scsi/ufs/ufshpb.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/scsi/ufs/ufshpb.c +5 -6
@@ -869,12 +869,6 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)struct ufshpb_region *rgn, *victim_rgn =NULL ;list_for_each_entry (rgn, &lru_info->lh_lru_rgn, list_lru_rgn) { -if (!rgn) { -dev_err (&hpb->sdev_ufs_lu->sdev_dev, -"%s: no region allocated\n" , - __func__); -return NULL ; - }if (ufshpb_check_srgns_issue_state (hpb, rgn))continue ;
@@ -890,6 +884,11 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)break ; } +if (!victim_rgn) +dev_err (&hpb->sdev_ufs_lu->sdev_dev, +"%s: no region allocated\n" , + __func__); +return victim_rgn; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 253/343 io_uring: nospec index for tags on files update
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ Upstream commit 34bb77184123ae401100a4d156584f12fa630e5c ]
Don't forget to array_index_nospec() for indexes before updating rsrc tags in __io_sqe_files_update(), just use already safe and precalculated index @i.
--- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
@@ -8700,7 +8700,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx, err = -EBADF ;break ; } - *io_get_tag_slot (data, up->offset + done) = tag; + *io_get_tag_slot (data, i) = tag;io_fixed_file_set (file_slot, file); err =io_sqe_file_register (ctx, file, i);if (err) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 257/343 SUNRPC: svc_tcp_sendmsg() should handle errors from xdr_alloc_bvec()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit b056fa070814897be32d83b079dbc311375588e7 ]
The allocation is done with GFP_KERNEL, but it could still fail in a low memory situation.
--- net/sunrpc/svcsock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/sunrpc/svcsock.c +3 -1
@@ -1096,7 +1096,9 @@ static int svc_tcp_sendmsg(struct socket *sock, struct xdr_buf *xdr,int ret; *sentp =0 ; -xdr_alloc_bvec (xdr,GFP_KERNEL ); + ret =xdr_alloc_bvec (xdr,GFP_KERNEL ); +if (ret <0 ) +return ret; ret =kernel_sendmsg (sock, &msg, &rm,1 , rm.iov_len);if (ret <0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 258/343 iommu/omap: Fix regression in probe for NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 71ff461c3f41f6465434b9e980c01782763e7ad8 ]
Commit 3f6634d997db ("iommu: Use right way to retrieve iommu_ops") started triggering a NULL pointer dereference for some omap variants:
__iommu_probe_device from probe_iommu_group+0x2c/0x38 probe_iommu_group from bus_for_each_dev+0x74/0xbc bus_for_each_dev from bus_iommu_probe+0x34/0x2e8 bus_iommu_probe from bus_set_iommu+0x80/0xc8 bus_set_iommu from omap_iommu_init+0x88/0xcc omap_iommu_init from do_one_initcall+0x44/0x24
This is caused by omap iommu probe returning 0 instead of ERR_PTR(-ENODEV) as noted by Jason Gunthorpe <[email protected]>.
Looks like the regression already happened with an earlier commit 6785eb9105e3 ("iommu/omap: Convert to probe/release_device() call-backs") that changed the function return type and missed converting one place.
--- drivers/iommu/omap-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/omap-iommu.c +1 -1
@@ -1661,7 +1661,7 @@ static struct iommu_device *omap_iommu_probe_device(struct device *dev) num_iommus =of_property_count_elems_of_size (dev->of_node,"iommus" ,sizeof (phandle));if (num_iommus <0 ) -return 0 ; +return ERR_PTR (-ENODEV ); arch_data =kcalloc (num_iommus +1 ,sizeof (*arch_data),GFP_KERNEL );if (!arch_data)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 262/343 perf session: Remap buf if there is no space for event
In reply to Greg Kroah-HartmanFrom: Denis Nikitin <[email protected]>
[ Upstream commit bc21e74d4775f883ae1f542c1f1dc7205b15d925 ]
If a perf event doesn't fit into remaining buffer space return NULL to remap buf and fetch the event again.
Keep the logic to error out on inadequate input from fuzzing.
This fixes perf failing on ChromeOS (with 32b userspace):
$ perf report -v -i perf.data ... prefetch_event: head=0x1fffff8 event->header_size=0x30, mmap_size=0x2000000: fuzzed or compressed perf.data? Error: failed to process sample
--- tools/perf/util/session.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
tools/perf/util/session.c +12 -3
@@ -2084,6 +2084,7 @@ prefetch_event(char *buf, u64 head, size_t mmap_size, bool needs_swap, union perf_event *error) { union perf_event *event; +u16 event_size;/* * Ensure we have enough space remaining to read
@@ -2096,15 +2097,23 @@ prefetch_event(char *buf, u64 head, size_t mmap_size,if (needs_swap)perf_event_header__bswap (&event->header); -if (head + event->header.size <= mmap_size) + event_size = event->header.size; +if (head + event_size <= mmap_size)return event;/* We're not fetching the event so swap back again */ if (needs_swap)perf_event_header__bswap (&event->header); -pr_debug ("%s: head=%#" PRIx64" event->header_size=%#x, mmap_size=%#zx:" -" fuzzed or compressed perf.data?\n" ,__func__, head, event->header.size, mmap_size); +/* Check if the event fits into the next mmapped buf. */ +if (event_size <= mmap_size - head % page_size) { +/* Remap buf and fetch again. */ +return NULL ; + } + +/* Invalid input. Event size should never exceed mmap_size. */ +pr_debug ("%s: head=%#" PRIx64" event->header.size=%#x, mmap_size=%#zx:" +" fuzzed or compressed perf.data?\n" , __func__, head, event_size, mmap_size);return error; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 239/343 net: openvswitch: dont send internal clone attribute to the userspace.
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
[ Upstream commit 3f2a3050b4a3e7f32fc0ea3c9b0183090ae00522 ]
'OVS_CLONE_ATTR_EXEC' is an internal attribute that is used for performance optimization inside the kernel. It's added by the kernel while parsing user-provided actions and should not be sent during the flow dump as it's not part of the uAPI.
The issue doesn't cause any significant problems to the ovs-vswitchd process, because reported actions are not really used in the application lifecycle and only supposed to be shown to a human via ovs-dpctl flow dump. However, the action list is still incorrect and causes the following error if the user wants to look at the datapath flows:
# ovs-dpctl add-dp system@ovs-system
# ovs-dpctl add-flow "<flow match>" "clone(ct(commit),0)"
# ovs-dpctl dump-flows
<flow match>, packets:0, bytes:0, used:never,
actions:clone(bad length 4, expected -1 for: action0(01 00 00 00),
ct(commit),0)With the fix:
# ovs-dpctl dump-flows
<flow match>, packets:0, bytes:0, used:never,
actions:clone(ct(commit),0)Additionally fixed an incorrect attribute name in the comment.
--- net/openvswitch/actions.c | 2 +- net/openvswitch/flow_netlink.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
net/openvswitch/actions.c +1 -1
@@ -1051,7 +1051,7 @@ static int clone(struct datapath *dp, struct sk_buff *skb,int rem =nla_len (attr);bool dont_clone_flow_key; -/* The first action is always 'OVS_CLONE_ATTR_ARG'. */ +/* The first action is always 'OVS_CLONE_ATTR_EXEC'. */ clone_arg =nla_data (attr); dont_clone_flow_key =nla_get_u32 (clone_arg); actions =nla_next (clone_arg, &rem);
net/openvswitch/flow_netlink.c +3 -1
@@ -3429,7 +3429,9 @@ static int clone_action_to_attr(const struct nlattr *attr,if (!start)return -EMSGSIZE ; - err =ovs_nla_put_actions (nla_data (attr), rem, skb); +/* Skipping the OVS_CLONE_ATTR_EXEC that is always the first attribute. */ + attr =nla_next (nla_data (attr), &rem); + err =ovs_nla_put_actions (attr, rem, skb);if (err)nla_nest_cancel (skb, start);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 240/343 net: ethernet: mv643xx: Fix over zealous checking of_get_mac_address()
In reply to Greg Kroah-HartmanFrom: Andrew Lunn <[email protected]>
[ Upstream commit 11f8e7c122ce013fa745029fa8c94c6db69c2e54 ]
There is often not a MAC address available in an EEPROM accessible by Linux with Marvell devices. Instead the bootload has the MAC address and directly programs it into the hardware. So don't consider an error from of_get_mac_address() has fatal. However, the check was added for the case where there is a MAC address in an the EEPROM, but the EEPROM has not probed yet, and -EPROBE_DEFER is returned. In that case the error should be returned. So make the check specific to this error code.
--- drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +1 -1
@@ -2751,7 +2751,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev, } ret =of_get_mac_address (pnp, ppd.mac_addr); -if (ret) +if (ret == -EPROBE_DEFER )return ret;mv643xx_eth_property (pnp,"tx-queue-size" , ppd.tx_queue_size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 241/343 net: openvswitch: fix leak of nested actions
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
[ Upstream commit 1f30fb9166d4f15a1aa19449b9da871fe0ed4796 ]
While parsing user-provided actions, openvswitch module may dynamically allocate memory and store pointers in the internal copy of the actions. So this memory has to be freed while destroying the actions.
Currently there are only two such actions: ct() and set(). However, there are many actions that can hold nested lists of actions and ovs_nla_free_flow_actions() just jumps over them leaking the memory.
For example, removal of the flow with the following actions will lead to a leak of the memory allocated by nf_ct_tmpl_alloc():
actions:clone(ct(commit),0)
Non-freed set() action may also leak the 'dst' structure for the tunnel info including device references.
Under certain conditions with a high rate of flow rotation that may cause significant memory leak problem (2MB per second in reporter's case). The problem is also hard to mitigate, because the user doesn't have direct control over the datapath flows generated by OVS.
Fix that by iterating over all the nested actions and freeing everything that needs to be freed recursively.
New build time assertion should protect us from this problem if new actions will be added in the future.
Unfortunately, openvswitch module doesn't use NLA_F_NESTED, so all attributes has to be explicitly checked. sample() and clone() actions are mixing extra attributes into the user-provided action list. That prevents some code generalization too.
--- net/openvswitch/flow_netlink.c | 95 ++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 5 deletions(-)
net/openvswitch/flow_netlink.c +90 -5
@@ -2288,6 +2288,62 @@ static struct sw_flow_actions *nla_alloc_flow_actions(int size)return sfa; } +static void ovs_nla_free_nested_actions (const struct nlattr *actions,int len); + +static void ovs_nla_free_check_pkt_len_action (const struct nlattr *action) +{ +const struct nlattr *a; +int rem; + +nla_for_each_nested (a, action, rem) { +switch (nla_type (a)) { +case OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL : +case OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER : +ovs_nla_free_nested_actions (nla_data (a),nla_len (a)); +break ; + } + } +} + +static void ovs_nla_free_clone_action (const struct nlattr *action) +{ +const struct nlattr *a =nla_data (action); +int rem =nla_len (action); + +switch (nla_type (a)) { +case OVS_CLONE_ATTR_EXEC : +/* The real list of actions follows this attribute. */ + a =nla_next (a, &rem); +ovs_nla_free_nested_actions (a, rem); +break ; + } +} + +static void ovs_nla_free_dec_ttl_action (const struct nlattr *action) +{ +const struct nlattr *a =nla_data (action); + +switch (nla_type (a)) { +case OVS_DEC_TTL_ATTR_ACTION : +ovs_nla_free_nested_actions (nla_data (a),nla_len (a)); +break ; + } +} + +static void ovs_nla_free_sample_action (const struct nlattr *action) +{ +const struct nlattr *a =nla_data (action); +int rem =nla_len (action); + +switch (nla_type (a)) { +case OVS_SAMPLE_ATTR_ARG : +/* The real list of actions follows this attribute. */ + a =nla_next (a, &rem); +ovs_nla_free_nested_actions (a, rem); +break ; + } +} +static void ovs_nla_free_set_action (const struct nlattr *a) {const struct nlattr *ovs_key =nla_data (a);
@@ -2301,25 +2357,54 @@ static void ovs_nla_free_set_action(const struct nlattr *a) } } -void ovs_nla_free_flow_actions (struct sw_flow_actions *sf_acts) +static void ovs_nla_free_nested_actions (const struct nlattr *actions,int len) {const struct nlattr *a;int rem; -if (!sf_acts) +/* Whenever new actions are added, the need to update this +* function should be considered. +*/ +BUILD_BUG_ON (OVS_ACTION_ATTR_MAX !=23 ); + +if (!actions)return ; -nla_for_each_attr (a, sf_acts->actions, sf_acts->actions_len, rem) { +nla_for_each_attr (a, actions, len, rem) {switch (nla_type (a)) { -case OVS_ACTION_ATTR_SET : -ovs_nla_free_set_action (a); +case OVS_ACTION_ATTR_CHECK_PKT_LEN : +ovs_nla_free_check_pkt_len_action (a); +break ; + +case OVS_ACTION_ATTR_CLONE : +ovs_nla_free_clone_action (a);break ; +case OVS_ACTION_ATTR_CT :ovs_ct_free_action (a);break ; + +case OVS_ACTION_ATTR_DEC_TTL : +ovs_nla_free_dec_ttl_action (a); +break ; + +case OVS_ACTION_ATTR_SAMPLE : +ovs_nla_free_sample_action (a); +break ; + +case OVS_ACTION_ATTR_SET : +ovs_nla_free_set_action (a); +break ; } } +} + +void ovs_nla_free_flow_actions (struct sw_flow_actions *sf_acts) +{ +if (!sf_acts) +return ; +ovs_nla_free_nested_actions (sf_acts->actions, sf_acts->actions_len);kfree (sf_acts); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 242/343 rxrpc: fix a race in rxrpc_exit_net()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 1946014ca3b19be9e485e780e862c375c6f98bad ]
Current code can lead to the following race:
CPU0 CPU1
rxrpc_exit_net()
rxrpc_peer_keepalive_worker()
if (rxnet->live)rxnet->live = false; del_timer_sync(&rxnet->peer_keepalive_timer);
timer_reduce(&rxnet->peer_keepalive_timer, jiffies + delay);
cancel_work_sync(&rxnet->peer_keepalive_work);
rxrpc_exit_net() exits while peer_keepalive_timer is still armed, leading to use-after-free.
syzbot report was:
ODEBUG: free active (active state 0) object type: timer_list hint: rxrpc_peer_keepalive_timeout+0x0/0xb0
WARNING: CPU: 0 PID: 3660 at lib/debugobjects.c:505 debug_print_object+0x16e/0x250 lib/debugobjects.c:505 Modules linked in: CPU: 0 PID: 3660 Comm: kworker/u4:6 Not tainted 5.17.0-syzkaller-13993-g88e6c0207623 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: netns cleanup_net RIP: 0010:debug_print_object+0x16e/0x250 lib/debugobjects.c:505 Code: ff df 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 af 00 00 00 48 8b 14 dd 00 1c 26 8a 4c 89 ee 48 c7 c7 00 10 26 8a e8 b1 e7 28 05 <0f> 0b 83 05 15 eb c5 09 01 48 83 c4 18 5b 5d 41 5c 41 5d 41 5e c3 RSP: 0018:ffffc9000353fb00 EFLAGS: 00010082 RAX: 0000000000000000 RBX: 0000000000000003 RCX: 0000000000000000 RDX: ffff888029196140 RSI: ffffffff815efad8 RDI: fffff520006a7f52 RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000 R10: ffffffff815ea4ae R11: 0000000000000000 R12: ffffffff89ce23e0 R13: ffffffff8a2614e0 R14: ffffffff816628c0 R15: dffffc0000000000 FS: 0000000000000000(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fe1f2908924 CR3: 0000000043720000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> __debug_check_no_obj_freed lib/debugobjects.c:992 [inline] debug_check_no_obj_freed+0x301/0x420 lib/debugobjects.c:1023 kfree+0xd6/0x310 mm/slab.c:3809 ops_free_list.part.0+0x119/0x370 net/core/net_namespace.c:176 ops_free_list net/core/net_namespace.c:174 [inline] cleanup_net+0x591/0xb00 net/core/net_namespace.c:598 process_one_work+0x996/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e9/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 </TASK>
--- net/rxrpc/net_ns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/net_ns.c +1 -1
@@ -113,8 +113,8 @@ static __net_exit void rxrpc_exit_net(struct net *net)struct rxrpc_net *rxnet =rxrpc_net (net); rxnet->live = false; -del_timer_sync (&rxnet->peer_keepalive_timer);cancel_work_sync (&rxnet->peer_keepalive_work); +del_timer_sync (&rxnet->peer_keepalive_timer);rxrpc_destroy_all_calls (rxnet);rxrpc_destroy_all_connections (rxnet);rxrpc_destroy_all_peers (rxnet);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 243/343 net: sfc: fix using uninitialized xdp tx_queue
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit fb5833d81e4333294add35d3ac7f7f52a7bf107f ]
In some cases, xdp tx_queue can get used before initialization.
1. interface up/down
2. ring buffer size change
When CPU cores are lower than maximum number of channels of sfc driver, it creates new channels only for XDP.
When an interface is up or ring buffer size is changed, all channels are initialized.
But xdp channels are always initialized later.
So, the below scenario is possible.
Packets are received to rx queue of normal channels and it is acted XDP_TX and tx_queue of xdp channels get used.
But these tx_queues are not initialized yet.
If so, TX DMA or queue error occurs.
In order to avoid this problem.
1. initializes xdp tx_queues earlier than other rx_queue in efx_start_channels().
2. checks whether tx_queue is initialized or not in efx_xdp_tx_buffers().
Splat looks like:
sfc 0000:08:00.1 enp8s0f1np1: TX queue 10 spurious TX completion id 250 sfc 0000:08:00.1 enp8s0f1np1: resetting (RECOVER_OR_ALL) sfc 0000:08:00.1 enp8s0f1np1: MC command 0x80 inlen 100 failed rc=-22 (raw=22) arg=789
sfc 0000:08:00.1 enp8s0f1np1: has been disabled
--- drivers/net/ethernet/sfc/efx_channels.c | 2 +- drivers/net/ethernet/sfc/tx.c | 3 +++ drivers/net/ethernet/sfc/tx_common.c | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/sfc/efx_channels.c +1 -1
@@ -1118,7 +1118,7 @@ void efx_start_channels(struct efx_nic *efx)struct efx_rx_queue *rx_queue;struct efx_channel *channel; -efx_for_each_channel (channel, efx) { +efx_for_each_channel_rev (channel, efx) {efx_for_each_channel_tx_queue (tx_queue, channel) {efx_init_tx_queue (tx_queue);atomic_inc (&efx->active_queues);
drivers/net/ethernet/sfc/tx.c +3 -0
@@ -443,6 +443,9 @@ int efx_xdp_tx_buffers(struct efx_nic *efx, int n, struct xdp_frame **xdpfs,if (unlikely (!tx_queue))return -EINVAL ; +if (!tx_queue->initialised) +return -EINVAL ; +if (efx->xdp_txq_queues_mode !=EFX_XDP_TX_QUEUES_DEDICATED )HARD_TX_LOCK (efx->net_dev, tx_queue->core_txq, cpu);
drivers/net/ethernet/sfc/tx_common.c +2 -0
@@ -101,6 +101,8 @@ void efx_fini_tx_queue(struct efx_tx_queue *tx_queue)netif_dbg (tx_queue->efx, drv, tx_queue->efx->net_dev,"shutting down TX queue %d\n" , tx_queue->queue); + tx_queue->initialised = false; +if (!tx_queue->buffer)return ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 268/343 mmc: mmci: stm32: correctly check all elements of sg list
In reply to Greg Kroah-HartmanFrom: Yann Gautier <[email protected]>
commit 0d319dd5a27183b75d984e3dc495248e59f99334 upstream.
Use sg and not data->sg when checking sg list elements. Else only the first element alignment is checked.
The last element should be checked the same way, for_each_sg already set sg to sg_next(sg).
--- drivers/mmc/host/mmci_stm32_sdmmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/mmci_stm32_sdmmc.c +3 -3
@@ -62,8 +62,8 @@ static int sdmmc_idma_validate_data(stru* excepted the last element which has no constraint on idmasize */ for_each_sg (data->sg, sg, data->sg_len -1 , i) { -if (!IS_ALIGNED (data->sg->offset,sizeof (u32)) || - !IS_ALIGNED (data->sg->length,SDMMC_IDMA_BURST )) { +if (!IS_ALIGNED (sg->offset,sizeof (u32)) || + !IS_ALIGNED (sg->length,SDMMC_IDMA_BURST )) {dev_err (mmc_dev (host->mmc),"unaligned scatterlist: ofst:%x length:%d\n" , data->sg->offset, data->sg->length);
@@ -71,7 +71,7 @@ static int sdmmc_idma_validate_data(stru } } -if (!IS_ALIGNED (data->sg->offset,sizeof (u32))) { +if (!IS_ALIGNED (sg->offset,sizeof (u32))) {dev_err (mmc_dev (host->mmc),"unaligned last scatterlist: ofst:%x length:%d\n" , data->sg->offset, data->sg->length);
Greg Kroah-Hartman
maintainerPATCH 271/343 mmc: core: Fixup support for writeback-cache for eMMC and SD
In reply to Greg Kroah-HartmanFrom: Michael Wu <[email protected]>
commit 08ebf903af57cda6d773f3dd1671b64f73b432b8 upstream.
During the card initialization process, the mmc core checks whether the eMMC/SD card supports an internal writeback-cache and then enables it inside the card.
Unfortunately, this isn't according to what the mmc core reports to the upper block layer. Instead, the writeback-cache support with REQ_FLUSH and REQ_FUA, are being enabled depending on whether the host supports the CMD23 (MMC_CAP_CMD23) and whether an eMMC supports the reliable-write command.
This is wrong and it may also sound awkward. In fact, it's a remnant from when both eMMC/SD cards didn't have dedicated commands/support to control the internal writeback-cache. In other words, it was the best we could do at that point in time.
To fix the problem, but also without breaking backwards compatibility, let's align the REQ_FLUSH support with whether the writeback-cache became successfully enabled - for both eMMC and SD cards.
Depends-on: 97fce126e279 ("mmc: block: Issue a cache flush only when it's enabled")
--- drivers/mmc/core/block.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/core/block.c +9 -3
@@ -2382,6 +2382,8 @@ static struct mmc_blk_data *mmc_blk_allostruct mmc_blk_data *md;int devidx, ret;char cap_str[10 ]; +bool cache_enabled = false; +bool fua_enabled = false; devidx =ida_simple_get (&mmc_blk_ida,0 , max_devices,GFP_KERNEL );if (devidx <0 ) {
@@ -2461,13 +2463,17 @@ static struct mmc_blk_data *mmc_blk_allo md->flags |=MMC_BLK_CMD23 ; } -if (mmc_card_mmc (card) && - md->flags &MMC_BLK_CMD23 && +if (md->flags &MMC_BLK_CMD23 && ((card->ext_csd.rel_param &EXT_CSD_WR_REL_PARAM_EN ) || card->ext_csd.rel_sectors)) { md->flags |=MMC_BLK_REL_WR ; -blk_queue_write_cache (md->queue.queue, true, true); + fua_enabled = true; + cache_enabled = true; } +if (mmc_cache_enabled (card->host)) + cache_enabled = true; + +blk_queue_write_cache (md->queue.queue, cache_enabled, fua_enabled);string_get_size ((u64 )size,512 ,STRING_UNITS_2 , cap_str,sizeof (cap_str));
Greg Kroah-Hartman
maintainerPATCH 272/343 lz4: fix LZ4_decompress_safe_partial read out of bound
In reply to Greg Kroah-HartmanFrom: Guo Xuenan <[email protected]>
commit eafc0a02391b7b36617b36c97c4b5d6832cf5e24 upstream.
When partialDecoding, it is EOF if we've either filled the output buffer or can't proceed with reading an offset for following match.
In some extreme corner cases when compressed data is suitably corrupted, UAF will occur. As reported by KASAN [1], LZ4_decompress_safe_partial may lead to read out of bound problem during decoding. lz4 upstream has fixed it [2] and this issue has been disscussed here [3] before.
current decompression routine was ported from lz4 v1.8.3, bumping lib/lz4 to v1.9.+ is certainly a huge work to be done later, so, we'd better fix it first.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://github.com/lz4/lz4/commit/c5d6f8a8be3927c0bec91bcc58667a6cfad244ad#
[3] https://lore.kernel.org/all/[email protected]/
--- lib/lz4/lz4_decompress.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
lib/lz4/lz4_decompress.c +6 -2
@@ -271,8 +271,12 @@ static FORCE_INLINE int LZ4_decompress_g ip += length; op += length; -/* Necessarily EOF, due to parsing restrictions */ -if (!partialDecoding || (cpy == oend)) +/* Necessarily EOF when !partialDecoding. +* When partialDecoding, it is EOF if we've either +* filled the output buffer or +* can't proceed with reading an offset for following match. +*/ +if (!partialDecoding || (cpy == oend) || (ip >= (iend -2 )))break ; }else {/* may overwrite up to WILDCOPYLENGTH beyond cpy */
Greg Kroah-Hartman
maintainerPATCH 276/343 io_uring: dont check req->file in io_fsync_prep()
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit ec858afda857e361182ceafc3d2ba2b164b8e889 upstream.
This is a leftover from the really old days where we weren't able to track and error early if we need a file and it wasn't assigned. Kill the check.
--- fs/io_uring.c | 3 --- 1 file changed, 3 deletions(-)
fs/io_uring.c +0 -3
@@ -4245,9 +4245,6 @@ static int io_fsync_prep(struct io_kiocb {struct io_ring_ctx *ctx = req->ctx; -if (!req->file) -return -EBADF ; -if (unlikely (ctx->flags &IORING_SETUP_IOPOLL ))return -EINVAL ; if (unlikely(sqe->addr || sqe->ioprio || sqe->buf_index ||
Greg Kroah-Hartman
maintainerPATCH 279/343 io_uring: fix race between timeout flush and removal
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit e677edbcabee849bfdd43f1602bccbecf736a646 upstream.
io_flush_timeouts() assumes the timeout isn't in progress of triggering or being removed/canceled, so it unconditionally removes it from the timeout list and attempts to cancel it.
Leave it on the list and let the normal timeout cancelation take care of it.
--- fs/io_uring.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/io_uring.c +3 -4
@@ -1644,12 +1644,11 @@ static __cold void io_flush_timeouts(str __must_hold(&ctx->completion_lock) {u32 seq = ctx->cached_cq_tail -atomic_read (&ctx->cq_timeouts); +struct io_kiocb *req, *tmp;spin_lock_irq (&ctx->timeout_lock); -while (!list_empty (&ctx->timeout_list)) { +list_for_each_entry_safe (req, tmp, &ctx->timeout_list, timeout.list) {u32 events_needed, events_got; -struct io_kiocb *req =list_first_entry (&ctx->timeout_list, - struct io_kiocb, timeout.list);if (io_is_timeout_noseq (req))break ;
@@ -1666,7 +1665,6 @@ static __cold void io_flush_timeouts(strif (events_got < events_needed)break ; -list_del_init (&req->timeout.list);io_kill_timeout (req,0 ); } ctx->cq_last_tm_flush = seq;
@@ -6276,6 +6274,7 @@ static int io_timeout_prep(struct io_kioif (data->ts.tv_sec <0 || data->ts.tv_nsec <0 )return -EINVAL ; +INIT_LIST_HEAD (&req->timeout.list); data->mode =io_translate_timeout_mode (flags);hrtimer_init (&data->timer,io_timeout_get_clock (data), data->mode);
Greg Kroah-Hartman
maintainerPATCH 288/343 spi: core: add dma_map_dev for __spi_unmap_msg()
In reply to Greg Kroah-HartmanFrom: Vinod Koul <[email protected]>
commit 409543cec01a84610029d6440c480c3fdd7214fb upstream.
Commit b470e10eb43f ("spi: core: add dma_map_dev for dma device") added dma_map_dev for _spi_map_msg() but missed to add for unmap routine, __spi_unmap_msg(), so add it now.
--- drivers/spi/spi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/spi/spi.c +4 -0
@@ -1149,11 +1149,15 @@ static int __spi_unmap_msg(struct spi_coif (ctlr->dma_tx) tx_dev = ctlr->dma_tx->device->dev; +else if (ctlr->dma_map_dev) + tx_dev = ctlr->dma_map_dev;else tx_dev = ctlr->dev.parent;if (ctlr->dma_rx) rx_dev = ctlr->dma_rx->device->dev; +else if (ctlr->dma_map_dev) + rx_dev = ctlr->dma_map_dev;else rx_dev = ctlr->dev.parent;
Greg Kroah-Hartman
maintainerPATCH 293/343 drbd: fix an invalid memory access caused by incorrect use of list iterator
In reply to Greg Kroah-HartmanFrom: Xiaomeng Tong <[email protected]>
commit ae4d37b5df749926891583d42a6801b5da11e3c1 upstream.
The bug is here:
idr_remove(&connection->peer_devices, vnr);
If the previous for_each_connection() don't exit early (no goto hit inside the loop), the iterator 'connection' after the loop will be a bogus pointer to an invalid structure object containing the HEAD (&resource->connections). As a result, the use of 'connection' above will lead to a invalid memory access (including a possible invalid free as idr_remove could call free_layer).
The original intention should have been to remove all peer_devices, but the following lines have already done the work. So just remove this line and the unneeded label, to fix this bug.
--- drivers/block/drbd/drbd_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/block/drbd/drbd_main.c +2 -4
@@ -2793,12 +2793,12 @@ enum drbd_ret_code drbd_create_device(stif (init_submitter (device)) { err =ERR_NOMEM ; - goto out_idr_remove_vol; + goto out_idr_remove_from_resource; } err =add_disk (disk);if (err) - goto out_idr_remove_vol; + goto out_idr_remove_from_resource;/* inherit the connection state */ device->state.conn =first_connection (resource)->cstate;
@@ -2812,8 +2812,6 @@ enum drbd_ret_code drbd_create_device(stdrbd_debugfs_device_add (device);return NO_ERROR ; -out_idr_remove_vol: -idr_remove (&connection->peer_devices, vnr); out_idr_remove_from_resource:for_each_connection (connection, resource) { peer_device =idr_remove (&connection->peer_devices, vnr);
Greg Kroah-Hartman
maintainerPATCH 294/343 gpio: Restrict usage of GPIO chip irq members before initialization
In reply to Greg Kroah-HartmanFrom: Shreeya Patel <[email protected]>
commit 5467801f1fcbdc46bc7298a84dbf3ca1ff2a7320 upstream.
GPIO chip irq members are exposed before they could be completely initialized and this leads to race conditions.
One such issue was observed for the gc->irq.domain variable which was accessed through the I2C interface in gpiochip_to_irq() before it could be initialized by gpiochip_add_irqchip(). This resulted in Kernel NULL pointer dereference.
Following are the logs for reference :-
kernel: Call Trace: kernel: gpiod_to_irq+0x53/0x70 kernel: acpi_dev_gpio_irq_get_by+0x113/0x1f0 kernel: i2c_acpi_get_irq+0xc0/0xd0 kernel: i2c_device_probe+0x28a/0x2a0 kernel: really_probe+0xf2/0x460 kernel: RIP: 0010:gpiochip_to_irq+0x47/0xc0
To avoid such scenarios, restrict usage of GPIO chip irq members before they are completely initialized.
--- drivers/gpio/gpiolib.c | 19 +++++++++++++++++++ include/linux/gpio/driver.h | 9 +++++++++ 2 files changed, 28 insertions(+)
drivers/gpio/gpiolib.c +19 -0
@@ -1404,6 +1404,16 @@ static int gpiochip_to_irq(struct gpio_c {struct irq_domain *domain = gc->irq.domain; +#ifdef CONFIG_GPIOLIB_IRQCHIP +/* +* Avoid race condition with other code, which tries to lookup +* an IRQ before the irqchip has been properly registered, +* i.e. while gpiochip is still being brought up. +*/ +if (!gc->irq.initialized) +return -EPROBE_DEFER ; +#endif +if (!gpiochip_irqchip_irq_valid (gc, offset))return -ENXIO ;
@@ -1593,6 +1603,15 @@ static int gpiochip_add_irqchip(struct gacpi_gpiochip_request_interrupts (gc); +/* +* Using barrier() here to prevent compiler from reordering +* gc->irq.initialized before initialization of above +* GPIO chip irq members. +*/ +barrier (); + + gc->irq.initialized = true; +return 0 ; }
include/linux/gpio/driver.h +9 -0
@@ -219,6 +219,15 @@ struct gpio_irq_chip {bool per_parent_data;/** +* @initialized: +* +* Flag to track GPIO chip irq member's initialization. +* This flag will make sure GPIO chip irq members are not used +* before they are initialized. +*/ +bool initialized; + +/** * @init_hw: optional routine to initialize hardware before * an IRQ chip will be added. This is quite useful when * a particular driver wants to clear IRQ related registers
Greg Kroah-Hartman
maintainerPATCH 297/343 perf/x86/intel: Dont extend the pseudo-encoding to GP counters
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit 4a263bf331c512849062805ef1b4ac40301a9829 upstream.
The INST_RETIRED.PREC_DIST event (0x0100) doesn't count on SPR. perf stat -e cpu/event=0xc0,umask=0x0/,cpu/event=0x0,umask=0x1/ -C0
Performance counter stats for 'CPU(s) 0':
607,246 cpu/event=0xc0,umask=0x0/
0 cpu/event=0x0,umask=0x1/The encoding for INST_RETIRED.PREC_DIST is pseudo-encoding, which doesn't work on the generic counters. However, current perf extends its mask to the generic counters.
The pseudo event-code for a fixed counter must be 0x00. Check and avoid extending the mask for the fixed counter event which using the pseudo-encoding, e.g., ref-cycles and PREC_DIST event.
With the patch,
perf stat -e cpu/event=0xc0,umask=0x0/,cpu/event=0x0,umask=0x1/ -C0
Performance counter stats for 'CPU(s) 0':
583,184 cpu/event=0xc0,umask=0x0/
583,048 cpu/event=0x0,umask=0x1/--- arch/x86/events/intel/core.c | 6 +++++- arch/x86/include/asm/perf_event.h | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-)
arch/x86/events/intel/core.c +5 -1
@@ -5515,7 +5515,11 @@ static void intel_pmu_check_event_constr/* Disabled fixed counters which are not in CPUID */ c->idxmsk64 &= intel_ctrl; -if (c->idxmsk64 !=INTEL_PMC_MSK_FIXED_REF_CYCLES ) +/* +* Don't extend the pseudo-encoding to the +* generic counters +*/ +if (!use_fixed_pseudo_encoding (c->code)) c->idxmsk64 |= (1ULL << num_counters) -1 ; } c->idxmsk64 &=
arch/x86/include/asm/perf_event.h +5 -0
@@ -241,6 +241,11 @@ struct x86_pmu_capability {#define INTEL_PMC_IDX_FIXED_SLOTS (INTEL_PMC_IDX_FIXED + 3)#define INTEL_PMC_MSK_FIXED_SLOTS (1ULL << INTEL_PMC_IDX_FIXED_SLOTS) +static inline bool use_fixed_pseudo_encoding (u64 code) +{ +return !(code &0xff ); +} +/* * We model BTS tracing as another fixed-mode PMC. *
Greg Kroah-Hartman
maintainerPATCH 304/343 drm/panel: ili9341: fix optional regulator handling
In reply to Greg Kroah-HartmanFrom: Daniel Mack <[email protected]>
commit d14eb80e27795b7b20060f7b151cdfe39722a813 upstream.
If the optional regulator lookup fails, reset the pointer to NULL. Other functions such as mipi_dbi_poweron_reset_conditional() only do a NULL pointer check and will otherwise dereference the error pointer.
--- drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-ilitek-ili9341.c +3 -1
@@ -612,8 +612,10 @@ static int ili9341_dbi_probe(struct spi_int ret; vcc =devm_regulator_get_optional (dev,"vcc" ); -if (IS_ERR (vcc)) +if (IS_ERR (vcc)) {dev_err (dev,"get optional vcc failed\n" ); + vcc =NULL ; + } dbidev =devm_drm_dev_alloc (dev, &ili9341_dbi_driver, struct mipi_dbi_dev, drm);
Greg Kroah-Hartman
maintainerPATCH 308/343 drm/amdgpu/vcn: Fix the register setting for vcn1
In reply to Greg Kroah-HartmanFrom: Emily Deng <[email protected]>
commit 02fc996d5098f4c3f65bdf6cdb6b28e3f29ba789 upstream.
Correct the code error for setting register UVD_GFX10_ADDR_CONFIG. Need to use inst_idx, or it only will set VCN0.
--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -2
@@ -569,8 +569,8 @@ static void vcn_v3_0_mc_resume_dpg_mode( AMDGPU_GPU_PAGE_ALIGN(sizeof(struct amdgpu_fw_shared)), 0, indirect);/* VCN global tiling registers */ -WREG32_SOC15_DPG_MODE (0 ,SOC15_DPG_MODE_OFFSET ( -UVD ,0 , mmUVD_GFX10_ADDR_CONFIG), adev->gfx.config.gb_addr_config,0 , indirect); +WREG32_SOC15_DPG_MODE (inst_idx,SOC15_DPG_MODE_OFFSET ( +UVD , inst_idx, mmUVD_GFX10_ADDR_CONFIG), adev->gfx.config.gb_addr_config,0 , indirect); }static void vcn_v3_0_disable_static_power_gating (struct amdgpu_device *adev,int inst)
Greg Kroah-Hartman
maintainerPATCH 311/343 drm/amdgpu: dont use BACO for reset in S3
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit ebc002e3ee78409c42156e62e4e27ad1d09c5a75 upstream.
Seems to cause a reboots or hangs on some systems.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +11 -0
@@ -1045,6 +1045,17 @@ bool amdgpu_dpm_is_baco_supported(structif (!pp_funcs || !pp_funcs->get_asic_baco_capability)return false; +/* Don't use baco for reset in S3. +* This is a workaround for some platforms +* where entering BACO during suspend +* seems to cause reboots or hangs. +* This might be related to the fact that BACO controls +* power to the whole GPU including devices like audio and USB. +* Powering down/up everything may adversely affect these other +* devices. Needs more investigation. +*/ +if (adev->in_s3) +return false;if (pp_funcs->get_asic_baco_capability (pp_handle, &baco_cap))return false;
Greg Kroah-Hartman
maintainerPATCH 313/343 Revert "ACPI: processor: idle: Only flush cache on entering C3"
In reply to Greg Kroah-HartmanFrom: Akihiko Odaki <[email protected]>
commit dfbba2518aac4204203b0697a894d3b2f80134d3 upstream.
Revert commit 87ebbb8c612b ("ACPI: processor: idle: Only flush cache on entering C3") that broke the assumptions of the acpi_idle_play_dead() callers.
Namely, the CPU cache must always be flushed in acpi_idle_play_dead(), regardless of the target C-state that is going to be requested, because this is likely to be part of a CPU offline procedure or preparation for entering a system-wide sleep state and the lack of synchronization between the CPU cache and RAM may lead to problems going forward, for example when the CPU is brought back online.
In particular, it breaks resume from suspend-to-RAM on Lenovo ThinkPad C13 which fails occasionally until the problematic commit is reverted.
--- drivers/acpi/processor_idle.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/acpi/processor_idle.c +1 -2
@@ -570,8 +570,7 @@ static int acpi_idle_play_dead(struct cp {struct acpi_processor_cx *cx =per_cpu (acpi_cstate[index], dev->cpu); -if (cx->type ==ACPI_STATE_C3 ) -ACPI_FLUSH_CPU_CACHE (); +ACPI_FLUSH_CPU_CACHE ();while (1 ) {
Greg Kroah-Hartman
maintainerPATCH 314/343 drm/amdkfd: Fix variable set but not used warning
In reply to Greg Kroah-HartmanFrom: Philip Yang <[email protected]>
commit 90c44207cdd18091ac9aa7cab8a3e7b0ef00e847 upstream.
All warnings (new ones prefixed by >>):
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c: In function
'svm_range_deferred_list_work':
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c:2067:22: warning:
variable 'p' set but not used [-Wunused-but-set-variable]
2067 | struct kfd_process *p;
|--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +0 -3
@@ -2066,13 +2066,10 @@ static void svm_range_deferred_list_workstruct svm_range_list *svms;struct svm_range *prange;struct mm_struct *mm; -struct kfd_process *p; svms = container_of(work, struct svm_range_list, deferred_list_work);pr_debug ("enter svms 0x%p\n" , svms); - p = container_of(svms, struct kfd_process, svms); -spin_lock (&svms->deferred_list_lock);while (!list_empty (&svms->deferred_range_list)) { prange = list_first_entry(&svms->deferred_range_list,
Greg Kroah-Hartman
maintainerPATCH 278/343 io_uring: implement compat handling for IORING_REGISTER_IOWQ_AFF
In reply to Greg Kroah-HartmanFrom: Eugene Syromiatnikov <[email protected]>
commit 0f5e4b83b37a96e3643951588ed7176b9b187c0a upstream.
Similarly to the way it is done im mbind syscall.
--- fs/io_uring.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/io_uring.c +9 -1
@@ -10860,7 +10860,15 @@ static __cold int io_register_iowq_aff(sif (len >cpumask_size ()) len =cpumask_size (); -if (copy_from_user (new_mask, arg, len)) { +if (in_compat_syscall ()) { + ret =compat_get_bitmap (cpumask_bits (new_mask), + (const compat_ulong_t __user *)arg, + len *8 /* CHAR_BIT */ ); + }else { + ret =copy_from_user (new_mask, arg, len); + } + +if (ret) {free_cpumask_var (new_mask);return -EFAULT ; }
Greg Kroah-Hartman
maintainerPATCH 287/343 btrfs: prevent subvol with swapfile from being deleted
In reply to Greg Kroah-HartmanFrom: Kaiwen Hu <[email protected]>
commit 60021bd754c6ca0addc6817994f20290a321d8d6 upstream.
A subvolume with an active swapfile must not be deleted otherwise it would not be possible to deactivate it.
After the subvolume is deleted, we cannot swapoff the swapfile in this deleted subvolume because the path is unreachable. The swapfile is still active and holding references, the filesystem cannot be unmounted.
The test looks like this:
mkfs.btrfs -f $dev > /dev/null
mount $dev $mnt
btrfs sub create $mnt/subvol
touch $mnt/subvol/swapfile
chmod 600 $mnt/subvol/swapfile
chattr +C $mnt/subvol/swapfile
dd if=/dev/zero of=$mnt/subvol/swapfile bs=1K count=4096 mkswap $mnt/subvol/swapfile
swapon $mnt/subvol/swapfile
btrfs sub delete $mnt/subvol
swapoff $mnt/subvol/swapfile # failed: No such file or directory swapoff --all
unmount $mnt # target is busy.
To prevent above issue, we simply check that whether the subvolume contains any active swapfile, and stop the deleting process. This behavior is like snapshot ioctl dealing with a swapfile.
--- fs/btrfs/inode.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +23 -1
@@ -4466,6 +4466,13 @@ int btrfs_delete_subvolume(struct inode dest->root_key.objectid);return -EPERM ; } +if (atomic_read (&dest->nr_swapfiles)) { +spin_unlock (&dest->root_item_lock); +btrfs_warn (fs_info, +"attempt to delete subvolume %llu with active swapfile" , + root->root_key.objectid); +return -EPERM ; + } root_flags =btrfs_root_flags (&dest->root_item);btrfs_set_root_flags (&dest->root_item, root_flags |BTRFS_ROOT_SUBVOL_DEAD );
@@ -10424,8 +10431,23 @@ static int btrfs_swap_activate(struct sw* set. We use this counter to prevent snapshots. We must increment it * before walking the extents because we don't want a concurrent * snapshot to run after we've already checked the extents. -*/ +* +* It is possible that subvolume is marked for deletion but still not +* removed yet. To prevent this race, we check the root status before +* activating the swapfile. +*/ +spin_lock (&root->root_item_lock); +if (btrfs_root_dead (root)) { +spin_unlock (&root->root_item_lock); + +btrfs_exclop_finish (fs_info); +btrfs_warn (fs_info, +"cannot activate swapfile because subvolume %llu is being deleted" , + root->root_key.objectid); +return -EPERM ; + }atomic_inc (&root->nr_swapfiles); +spin_unlock (&root->root_item_lock); isize =ALIGN_DOWN (inode->i_size, fs_info->sectorsize);
Greg Kroah-Hartman
maintainerPATCH 305/343 drm/amd/display: Fix by adding FPU protection for dcn30_internal_validate_bw
In reply to Greg Kroah-HartmanFrom: CHANDAN VURDIGERE NATARAJ <[email protected]>
commit ca1198849ab0e7af5efb392ef6baf1138f6fc086 upstream.
[Why]
Below general protection fault observed when WebGL Aquarium is run for longer duration. If drm debug logs are enabled and set to 0x1f then the issue is observed within 10 minutes of run.
[ 100.717056] general protection fault, probably for non-canonical address 0x2d33302d32323032: 0000 [#1] PREEMPT SMP NOPTI [ 100.727921] CPU: 3 PID: 1906 Comm: DrmThread Tainted: G W 5.15.30 #12 d726c6a2d6ebe5cf9223931cbca6892f916fe18b [ 100.754419] RIP: 0010:CalculateSwathWidth+0x1f7/0x44f [ 100.767109] Code: 00 00 00 f2 42 0f 11 04 f0 48 8b 85 88 00 00 00 f2 42 0f 10 04 f0 48 8b 85 98 00 00 00 f2 42 0f 11 04 f0 48 8b 45 10 0f 57 c0 <f3> 42 0f 2a 04 b0 0f 57 c9 f3 43 0f 2a 0c b4 e8 8c e2 f3 ff 48 8b [ 100.781269] RSP: 0018:ffffa9230079eeb0 EFLAGS: 00010246 [ 100.812528] RAX: 2d33302d32323032 RBX: 0000000000000500 RCX: 0000000000000000 [ 100.819656] RDX: 0000000000000001 RSI: ffff99deb712c49c RDI: 0000000000000000 [ 100.826781] RBP: ffffa9230079ef50 R08: ffff99deb712460c R09: ffff99deb712462c [ 100.833907] R10: ffff99deb7124940 R11: ffff99deb7124d70 R12: ffff99deb712ae44 [ 100.841033] R13: 0000000000000001 R14: 0000000000000000 R15: ffffa9230079f0a0 [ 100.848159] FS: 00007af121212640(0000) GS:ffff99deba780000(0000) knlGS:0000000000000000 [ 100.856240] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 100.861980] CR2: 0000209000fe1000 CR3: 000000011b18c000 CR4: 0000000000350ee0 [ 100.869106] Call Trace: [ 100.871555] <TASK> [ 100.873655] ? asm_sysvec_reschedule_ipi+0x12/0x20 [ 100.878449] CalculateSwathAndDETConfiguration+0x1a3/0x6dd [ 100.883937] dml31_ModeSupportAndSystemConfigurationFull+0x2ce4/0x76da [ 100.890467] ? kallsyms_lookup_buildid+0xc8/0x163 [ 100.895173] ? kallsyms_lookup_buildid+0xc8/0x163 [ 100.899874] ? __sprint_symbol+0x80/0x135 [ 100.903883] ? dm_update_plane_state+0x3f9/0x4d2 [ 100.908500] ? symbol_string+0xb7/0xde [ 100.912250] ? number+0x145/0x29b [ 100.915566] ? vsnprintf+0x341/0x5ff [ 100.919141] ? desc_read_finalized_seq+0x39/0x87 [ 100.923755] ? update_load_avg+0x1b9/0x607 [ 100.927849] ? compute_mst_dsc_configs_for_state+0x7d/0xd5b [ 100.933416] ? fetch_pipe_params+0xa4d/0xd0c [ 100.937686] ? dc_fpu_end+0x3d/0xa8 [ 100.941175] dml_get_voltage_level+0x16b/0x180 [ 100.945619] dcn30_internal_validate_bw+0x10e/0x89b [ 100.950495] ? dcn31_validate_bandwidth+0x68/0x1fc [ 100.955285] ? resource_build_scaling_params+0x98b/0xb8c [ 100.960595] ? dcn31_validate_bandwidth+0x68/0x1fc [ 100.965384] dcn31_validate_bandwidth+0x9a/0x1fc [ 100.970001] dc_validate_global_state+0x238/0x295 [ 100.974703] amdgpu_dm_atomic_check+0x9c1/0xbce [ 100.979235] ? _printk+0x59/0x73 [ 100.982467] drm_atomic_check_only+0x403/0x78b [ 100.986912] drm_mode_atomic_ioctl+0x49b/0x546 [ 100.991358] ? drm_ioctl+0x1c1/0x3b3 [ 100.994936] ? drm_atomic_set_property+0x92a/0x92a [ 100.999725] drm_ioctl_kernel+0xdc/0x149 [ 101.003648] drm_ioctl+0x27f/0x3b3 [ 101.007051] ? drm_atomic_set_property+0x92a/0x92a [ 101.011842] amdgpu_drm_ioctl+0x49/0x7d [ 101.015679] __se_sys_ioctl+0x7c/0xb8 [ 101.015685] do_syscall_64+0x5f/0xb8 [ 101.015690] ? __irq_exit_rcu+0x34/0x96
[How]
It calles populate_dml_pipes which uses doubles to initialize. Adding FPU protection avoids context switch and probable loss of vba context as there is potential contention while drm debug logs are enabled.
--- drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c +2 -0
@@ -2025,7 +2025,9 @@ bool dcn31_validate_bandwidth(struct dcBW_VAL_TRACE_COUNT (); +DC_FP_START (); out =dcn30_internal_validate_bw (dc, context, pipes, &pipe_cnt, &vlevel, fast_validate); +DC_FP_END ();// Disable fast_validate to set min dcfclk in alculate_wm_and_dlg if (pipe_cnt ==0 )
Greg Kroah-Hartman
maintainerPATCH 317/343 bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
In reply to Greg Kroah-HartmanFrom: Jakub Sitnicki <[email protected]>
commit 9a69e2b385f443f244a7e8b8bcafe5ccfb0866b4 upstream.
remote_port is another case of a BPF context field documented as a 32-bit value in network byte order for which the BPF context access converter generates a load of a zero-padded 16-bit integer in network byte order.
First such case was dst_port in bpf_sock which got addressed in commit 4421a582718a ("bpf: Make dst_port field in struct bpf_sock 16-bit wide").
Loading 4-bytes from the remote_port offset and converting the value with bpf_ntohl() leads to surprising results, as the expected value is shifted by 16 bits.
Reduce the confusion by splitting the field in two - a 16-bit field holding a big-endian integer, and a 16-bit zero-padding anonymous field that follows it.
--- include/uapi/linux/bpf.h | 3 ++- net/bpf/test_run.c | 4 ++-- net/core/filter.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
include/uapi/linux/bpf.h +2 -1
@@ -6379,7 +6379,8 @@ struct bpf_sk_lookup {__u32 protocol;/* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */ __u32 remote_ip4;/* Network byte order */ __u32 remote_ip6[4 ];/* Network byte order */ -__u32 remote_port;/* Network byte order */ +__be16 remote_port;/* Network byte order */ + __u16 :16 ;/* Zero padding */ __u32 local_ip4;/* Network byte order */ __u32 local_ip6[4 ];/* Network byte order */ __u32 local_port;/* Host byte order */
net/bpf/test_run.c +2 -2
@@ -960,7 +960,7 @@ int bpf_prog_test_run_sk_lookup(struct bif (!range_is_zero (user_ctx,offsetofend (typeof (*user_ctx), local_port),sizeof (*user_ctx))) goto out; -if (user_ctx->local_port >U16_MAX || user_ctx->remote_port >U16_MAX ) { +if (user_ctx->local_port >U16_MAX ) { ret = -ERANGE ; goto out; }
@@ -968,7 +968,7 @@ int bpf_prog_test_run_sk_lookup(struct b ctx.family = (u16 )user_ctx->family; ctx.protocol = (u16 )user_ctx->protocol; ctx.dport = (u16 )user_ctx->local_port; - ctx.sport = (__force __be16 )user_ctx->remote_port; + ctx.sport = user_ctx->remote_port;switch (ctx.family) {case AF_INET :
net/core/filter.c +2 -1
@@ -10621,7 +10621,8 @@ static bool sk_lookup_is_valid_access(in case bpf_ctx_range(struct bpf_sk_lookup, local_ip4): case bpf_ctx_range_till(struct bpf_sk_lookup, remote_ip6[0], remote_ip6[3]): case bpf_ctx_range_till(struct bpf_sk_lookup, local_ip6[0], local_ip6[3]): - case bpf_ctx_range(struct bpf_sk_lookup, remote_port): + case offsetof(struct bpf_sk_lookup, remote_port) ... + offsetof(struct bpf_sk_lookup , local_ip4) -1 : case bpf_ctx_range(struct bpf_sk_lookup, local_port): case bpf_ctx_range(struct bpf_sk_lookup, ingress_ifindex):bpf_ctx_record_field_size (info,sizeof (__u32));
Greg Kroah-Hartman
maintainerPATCH 318/343 selftests/bpf: Fix u8 narrow load checks for bpf_sk_lookup remote_port
In reply to Greg Kroah-HartmanFrom: Jakub Sitnicki <[email protected]>
commit 3c69611b8926f8e74fcf76bd97ae0e5dafbeb26a upstream.
In commit 9a69e2b385f4 ("bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide") ->remote_port field changed from __u32 to __be16.
However, narrow load tests which exercise 1-byte sized loads from offsetof(struct bpf_sk_lookup, remote_port) were not adopted to reflect the change.
As a result, on little-endian we continue testing loads from addresses:
- (__u8 *)&ctx->remote_port + 3
- (__u8 *)&ctx->remote_port + 4
which map to the zero padding following the remote_port field, and don't break the tests because there is no observable change.
While on big-endian, we observe breakage because tests expect to see zeros for values loaded from:
- (__u8 *)&ctx->remote_port - 1
- (__u8 *)&ctx->remote_port - 2
Above addresses map to ->remote_ip6 field, which precedes ->remote_port, and are populated during the bpf_sk_lookup IPv6 tests.
Unsurprisingly, on s390x we observe:
#136/38 sk_lookup/narrow access to ctx v4:OK
#136/39 sk_lookup/narrow access to ctx v6:FAIL
Fix it by removing the checks for 1-byte loads from offsets outside of the ->remote_port field.
--- tools/testing/selftests/bpf/progs/test_sk_lookup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/bpf/progs/test_sk_lookup.c +1 -2
@@ -412,8 +412,7 @@ int ctx_narrow_access(struct bpf_sk_look/* Narrow loads from remote_port field. Expect SRC_PORT. */ if (LSB (ctx->remote_port,0 ) != ((SRC_PORT >>0 ) &0xff ) || -LSB (ctx->remote_port,1 ) != ((SRC_PORT >>8 ) &0xff ) || -LSB (ctx->remote_port,2 ) !=0 ||LSB (ctx->remote_port,3 ) !=0 ) +LSB (ctx->remote_port,1 ) != ((SRC_PORT >>8 ) &0xff ))return SK_DROP ;if (LSW (ctx->remote_port,0 ) !=SRC_PORT )return SK_DROP ;
Greg Kroah-Hartman
maintainerPATCH 321/343 perf python: Fix probing for some clang command line options
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit dd6e1fe91cdd52774ca642d1da75b58a86356b56 upstream.
The clang compiler complains about some options even without a source file being available, while others require one, so use the simple tools/build/feature/test-hello.c file.
Then check for the "is not supported" string in its output, in addition to the "unknown argument" already being looked for.
This was noticed when building with clang-13 where -ffat-lto-objects isn't supported and since we were looking just for "unknown argument" and not providing a source code to clang, was mistakenly assumed as being available and not being filtered to set of command line options provided to clang, leading to a build failure.
--- tools/perf/util/setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/setup.py +4 -2
@@ -1,12 +1,14 @@ -from os import getenv +from os import getenv, path from subprocess import Popen, PIPE from re import sub cc = getenv("CC") cc_is_clang = b"clang version" in Popen([cc.split()[0], "-v"], stderr=PIPE).stderr.readline() +src_feature_tests = getenv('srctree') + '/tools/build/feature' def clang_has_option(option): - return [o for o in Popen([cc, option], stderr=PIPE).stderr.readlines() if b"unknown argument" in o] == [ ] + cc_output = Popen([cc, option, path.join(src_feature_tests, "test-hello.c") ], stderr=PIPE).stderr.readlines() + return [o for o in cc_output if ((b"unknown argument" in o) or (b"is not supported" in o))] == [ ] if cc_is_clang: from distutils.sysconfig import get_config_vars
Greg Kroah-Hartman
maintainerPATCH 327/343 powerpc: Fix virt_addr_valid() for 64-bit Book3E & 32-bit
In reply to Greg Kroah-HartmanFrom: Kefeng Wang <[email protected]>
commit ffa0b64e3be58519ae472ea29a1a1ad681e32f48 upstream.
mpe: On 64-bit Book3E vmalloc space starts at 0x8000000000000000.
Because of the way __pa() works we have:
__pa(0x8000000000000000) == 0, and therefore virt_to_pfn(0x8000000000000000) == 0, and therefore virt_addr_valid(0x8000000000000000) == true
Which is wrong, virt_addr_valid() should be false for vmalloc space. In fact all vmalloc addresses that alias with a valid PFN will return true from virt_addr_valid(). That can cause bugs with hardened usercopy as described below by Kefeng Wang:
When running ethtool eth0 on 64-bit Book3E, a BUG occurred:
usercopy: Kernel memory exposure attempt detected from SLUB object not in SLUB page?! (offset 0, size 1048)!
kernel BUG at mm/usercopy.c:99
...
usercopy_abort+0x64/0xa0 (unreliable)
__check_heap_object+0x168/0x190
__check_object_size+0x1a0/0x200
dev_ethtool+0x2494/0x2b20
dev_ioctl+0x5d0/0x770
sock_do_ioctl+0xf0/0x1d0
sock_ioctl+0x3ec/0x5a0
__se_sys_ioctl+0xf0/0x160
system_call_exception+0xfc/0x1f0
system_call_common+0xf8/0x200The code shows below,
data = vzalloc(array_size(gstrings.len, ETH_GSTRING_LEN)); copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
The data is alloced by vmalloc(), virt_addr_valid(ptr) will return true on 64-bit Book3E, which leads to the panic.
As commit 4dd7554a6456 ("powerpc/64: Add VIRTUAL_BUG_ON checks for __va and __pa addresses") does, make sure the virt addr above PAGE_OFFSET in the virt_addr_valid() for 64-bit, also add upper limit check to make sure the virt is below high_memory.
Meanwhile, for 32-bit PAGE_OFFSET is the virtual address of the start of lowmem, high_memory is the upper low virtual address, the check is suitable for 32-bit, this will fix the issue mentioned in commit 602946ec2f90 ("powerpc: Set max_mapnr correctly") too.
On 32-bit there is a similar problem with high memory, that was fixed in commit 602946ec2f90 ("powerpc: Set max_mapnr correctly"), but that commit breaks highmem and needs to be reverted.
We can't easily fix __pa(), we have code that relies on its current behaviour. So for now add extra checks to virt_addr_valid().
For 64-bit Book3S the extra checks are not necessary, the combination of virt_to_pfn() and pfn_valid() should yield the correct result, but they are harmless.
--- arch/powerpc/include/asm/page.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/page.h +5 -1
@@ -132,7 +132,11 @@ static inline bool pfn_valid(unsigned lo#define virt_to_page (kaddr) pfn_to_page(virt_to_pfn(kaddr))#define pfn_to_kaddr (pfn) __va((pfn) << PAGE_SHIFT) -#define virt_addr_valid (kaddr) pfn_valid(virt_to_pfn(kaddr)) +#define virt_addr_valid (vaddr) ({ \ + unsigned long _addr = (unsigned long)vaddr; \ + _addr >= PAGE_OFFSET && _addr < (unsigned long)high_memory && \ + pfn_valid(virt_to_pfn(_addr)); \ +})/* * On Book-E parts we need __va to parse the device tree and we can't
Greg Kroah-Hartman
maintainerPATCH 326/343 Drivers: hv: vmbus: Replace smp_store_mb() with virt_store_mb()
In reply to Greg Kroah-HartmanFrom: Andrea Parri (Microsoft) <[email protected]>
commit eaa03d34535872d29004cb5cf77dc9dec1ba9a25 upstream.
Following the recommendation in Documentation/memory-barriers.txt for virtual machine guests.
--- drivers/hv/channel_mgmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hv/channel_mgmt.c +3 -3
@@ -380,7 +380,7 @@ void vmbus_channel_map_relid(struct vmbu* execute: * * (a) In the "normal (i.e., not resuming from hibernation)" path, -* the full barrier in smp_store_mb() guarantees that the store +* the full barrier in virt_store_mb() guarantees that the store * is propagated to all CPUs before the add_channel_work work * is queued. In turn, add_channel_work is queued before the * channel's ring buffer is allocated/initialized and the
@@ -392,14 +392,14 @@ void vmbus_channel_map_relid(struct vmbu* recv_int_page before retrieving the channel pointer from the * array of channels. * -* (b) In the "resuming from hibernation" path, the smp_store_mb() +* (b) In the "resuming from hibernation" path, the virt_store_mb() * guarantees that the store is propagated to all CPUs before * the VMBus connection is marked as ready for the resume event * (cf. check_ready_for_resume_event()). The interrupt handler * of the VMBus driver and vmbus_chan_sched() can not run before * vmbus_bus_resume() has completed execution (cf. resume_noirq). */ -smp_store_mb ( +virt_store_mb ( vmbus_connection.channels[channel->offermsg.child_relid], channel); }
Greg Kroah-Hartman
maintainerPATCH 330/343 objtool: Fix SLS validation for kcov tail-call replacement
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 7a53f408902d913cd541b4f8ad7dbcd4961f5b82 upstream.
Since not all compilers have a function attribute to disable KCOV instrumentation, objtool can rewrite KCOV instrumentation in noinstr functions as per commit:
f56dae88a81f ("objtool: Handle __sanitize_cov*() tail calls")
However, this has subtle interaction with the SLS validation from commit:
1cc1e4c8aab4 ("objtool: Add straight-line-speculation validation")
In that when a tail-call instrucion is replaced with a RET an additional INT3 instruction is also written, but is not represented in the decoded instruction stream.
This then leads to false positive missing INT3 objtool warnings in noinstr code.
Instead of adding additional struct instruction objects, mark the RET instruction with retpoline_safe to suppress the warning (since we know there really is an INT3).
--- tools/objtool/check.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/objtool/check.c +11 -0
@@ -1090,6 +1090,17 @@ static void annotate_call_site(struct ob : arch_nop_insn(insn->len)); insn->type = sibling ?INSN_RETURN :INSN_NOP ; + +if (sibling) { +/* +* We've replaced the tail-call JMP insn by two new +* insn: RET; INT3, except we only have a single struct +* insn here. Mark it retpoline_safe to avoid the SLS +* warning, instead of adding another insn. +*/ + insn->retpoline_safe = true; + } +return ; }
Greg Kroah-Hartman
maintainerPATCH 341/343 io_uring: propagate issue_flags state down to file assignment
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 5106dd6e74ab6c94daac1c357094f11e6934b36f upstream.
We'll need this in a future patch, when we could be assigning the file after the prep stage. While at it, get rid of the io_file_get() helper, it just makes the code harder to read.
--- fs/io_uring.c | 82 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 35 deletions(-)
fs/io_uring.c +47 -35
@@ -1128,8 +1128,9 @@ static int __io_register_rsrc_update(strstruct io_uring_rsrc_update2 *up, unsigned nr_args);static void io_clean_op (struct io_kiocb *req); -static struct file *io_file_get (struct io_ring_ctx *ctx, -struct io_kiocb *req,int fd,bool fixed); +static inline struct file *io_file_get_fixed (struct io_kiocb *req,int fd, +unsigned issue_flags); +static inline struct file *io_file_get_normal (struct io_kiocb *req,int fd);static void __io_queue_sqe (struct io_kiocb *req);static void io_rsrc_put_work (struct work_struct *work);
@@ -1258,13 +1259,20 @@ static void io_rsrc_refs_refill(struct i }static inline void io_req_set_rsrc_node (struct io_kiocb *req, -struct io_ring_ctx *ctx) +struct io_ring_ctx *ctx, +unsigned int issue_flags) {if (!req->fixed_rsrc_refs) { req->fixed_rsrc_refs = &ctx->rsrc_node->refs; - ctx->rsrc_cached_refs--; -if (unlikely (ctx->rsrc_cached_refs <0 )) -io_rsrc_refs_refill (ctx); + +if (!(issue_flags &IO_URING_F_UNLOCKED )) { +lockdep_assert_held (&ctx->uring_lock); + ctx->rsrc_cached_refs--; +if (unlikely (ctx->rsrc_cached_refs <0 )) +io_rsrc_refs_refill (ctx); + }else { +percpu_ref_get (req->fixed_rsrc_refs); + } } }
@@ -3122,7 +3130,8 @@ static int __io_import_fixed(struct io_kreturn 0 ; } -static int io_import_fixed (struct io_kiocb *req,int rw,struct iov_iter *iter) +static int io_import_fixed (struct io_kiocb *req,int rw,struct iov_iter *iter, +unsigned int issue_flags) {struct io_mapped_ubuf *imu = req->imu;u16 index, buf_index = req->buf_index;
@@ -3132,7 +3141,7 @@ static int io_import_fixed(struct io_kioif (unlikely (buf_index >= ctx->nr_user_bufs))return -EFAULT ; -io_req_set_rsrc_node (req, ctx); +io_req_set_rsrc_node (req, ctx, issue_flags); index =array_index_nospec (buf_index, ctx->nr_user_bufs); imu =READ_ONCE (ctx->user_bufs[index]); req->imu = imu;
@@ -3288,7 +3297,7 @@ static struct iovec *__io_import_iovec(issize_t ret;if (opcode ==IORING_OP_READ_FIXED || opcode ==IORING_OP_WRITE_FIXED ) { - ret =io_import_fixed (req, rw, iter); + ret =io_import_fixed (req, rw, iter, issue_flags);if (ret)return ERR_PTR (ret);return NULL ;
@@ -4167,8 +4176,10 @@ static int io_tee(struct io_kiocb *req,if (issue_flags &IO_URING_F_NONBLOCK )return -EAGAIN ; - in =io_file_get (req->ctx, req, sp->splice_fd_in, - (sp->flags &SPLICE_F_FD_IN_FIXED )); +if (sp->flags &SPLICE_F_FD_IN_FIXED ) + in =io_file_get_fixed (req, sp->splice_fd_in,IO_URING_F_UNLOCKED ); +else + in =io_file_get_normal (req, sp->splice_fd_in);if (!in) { ret = -EBADF ; goto done;
@@ -4207,8 +4218,10 @@ static int io_splice(struct io_kiocb *reif (issue_flags &IO_URING_F_NONBLOCK )return -EAGAIN ; - in =io_file_get (req->ctx, req, sp->splice_fd_in, - (sp->flags &SPLICE_F_FD_IN_FIXED )); +if (sp->flags &SPLICE_F_FD_IN_FIXED ) + in =io_file_get_fixed (req, sp->splice_fd_in,IO_URING_F_UNLOCKED ); +else + in =io_file_get_normal (req, sp->splice_fd_in);if (!in) { ret = -EBADF ; goto done;
@@ -5513,7 +5526,7 @@ static void io_poll_remove_entries(struc* either spurious wakeup or multishot CQE is served. 0 when it's done with * the request, then the mask is stored in req->result. */ -static int io_poll_check_events (struct io_kiocb *req) +static int io_poll_check_events (struct io_kiocb *req,bool locked) {struct io_ring_ctx *ctx = req->ctx;struct io_poll_iocb *poll =io_poll_get_single (req);
@@ -5569,7 +5582,7 @@ static void io_poll_task_func(struct io_struct io_ring_ctx *ctx = req->ctx;int ret; - ret =io_poll_check_events (req); + ret =io_poll_check_events (req, *locked);if (ret >0 )return ;
@@ -5594,7 +5607,7 @@ static void io_apoll_task_func(struct iostruct io_ring_ctx *ctx = req->ctx;int ret; - ret =io_poll_check_events (req); + ret =io_poll_check_events (req, *locked);if (ret >0 )return ;
@@ -6962,30 +6975,36 @@ static void io_fixed_file_set(struct io_ file_slot->file_ptr = file_ptr; } -static inline struct file *io_file_get_fixed (struct io_ring_ctx *ctx, -struct io_kiocb *req,int fd) +static inline struct file *io_file_get_fixed (struct io_kiocb *req,int fd, +unsigned int issue_flags) { -struct file *file; +struct io_ring_ctx *ctx = req->ctx; +struct file *file =NULL ;unsigned long file_ptr; +if (issue_flags &IO_URING_F_UNLOCKED ) +mutex_lock (&ctx->uring_lock); +if (unlikely ((unsigned int )fd >= ctx->nr_user_files)) -return NULL ; + goto out; fd =array_index_nospec (fd, ctx->nr_user_files); file_ptr =io_fixed_file_slot (&ctx->file_table, fd)->file_ptr; file = (struct file *) (file_ptr &FFS_MASK ); file_ptr &= ~FFS_MASK ;/* mask in overlapping REQ_F and FFS bits */ req->flags |= (file_ptr <<REQ_F_SUPPORT_NOWAIT_BIT ); -io_req_set_rsrc_node (req, ctx); +io_req_set_rsrc_node (req, ctx,0 ); +out: +if (issue_flags &IO_URING_F_UNLOCKED ) +mutex_unlock (&ctx->uring_lock);return file; } -static struct file *io_file_get_normal (struct io_ring_ctx *ctx, -struct io_kiocb *req,int fd) +static struct file *io_file_get_normal (struct io_kiocb *req,int fd) {struct file *file =fget (fd); -trace_io_uring_file_get (ctx, fd); +trace_io_uring_file_get (req->ctx, fd);/* we don't allow fixed io_uring files */ if (file &&unlikely (file->f_op == &io_uring_fops))
@@ -6993,15 +7012,6 @@ static struct file *io_file_get_normal(sreturn file; } -static inline struct file *io_file_get (struct io_ring_ctx *ctx, -struct io_kiocb *req,int fd,bool fixed) -{ -if (fixed) -return io_file_get_fixed (ctx, req, fd); -else -return io_file_get_normal (ctx, req, fd); -} -static void io_req_task_link_timeout (struct io_kiocb *req,bool *locked) {struct io_kiocb *prev = req->timeout.prev;
@@ -7249,8 +7259,10 @@ static int io_init_req(struct io_ring_ctblk_start_plug_nr_ios (&state->plug, state->submit_nr); } - req->file =io_file_get (ctx, req,READ_ONCE (sqe->fd), - (sqe_flags &IOSQE_FIXED_FILE )); +if (req->flags &REQ_F_FIXED_FILE ) + req->file =io_file_get_fixed (req,READ_ONCE (sqe->fd),0 ); +else + req->file =io_file_get_normal (req,READ_ONCE (sqe->fd));if (unlikely (!req->file))return -EBADF ; }
Greg Kroah-Hartman
maintainerPATCH 343/343 io_uring: drop the old style inflight file tracking
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit d5361233e9ab920e135819f73dd8466355f1fddd upstream.
io_uring tracks requests that are referencing an io_uring descriptor to be able to cancel without worrying about loops in the references. Since we now assign the file at execution time, the easier approach is to drop a potentially problematic reference before we punt the request. This eliminates the need to special case these types of files beyond just marking them as such, and simplifies cancelation quite a bit.
This also fixes a recent issue where an async punted tee operation would with the io_uring descriptor as the output file would crash when attempting to get a reference to the file from the io-wq worker. We could have worked around that, but this is the much cleaner fix.
--- fs/io_uring.c | 85 ++++++++++++++++++---------------------------------------- 1 file changed, 27 insertions(+), 58 deletions(-)
fs/io_uring.c +27 -58
@@ -112,8 +112,7 @@ IOSQE_IO_DRAIN | IOSQE_CQE_SKIP_SUCCESS)#define IO_REQ_CLEAN_FLAGS (REQ_F_BUFFER_SELECTED | REQ_F_NEED_CLEANUP | \ - REQ_F_POLLED | REQ_F_INFLIGHT | REQ_F_CREDS | \ - REQ_F_ASYNC_DATA) + REQ_F_POLLED | REQ_F_CREDS | REQ_F_ASYNC_DATA)#define IO_TCTX_REFS_CACHE_NR (1U << 10)
@@ -469,7 +468,6 @@ struct io_uring_task {const struct io_ring_ctx *last;struct io_wq *io_wq;struct percpu_counter inflight; -atomic_t inflight_tracked;atomic_t in_idle;spinlock_t task_lock;
@@ -1131,6 +1129,8 @@ static void io_clean_op(struct io_kiocbstatic inline struct file *io_file_get_fixed (struct io_kiocb *req,int fd,unsigned issue_flags);static inline struct file *io_file_get_normal (struct io_kiocb *req,int fd); +static void io_drop_inflight_file (struct io_kiocb *req); +static bool io_assign_file (struct io_kiocb *req,unsigned int issue_flags);static void __io_queue_sqe (struct io_kiocb *req);static void io_rsrc_put_work (struct work_struct *work);
@@ -1312,29 +1312,9 @@ static bool io_match_task(struct io_kioc bool cancel_all) __must_hold(&req->ctx->timeout_lock) { -struct io_kiocb *req; -if (task && head->task != task)return false; -if (cancel_all) -return true; - -io_for_each_link (req, head) { -if (req->flags &REQ_F_INFLIGHT ) -return true; - } -return false; -} - -static bool io_match_linked (struct io_kiocb *head) -{ -struct io_kiocb *req; - -io_for_each_link (req, head) { -if (req->flags &REQ_F_INFLIGHT ) -return true; - } -return false; +return cancel_all; }/*
@@ -1344,24 +1324,9 @@ static bool io_match_linked(struct io_kistatic bool io_match_task_safe (struct io_kiocb *head,struct task_struct *task,bool cancel_all) { -bool matched; -if (task && head->task != task)return false; -if (cancel_all) -return true; - -if (head->flags &REQ_F_LINK_TIMEOUT ) { -struct io_ring_ctx *ctx = head->ctx; - -/* protect against races with linked timeouts */ -spin_lock_irq (&ctx->timeout_lock); - matched =io_match_linked (head); -spin_unlock_irq (&ctx->timeout_lock); - }else { - matched =io_match_linked (head); - } -return matched; +return cancel_all; }static inline bool req_has_async_data (struct io_kiocb *req)
@@ -1509,14 +1474,6 @@ static inline bool io_req_ffs_set(structreturn req->flags &REQ_F_FIXED_FILE ; } -static inline void io_req_track_inflight (struct io_kiocb *req) -{ -if (!(req->flags &REQ_F_INFLIGHT )) { - req->flags |=REQ_F_INFLIGHT ; -atomic_inc (¤t->io_uring->inflight_tracked); - } -} -static struct io_kiocb *__io_prep_linked_timeout (struct io_kiocb *req) {if (WARN_ON_ONCE (!req->link))
@@ -2380,6 +2337,8 @@ static void io_req_task_work_add(structWARN_ON_ONCE (!tctx); +io_drop_inflight_file (req); +spin_lock_irqsave (&tctx->task_lock, flags);if (priority)wq_list_add_tail (&req->io_task_work.node, &tctx->prior_task_list);
@@ -5548,7 +5507,10 @@ static int io_poll_check_events(struct iif (!req->result) {struct poll_table_struct pt = { ._key = poll->events }; - req->result =vfs_poll (req->file, &pt) & poll->events; +if (unlikely (!io_assign_file (req,IO_URING_F_UNLOCKED ))) + req->result = -EBADF ; +else + req->result =vfs_poll (req->file, &pt) & poll->events; }/* multishot, just fill an CQE and proceed */
@@ -6731,11 +6693,6 @@ static void io_clean_op(struct io_kiocbkfree (req->apoll); req->apoll =NULL ; } -if (req->flags &REQ_F_INFLIGHT ) { -struct io_uring_task *tctx = req->task->io_uring; - -atomic_dec (&tctx->inflight_tracked); - }if (req->flags &REQ_F_CREDS )put_cred (req->creds);if (req->flags &REQ_F_ASYNC_DATA ) {
@@ -7024,6 +6981,19 @@ out:return file; } +/* +* Drop the file for requeue operations. Only used of req->file is the +* io_uring descriptor itself. +*/ +static void io_drop_inflight_file (struct io_kiocb *req) +{ +if (unlikely (req->flags &REQ_F_INFLIGHT )) { +fput (req->file); + req->file =NULL ; + req->flags &= ~REQ_F_INFLIGHT ; + } +} +static struct file *io_file_get_normal (struct io_kiocb *req,int fd) {struct file *file =fget (fd);
@@ -7031,8 +7001,8 @@ static struct file *io_file_get_normal(strace_io_uring_file_get (req->ctx, fd);/* we don't allow fixed io_uring files */ -if (file &&unlikely (file->f_op == &io_uring_fops)) -io_req_track_inflight (req); +if (file && file->f_op == &io_uring_fops) + req->flags |=REQ_F_INFLIGHT ;return file; }
@@ -8804,7 +8774,6 @@ static __cold int io_uring_alloc_task_coxa_init (&tctx->xa);init_waitqueue_head (&tctx->wait);atomic_set (&tctx->in_idle,0 ); -atomic_set (&tctx->inflight_tracked,0 ); task->io_uring = tctx;spin_lock_init (&tctx->task_lock);INIT_WQ_LIST (&tctx->task_list);
@@ -9942,7 +9911,7 @@ static __cold void io_uring_clean_tctx(sstatic s64 tctx_inflight (struct io_uring_task *tctx,bool tracked) {if (tracked) -return atomic_read (&tctx->inflight_tracked); +return 0 ;return percpu_counter_sum (&tctx->inflight); }
Greg Kroah-Hartman
maintainerPATCH 340/343 io_uring: move read/write file prep state into actual opcode handler
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 584b0180f0f4d67d7145950fe68c625f06c88b10 upstream.
In preparation for not necessarily having a file assigned at prep time, defer any initialization associated with the file to when the opcode handler is run.
--- fs/io_uring.c | 119 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 57 deletions(-)
fs/io_uring.c +62 -57
@@ -560,7 +560,8 @@ struct io_rw {/* NOTE: kiocb has the file as the first member, so don't do it here */ struct kiocb kiocb;u64 addr; -u64 len; +u32 len; +u32 flags; };struct io_connect {
@@ -2984,50 +2985,11 @@ static inline bool io_file_supports_nowastatic int io_prep_rw (struct io_kiocb *req,const struct io_uring_sqe *sqe) { -struct io_ring_ctx *ctx = req->ctx;struct kiocb *kiocb = &req->rw.kiocb; -struct file *file = req->file;unsigned ioprio;int ret; -if (!io_req_ffs_set (req)) - req->flags |=io_file_get_flags (file) <<REQ_F_SUPPORT_NOWAIT_BIT ; - kiocb->ki_pos =READ_ONCE (sqe->off); -if (kiocb->ki_pos ==-1 ) { -if (!(file->f_mode &FMODE_STREAM )) { - req->flags |=REQ_F_CUR_POS ; - kiocb->ki_pos = file->f_pos; - }else { - kiocb->ki_pos =0 ; - } - } - kiocb->ki_flags =iocb_flags (file); - ret =kiocb_set_rw_flags (kiocb,READ_ONCE (sqe->rw_flags)); -if (unlikely (ret)) -return ret; - -/* -* If the file is marked O_NONBLOCK, still allow retry for it if it -* supports async. Otherwise it's impossible to use O_NONBLOCK files -* reliably. If not, or it IOCB_NOWAIT is set, don't retry. -*/ -if ((kiocb->ki_flags &IOCB_NOWAIT ) || - ((file->f_flags &O_NONBLOCK ) && !io_file_supports_nowait (req))) - req->flags |=REQ_F_NOWAIT ; - -if (ctx->flags &IORING_SETUP_IOPOLL ) { -if (!(kiocb->ki_flags &IOCB_DIRECT ) || !file->f_op->iopoll) -return -EOPNOTSUPP ; - - kiocb->ki_flags |=IOCB_HIPRI |IOCB_ALLOC_CACHE ; - kiocb->ki_complete = io_complete_rw_iopoll; - req->iopoll_completed =0 ; - }else { -if (kiocb->ki_flags &IOCB_HIPRI ) -return -EINVAL ; - kiocb->ki_complete = io_complete_rw; - } ioprio =READ_ONCE (sqe->ioprio);if (ioprio) {
@@ -3043,6 +3005,7 @@ static int io_prep_rw(struct io_kiocb *r req->imu =NULL ; req->rw.addr =READ_ONCE (sqe->addr); req->rw.len =READ_ONCE (sqe->len); + req->rw.flags =READ_ONCE (sqe->rw_flags); req->buf_index =READ_ONCE (sqe->buf_index);return 0 ; }
@@ -3523,13 +3486,6 @@ static inline int io_rw_prep_async(strucreturn 0 ; } -static int io_read_prep (struct io_kiocb *req,const struct io_uring_sqe *sqe) -{ -if (unlikely (!(req->file->f_mode &FMODE_READ ))) -return -EBADF ; -return io_prep_rw (req, sqe); -} -/* * This is our waitqueue callback handler, registered through __folio_lock_async() * when we initially tried to do the IO with the iocb armed our waitqueue.
@@ -3617,6 +3573,58 @@ static bool need_read_all(struct io_kiocS_ISBLK (file_inode (req->file)->i_mode); } +static int io_rw_init_file (struct io_kiocb *req,fmode_t mode) +{ +struct kiocb *kiocb = &req->rw.kiocb; +struct io_ring_ctx *ctx = req->ctx; +struct file *file = req->file; +int ret; + +if (unlikely (!file || !(file->f_mode & mode))) +return -EBADF ; + +if (!io_req_ffs_set (req)) + req->flags |=io_file_get_flags (file) <<REQ_F_SUPPORT_NOWAIT_BIT ; + +if (kiocb->ki_pos ==-1 ) { +if (!(file->f_mode &FMODE_STREAM )) { + req->flags |=REQ_F_CUR_POS ; + kiocb->ki_pos = file->f_pos; + }else { + kiocb->ki_pos =0 ; + } + } + + kiocb->ki_flags =iocb_flags (file); + ret =kiocb_set_rw_flags (kiocb, req->rw.flags); +if (unlikely (ret)) +return ret; + +/* +* If the file is marked O_NONBLOCK, still allow retry for it if it +* supports async. Otherwise it's impossible to use O_NONBLOCK files +* reliably. If not, or it IOCB_NOWAIT is set, don't retry. +*/ +if ((kiocb->ki_flags &IOCB_NOWAIT ) || + ((file->f_flags &O_NONBLOCK ) && !io_file_supports_nowait (req))) + req->flags |=REQ_F_NOWAIT ; + +if (ctx->flags &IORING_SETUP_IOPOLL ) { +if (!(kiocb->ki_flags &IOCB_DIRECT ) || !file->f_op->iopoll) +return -EOPNOTSUPP ; + + kiocb->ki_flags |=IOCB_HIPRI |IOCB_ALLOC_CACHE ; + kiocb->ki_complete = io_complete_rw_iopoll; + req->iopoll_completed =0 ; + }else { +if (kiocb->ki_flags &IOCB_HIPRI ) +return -EINVAL ; + kiocb->ki_complete = io_complete_rw; + } + +return 0 ; +} +static int io_read (struct io_kiocb *req,unsigned int issue_flags) {struct io_rw_state __s, *s = &__s;
@@ -3641,6 +3649,9 @@ static int io_read(struct io_kiocb *req,iov_iter_restore (&s->iter, &s->iter_state); iovec =NULL ; } + ret =io_rw_init_file (req,FMODE_READ ); +if (unlikely (ret)) +return ret; req->result =iov_iter_count (&s->iter);if (force_nonblock) {
@@ -3739,14 +3750,6 @@ out_free:return 0 ; } -static int io_write_prep (struct io_kiocb *req,const struct io_uring_sqe *sqe) -{ -if (unlikely (!(req->file->f_mode &FMODE_WRITE ))) -return -EBADF ; - req->rw.kiocb.ki_hint =ki_hint_validate (file_write_hint (req->file)); -return io_prep_rw (req, sqe); -} -static int io_write (struct io_kiocb *req,unsigned int issue_flags) {struct io_rw_state __s, *s = &__s;
@@ -3766,6 +3769,9 @@ static int io_write(struct io_kiocb *reqiov_iter_restore (&s->iter, &s->iter_state); iovec =NULL ; } + ret =io_rw_init_file (req,FMODE_WRITE ); +if (unlikely (ret)) +return ret; req->result =iov_iter_count (&s->iter);if (force_nonblock) {
@@ -6501,11 +6507,10 @@ static int io_req_prep(struct io_kiocb *case IORING_OP_READV :case IORING_OP_READ_FIXED :case IORING_OP_READ : -return io_read_prep (req, sqe);case IORING_OP_WRITEV :case IORING_OP_WRITE_FIXED :case IORING_OP_WRITE : -return io_write_prep (req, sqe); +return io_prep_rw (req, sqe);case IORING_OP_POLL_ADD :return io_poll_add_prep (req, sqe);case IORING_OP_POLL_REMOVE :
Greg Kroah-Hartman
maintainerPATCH 324/343 dmaengine: Revert "dmaengine: shdma: Fix runtime PM imbalance on error"
In reply to Greg Kroah-HartmanFrom: Vinod Koul <[email protected]>
commit d143f939a95696d38ff800ada14402fa50ebbd6c upstream.
This reverts commit 455896c53d5b ("dmaengine: shdma: Fix runtime PM imbalance on error") as the patch wrongly reduced the count on error and did not bail out. So drop the count by reverting the patch .
--- drivers/dma/sh/shdma-base.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/dma/sh/shdma-base.c +1 -3
@@ -115,10 +115,8 @@ static dma_cookie_t shdma_tx_submit(stru ret =pm_runtime_get (schan->dev);spin_unlock_irq (&schan->chan_lock); -if (ret <0 ) { +if (ret <0 )dev_err (schan->dev,"%s(): GET = %d\n" , __func__, ret); -pm_runtime_put (schan->dev); - }pm_runtime_barrier (schan->dev);
Greg Kroah-Hartman
maintainerPATCH 329/343 x86/bug: Prevent shadowing in __WARN_FLAGS
In reply to Greg Kroah-HartmanFrom: Vincent Mailhol <[email protected]>
commit 9ce02f0fc68326dd1f87a0a3a4c6ae7fdd39e6f6 upstream.
The macro __WARN_FLAGS() uses a local variable named "f". This being a common name, there is a risk of shadowing other variables.
For example, GCC would yield:
| In file included from ./include/linux/bug.h:5, | from ./include/linux/cpumask.h:14, | from ./arch/x86/include/asm/cpumask.h:5, | from ./arch/x86/include/asm/msr.h:11, | from ./arch/x86/include/asm/processor.h:22, | from ./arch/x86/include/asm/timex.h:5, | from ./include/linux/timex.h:65, | from ./include/linux/time32.h:13, | from ./include/linux/time.h:60, | from ./include/linux/stat.h:19, | from ./include/linux/module.h:13, | from virt/lib/irqbypass.mod.c:1: | ./include/linux/rcupdate.h: In function 'rcu_head_after_call_rcu': | ./arch/x86/include/asm/bug.h:80:21: warning: declaration of 'f' shadows a parameter [-Wshadow] | 80 | __auto_type f = BUGFLAG_WARNING|(flags); \ | | ^ | ./include/asm-generic/bug.h:106:17: note: in expansion of macro '__WARN_FLAGS' | 106 | __WARN_FLAGS(BUGFLAG_ONCE | \ | | ^~~~~~~~~~~~ | ./include/linux/rcupdate.h:1007:9: note: in expansion of macro 'WARN_ON_ONCE' | 1007 | WARN_ON_ONCE(func != (rcu_callback_t)~0L); | | ^~~~~~~~~~~~ | In file included from ./include/linux/rbtree.h:24, | from ./include/linux/mm_types.h:11, | from ./include/linux/buildid.h:5, | from ./include/linux/module.h:14, | from virt/lib/irqbypass.mod.c:1: | ./include/linux/rcupdate.h:1001:62: note: shadowed declaration is here | 1001 | rcu_head_after_call_rcu(struct rcu_head *rhp, rcu_callback_t f) | | ~~~~~~~~~~~~~~~^
For reference, sparse also warns about it, c.f. [1].
This patch renames the variable from f to __flags (with two underscore prefixes as suggested in the Linux kernel coding style [2]) in order to prevent collisions.
[1] https://lore.kernel.org/all/CAFGhKbyifH1a+nAMCvWM88TK6fpNPdzFtUXPmRGnnQeePV+1sw@mail.gmail.com/
[2] Linux kernel coding style, section 12) Macros, Enums and RTL, paragraph 5) namespace collisions when defining local variables in macros resembling functions
https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl
--- arch/x86/include/asm/bug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/bug.h +2 -2
@@ -77,9 +77,9 @@ do { \*/ #define __WARN_FLAGS (flags) \ do { \ - __auto_type f = BUGFLAG_WARNING|(flags); \ + __auto_type __flags = BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, f, ASM_REACHABLE); \ + _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ instrumentation_end(); \ } while (0)
Greg Kroah-Hartman
maintainerPATCH 338/343 mm/sparsemem: fix mem_section will never be NULL gcc 12 warning
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
commit a431dbbc540532b7465eae4fc8b56a85a9fc7d17 upstream.
The gcc 12 compiler reports a "'mem_section' will never be NULL" warning on the following code:
static inline struct mem_section *__nr_to_section(unsigned long nr)
{
#ifdef CONFIG_SPARSEMEM_EXTREME
if (!mem_section)
return NULL;
#endif
if (!mem_section[SECTION_NR_TO_ROOT(nr)])
return NULL;
:It happens with CONFIG_SPARSEMEM_EXTREME off. The mem_section definition is
#ifdef CONFIG_SPARSEMEM_EXTREME
extern struct mem_section **mem_section;
#else
extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT];
#endifIn the !CONFIG_SPARSEMEM_EXTREME case, mem_section is a static 2-dimensional array and so the check "!mem_section[SECTION_NR_TO_ROOT(nr)]" doesn't make sense.
Fix this warning by moving the "!mem_section[SECTION_NR_TO_ROOT(nr)]" check up inside the CONFIG_SPARSEMEM_EXTREME block and adding an explicit NR_SECTION_ROOTS check to make sure that there is no out-of-bound array access.
--- include/linux/mmzone.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
include/linux/mmzone.h +7 -4
@@ -1389,13 +1389,16 @@ static inline unsigned long *section_to_static inline struct mem_section *__nr_to_section (unsigned long nr) { +unsigned long root =SECTION_NR_TO_ROOT (nr); + +if (unlikely (root >=NR_SECTION_ROOTS )) +return NULL ; +#ifdef CONFIG_SPARSEMEM_EXTREME -if (!mem_section) +if (!mem_section || !mem_section[root])return NULL ;#endif -if (!mem_section[SECTION_NR_TO_ROOT (nr)]) -return NULL ; -return &mem_section[SECTION_NR_TO_ROOT (nr)][nr &SECTION_ROOT_MASK ]; +return &mem_section[root][nr &SECTION_ROOT_MASK ]; }extern size_t mem_section_usage_size (void );
Greg Kroah-Hartman
maintainerPATCH 339/343 static_call: Dont make __static_call_return0 static
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 8fd4ddda2f49a66bf5dd3d0c01966c4b1971308b upstream.
System.map shows that vmlinux contains several instances of __static_call_return0():
c0004fc0 t __static_call_return0 c0011518 t __static_call_return0 c00d8160 t __static_call_return0
arch_static_call_transform() uses the middle one to check whether we are setting a call to __static_call_return0 or not:
c0011520 <arch_static_call_transform>: c0011520: 3d 20 c0 01 lis r9,-16383 <== r9 = 0xc001 << 16 c0011524: 39 29 15 18 addi r9,r9,5400 <== r9 += 0x1518 c0011528: 7c 05 48 00 cmpw r5,r9 <== r9 has value 0xc0011518 here
So if static_call_update() is called with one of the other instances of __static_call_return0(), arch_static_call_transform() won't recognise it.
In order to work properly, global single instance of __static_call_return0() is required.
--- include/linux/static_call.h | 5 kernel/Makefile | 3 kernel/static_call.c | 542 ------------------------------------------- kernel/static_call_inline.c | 543 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 547 insertions(+), 546 deletions(-) create mode 100644 kernel/static_call_inline.c
include/linux/static_call.h +1 -4
@@ -248,10 +248,7 @@ static inline int static_call_text_reserreturn 0 ; } -static inline long __static_call_return0 (void ) -{ -return 0 ; -} +extern long __static_call_return0 (void );#define EXPORT_STATIC_CALL (name) \ EXPORT_SYMBOL(STATIC_CALL_KEY(name)); \
kernel/Makefile +2 -1
@@ -113,7 +113,8 @@ obj-$(CONFIG_CPU_PM) += cpu_pm.o obj-$(CONFIG_BPF) += bpf/ obj-$(CONFIG_KCSAN) += kcsan/ obj-$(CONFIG_SHADOW_CALL_STACK) += scs.o -obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) += static_call.o +obj-$(CONFIG_HAVE_STATIC_CALL) += static_call.o +obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) += static_call_inline.o obj-$(CONFIG_CFI_CLANG) += cfi.o obj-$(CONFIG_PERF_EVENTS) += events/
kernel/static_call.c +1 -541
549 lines not on this page · raw message
kernel/static_call_inline.c new file +543 -0
543 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 323/343 tools build: Use $(shell ) instead of `` to get embedded libperls ccopts
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit 541f695cbcb6932c22638b06e0cbe1d56177e2e9 upstream.
Just like its done for ldopts and for both in tools/perf/Makefile.config.
Using `` to initialize PERL_EMBED_CCOPTS somehow precludes using:
$(filter-out SOMETHING_TO_FILTER,$(PERL_EMBED_CCOPTS))
And we need to do it to allow for building with versions of clang where some gcc options selected by distros are not available.
--- tools/build/feature/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/feature/Makefile +1 -1
@@ -217,7 +217,7 @@ strip-libs = $(filter-out -l%,$(1)) PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) -PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` +PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifeq ($(CC_NO_CLANG), 0)
Greg Kroah-Hartman
maintainerPATCH 325/343 KVM: avoid NULL pointer dereference in kvm_dirty_ring_push
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 5593473a1e6c743764b08e3b6071cb43b5cfa6c4 upstream.
kvm_vcpu_release() will call kvm_dirty_ring_free(), freeing ring->dirty_gfns and setting it to NULL. Afterwards, it calls kvm_arch_vcpu_destroy().
However, if closing the file descriptor races with KVM_RUN in such away that vcpu->arch.st.preempted == 0, the following call stack leads to a NULL pointer dereference in kvm_dirty_run_push():
mark_page_dirty_in_slot+0x192/0x270 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3171 kvm_steal_time_set_preempted arch/x86/kvm/x86.c:4600 [inline] kvm_arch_vcpu_put+0x34e/0x5b0 arch/x86/kvm/x86.c:4618 vcpu_put+0x1b/0x70 arch/x86/kvm/../../../virt/kvm/kvm_main.c:211 vmx_free_vcpu+0xcb/0x130 arch/x86/kvm/vmx/vmx.c:6985 kvm_arch_vcpu_destroy+0x76/0x290 arch/x86/kvm/x86.c:11219 kvm_vcpu_destroy arch/x86/kvm/../../../virt/kvm/kvm_main.c:441 [inline]
The fix is to release the dirty page ring after kvm_arch_vcpu_destroy has run.
--- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
@@ -439,8 +439,8 @@ static void kvm_vcpu_init(struct kvm_vcpstatic void kvm_vcpu_destroy (struct kvm_vcpu *vcpu) { -kvm_dirty_ring_free (&vcpu->dirty_ring);kvm_arch_vcpu_destroy (vcpu); +kvm_dirty_ring_free (&vcpu->dirty_ring);/* * No need for rcu_read_lock as VCPU_RUN is the only place that changes
Greg Kroah-Hartman
maintainerPATCH 328/343 Revert "powerpc: Set max_mapnr correctly"
In reply to Greg Kroah-HartmanFrom: Kefeng Wang <[email protected]>
commit 1ff5c8e8c835e8a81c0868e3050c76563dd56a2c upstream.
This reverts commit 602946ec2f90d5bd965857753880db29d2d9a1e9.
If CONFIG_HIGHMEM is enabled, no highmem will be added with max_mapnr set to max_low_pfn, see mem_init():
for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
...
free_highmem_page();
}Now that virt_addr_valid() has been fixed in the previous commit, we can revert the change to max_mapnr.
--- arch/powerpc/mm/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/mem.c +1 -1
@@ -255,7 +255,7 @@ void __init mem_init(void)#endif high_memory = (void *)__va (max_low_pfn *PAGE_SIZE ); -set_max_mapnr (max_low_pfn); +set_max_mapnr (max_pfn);kasan_late_init ();
Greg Kroah-Hartman
maintainerPATCH 333/343 x86,static_call: Fix __static_call_return0 for i386
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 1cd5f059d956e6f614ba6666ecdbcf95db05d5f5 upstream.
Paolo reported that the instruction sequence that is used to replace:
call __static_call_return0
namely:
66 66 48 31 c0 data16 data16 xor %rax,%rax
decodes to something else on i386, namely:
66 66 48 data16 dec %ax
31 c0 xor %eax,%eaxWhich is a nonsensical sequence that happens to have the same outcome. *However* an important distinction is that it consists of 2 instructions which is a problem when the thing needs to be overwriten with a regular call instruction again.
As such, replace the instruction with something that decodes the same on both i386 and x86_64.
--- arch/x86/kernel/static_call.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/static_call.c +2 -3
@@ -12,10 +12,9 @@ enum insn_type { };/* -* data16 data16 xorq %rax, %rax - a single 5 byte instruction that clears %rax -* The REX.W cancels the effect of any data16. +* cs cs cs xorl %eax, %eax - a single 5 byte instruction that clears %[er]ax */ -static const u8 xor5rax[] = {0x66 ,0x66 ,0x48 ,0x31 ,0xc0 }; +static const u8 xor5rax[] = {0x2e ,0x2e ,0x2e ,0x31 ,0xc0 };static const u8 retinsn[] = {RET_INSN_OPCODE ,0xcc ,0xcc ,0xcc ,0xcc };
Greg Kroah-Hartman
maintainerPATCH 334/343 x86/extable: Prefer local labels in .set directives
In reply to Greg Kroah-HartmanFrom: Nick Desaulniers <[email protected]>
commit 334865b2915c33080624e0d06f1c3e917036472c upstream.
Bernardo reported an error that Nathan bisected down to (x86_64) defconfig+LTO_CLANG_FULL+X86_PMEM_LEGACY.
LTO vmlinux.o
ld.lld: error: <instantiation>:1:13: redefinition of 'found' .set found, 0
^
<inline asm>:29:1: while in macro instantiation extable_type_reg reg=%eax, type=(17 | ((0) << 16)) ^
This appears to be another LTO specific issue similar to what was folded into commit 4b5305decc84 ("x86/extable: Extend extable functionality"), where the .set found, 0 in DEFINE_EXTABLE_TYPE_REG in arch/x86/include/asm/asm.h conflicts with the symbol for the static function found in arch/x86/kernel/pmem.c.
Assembler .set directive declare symbols with global visibility, so the assembler may not rename such symbols in the event of a conflict. LTO could rename static functions if there was a conflict in C sources, but it cannot see into symbols defined in inline asm.
The symbols are also retained in the symbol table, regardless of LTO.
Give the symbols .L prefixes making them locally visible, so that they may be renamed for LTO to avoid conflicts, and to drop them from the symbol table regardless of LTO.
--- arch/x86/include/asm/asm.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/asm.h +10 -10
@@ -154,24 +154,24 @@# define DEFINE_EXTABLE_TYPE_REG \ ".macro extable_type_reg type:req reg:req\n" \ - ".set found, 0\n" \ - ".set regnr, 0\n" \ + ".set .Lfound, 0\n" \ + ".set .Lregnr, 0\n" \ ".irp rs,rax,rcx,rdx,rbx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15\n" \ ".ifc \\reg, %%\\rs\n" \ - ".set found, found+1\n" \ - ".long \\type + (regnr << 8)\n" \ + ".set .Lfound, .Lfound+1\n" \ + ".long \\type + (.Lregnr << 8)\n" \ ".endif\n" \ - ".set regnr, regnr+1\n" \ + ".set .Lregnr, .Lregnr+1\n" \ ".endr\n" \ - ".set regnr, 0\n" \ + ".set .Lregnr, 0\n" \ ".irp rs,eax,ecx,edx,ebx,esp,ebp,esi,edi,r8d,r9d,r10d,r11d,r12d,r13d,r14d,r15d\n" \ ".ifc \\reg, %%\\rs\n" \ - ".set found, found+1\n" \ - ".long \\type + (regnr << 8)\n" \ + ".set .Lfound, .Lfound+1\n" \ + ".long \\type + (.Lregnr << 8)\n" \ ".endif\n" \ - ".set regnr, regnr+1\n" \ + ".set .Lregnr, .Lregnr+1\n" \ ".endr\n" \ - ".if (found != 1)\n" \ + ".if (.Lfound != 1)\n" \ ".error \"extable_type_reg: bad register argument\"\n" \ ".endif\n" \ ".endm\n"
Greg Kroah-Hartman
maintainerPATCH 331/343 sched/core: Fix forceidle balancing
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 5b6547ed97f4f5dfc23f8e3970af6d11d7b7ed7e upstream.
Steve reported that ChromeOS encounters the forceidle balancer being ran from rt_mutex_setprio()'s balance_callback() invocation and explodes.
Now, the forceidle balancer gets queued every time the idle task gets selected, set_next_task(), which is strictly too often. rt_mutex_setprio() also uses set_next_task() in the 'change' pattern:
queued = task_on_rq_queued(p); /* p->on_rq == TASK_ON_RQ_QUEUED */ running = task_current(rq, p); /* rq->curr == p */ if (queued) dequeue_task(...); if (running) put_prev_task(...); /* change task properties */ if (queued) enqueue_task(...); if (running) set_next_task(...);
However, rt_mutex_setprio() will explicitly not run this pattern on the idle task (since priority boosting the idle task is quite insane). Most other 'change' pattern users are pidhash based and would also not apply to idle.
Also, the change pattern doesn't contain a __balance_callback() invocation and hence we could have an out-of-band balance-callback, which *should* trigger the WARN in rq_pin_lock() (which guards against this exact anti-pattern).
So while none of that explains how this happens, it does indicate that having it in set_next_task() might not be the most robust option.
Instead, explicitly queue the forceidle balancer from pick_next_task() when it does indeed result in forceidle selection. Having it here, ensures it can only be triggered under the __schedule() rq->lock instance, and hence must be ran from that context.
This also happens to clean up the code a little, so win-win.
--- kernel/sched/core.c | 14 ++++++++++---- kernel/sched/idle.c | 1 - kernel/sched/sched.h | 6 ------ 3 files changed, 10 insertions(+), 11 deletions(-)
kernel/sched/core.c +10 -4
@@ -5675,6 +5675,8 @@ static inline struct task_struct *pick_textern void task_vruntime_update (struct rq *rq,struct task_struct *p,bool in_fi); +static void queue_core_balance (struct rq *rq); +static struct task_struct *pick_next_task (struct rq *rq,struct task_struct *prev,struct rq_flags *rf) {
@@ -5724,7 +5726,7 @@ pick_next_task(struct rq *rq, struct tas } rq->core_pick =NULL ; -return next; + goto out; }put_prev_task_balance (rq, prev, rf);
@@ -5774,7 +5776,7 @@ pick_next_task(struct rq *rq, struct tas*/ WARN_ON_ONCE (fi_before);task_vruntime_update (rq, next, false); - goto done; + goto out_set_next; } }
@@ -5893,8 +5895,12 @@ pick_next_task(struct rq *rq, struct tasresched_curr (rq_i); } -done: +out_set_next:set_next_task (rq, next); +out: +if (rq->core->core_forceidle_count && next == rq->idle) +queue_core_balance (rq); +return next; }
@@ -5989,7 +5995,7 @@ static void sched_core_balance(struct rq static DEFINE_PER_CPU(struct callback_head, core_balance_head); -void queue_core_balance (struct rq *rq) +static void queue_core_balance (struct rq *rq) {if (!sched_core_enabled (rq))return ;
kernel/sched/idle.c +0 -1
@@ -437,7 +437,6 @@ static void set_next_task_idle(struct rq {update_idle_core (rq);schedstat_inc (rq->sched_goidle); -queue_core_balance (rq); }#ifdef CONFIG_SMP
kernel/sched/sched.h +0 -6
@@ -1247,8 +1247,6 @@ static inline bool sched_group_cookie_mareturn false; } -extern void queue_core_balance (struct rq *rq); -static inline bool sched_core_enqueued (struct task_struct *p) {return !RB_EMPTY_NODE (&p->core_node);
@@ -1282,10 +1280,6 @@ static inline raw_spinlock_t *__rq_lockpreturn &rq->__lock; } -static inline void queue_core_balance (struct rq *rq) -{ -} -static inline bool sched_cpu_cookie_match (struct rq *rq,struct task_struct *p) {return true;
Greg Kroah-Hartman
maintainerPATCH 284/343 btrfs: zoned: traverse devices under chunk_mutex in btrfs_can_activate_zone
In reply to Greg Kroah-HartmanFrom: Johannes Thumshirn <[email protected]>
commit 0b9e66762aa0cda2a9c2d5542d64e04dac528fa6 upstream.
btrfs_can_activate_zone() can be called with the device_list_mutex already held, which will lead to a deadlock:
insert_dev_extents() // Takes device_list_mutex
`-> insert_dev_extent()
`-> btrfs_insert_empty_item()
`-> btrfs_insert_empty_items()
`-> btrfs_search_slot()
`-> btrfs_cow_block()
`-> __btrfs_cow_block()
`-> btrfs_alloc_tree_block()
`-> btrfs_reserve_extent()
`-> find_free_extent()
`-> find_free_extent_update_loop()
`-> can_allocate_chunk()
`-> btrfs_can_activate_zone() // Takes device_list_mutex againInstead of using the RCU on fs_devices->device_list we
can use fs_devices->alloc_list, protected by the chunk_mutex to traverse the list of active devices.
We are in the chunk allocation thread. The newer chunk allocation happens from the devices in the fs_device->alloc_list protected by the chunk_mutex.
btrfs_create_chunk()
lockdep_assert_held(&info->chunk_mutex);
gather_device_info
list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list)Also, a device that reappears after the mount won't join the alloc_list yet and, it will be in the dev_list, which we don't want to consider in the context of the chunk alloc.
[15.166572] WARNING: possible recursive locking detected
[15.167117] 5.17.0-rc6-dennis #79 Not tainted
[15.167487] --------------------------------------------
[15.167733] kworker/u8:3/146 is trying to acquire lock:
[15.167733] ffff888102962ee0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: find_free_extent+0x15a/0x14f0 [btrfs]
[15.167733]
[15.167733] but task is already holding lock:
[15.167733] ffff888102962ee0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: btrfs_create_pending_block_groups+0x20a/0x560 [btrfs]
[15.167733]
[15.167733] other info that might help us debug this:
[15.167733] Possible unsafe locking scenario:
[15.167733]
[15.171834] CPU0
[15.171834] ----
[15.171834] lock(&fs_devs->device_list_mutex);
[15.171834] lock(&fs_devs->device_list_mutex);
[15.171834]
[15.171834] *** DEADLOCK ***
[15.171834]
[15.171834] May be due to missing lock nesting notation
[15.171834]
[15.171834] 5 locks held by kworker/u8:3/146:
[15.171834] #0: ffff888100050938 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work+0x1c3/0x5a0
[15.171834] #1: ffffc9000067be80 ((work_completion)(&fs_info->async_data_reclaim_work)){+.+.}-{0:0}, at: process_one_work+0x1c3/0x5a0
[15.176244] #2: ffff88810521e620 (sb_internal){.+.+}-{0:0}, at: flush_space+0x335/0x600 [btrfs]
[15.176244] #3: ffff888102962ee0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: btrfs_create_pending_block_groups+0x20a/0x560 [btrfs]
[15.176244] #4: ffff8881152e4b78 (btrfs-dev-00){++++}-{3:3}, at: __btrfs_tree_lock+0x27/0x130 [btrfs]
[15.179641]
[15.179641] stack backtrace:
[15.179641] CPU: 1 PID: 146 Comm: kworker/u8:3 Not tainted 5.17.0-rc6-dennis #79
[15.179641] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1.fc35 04/01/2014
[15.179641] Workqueue: events_unbound btrfs_async_reclaim_data_space [btrfs]
[15.179641] Call Trace:
[15.179641] <TASK>
[15.179641] dump_stack_lvl+0x45/0x59
[15.179641] __lock_acquire.cold+0x217/0x2b2
[15.179641] lock_acquire+0xbf/0x2b0
[15.183838] ? find_free_extent+0x15a/0x14f0 [btrfs]
[15.183838] __mutex_lock+0x8e/0x970
[15.183838] ? find_free_extent+0x15a/0x14f0 [btrfs]
[15.183838] ? find_free_extent+0x15a/0x14f0 [btrfs]
[15.183838] ? lock_is_held_type+0xd7/0x130
[15.183838] ? find_free_extent+0x15a/0x14f0 [btrfs]
[15.183838] find_free_extent+0x15a/0x14f0 [btrfs]
[15.183838] ? _raw_spin_unlock+0x24/0x40
[15.183838] ? btrfs_get_alloc_profile+0x106/0x230 [btrfs]
[15.187601] btrfs_reserve_extent+0x131/0x260 [btrfs]
[15.187601] btrfs_alloc_tree_block+0xb5/0x3b0 [btrfs]
[15.187601] __btrfs_cow_block+0x138/0x600 [btrfs]
[15.187601] btrfs_cow_block+0x10f/0x230 [btrfs]
[15.187601] btrfs_search_slot+0x55f/0xbc0 [btrfs]
[15.187601] ? lock_is_held_type+0xd7/0x130
[15.187601] btrfs_insert_empty_items+0x2d/0x60 [btrfs]
[15.187601] btrfs_create_pending_block_groups+0x2b3/0x560 [btrfs]
[15.187601] __btrfs_end_transaction+0x36/0x2a0 [btrfs]
[15.192037] flush_space+0x374/0x600 [btrfs]
[15.192037] ? find_held_lock+0x2b/0x80
[15.192037] ? btrfs_async_reclaim_data_space+0x49/0x180 [btrfs]
[15.192037] ? lock_release+0x131/0x2b0
[15.192037] btrfs_async_reclaim_data_space+0x70/0x180 [btrfs]
[15.192037] process_one_work+0x24c/0x5a0
[15.192037] worker_thread+0x4a/0x3d0--- fs/btrfs/zoned.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/btrfs/zoned.c +5 -4
@@ -1927,18 +1927,19 @@ int btrfs_zone_finish(struct btrfs_blockbool btrfs_can_activate_zone (struct btrfs_fs_devices *fs_devices,u64 flags) { +struct btrfs_fs_info *fs_info = fs_devices->fs_info;struct btrfs_device *device;bool ret = false; -if (!btrfs_is_zoned (fs_devices->fs_info)) +if (!btrfs_is_zoned (fs_info))return true;/* Non-single profiles are not supported yet */ ASSERT ((flags &BTRFS_BLOCK_GROUP_PROFILE_MASK ) ==0 );/* Check if there is a device with active zones left */ -mutex_lock (&fs_devices->device_list_mutex); -list_for_each_entry (device, &fs_devices->devices, dev_list) { +mutex_lock (&fs_info->chunk_mutex); +list_for_each_entry (device, &fs_devices->alloc_list, dev_alloc_list) {struct btrfs_zoned_device_info *zinfo = device->zone_info;if (!device->bdev)
@@ -1950,7 +1951,7 @@ bool btrfs_can_activate_zone(struct btrfbreak ; } } -mutex_unlock (&fs_devices->device_list_mutex); +mutex_unlock (&fs_info->chunk_mutex);return ret; }
Greg Kroah-Hartman
maintainerPATCH 322/343 tools build: Filter out options and warnings not supported by clang
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit 41caff459a5b956b3e23ba9ca759dd0629ad3dda upstream.
These make the feature check fail when using clang, so remove them just like is done in tools/perf/Makefile.config to build perf itself.
Adding -Wno-compound-token-split-by-macro to tools/perf/Makefile.config when building with clang is also necessary to avoid these warnings turned into errors (-Werror):
CC /tmp/build/perf/util/scripting-engines/trace-event-perl.o
In file included from util/scripting-engines/trace-event-perl.c:35:
In file included from /usr/lib64/perl5/CORE/perl.h:4085:
In file included from /usr/lib64/perl5/CORE/hv.h:659:
In file included from /usr/lib64/perl5/CORE/hv_func.h:34:
In file included from /usr/lib64/perl5/CORE/sbox32_hash.h:4:
/usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/perl5/CORE/zaphod32_hash.h:80:38: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
#define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START { \
^~~~~~~~~~
/usr/lib64/perl5/CORE/perl.h:737:29: note: expanded from macro 'STMT_START'
# define STMT_START (void)( /* gcc supports "({ STATEMENTS; })" */
^
/usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: '{' token is here
ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/perl5/CORE/zaphod32_hash.h:80:49: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
#define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START { \
^
/usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/perl5/CORE/zaphod32_hash.h:87:41: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
v ^= (v>>23); \
^
/usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: ')' token is here
ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/perl5/CORE/zaphod32_hash.h:88:3: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
} STMT_END
^~~~~~~~
/usr/lib64/perl5/CORE/perl.h:738:21: note: expanded from macro 'STMT_END'
# define STMT_END )
^Please refer to the discussion on the Link: tag below, where Nathan clarifies the situation:
<quote>
acme> And then get to the problems at the end of this message, which seem acme> similar to the problem described here:
acme>
acme> From Nathan Chancellor <>
acme> Subject [PATCH] mwifiex: Remove unnecessary braces from HostCmd_SET_SEQ_NO_BSS_INFO
acme>
acme> https://lkml.org/lkml/2020/9/1/135
acme>
acme> So perhaps in this case its better to disable that acme> -Werror,-Wcompound-token-split-by-macro when building with clang?
Yes, I think that is probably the best solution. As far as I can tell, at least in this file and context, the warning appears harmless, as the "create a GNU C statement expression from two different macros" is very much intentional, based on the presence of PERL_USE_GCC_BRACE_GROUPS. The warning is fixed in upstream Perl by just avoiding creating GNU C statement expressions using STMT_START and STMT_END:
https://github.com/Perl/perl5/issues/18780
https://github.com/Perl/perl5/pull/18984
If I am reading the source code correctly, an alternative to disabling the warning would be specifying -DPERL_GCC_BRACE_GROUPS_FORBIDDEN but it seems like that might end up impacting more than just this site, according to the issue discussion above.
</quote>
--- tools/build/feature/Makefile | 7 +++++++ tools/perf/Makefile.config | 3 +++ 2 files changed, 10 insertions(+)
tools/build/feature/Makefile +7 -0
@@ -220,6 +220,13 @@ PERL_EMBED_LIBADD = $(call grep-libs,$(P PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) +ifeq ($(CC_NO_CLANG), 0) + PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) + PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS)) + PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) + FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro +endif + $(OUTPUT)test-libperl.bin: $(BUILD) $(FLAGS_PERL_EMBED)
tools/perf/Makefile.config +3 -0
@@ -793,6 +793,9 @@ else LDFLAGS += $(PERL_EMBED_LDFLAGS) EXTLIBS += $(PERL_EMBED_LIBADD) CFLAGS += -DHAVE_LIBPERL_SUPPORT + ifeq ($(CC_NO_CLANG), 0) + CFLAGS += -Wno-compound-token-split-by-macro + endif $(call detected,CONFIG_LIBPERL) endif endif
Greg Kroah-Hartman
maintainerPATCH 332/343 sched: Teach the forced-newidle balancer about CPU affinity limitation.
In reply to Greg Kroah-HartmanFrom: Sebastian Andrzej Siewior <[email protected]>
commit 386ef214c3c6ab111d05e1790e79475363abaa05 upstream.
try_steal_cookie() looks at task_struct::cpus_mask to decide if the task could be moved to `this' CPU. It ignores that the task might be in a migration disabled section while not on the CPU. In this case the task must not be moved otherwise per-CPU assumption are broken.
Use is_cpu_allowed(), as suggested by Peter Zijlstra, to decide if the a task can be moved.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -5929,7 +5929,7 @@ static bool try_steal_cookie(int this, iif (p == src->core_pick || p == src->curr) goto next; -if (!cpumask_test_cpu (this, &p->cpus_mask)) +if (!is_cpu_allowed (p, this)) goto next;if (p->core_occupation > dst->idle->core_occupation)
Greg Kroah-Hartman
maintainerPATCH 283/343 btrfs: fix qgroup reserve overflow the qgroup limit
In reply to Greg Kroah-HartmanFrom: Ethan Lien <[email protected]>
commit b642b52d0b50f4d398cb4293f64992d0eed2e2ce upstream.
We use extent_changeset->bytes_changed in qgroup_reserve_data() to record how many bytes we set for EXTENT_QGROUP_RESERVED state. Currently the bytes_changed is set as "unsigned int", and it will overflow if we try to fallocate a range larger than 4GiB. The result is we reserve less bytes and eventually break the qgroup limit.
Unlike regular buffered/direct write, which we use one changeset for each ordered extent, which can never be larger than 256M. For fallocate, we use one changeset for the whole range, thus it no longer respects the 256M per extent limit, and caused the problem.
The following example test script reproduces the problem:
$ cat qgroup-overflow.sh #!/bin/bash
DEV=/dev/sdj
MNT=/mnt/sdj
mkfs.btrfs -f $DEV
mount $DEV $MNT
# Set qgroup limit to 2GiB.
btrfs quota enable $MNT
btrfs qgroup limit 2G $MNT
# Try to fallocate a 3GiB file. This should fail. echo
echo "Try to fallocate a 3GiB file..." fallocate -l 3G $MNT/3G.file
# Try to fallocate a 5GiB file.
echo
echo "Try to fallocate a 5GiB file..."
fallocate -l 5G $MNT/5G.file
# See we break the qgroup limit.
echo
sync
btrfs qgroup show -r $MNT
umount $MNT
When running the test:
$ ./qgroup-overflow.sh (...)
Try to fallocate a 3GiB file...
fallocate: fallocate failed: Disk quota exceeded
Try to fallocate a 5GiB file...
qgroupid rfer excl max_rfer
-------- ---- ---- --------
0/5 5.00GiB 5.00GiB 2.00GiB
Since we have no control of how bytes_changed is used, it's better to set it to u64.
--- fs/btrfs/extent_io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/extent_io.h +1 -1
@@ -118,7 +118,7 @@ struct btrfs_bio_ctrl {*/ struct extent_changeset {/* How many bytes are set/cleared in this operation */ -unsigned int bytes_changed; +u64 bytes_changed;/* Changed ranges */ struct ulist range_changed;
Greg Kroah-Hartman
maintainerPATCH 285/343 btrfs: remove device item and update super block in the same transaction
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit bbac58698a55cc0a6f0c0d69a6dcd3f9f3134c11 upstream.
[BUG]
There is a report that a btrfs has a bad super block num devices.
This makes btrfs to reject the fs completely.
BTRFS error (device sdd3): super_num_devices 3 mismatch with num_devices 2 found here BTRFS error (device sdd3): failed to read chunk tree: -22
BTRFS error (device sdd3): open_ctree failed
[CAUSE]
During btrfs device removal, chunk tree and super block num devs are updated in two different transactions:
btrfs_rm_device()
|- btrfs_rm_dev_item(device) | |- trans = btrfs_start_transaction() | | Now we got transaction X | | | |- btrfs_del_item() | | Now device item is removed from chunk tree | | | |- btrfs_commit_transaction() | Transaction X got committed, super num devs untouched, | but device item removed from chunk tree. | (AKA, super num devs is already incorrect) | |- cur_devices->num_devices--; |- cur_devices->total_devices--; |- btrfs_set_super_num_devices()
All those operations are not in transaction X, thus it will only be written back to disk in next transaction.
So after the transaction X in btrfs_rm_dev_item() committed, but before transaction X+1 (which can be minutes away), a power loss happen, then we got the super num mismatch.
[FIX]
Instead of starting and committing a transaction inside btrfs_rm_dev_item(), start a transaction in side btrfs_rm_device() and pass it to btrfs_rm_dev_item().
And only commit the transaction after everything is done.
--- fs/btrfs/volumes.c | 65 ++++++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 37 deletions(-)
fs/btrfs/volumes.c +28 -37
@@ -1945,23 +1945,18 @@ static void update_dev_time(const char *path_put (&path); } -static int btrfs_rm_dev_item (struct btrfs_device *device) +static int btrfs_rm_dev_item (struct btrfs_trans_handle *trans, +struct btrfs_device *device) {struct btrfs_root *root = device->fs_info->chunk_root;int ret;struct btrfs_path *path;struct btrfs_key key; -struct btrfs_trans_handle *trans; path =btrfs_alloc_path ();if (!path)return -ENOMEM ; - trans =btrfs_start_transaction (root,0 ); -if (IS_ERR (trans)) { -btrfs_free_path (path); -return PTR_ERR (trans); - } key.objectid =BTRFS_DEV_ITEMS_OBJECTID ; key.type =BTRFS_DEV_ITEM_KEY ; key.offset = device->devid;
@@ -1972,21 +1967,12 @@ static int btrfs_rm_dev_item(struct btrfif (ret) {if (ret >0 ) ret = -ENOENT ; -btrfs_abort_transaction (trans, ret); -btrfs_end_transaction (trans); goto out; } ret =btrfs_del_item (trans, root, path); -if (ret) { -btrfs_abort_transaction (trans, ret); -btrfs_end_transaction (trans); - } - out:btrfs_free_path (path); -if (!ret) - ret =btrfs_commit_transaction (trans);return ret; }
@@ -2127,6 +2113,7 @@ int btrfs_rm_device(struct btrfs_fs_infostruct btrfs_dev_lookup_args *args, struct block_device **bdev, fmode_t *mode) { + struct btrfs_trans_handle *trans;struct btrfs_device *device;struct btrfs_fs_devices *cur_devices;struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
@@ -2142,7 +2129,7 @@ int btrfs_rm_device(struct btrfs_fs_info ret =btrfs_check_raid_min_devices (fs_info, num_devices -1 );if (ret) - goto out; +return ret; device =btrfs_find_device (fs_info->fs_devices, args);if (!device) {
@@ -2150,27 +2137,22 @@ int btrfs_rm_device(struct btrfs_fs_info ret =BTRFS_ERROR_DEV_MISSING_NOT_FOUND ; else ret = -ENOENT ; - goto out; +return ret; }if (btrfs_pinned_by_swapfile (fs_info, device)) {btrfs_warn_in_rcu (fs_info,"cannot remove device %s (devid %llu) due to active swapfile" ,rcu_str_deref (device->name), device->devid); - ret = -ETXTBSY ; - goto out; +return -ETXTBSY ; } -if (test_bit (BTRFS_DEV_STATE_REPLACE_TGT , &device->dev_state)) { - ret =BTRFS_ERROR_DEV_TGT_REPLACE ; - goto out; - } +if (test_bit (BTRFS_DEV_STATE_REPLACE_TGT , &device->dev_state)) +return BTRFS_ERROR_DEV_TGT_REPLACE ;if (test_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state) && - fs_info->fs_devices->rw_devices ==1 ) { - ret =BTRFS_ERROR_DEV_ONLY_WRITABLE ; - goto out; - } + fs_info->fs_devices->rw_devices ==1 ) +return BTRFS_ERROR_DEV_ONLY_WRITABLE ;if (test_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state)) {mutex_lock (&fs_info->chunk_mutex);
@@ -2183,14 +2165,22 @@ int btrfs_rm_device(struct btrfs_fs_infoif (ret) goto error_undo; -/* -* TODO: the superblock still includes this device in its num_devices -* counter although write_all_supers() is not locked out. This -* could give a filesystem state which requires a degraded mount. -*/ - ret =btrfs_rm_dev_item (device); -if (ret) + trans =btrfs_start_transaction (fs_info->chunk_root,0 ); +if (IS_ERR (trans)) { + ret =PTR_ERR (trans); goto error_undo; + } + + ret =btrfs_rm_dev_item (trans, device); +if (ret) { +/* Any error in dev item removal is critical */ +btrfs_crit (fs_info, +"failed to remove device item for devid %llu: %d" , + device->devid, ret); +btrfs_abort_transaction (trans, ret); +btrfs_end_transaction (trans); +return ret; + }clear_bit (BTRFS_DEV_STATE_IN_FS_METADATA , &device->dev_state);btrfs_scrub_cancel_dev (device);
@@ -2273,7 +2263,8 @@ int btrfs_rm_device(struct btrfs_fs_infofree_fs_devices (cur_devices); } -out: + ret =btrfs_commit_transaction (trans); +return ret; error_undo:
@@ -2284,7 +2275,7 @@ error_undo: device->fs_devices->rw_devices++;mutex_unlock (&fs_info->chunk_mutex); } - goto out; +return ret; }void btrfs_rm_dev_replace_remove_srcdev (struct btrfs_device *srcdev)
Greg Kroah-Hartman
maintainerPATCH 286/343 btrfs: avoid defragging extents whose next extents are not targets
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit 75a36a7d3ea904cef2e5b56af0c58cc60dcf947a upstream.
[BUG]
There is a report that autodefrag is defragging single sector, which is completely waste of IO, and no help for defragging:
btrfs-cleaner-808 defrag_one_locked_range: root=256 ino=651122 start=0 len=4096
[CAUSE]
In defrag_collect_targets(), we check if the current range (A) can be merged with next one (B).
If mergeable, we will add range A into target for defrag.
However there is a catch for autodefrag, when checking mergeability against range B, we intentionally pass 0 as @newer_than, hoping to get a higher chance to merge with the next extent.
But in the next iteration, range B will looked up by defrag_lookup_extent(), with non-zero @newer_than.
And if range B is not really newer, it will rejected directly, causing only range A being defragged, while we expect to defrag both range A and B.
[FIX]
Since the root cause is the difference in check condition of defrag_check_next_extent() and defrag_collect_targets(), we fix it by:
1. Pass @newer_than to defrag_check_next_extent()
2. Pass @extent_thresh to defrag_check_next_extent()
This makes the check between defrag_collect_targets() and defrag_check_next_extent() more consistent.
While there is still some minor difference, the remaining checks are focus on runtime flags like writeback/delalloc, which are mostly transient and safe to be checked only in defrag_collect_targets().
--- fs/btrfs/ioctl.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
fs/btrfs/ioctl.c +14 -6
@@ -1215,7 +1215,7 @@ static u32 get_extent_max_capacity(const }static bool defrag_check_next_extent (struct inode *inode,struct extent_map *em, -bool locked) +u32 extent_thresh,u64 newer_than,bool locked) {struct extent_map *next;bool ret = false;
@@ -1225,11 +1225,12 @@ static bool defrag_check_next_extent(strreturn false;/* -* We want to check if the next extent can be merged with the current -* one, which can be an extent created in a past generation, so we pass -* a minimum generation of 0 to defrag_lookup_extent(). +* Here we need to pass @newer_then when checking the next extent, or +* we will hit a case we mark current extent for defrag, but the next +* one will not be a target. +* This will just cause extra IO without really reducing the fragments. */ - next =defrag_lookup_extent (inode, em->start + em->len,0 , locked); + next =defrag_lookup_extent (inode, em->start + em->len, newer_than, locked);/* No more em or hole */ if (!next || next->block_start >=EXTENT_MAP_LAST_BYTE ) goto out;
@@ -1241,6 +1242,13 @@ static bool defrag_check_next_extent(str*/ if (next->len >=get_extent_max_capacity (em)) goto out; +/* Skip older extent */ +if (next->generation < newer_than) + goto out; +/* Also check extent size */ +if (next->len >= extent_thresh) + goto out; + ret = true; out:free_extent_map (next);
@@ -1446,7 +1454,7 @@ static int defrag_collect_targets(struct goto next; next_mergeable =defrag_check_next_extent (&inode->vfs_inode, em, - locked); + extent_thresh, newer_than, locked);if (!next_mergeable) {struct defrag_target_range *last;
Greg Kroah-Hartman
maintainerPATCH 320/343 perf build: Dont use -ffat-lto-objects in the python feature test when building with clang-13
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit 3a8a0475861a443f02e3a9b57d044fe2a0a99291 upstream.
Using -ffat-lto-objects in the python feature test when building with clang-13 results in:
clang-13: error: optimization flag '-ffat-lto-objects' is not supported [-Werror,-Wignored-optimization-argument]
error: command '/usr/sbin/clang' failed with exit code 1
cp: cannot stat '/tmp/build/perf/python_ext_build/lib/perf*.so': No such file or directory make[2]: *** [Makefile.perf:639: /tmp/build/perf/python/perf.so] Error 1
Noticed when building on a docker.io/library/archlinux:base container.
--- tools/perf/Makefile.config | 3 +++ tools/perf/util/setup.py | 2 ++ 2 files changed, 5 insertions(+)
tools/perf/Makefile.config +3 -0
@@ -272,6 +272,9 @@ ifdef PYTHON_CONFIG PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) + ifeq ($(CC_NO_CLANG), 0) + PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS)) + endif endif FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
tools/perf/util/setup.py +2 -0
@@ -23,6 +23,8 @@ if cc_is_clang: vars[var] = sub("-fstack-protector-strong", "", vars[var]) if not clang_has_option("-fno-semantic-interposition"): vars[var] = sub("-fno-semantic-interposition", "", vars[var]) + if not clang_has_option("-ffat-lto-objects"): + vars[var] = sub("-ffat-lto-objects", "", vars[var]) from distutils.core import setup, Extension
Greg Kroah-Hartman
maintainerPATCH 298/343 ata: sata_dwc_460ex: Fix crash due to OOB write
In reply to Greg Kroah-HartmanFrom: Christian Lamparter <[email protected]>
commit 7aa8104a554713b685db729e66511b93d989dd6a upstream.
the driver uses libata's "tag" values from in various arrays. Since the mentioned patch bumped the ATA_TAG_INTERNAL to 32, the value of the SATA_DWC_QCMD_MAX needs to account for that.
Otherwise ATA_TAG_INTERNAL usage cause similar crashes like this as reported by Tice Rex on the OpenWrt Forum and reproduced (with symbols) here:
| BUG: Kernel NULL pointer dereference at 0x00000000 | Faulting instruction address: 0xc03ed4b8 | Oops: Kernel access of bad area, sig: 11 [#1] | BE PAGE_SIZE=4K PowerPC 44x Platform | CPU: 0 PID: 362 Comm: scsi_eh_1 Not tainted 5.4.163 #0 | NIP: c03ed4b8 LR: c03d27e8 CTR: c03ed36c | REGS: cfa59950 TRAP: 0300 Not tainted (5.4.163) | MSR: 00021000 <CE,ME> CR: 42000222 XER: 00000000 | DEAR: 00000000 ESR: 00000000 | GPR00: c03d27e8 cfa59a08 cfa55fe0 00000000 0fa46bc0 [...] | [..] | NIP [c03ed4b8] sata_dwc_qc_issue+0x14c/0x254 | LR [c03d27e8] ata_qc_issue+0x1c8/0x2dc | Call Trace: | [cfa59a08] [c003f4e0] __cancel_work_timer+0x124/0x194 (unreliable) | [cfa59a78] [c03d27e8] ata_qc_issue+0x1c8/0x2dc | [cfa59a98] [c03d2b3c] ata_exec_internal_sg+0x240/0x524 | [cfa59b08] [c03d2e98] ata_exec_internal+0x78/0xe0 | [cfa59b58] [c03d30fc] ata_read_log_page.part.38+0x1dc/0x204 | [cfa59bc8] [c03d324c] ata_identify_page_supported+0x68/0x130 | [...]
This is because sata_dwc_dma_xfer_complete() NULLs the dma_pending's next neighbour "chan" (a *dma_chan struct) in this '32' case right here (line ~735):
Quoted 1 line
hsdevp->dma_pending[tag] =
SATA_DWC_DMA_PENDING_NONE;
Then the next time, a dma gets issued; dma_dwc_xfer_setup() passes the NULL'd hsdevp->chan to the dmaengine_slave_config() which then causes the crash.
With this patch, SATA_DWC_QCMD_MAX is now set to ATA_MAX_QUEUE + 1. This avoids the OOB. But please note, there was a worthwhile discussion on what ATA_TAG_INTERNAL and ATA_MAX_QUEUE is. And why there should not be a "fake" 33 command-long queue size.
Ideally, the dw driver should account for the ATA_TAG_INTERNAL. In Damien Le Moal's words: "... having looked at the driver, it is a bigger change than just faking a 33rd "tag" that is in fact not a command tag at all."
--- drivers/ata/sata_dwc_460ex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ata/sata_dwc_460ex.c +5 -1
@@ -137,7 +137,11 @@ struct sata_dwc_device {#endif }; -#define SATA_DWC_QCMD_MAX 32 +/* +* Allow one extra special slot for commands and DMA management +* to account for libata internal commands. +*/ +#define SATA_DWC_QCMD_MAX (ATA_MAX_QUEUE + 1)struct sata_dwc_device_port {struct sata_dwc_device *hsdev;
Greg Kroah-Hartman
maintainerPATCH 315/343 net/smc: send directly on setting TCP_NODELAY
In reply to Greg Kroah-HartmanFrom: Dust Li <[email protected]>
commit b70a5cc045197aad9c159042621baf3c015f6cc7 upstream.
In commit ea785a1a573b("net/smc: Send directly when TCP_CORK is cleared"), we don't use delayed work to implement cork.
This patch use the same algorithm, removes the delayed work when setting TCP_NODELAY and send directly in setsockopt(). This also makes the TCP_NODELAY the same as TCP.
--- net/smc/af_smc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/af_smc.c +2 -2
@@ -2625,8 +2625,8 @@ static int smc_setsockopt(struct socket sk->sk_state != SMC_CLOSED) {if (val) {SMC_STAT_INC (smc, ndly_cnt); -mod_delayed_work (smc->conn.lgr->tx_wq, - &smc->conn.tx_work,0 ); +smc_tx_pending (&smc->conn); +cancel_delayed_work (&smc->conn.tx_work); } }break ;
Greg Kroah-Hartman
maintainerPATCH 281/343 x86/speculation: Restore speculation related MSRs during S3 resume
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit e2a1256b17b16f9b9adf1b6fea56819e7b68e463 upstream.
After resuming from suspend-to-RAM, the MSRs that control CPU's speculative execution behavior are not being restored on the boot CPU.
These MSRs are used to mitigate speculative execution vulnerabilities. Not restoring them correctly may leave the CPU vulnerable. Secondary CPU's MSRs are correctly being restored at S3 resume by identify_secondary_cpu().
During S3 resume, restore these MSRs for boot CPU when restoring its processor state.
--- arch/x86/power/cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/x86/power/cpu.c +14 -0
@@ -503,10 +503,24 @@ static int pm_cpu_check(const struct x86return ret; } +static void pm_save_spec_msr (void ) +{ +u32 spec_msr_id[] = { +MSR_IA32_SPEC_CTRL , +MSR_IA32_TSX_CTRL , +MSR_TSX_FORCE_ABORT , +MSR_IA32_MCU_OPT_CTRL , +MSR_AMD64_LS_CFG , + }; + +msr_build_context (spec_msr_id,ARRAY_SIZE (spec_msr_id)); +} +static int pm_check_save_msr (void ) {dmi_check_system (msr_save_dmi_table);pm_cpu_check (msr_save_cpu_table); +pm_save_spec_msr ();return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 312/343 SUNRPC: Ensure we flush any closed sockets before xs_xprt_free()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit f00432063db1a0db484e85193eccc6845435b80e upstream.
We must ensure that all sockets are closed before we call xprt_free() and release the reference to the net namespace. The problem is that calling fput() will defer closing the socket until delayed_fput() gets called.
Let's fix the situation by allowing rpciod and the transport teardown code (which runs on the system wq) to call __fput_sync(), and directly close the socket.
--- fs/file_table.c | 1 + include/trace/events/sunrpc.h | 1 - net/sunrpc/xprt.c | 7 +------ net/sunrpc/xprtsock.c | 16 +++++++++++++--- 4 files changed, 15 insertions(+), 10 deletions(-)
fs/file_table.c +1 -0
@@ -412,6 +412,7 @@ void __fput_sync(struct file *file) }EXPORT_SYMBOL (fput); +EXPORT_SYMBOL (__fput_sync);void __init files_init (void ) {
include/trace/events/sunrpc.h +0 -1
@@ -1005,7 +1005,6 @@ DEFINE_RPC_XPRT_LIFETIME_EVENT(connect);DEFINE_RPC_XPRT_LIFETIME_EVENT (disconnect_auto);DEFINE_RPC_XPRT_LIFETIME_EVENT (disconnect_done);DEFINE_RPC_XPRT_LIFETIME_EVENT (disconnect_force); -DEFINE_RPC_XPRT_LIFETIME_EVENT (disconnect_cleanup);DEFINE_RPC_XPRT_LIFETIME_EVENT (destroy); DECLARE_EVENT_CLASS(rpc_xprt_event,
net/sunrpc/xprt.c +1 -6
@@ -929,12 +929,7 @@ void xprt_connect(struct rpc_task *task)if (!xprt_lock_write (xprt, task))return ; -if (test_and_clear_bit (XPRT_CLOSE_WAIT , &xprt->state)) { -trace_xprt_disconnect_cleanup (xprt); - xprt->ops->close (xprt); - } - -if (!xprt_connected (xprt)) { +if (!xprt_connected (xprt) && !test_bit (XPRT_CLOSE_WAIT , &xprt->state)) { task->tk_rqstp->rq_connect_cookie = xprt->connect_cookie;rpc_sleep_on_timeout (&xprt->pending, task,NULL ,xprt_request_timeout (task->tk_rqstp));
net/sunrpc/xprtsock.c +13 -3
@@ -880,7 +880,7 @@ static int xs_local_send_request(struct/* Close the stream if the previous transmission was incomplete */ if (xs_send_request_was_aborted (transport, req)) { -xs_close (xprt); +xprt_force_disconnect (xprt);return -ENOTCONN ; }
@@ -918,7 +918,7 @@ static int xs_local_send_request(struct -status); fallthrough;case -EPIPE : -xs_close (xprt); +xprt_force_disconnect (xprt); status = -ENOTCONN ; }
@@ -1203,6 +1203,16 @@ static void xs_reset_transport(struct soif (sk ==NULL )return ; +/* +* Make sure we're calling this in a context from which it is safe +* to call __fput_sync(). In practice that means rpciod and the +* system workqueue. +*/ +if (!(current->flags &PF_WQ_WORKER )) { +WARN_ON_ONCE (1 ); +set_bit (XPRT_CLOSE_WAIT , &xprt->state); +return ; + }if (atomic_read (&transport->xprt.swapper))sk_clear_memalloc (sk);
@@ -1226,7 +1236,7 @@ static void xs_reset_transport(struct somutex_unlock (&transport->recv_mutex);trace_rpc_socket_close (xprt, sock); -fput (filp); +__fput_sync (filp);xprt_disconnect_done (xprt); }
Greg Kroah-Hartman
maintainerPATCH 72/343 PCI: endpoint: Fix alignment fault error in copy tests
In reply to Greg Kroah-HartmanFrom: Hou Zhiqiang <[email protected]>
[ Upstream commit 829cc0e2ea2d61fb6c54bc3f8a17f86c56e11864 ]
The copy test uses the memcpy() to copy data between IO memory spaces. This can trigger an alignment fault error (pasted the error logs below) because memcpy() may use unaligned accesses on a mapped memory that is just IO, which does not support unaligned memory accesses.
Fix it by using the correct memcpy API to copy from/to IO memory.
Alignment fault error logs:
Unable to handle kernel paging request at virtual address ffff8000101cd3c1
Mem abort info:
ESR = 0x96000021
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x21: alignment fault
Data abort info:
ISV = 0, ISS = 0x00000021
CM = 0, WnR = 0
swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000081773000
[ffff8000101cd3c1] pgd=1000000082410003, p4d=1000000082410003, pud=1000000082411003, pmd=1000000082412003, pte=0068004000001f13
Internal error: Oops: 96000021 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 6 Comm: kworker/0:0H Not tainted 5.15.0-rc1-next-20210914-dirty #2
Hardware name: LS1012A RDB Board (DT)
Workqueue: kpcitest pci_epf_test_cmd_handler
pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : __memcpy+0x168/0x230
lr : pci_epf_test_cmd_handler+0x6f0/0xa68
sp : ffff80001003bce0
x29: ffff80001003bce0 x28: ffff800010135000 x27: ffff8000101e5000
x26: ffff8000101cd000 x25: ffff6cda941cf6c8 x24: 0000000000000000
x23: ffff6cda863f2000 x22: ffff6cda9096c800 x21: ffff800010135000
x20: ffff6cda941cf680 x19: ffffaf39fd999000 x18: 0000000000000000
x17: 0000000000000000 x16: 0000000000000000 x15: ffffaf39fd2b6000
x14: 0000000000000000 x13: 15f5c8fa2f984d57 x12: 604d132b60275454
x11: 065cee5e5fb428b6 x10: aae662eb17d0cf3e x9 : 1d97c9a1b4ddef37
x8 : 7541b65edebf928c x7 : e71937c4fc595de0 x6 : b8a0e09562430d1c
x5 : ffff8000101e5401 x4 : ffff8000101cd401 x3 : ffff8000101e5380
x2 : fffffffffffffff1 x1 : ffff8000101cd3c0 x0 : ffff8000101e5000
Call trace:
__memcpy+0x168/0x230
process_one_work+0x1ec/0x370
worker_thread+0x44/0x478
kthread+0x154/0x160
ret_from_fork+0x10/0x20
Code: a984346c a9c4342c f1010042 54fffee8 (a97c3c8e)
---[ end trace 568c28c7b6336335 ]------ drivers/pci/endpoint/functions/pci-epf-test.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-test.c +11 -1
@@ -285,7 +285,17 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test)if (ret)dev_err (dev,"Data transfer failed\n" ); }else { -memcpy (dst_addr, src_addr, reg->size); +void *buf; + + buf =kzalloc (reg->size,GFP_KERNEL ); +if (!buf) { + ret = -ENOMEM ; + goto err_map_addr; + } + +memcpy_fromio (buf, src_addr, reg->size); +memcpy_toio (dst_addr, buf, reg->size); +kfree (buf); }ktime_get_ts64 (&end);pci_epf_test_print_rate ("COPY" , reg->size, &start, &end, use_dma);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 85/343 HID: apple: Report Magic Keyboard 2021 with fingerprint reader battery over USB
In reply to Greg Kroah-HartmanFrom: José Expósito <[email protected]>
[ Upstream commit cbfcfbfc384890a062a5d0cc4792df094a6cc7a8 ]
Like the Apple Magic Keyboard 2015, when connected over USB, the 2021 version with fingerprint reader registers 2 different interfaces. One of them is used to report the battery level.
However, unlike when connected over Bluetooth, the battery level is not reported automatically and it is required to fetch it manually.
Add the APPLE_RDESC_BATTERY quirk to fix the battery report descriptor and manually fetch the battery level.
Tested with the ANSI variant of the keyboard with and without numpad.
--- drivers/hid/hid-apple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hid-apple.c +2 -2
@@ -752,11 +752,11 @@ static const struct hid_device_id apple_devices[] = { { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021), .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021), - .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021), .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021), - .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021), .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 296/343 x86/mm/tlb: Revert retpoline avoidance approach
In reply to Greg Kroah-HartmanFrom: Dave Hansen <[email protected]>
commit d39268ad24c0fd0665d0c5cf55a7c1a0ebf94766 upstream.
0day reported a regression on a microbenchmark which is intended to stress the TLB flushing path:
https://lore.kernel.org/all/20220317090415.GE735@xsang-OptiPlex-9020/
It pointed at a commit from Nadav which intended to remove retpoline overhead in the TLB flushing path by taking the 'cond'-ition in on_each_cpu_cond_mask(), pre-calculating it, and incorporating it into 'cpumask'. That allowed the code to use a bunch of earlier direct calls instead of later indirect calls that need a retpoline.
But, in practice, threads can go idle (and into lazy TLB mode where they don't need to flush their TLB) between the early and late calls. It works in this direction and not in the other because TLB-flushing threads tend to hold mmap_lock for write. Contention on that lock causes threads to _go_ idle right in this early/late window.
There was not any performance data in the original commit specific to the retpoline overhead. I did a few tests on a system with retpolines:
https://lore.kernel.org/all/[email protected]/
which showed a possible small win. But, that small win pales in comparison with the bigger loss induced on non-retpoline systems.
Revert the patch that removed the retpolines. This was not a clean revert, but it was self-contained enough not to be too painful.
--- arch/x86/mm/tlb.c | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-)
arch/x86/mm/tlb.c +5 -32
@@ -854,13 +854,11 @@ done: nr_invalidate); } -static bool tlb_is_not_lazy (int cpu) +static bool tlb_is_not_lazy (int cpu,void *data) {return !per_cpu (cpu_tlbstate_shared.is_lazy, cpu); } -static DEFINE_PER_CPU(cpumask_t, flush_tlb_mask); - DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state_shared, cpu_tlbstate_shared);EXPORT_PER_CPU_SYMBOL (cpu_tlbstate_shared);
@@ -889,36 +887,11 @@ STATIC_NOPV void native_flush_tlb_multi(* up on the new contents of what used to be page tables, while * doing a speculative memory access. */ -if (info->freed_tables) { +if (info->freed_tables)on_each_cpu_mask (cpumask, flush_tlb_func, (void *)info, true); - }else { -/* -* Although we could have used on_each_cpu_cond_mask(), -* open-coding it has performance advantages, as it eliminates -* the need for indirect calls or retpolines. In addition, it -* allows to use a designated cpumask for evaluating the -* condition, instead of allocating one. -* -* This code works under the assumption that there are no nested -* TLB flushes, an assumption that is already made in -* flush_tlb_mm_range(). -* -* cond_cpumask is logically a stack-local variable, but it is -* more efficient to have it off the stack and not to allocate -* it on demand. Preemption is disabled and this code is -* non-reentrant. -*/ -struct cpumask *cond_cpumask =this_cpu_ptr (&flush_tlb_mask); -int cpu; - -cpumask_clear (cond_cpumask); - -for_each_cpu (cpu, cpumask) { -if (tlb_is_not_lazy (cpu)) -__cpumask_set_cpu (cpu, cond_cpumask); - } -on_each_cpu_mask (cond_cpumask, flush_tlb_func, (void *)info, true); - } +else +on_each_cpu_cond_mask (tlb_is_not_lazy, flush_tlb_func, + (void *)info,1 , cpumask); } void flush_tlb_multi(const struct cpumask *cpumask,
Greg Kroah-Hartman
maintainerPATCH 94/343 ath11k: Fix frames flush failure caused by deadlock
In reply to Greg Kroah-HartmanFrom: Baochen Qiang <[email protected]>
[ Upstream commit 261b07519518bd14cb168b287b17e1d195f8d0c8 ]
We are seeing below warnings:
kernel: [25393.301506] ath11k_pci 0000:01:00.0: failed to flush mgmt transmit queue 0
kernel: [25398.421509] ath11k_pci 0000:01:00.0: failed to flush mgmt transmit queue 0
kernel: [25398.421831] ath11k_pci 0000:01:00.0: dropping mgmt frame for vdev 0, is_started 0
this means ath11k fails to flush mgmt. frames because wmi_mgmt_tx_work has no chance to run in 5 seconds.
By setting /proc/sys/kernel/hung_task_timeout_secs to 20 and increasing ATH11K_FLUSH_TIMEOUT to 50 we get below warnings:
kernel: [ 120.763160] INFO: task wpa_supplicant:924 blocked for more than 20 seconds.
kernel: [ 120.763169] Not tainted 5.10.90 #12
kernel: [ 120.763177] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
kernel: [ 120.763186] task:wpa_supplicant state:D stack: 0 pid: 924 ppid: 1 flags:0x000043a0
kernel: [ 120.763201] Call Trace:
kernel: [ 120.763214] __schedule+0x785/0x12fa
kernel: [ 120.763224] ? lockdep_hardirqs_on_prepare+0xe2/0x1bb
kernel: [ 120.763242] schedule+0x7e/0xa1
kernel: [ 120.763253] schedule_timeout+0x98/0xfe
kernel: [ 120.763266] ? run_local_timers+0x4a/0x4a
kernel: [ 120.763291] ath11k_mac_flush_tx_complete+0x197/0x2b1 [ath11k 13c3a9bf37790f4ac8103b3decf7ab4008ac314a]
kernel: [ 120.763306] ? init_wait_entry+0x2e/0x2e
kernel: [ 120.763343] __ieee80211_flush_queues+0x167/0x21f [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.763378] __ieee80211_recalc_idle+0x105/0x125 [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.763411] ieee80211_recalc_idle+0x14/0x27 [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.763441] ieee80211_free_chanctx+0x77/0xa2 [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.763473] __ieee80211_vif_release_channel+0x100/0x131 [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.763540] ieee80211_vif_release_channel+0x66/0x81 [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.763572] ieee80211_destroy_auth_data+0xa3/0xe6 [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.763612] ieee80211_mgd_deauth+0x178/0x29b [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.763654] cfg80211_mlme_deauth+0x1a8/0x22c [cfg80211 8945aa5bc2af5f6972336665d8ad6f9c191ad5be]
kernel: [ 120.763697] nl80211_deauthenticate+0xfa/0x123 [cfg80211 8945aa5bc2af5f6972336665d8ad6f9c191ad5be]
kernel: [ 120.763715] genl_rcv_msg+0x392/0x3c2
kernel: [ 120.763750] ? nl80211_associate+0x432/0x432 [cfg80211 8945aa5bc2af5f6972336665d8ad6f9c191ad5be]
kernel: [ 120.763782] ? nl80211_associate+0x432/0x432 [cfg80211 8945aa5bc2af5f6972336665d8ad6f9c191ad5be]
kernel: [ 120.763802] ? genl_rcv+0x36/0x36
kernel: [ 120.763814] netlink_rcv_skb+0x89/0xf7
kernel: [ 120.763829] genl_rcv+0x28/0x36
kernel: [ 120.763840] netlink_unicast+0x179/0x24b
kernel: [ 120.763854] netlink_sendmsg+0x393/0x401
kernel: [ 120.763872] sock_sendmsg+0x72/0x76
kernel: [ 120.763886] ____sys_sendmsg+0x170/0x1e6
kernel: [ 120.763897] ? copy_msghdr_from_user+0x7a/0xa2
kernel: [ 120.763914] ___sys_sendmsg+0x95/0xd1
kernel: [ 120.763940] __sys_sendmsg+0x85/0xbf
kernel: [ 120.763956] do_syscall_64+0x43/0x55
kernel: [ 120.763966] entry_SYSCALL_64_after_hwframe+0x44/0xa9
kernel: [ 120.763977] RIP: 0033:0x79089f3fcc83
kernel: [ 120.763986] RSP: 002b:00007ffe604f0508 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
kernel: [ 120.763997] RAX: ffffffffffffffda RBX: 000059b40e987690 RCX: 000079089f3fcc83
kernel: [ 120.764006] RDX: 0000000000000000 RSI: 00007ffe604f0558 RDI: 0000000000000009
kernel: [ 120.764014] RBP: 00007ffe604f0540 R08: 0000000000000004 R09: 0000000000400000
kernel: [ 120.764023] R10: 00007ffe604f0638 R11: 0000000000000246 R12: 000059b40ea04980
kernel: [ 120.764032] R13: 00007ffe604f0638 R14: 000059b40e98c360 R15: 00007ffe604f0558
...
kernel: [ 120.765230] INFO: task kworker/u32:26:4239 blocked for more than 20 seconds.
kernel: [ 120.765238] Not tainted 5.10.90 #12
kernel: [ 120.765245] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
kernel: [ 120.765253] task:kworker/u32:26 state:D stack: 0 pid: 4239 ppid: 2 flags:0x00004080
kernel: [ 120.765284] Workqueue: phy0 ieee80211_iface_work [mac80211]
kernel: [ 120.765295] Call Trace:
kernel: [ 120.765306] __schedule+0x785/0x12fa
kernel: [ 120.765316] ? find_held_lock+0x3d/0xb2
kernel: [ 120.765331] schedule+0x7e/0xa1
kernel: [ 120.765340] schedule_preempt_disabled+0x15/0x1e
kernel: [ 120.765349] __mutex_lock_common+0x561/0xc0d
kernel: [ 120.765375] ? ieee80211_sta_work+0x3e/0x1232 [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.765390] mutex_lock_nested+0x20/0x26
kernel: [ 120.765416] ieee80211_sta_work+0x3e/0x1232 [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.765430] ? skb_dequeue+0x54/0x5e
kernel: [ 120.765456] ? ieee80211_iface_work+0x7b/0x339 [mac80211 335da900954f1c5ea7f1613d92088ce83342042c]
kernel: [ 120.765485] process_one_work+0x270/0x504
kernel: [ 120.765501] worker_thread+0x215/0x376
kernel: [ 120.765514] kthread+0x159/0x168
kernel: [ 120.765526] ? pr_cont_work+0x5b/0x5b
kernel: [ 120.765536] ? kthread_blkcg+0x31/0x31
kernel: [ 120.765550] ret_from_fork+0x22/0x30
...
kernel: [ 120.765867] Showing all locks held in the system:
...
kernel: [ 120.766164] 5 locks held by wpa_supplicant/924:
kernel: [ 120.766172] #0: ffffffffb1e63eb0 (cb_lock){++++}-{3:3}, at: genl_rcv+0x19/0x36
kernel: [ 120.766197] #1: ffffffffb1e5b1c8 (rtnl_mutex){+.+.}-{3:3}, at: nl80211_pre_doit+0x2a/0x15c [cfg80211]
kernel: [ 120.766238] #2: ffff99f08347cd08 (&wdev->mtx){+.+.}-{3:3}, at: nl80211_deauthenticate+0xde/0x123 [cfg80211]
kernel: [ 120.766279] #3: ffff99f09df12a48 (&local->mtx){+.+.}-{3:3}, at: ieee80211_destroy_auth_data+0x9b/0xe6 [mac80211]
kernel: [ 120.766321] #4: ffff99f09df12ce0 (&local->chanctx_mtx){+.+.}-{3:3}, at: ieee80211_vif_release_channel+0x5e/0x81 [mac80211]
...
kernel: [ 120.766585] 3 locks held by kworker/u32:26/4239:
kernel: [ 120.766593] #0: ffff99f04458f948 ((wq_completion)phy0){+.+.}-{0:0}, at: process_one_work+0x19a/0x504
kernel: [ 120.766621] #1: ffffbad54b3cfe50 ((work_completion)(&sdata->work)){+.+.}-{0:0}, at: process_one_work+0x1c0/0x504
kernel: [ 120.766649] #2: ffff99f08347cd08 (&wdev->mtx){+.+.}-{3:3}, at: ieee80211_sta_work+0x3e/0x1232 [mac80211]
With above info the issue is clear: First wmi_mgmt_tx_work is inserted to local->workqueue after sdata->work inserted, then wpa_supplicant acquires wdev->mtx in nl80211_deauthenticate and finally calls ath11k_mac_op_flush where it waits all mgmt. frames to be sent out by wmi_mgmt_tx_work. Meanwhile, sdata->work is blocked by wdev->mtx in ieee80211_sta_work, as a result wmi_mgmt_tx_work has no chance to run.
Change to use ab->workqueue instead of local->workqueue to fix this issue.
--- drivers/net/wireless/ath/ath11k/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/mac.c +1 -1
@@ -5574,7 +5574,7 @@ static int ath11k_mac_mgmt_tx(struct ath11k *ar, struct sk_buff *skb,skb_queue_tail (q, skb);atomic_inc (&ar->num_pending_mgmt_tx); -ieee80211_queue_work (ar->hw, &ar->wmi_mgmt_tx_work); +queue_work (ar->ab->workqueue, &ar->wmi_mgmt_tx_work);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 100/343 vfio/pci: Stub vfio_pci_vga_rw when !CONFIG_VFIO_PCI_VGA
In reply to Greg Kroah-HartmanFrom: Alex Williamson <[email protected]>
[ Upstream commit 6e031ec0e5a2dda53e12e0d2a7e9b15b47a3c502 ]
Resolve build errors reported against UML build for undefined ioport_map() and ioport_unmap() functions. Without this config option a device cannot have vfio_pci_core_device.has_vga set, so the existing function would always return -EINVAL anyway.
--- drivers/vfio/pci/vfio_pci_rdwr.c | 2 ++ include/linux/vfio_pci_core.h | 9 +++++++++ 2 files changed, 11 insertions(+)
drivers/vfio/pci/vfio_pci_rdwr.c +2 -0
@@ -288,6 +288,7 @@ ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf,return done; } +#ifdef CONFIG_VFIO_PCI_VGA ssize_t vfio_pci_vga_rw (struct vfio_pci_core_device *vdev,char __user *buf,size_t count,loff_t *ppos,bool iswrite) {
@@ -355,6 +356,7 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __user *buf, return done; } +#endif static void vfio_pci_ioeventfd_do_write (struct vfio_pci_ioeventfd *ioeventfd,bool test_mem)
include/linux/vfio_pci_core.h +9 -0
@@ -159,8 +159,17 @@ extern ssize_t vfio_pci_config_rw(struct vfio_pci_core_device *vdev,extern ssize_t vfio_pci_bar_rw (struct vfio_pci_core_device *vdev,char __user *buf,size_t count,loff_t *ppos,bool iswrite); +#ifdef CONFIG_VFIO_PCI_VGA extern ssize_t vfio_pci_vga_rw (struct vfio_pci_core_device *vdev,char __user *buf,size_t count,loff_t *ppos,bool iswrite); +#else +static inline ssize_t vfio_pci_vga_rw (struct vfio_pci_core_device *vdev, +char __user *buf,size_t count, +loff_t *ppos,bool iswrite) +{ +return -EINVAL ; +} +#endif extern long vfio_pci_ioeventfd (struct vfio_pci_core_device *vdev,loff_t offset,uint64_t data,int count,int fd);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 104/343 scsi: pm8001: Fix task leak in pm8001_send_abort_all()
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
[ Upstream commit f90a74892f3acf0cdec5844e90fc8686ca13e7d7 ]
In pm8001_send_abort_all(), make sure to free the allocated sas task if pm8001_tag_alloc() or pm8001_mpi_build_cmd() fail.
--- drivers/scsi/pm8001/pm8001_hwi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/scsi/pm8001/pm8001_hwi.c +6 -3
@@ -1765,7 +1765,6 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, } task =sas_alloc_slow_task (GFP_ATOMIC ); -if (!task) {pm8001_dbg (pm8001_ha,FAIL ,"cannot allocate task\n" );return ;
@@ -1774,8 +1773,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, task->task_done = pm8001_task_done; res =pm8001_tag_alloc (pm8001_ha, &ccb_tag); -if (res) +if (res) { +sas_free_task (task);return ; + } ccb = &pm8001_ha->ccb_info[ccb_tag]; ccb->device = pm8001_ha_dev;
@@ -1792,8 +1793,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, ret =pm8001_mpi_build_cmd (pm8001_ha, circularQ, opc, &task_abort,sizeof (task_abort),0 ); -if (ret) +if (ret) { +sas_free_task (task);pm8001_tag_free (pm8001_ha, ccb_tag); + } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 98/343 dm: requeue IO if mapping table not yet available
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
[ Upstream commit fa247089de9936a46e290d4724cb5f0b845600f5 ]
Update both bio-based and request-based DM to requeue IO if the mapping table not available.
This race of IO being submitted before the DM device ready is so narrow, yet possible for initial table load given that the DM device's request_queue is created prior, that it best to requeue IO to handle this unlikely case.
--- drivers/md/dm-rq.c | 7 ++++++- drivers/md/dm.c | 11 +++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/md/dm-rq.c +6 -1
@@ -499,8 +499,13 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,if (unlikely (!ti)) {int srcu_idx; -struct dm_table *map =dm_get_live_table (md, &srcu_idx); +struct dm_table *map; + map =dm_get_live_table (md, &srcu_idx); +if (unlikely (!map)) { +dm_put_live_table (md, srcu_idx); +return BLK_STS_RESOURCE ; + } ti =dm_table_find_target (map,0 );dm_put_live_table (md, srcu_idx); }
drivers/md/dm.c +3 -8
@@ -1519,15 +1519,10 @@ static void dm_submit_bio(struct bio *bio)struct dm_table *map; map =dm_get_live_table (md, &srcu_idx); -if (unlikely (!map)) { -DMERR_LIMIT ("%s: mapping table unavailable, erroring io" , -dm_device_name (md)); -bio_io_error (bio); - goto out; - } -/* If suspended, queue this IO for later */ -if (unlikely (test_bit (DMF_BLOCK_IO_FOR_SUSPEND , &md->flags))) { +/* If suspended, or map not yet available, queue this IO for later */ +if (unlikely (test_bit (DMF_BLOCK_IO_FOR_SUSPEND , &md->flags)) || +unlikely (!map)) {if (bio->bi_opf &REQ_NOWAIT )bio_wouldblock_error (bio);else if (bio->bi_opf &REQ_RAHEAD )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 101/343 scsi: pm8001: Fix pm80xx_pci_mem_copy() interface
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
[ Upstream commit 3762d8f6edcdb03994c919f9487fd6d336c06561 ]
The declaration of the local variable destination1 in pm80xx_pci_mem_copy() as a pointer to a u32 results in the sparse warning:
warning: incorrect type in assignment (different base types)
expected unsigned int [usertype]
got restricted __le32 [usertype]
Furthermore, the destination" argument of pm80xx_pci_mem_copy() is wrongly declared with the const attribute.
Fix both problems by changing the type of the "destination" argument to "__le32 *" and use this argument directly inside the pm80xx_pci_mem_copy() function, thus removing the need for the destination1 local variable.
--- drivers/scsi/pm8001/pm80xx_hwi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/scsi/pm8001/pm80xx_hwi.c +3 -5
@@ -67,18 +67,16 @@ int pm80xx_bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shift_value) }static void pm80xx_pci_mem_copy (struct pm8001_hba_info *pm8001_ha,u32 soffset, -const void *destination, +__le32 *destination,u32 dw_count,u32 bus_base_number) {u32 index, value, offset; -u32 *destination1; - destination1 = (u32 *)destination; -for (index =0 ; index < dw_count; index +=4 , destination1++) { +for (index =0 ; index < dw_count; index +=4 , destination++) { offset = (soffset + index);if (offset < (64 *1024 )) { value =pm8001_cr32 (pm8001_ha, bus_base_number, offset); - *destination1 =cpu_to_le32 (value); + *destination =cpu_to_le32 (value); } }return ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 117/343 mips: ralink: fix a refcount leak in ill_acc_of_setup()
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
[ Upstream commit 4a0a1436053b17e50b7c88858fb0824326641793 ]
of_node_put(np) needs to be called when pdev == NULL.
--- arch/mips/ralink/ill_acc.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/ralink/ill_acc.c +1 -0
@@ -61,6 +61,7 @@ static int __init ill_acc_of_setup(void) pdev =of_find_device_by_node (np);if (!pdev) {pr_err ("%pOFn: failed to lookup pdev\n" , np); +of_node_put (np);return -EINVAL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 122/343 Bluetooth: mediatek: fix the conflict between mtk and msft vendor event
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit e4412654e260842e1a94ffe0d4026e8a6fd34246 ]
There is a conflict between MediaTek wmt event and msft vendor extension logic in the core layer since 145373cb1b1f ("Bluetooth: Add framework for Microsoft vendor extension") was introduced because we changed the type of mediatek wmt event to the type of msft vendor event in the driver.
But the purpose we reported mediatek event to the core layer is for the diagnostic purpose with that we are able to see the full packet trace via monitoring socket with btmon. Thus, it is harmless we keep the original type of mediatek vendor event here to avoid breaking the msft extension function especially they can be supported by Mediatek chipset like MT7921 , MT7922 devices and future devices.
--- drivers/bluetooth/btmtk.h | 1 + drivers/bluetooth/btmtksdio.c | 9 +-------- drivers/bluetooth/btusb.c | 8 -------- 3 files changed, 2 insertions(+), 16 deletions(-)
drivers/bluetooth/btmtk.h +1 -0
@@ -5,6 +5,7 @@#define FIRMWARE_MT7668 "mediatek/mt7668pr2h.bin"#define FIRMWARE_MT7961 "mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin" +#define HCI_EV_WMT 0xe4#define HCI_WMT_MAX_EVENT_SIZE 64#define BTMTK_WMT_REG_READ 0x2
drivers/bluetooth/btmtksdio.c +1 -8
@@ -370,13 +370,6 @@ static int btmtksdio_recv_event(struct hci_dev *hdev, struct sk_buff *skb)struct hci_event_hdr *hdr = (void *)skb->data;int err; -/* Fix up the vendor event id with 0xff for vendor specific instead -* of 0xe4 so that event send via monitoring socket can be parsed -* properly. -*/ -if (hdr->evt ==0xe4 ) - hdr->evt =HCI_EV_VENDOR ; -/* When someone waits for the WMT event, the skb is being cloned * and being processed the events from there then. */
@@ -392,7 +385,7 @@ static int btmtksdio_recv_event(struct hci_dev *hdev, struct sk_buff *skb)if (err <0 ) goto err_free_skb; -if (hdr->evt ==HCI_EV_VENDOR ) { +if (hdr->evt ==HCI_EV_WMT ) {if (test_and_clear_bit (BTMTKSDIO_TX_WAIT_VND_EVT , &bdev->tx_state)) {/* Barrier to sync with other CPUs */
drivers/bluetooth/btusb.c +0 -8
@@ -2254,7 +2254,6 @@ static void btusb_mtk_wmt_recv(struct urb *urb) {struct hci_dev *hdev = urb->context;struct btusb_data *data =hci_get_drvdata (hdev); -struct hci_event_hdr *hdr;struct sk_buff *skb;int err;
@@ -2274,13 +2273,6 @@ static void btusb_mtk_wmt_recv(struct urb *urb)hci_skb_pkt_type (skb) =HCI_EVENT_PKT ;skb_put_data (skb, urb->transfer_buffer, urb->actual_length); - hdr = (void *)skb->data; -/* Fix up the vendor event id with 0xff for vendor specific -* instead of 0xe4 so that event send via monitoring socket can -* be parsed properly. -*/ - hdr->evt =0xff ; -/* When someone waits for the WMT event, the skb is being cloned * and being processed the events from there then. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 123/343 Bluetooth: Fix not checking for valid hdev on bt_dev_{info,warn,err,dbg}
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 9b392e0e0b6d026da5a62bb79a08f32e27af858e ]
This fixes attemting to print hdev->name directly which causes them to print an error:
kernel: read_version:367: (efault): sock 000000006a3008f2
--- include/net/bluetooth/bluetooth.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
include/net/bluetooth/bluetooth.h +8 -6
@@ -204,19 +204,21 @@ void bt_err_ratelimited(const char *fmt, ...);#define BT_DBG (fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__)#endif +#define bt_dev_name (hdev) ((hdev) ? (hdev)->name : "null") +#define bt_dev_info (hdev, fmt, ...) \ - BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + BT_INFO("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)#define bt_dev_warn (hdev, fmt, ...) \ - BT_WARN("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)#define bt_dev_err (hdev, fmt, ...) \ - BT_ERR("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + BT_ERR("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)#define bt_dev_dbg (hdev, fmt, ...) \ - BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + BT_DBG("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)#define bt_dev_warn_ratelimited (hdev, fmt, ...) \ - bt_warn_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + bt_warn_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)#define bt_dev_err_ratelimited (hdev, fmt, ...) \ - bt_err_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + bt_err_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)/* Connection and socket states */ enum {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 124/343 Bluetooth: use memset avoid memory leaks
In reply to Greg Kroah-HartmanFrom: Minghao Chi (CGEL ZTE) <[email protected]>
[ Upstream commit d3715b2333e9a21692ba16ef8645eda584a9515d ]
Use memset to initialize structs to prevent memory leaks in l2cap_ecred_connect
--- net/bluetooth/l2cap_core.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/l2cap_core.c +1 -0
@@ -1436,6 +1436,7 @@ static void l2cap_ecred_connect(struct l2cap_chan *chan)l2cap_ecred_init (chan,0 ); +memset (&data,0 ,sizeof (data)); data.pdu.req.psm = chan->psm; data.pdu.req.mtu =cpu_to_le16 (chan->imtu); data.pdu.req.mps =cpu_to_le16 (chan->mps);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 235/343 ipv6: Fix stats accounting in ip6_pkt_drop
In reply to Greg Kroah-HartmanFrom: David Ahern <[email protected]>
[ Upstream commit 1158f79f82d437093aeed87d57df0548bdd68146 ]
VRF devices are the loopbacks for VRFs, and a loopback can not be assigned to a VRF. Accordingly, the condition in ip6_pkt_drop should be '||' not '&&'.
--- net/ipv6/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/route.c +1 -1
@@ -4495,7 +4495,7 @@ static int ip6_pkt_drop(struct sk_buff *skb, u8 code, int ipstats_mib_noroutes)struct inet6_dev *idev;int type; -if (netif_is_l3_master (skb->dev) && +if (netif_is_l3_master (skb->dev) || dst->dev == net->loopback_dev) idev =__in6_dev_get_safely (dev_get_by_index_rcu (net,IP6CB (skb)->iif));else
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 244/343 net: phy: mscc-miim: reject clause 45 register accesses
In reply to Greg Kroah-HartmanFrom: Michael Walle <[email protected]>
[ Upstream commit 8d90991e5bf7fdb9f264f5f579d18969913054b7 ]
The driver doesn't support clause 45 register access yet, but doesn't check if the access is a c45 one either. This leads to spurious register reads and writes. Add the check.
--- drivers/net/mdio/mdio-mscc-miim.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/mdio/mdio-mscc-miim.c +6 -0
@@ -93,6 +93,9 @@ static int mscc_miim_read(struct mii_bus *bus, int mii_id, int regnum)u32 val;int ret; +if (regnum &MII_ADDR_C45 ) +return -EOPNOTSUPP ; + ret =mscc_miim_wait_pending (bus);if (ret) goto out;
@@ -136,6 +139,9 @@ static int mscc_miim_write(struct mii_bus *bus, int mii_id,struct mscc_miim_dev *miim = bus->priv;int ret; +if (regnum &MII_ADDR_C45 ) +return -EOPNOTSUPP ; + ret =mscc_miim_wait_pending (bus);if (ret <0 ) goto out;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 248/343 drm/amd/display: Remove redundant dsc power gating from init_hw
In reply to Greg Kroah-HartmanFrom: Roman Li <[email protected]>
[ Upstream commit 95707203407c4cf0b7e520a99d6f46d8aed4b57f ]
[Why]
DSC Power down code has been moved from dcn31_init_hw into init_pipes() Need to remove it from dcn10_init_hw() as well to avoid duplicated action on dcn1.x/2.x
[How]
Remove DSC power down code from dcn10_init_hw()
--- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +0 -7
@@ -1493,13 +1493,6 @@ void dcn10_init_hw(struct dc *dc) link->link_status.link_active = true; } -/* Power gate DSCs */ -if (!is_optimized_init_done) { -for (i =0 ; i < res_pool->res_cap->num_dsc; i++) -if (hws->funcs.dsc_pg_control !=NULL ) - hws->funcs.dsc_pg_control (hws, res_pool->dscs[i]->inst, false); - } -/* we want to turn off all dp displays before doing detection */ if (dc->config.power_down_display_on_boot)dc_link_blank_all_dp_displays (dc);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 299/343 perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator
In reply to Greg Kroah-HartmanFrom: Xiaomeng Tong <[email protected]>
commit 2012a9e279013933885983cbe0a5fe828052563b upstream.
The bug is here:
return cluster;
The list iterator value 'cluster' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found.
To fix the bug, return 'cluster' when found, otherwise return NULL.
--- drivers/perf/qcom_l2_pmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/perf/qcom_l2_pmu.c +3 -3
@@ -736,7 +736,7 @@ static struct cluster_pmu *l2_cache_asso {u64 mpidr;int cpu_cluster_id; -struct cluster_pmu *cluster =NULL ; +struct cluster_pmu *cluster;/* * This assumes that the cluster_id is in MPIDR[aff1] for
@@ -758,10 +758,10 @@ static struct cluster_pmu *l2_cache_asso cluster->cluster_id);cpumask_set_cpu (cpu, &cluster->cluster_cpus); *per_cpu_ptr (l2cache_pmu->pmu_cluster, cpu) = cluster; -break ; +return cluster; } -return cluster; +return NULL ; }static int l2cache_pmu_online_cpu (unsigned int cpu,struct hlist_node *node)
Greg Kroah-Hartman
maintainerPATCH 335/343 irqchip/gic-v4: Wait for GICR_VPENDBASER.Dirty to clear before descheduling
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit af27e41612ec7e5b4783f589b753a7c31a37aac8 upstream.
The way KVM drives GICv4.{0,1} is as follows:
- vcpu_load() makes the VPE resident, instructing the RD to start scanning for interrupts
- just before entering the guest, we check that the RD has finished scanning and that we can start running the vcpu
- on preemption, we deschedule the VPE by making it invalid on the RD
However, we are preemptible between the first two steps. If it so happens *and* that the RD was still scanning, we nonetheless write to the GICR_VPENDBASER register while Dirty is set, and bad things happen (we're in UNPRED land).
This affects both the 4.0 and 4.1 implementations.
Make sure Dirty is cleared before performing the deschedule, meaning that its_clear_vpend_valid() becomes a sort of full VPE residency barrier.
--- drivers/irqchip/irq-gic-v3-its.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +19 -9
@@ -3011,18 +3011,12 @@ static int __init allocate_lpi_tables(voreturn 0 ; } -static u64 its_clear_vpend_valid (void __iomem *vlpi_base,u64 clr,u64 set) +static u64 read_vpend_dirty_clear (void __iomem *vlpi_base) {u32 count =1000000 ;/* 1s! */ bool clean;u64 val; - val =gicr_read_vpendbaser (vlpi_base +GICR_VPENDBASER ); - val &= ~GICR_VPENDBASER_Valid; - val &= ~clr; - val |= set; -gicr_write_vpendbaser (val, vlpi_base +GICR_VPENDBASER ); - do { val = gicr_read_vpendbaser(vlpi_base + GICR_VPENDBASER); clean = !(val & GICR_VPENDBASER_Dirty);
@@ -3033,10 +3027,26 @@ static u64 its_clear_vpend_valid(void __ } }while (!clean && count); -if (unlikely (val & GICR_VPENDBASER_Dirty)) { +if (unlikely (!clean))pr_err_ratelimited ("ITS virtual pending table not cleaning\n" ); + +return val; +} + +static u64 its_clear_vpend_valid (void __iomem *vlpi_base,u64 clr,u64 set) +{ +u64 val; + +/* Make sure we wait until the RD is done with the initial scan */ + val =read_vpend_dirty_clear (vlpi_base); + val &= ~GICR_VPENDBASER_Valid; + val &= ~clr; + val |= set; +gicr_write_vpendbaser (val, vlpi_base +GICR_VPENDBASER ); + + val =read_vpend_dirty_clear (vlpi_base); +if (unlikely (val & GICR_VPENDBASER_Dirty)) val |= GICR_VPENDBASER_PendingLast; - }return val; }
Greg Kroah-Hartman
maintainerPATCH 26/343 ptp: replace snprintf with sysfs_emit
In reply to Greg Kroah-HartmanFrom: Yang Guang <[email protected]>
[ Upstream commit e2cf07654efb0fd7bbcb475c6f74be7b5755a8fd ]
coccinelle report:
./drivers/ptp/ptp_sysfs.c:17:8-16:
WARNING: use scnprintf or sprintf
./drivers/ptp/ptp_sysfs.c:390:8-16:
WARNING: use scnprintf or sprintf
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
--- drivers/ptp/ptp_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ptp/ptp_sysfs.c +2 -2
@@ -14,7 +14,7 @@ static ssize_t clock_name_show(struct device *dev, struct device_attribute *attr, char *page) { struct ptp_clock *ptp = dev_get_drvdata(dev); -return snprintf (page,PAGE_SIZE -1 ,"%s\n" , ptp->info->name); +return sysfs_emit (page,"%s\n" , ptp->info->name); }static DEVICE_ATTR_RO (clock_name);
@@ -387,7 +387,7 @@ static ssize_t ptp_pin_show(struct device *dev, struct device_attribute *attr,mutex_unlock (&ptp->pincfg_mux); -return snprintf (page,PAGE_SIZE ,"%u %u\n" , func, chan); +return sysfs_emit (page,"%u %u\n" , func, chan); } static ssize_t ptp_pin_store(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 68/343 KVM: arm64: Do not change the PMU event filter after a VCPU has run
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
[ Upstream commit 5177fe91e4cf78a659aada2c9cf712db4d788481 ]
Userspace can specify which events a guest is allowed to use with the KVM_ARM_VCPU_PMU_V3_FILTER attribute. The list of allowed events can be identified by a guest from reading the PMCEID{0,1}_EL0 registers.
Changing the PMU event filter after a VCPU has run can cause reads of the registers performed before the filter is changed to return different values than reads performed with the new event filter in place. The architecture defines the two registers as read-only, and this behaviour contradicts that.
Keep track when the first VCPU has run and deny changes to the PMU event filter to prevent this from happening.
--- Documentation/virt/kvm/devices/vcpu.rst | 2 +- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 4 +++ arch/arm64/kvm/pmu-emul.c | 33 +++++++++++++++---------- 4 files changed, 26 insertions(+), 14 deletions(-)
Documentation/virt/kvm/devices/vcpu.rst +1 -1
@@ -70,7 +70,7 @@ irqchip. -ENODEV PMUv3 not supported or GIC not initialized -ENXIO PMUv3 not properly configured or in-kernel irqchip not configured as required prior to calling this attribute - -EBUSY PMUv3 already initialized + -EBUSY PMUv3 already initialized or a VCPU has already run -EINVAL Invalid filter range ======= ======================================================
arch/arm64/include/asm/kvm_host.h +1 -0
@@ -136,6 +136,7 @@ struct kvm_arch {/* Memory Tagging Extension enabled for the guest */ bool mte_enabled; +bool ran_once; };struct kvm_vcpu_fault_info {
arch/arm64/kvm/arm.c +4 -0
@@ -634,6 +634,10 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)if (kvm_vm_is_protected (kvm))kvm_call_hyp_nvhe (__pkvm_vcpu_init_traps, vcpu); +mutex_lock (&kvm->lock); + kvm->arch.ran_once = true; +mutex_unlock (&kvm->lock); +return ret; }
arch/arm64/kvm/pmu-emul.c +20 -13
@@ -924,6 +924,8 @@ static bool pmu_irq_is_valid(struct kvm *kvm, int irq)int kvm_arm_pmu_v3_set_attr (struct kvm_vcpu *vcpu,struct kvm_device_attr *attr) { +struct kvm *kvm = vcpu->kvm; +if (!kvm_vcpu_has_pmu (vcpu))return -ENODEV ;
@@ -941,7 +943,7 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr)int __user *uaddr = (int __user *)(long )attr->addr;int irq; -if (!irqchip_in_kernel (vcpu->kvm)) +if (!irqchip_in_kernel (kvm))return -EINVAL ;if (get_user (irq, uaddr))
@@ -951,7 +953,7 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr)if (!(irq_is_ppi (irq) ||irq_is_spi (irq)))return -EINVAL ; -if (!pmu_irq_is_valid (vcpu->kvm, irq)) +if (!pmu_irq_is_valid (kvm, irq))return -EINVAL ;if (kvm_arm_pmu_irq_initialized (vcpu))
@@ -966,7 +968,7 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr)struct kvm_pmu_event_filter filter;int nr_events; - nr_events =kvm_pmu_event_mask (vcpu->kvm) +1 ; + nr_events =kvm_pmu_event_mask (kvm) +1 ; uaddr = (struct kvm_pmu_event_filter __user *)(long )attr->addr;
@@ -978,12 +980,17 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr) filter.action != KVM_PMU_EVENT_DENY))return -EINVAL ; -mutex_lock (&vcpu->kvm->lock); +mutex_lock (&kvm->lock); + +if (kvm->arch.ran_once) { +mutex_unlock (&kvm->lock); +return -EBUSY ; + } -if (!vcpu->kvm->arch.pmu_filter) { - vcpu->kvm->arch.pmu_filter =bitmap_alloc (nr_events,GFP_KERNEL_ACCOUNT ); -if (!vcpu->kvm->arch.pmu_filter) { -mutex_unlock (&vcpu->kvm->lock); +if (!kvm->arch.pmu_filter) { + kvm->arch.pmu_filter =bitmap_alloc (nr_events,GFP_KERNEL_ACCOUNT ); +if (!kvm->arch.pmu_filter) { +mutex_unlock (&kvm->lock);return -ENOMEM ; }
@@ -994,17 +1001,17 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr)* events, the default is to allow. */ if (filter.action ==KVM_PMU_EVENT_ALLOW ) -bitmap_zero (vcpu->kvm->arch.pmu_filter, nr_events); +bitmap_zero (kvm->arch.pmu_filter, nr_events);else -bitmap_fill (vcpu->kvm->arch.pmu_filter, nr_events); +bitmap_fill (kvm->arch.pmu_filter, nr_events); }if (filter.action ==KVM_PMU_EVENT_ALLOW ) -bitmap_set (vcpu->kvm->arch.pmu_filter, filter.base_event, filter.nevents); +bitmap_set (kvm->arch.pmu_filter, filter.base_event, filter.nevents);else -bitmap_clear (vcpu->kvm->arch.pmu_filter, filter.base_event, filter.nevents); +bitmap_clear (kvm->arch.pmu_filter, filter.base_event, filter.nevents); -mutex_unlock (&vcpu->kvm->lock); +mutex_unlock (&kvm->lock);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 131/343 scsi: libfc: Fix use after free in fc_exch_abts_resp()
In reply to Greg Kroah-HartmanFrom: Jianglei Nie <[email protected]>
[ Upstream commit 271add11994ba1a334859069367e04d2be2ebdd4 ]
fc_exch_release(ep) will decrease the ep's reference count. When the reference count reaches zero, it is freed. But ep is still used in the following code, which will lead to a use after free.
Return after the fc_exch_release() call to avoid use after free.
--- drivers/scsi/libfc/fc_exch.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/libfc/fc_exch.c +1 -0
@@ -1701,6 +1701,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)if (cancel_delayed_work_sync (&ep->timeout_work)) {FC_EXCH_DBG (ep,"Exchange timer canceled due to ABTS response\n" );fc_exch_release (ep);/* release from pending timer hold */ +return ; }spin_lock_bh (&ep->ex_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 133/343 can: isotp: set default value for N_As to 50 micro seconds
In reply to Greg Kroah-HartmanFrom: Oliver Hartkopp <[email protected]>
[ Upstream commit 530e0d46c61314c59ecfdb8d3bcb87edbc0f85d3 ]
The N_As value describes the time a CAN frame needs on the wire when transmitted by the CAN controller. Even very short CAN FD frames need arround 100 usecs (bitrate 1Mbit/s, data bitrate 8Mbit/s).
Having N_As to be zero (the former default) leads to 'no CAN frame separation' when STmin is set to zero by the receiving node. This 'burst mode' should not be enabled by default as it could potentially dump a high number of CAN frames into the netdev queue from the soft hrtimer context. This does not affect the system stability but is just not nice and cooperative.
With this N_As/frame_txtime value the 'burst mode' is disabled by default.
As user space applications usually do not set the frame_txtime element of struct can_isotp_options the new in-kernel default is very likely overwritten with zero when the sockopt() CAN_ISOTP_OPTS is invoked. To make sure that a N_As value of zero is only set intentional the value '0' is now interpreted as 'do not change the current value'. When a frame_txtime of zero is required for testing purposes this CAN_ISOTP_FRAME_TXTIME_ZERO u32 value has to be set in frame_txtime.
--- include/uapi/linux/can/isotp.h | 28 ++++++++++++++++++++++------ net/can/isotp.c | 12 +++++++++++- 2 files changed, 33 insertions(+), 7 deletions(-)
include/uapi/linux/can/isotp.h +22 -6
@@ -137,20 +137,16 @@ struct can_isotp_ll_options {#define CAN_ISOTP_WAIT_TX_DONE 0x400/* wait for tx completion */ #define CAN_ISOTP_SF_BROADCAST 0x800/* 1-to-N functional addressing */ -/* default values */ +/* protocol machine default values */ #define CAN_ISOTP_DEFAULT_FLAGS 0#define CAN_ISOTP_DEFAULT_EXT_ADDRESS 0x00#define CAN_ISOTP_DEFAULT_PAD_CONTENT 0xCC/* prevent bit-stuffing */ -#define CAN_ISOTP_DEFAULT_FRAME_TXTIME 0 +#define CAN_ISOTP_DEFAULT_FRAME_TXTIME 50000/* 50 micro seconds */ #define CAN_ISOTP_DEFAULT_RECV_BS 0#define CAN_ISOTP_DEFAULT_RECV_STMIN 0x00#define CAN_ISOTP_DEFAULT_RECV_WFTMAX 0 -#define CAN_ISOTP_DEFAULT_LL_MTU CAN_MTU -#define CAN_ISOTP_DEFAULT_LL_TX_DL CAN_MAX_DLEN -#define CAN_ISOTP_DEFAULT_LL_TX_FLAGS 0 -/* * Remark on CAN_ISOTP_DEFAULT_RECV_* values: *
@@ -162,4 +158,24 @@ struct can_isotp_ll_options {* consistency and copied directly into the flow control (FC) frame. */ +/* link layer default values => make use of Classical CAN frames */ + +#define CAN_ISOTP_DEFAULT_LL_MTU CAN_MTU +#define CAN_ISOTP_DEFAULT_LL_TX_DL CAN_MAX_DLEN +#define CAN_ISOTP_DEFAULT_LL_TX_FLAGS 0 + +/* +* The CAN_ISOTP_DEFAULT_FRAME_TXTIME has become a non-zero value as +* it only makes sense for isotp implementation tests to run without +* a N_As value. As user space applications usually do not set the +* frame_txtime element of struct can_isotp_options the new in-kernel +* default is very likely overwritten with zero when the sockopt() +* CAN_ISOTP_OPTS is invoked. +* To make sure that a N_As value of zero is only set intentional the +* value '0' is now interpreted as 'do not change the current value'. +* When a frame_txtime of zero is required for testing purposes this +* CAN_ISOTP_FRAME_TXTIME_ZERO u32 value has to be set in frame_txtime. +*/ +#define CAN_ISOTP_FRAME_TXTIME_ZERO 0xFFFFFFFF +#endif /* !_UAPI_CAN_ISOTP_H */
net/can/isotp.c +11 -1
@@ -141,6 +141,7 @@ struct isotp_sock {struct can_isotp_options opt;struct can_isotp_fc_options rxfc, txfc;struct can_isotp_ll_options ll; +u32 frame_txtime;u32 force_tx_stmin;u32 force_rx_stmin;struct tpcon rx, tx;
@@ -360,7 +361,7 @@ static int isotp_rcv_fc(struct isotp_sock *so, struct canfd_frame *cf, int ae) so->tx_gap =ktime_set (0 ,0 );/* add transmission time for CAN frame N_As */ - so->tx_gap =ktime_add_ns (so->tx_gap, so->opt.frame_txtime); + so->tx_gap =ktime_add_ns (so->tx_gap, so->frame_txtime);/* add waiting time for consecutive frames N_Cs */ if (so->opt.flags &CAN_ISOTP_FORCE_TXSTMIN ) so->tx_gap = ktime_add_ns(so->tx_gap,
@@ -1247,6 +1248,14 @@ static int isotp_setsockopt_locked(struct socket *sock, int level, int optname,/* no separate rx_ext_address is given => use ext_address */ if (!(so->opt.flags &CAN_ISOTP_RX_EXT_ADDR )) so->opt.rx_ext_address = so->opt.ext_address; + +/* check for frame_txtime changes (0 => no changes) */ +if (so->opt.frame_txtime) { +if (so->opt.frame_txtime ==CAN_ISOTP_FRAME_TXTIME_ZERO ) + so->frame_txtime =0 ; +else + so->frame_txtime = so->opt.frame_txtime; + }break ;case CAN_ISOTP_RECV_FC :
@@ -1448,6 +1457,7 @@ static int isotp_init(struct sock *sk) so->opt.rxpad_content =CAN_ISOTP_DEFAULT_PAD_CONTENT ; so->opt.txpad_content =CAN_ISOTP_DEFAULT_PAD_CONTENT ; so->opt.frame_txtime =CAN_ISOTP_DEFAULT_FRAME_TXTIME ; + so->frame_txtime =CAN_ISOTP_DEFAULT_FRAME_TXTIME ; so->rxfc.bs =CAN_ISOTP_DEFAULT_RECV_BS ; so->rxfc.stmin =CAN_ISOTP_DEFAULT_RECV_STMIN ; so->rxfc.wftmax =CAN_ISOTP_DEFAULT_RECV_WFTMAX ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 132/343 platform/x86: x86-android-tablets: Depend on EFI and SPI
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 1e8aa2aa1274953e8e595f0630436744597d0d64 ]
The recently added support for Lenovo Yoga Tablet 2 tablets uses symbols from EFI and SPI add "depends on EFI && SPI" to the X86_ANDROID_TABLETS Kconfig entry.
--- drivers/platform/x86/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/Kconfig +1 -1
@@ -1027,7 +1027,7 @@ config TOUCHSCREEN_DMI config X86_ANDROID_TABLETS tristate "X86 Android tablet support" - depends on I2C && SERIAL_DEV_BUS && ACPI && GPIOLIB + depends on I2C && SPI && SERIAL_DEV_BUS && ACPI && EFI && GPIOLIB help X86 tablets which ship with Android as (part of) the factory image typically have various problems with their DSDTs. The factory kernels
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 128/343 powerpc/code-patching: Pre-map patch area
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
[ Upstream commit 591b4b268435f00d2f0b81f786c2c7bd5ef66416 ]
Paul reported a warning with DEBUG_ATOMIC_SLEEP=y:
BUG: sleeping function called from invalid context at include/linux/sched/mm.h:256
in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 1, name: swapper/0
preempt_count: 0, expected: 0
...
Call Trace:
dump_stack_lvl+0xa0/0xec (unreliable)
__might_resched+0x2f4/0x310
kmem_cache_alloc+0x220/0x4b0
__pud_alloc+0x74/0x1d0
hash__map_kernel_page+0x2cc/0x390
do_patch_instruction+0x134/0x4a0
arch_jump_label_transform+0x64/0x78
__jump_label_update+0x148/0x180
static_key_enable_cpuslocked+0xd0/0x120
static_key_enable+0x30/0x50
check_kvm_guest+0x60/0x88
pSeries_smp_probe+0x54/0xb0
smp_prepare_cpus+0x3e0/0x430
kernel_init_freeable+0x20c/0x43c
kernel_init+0x30/0x1a0
ret_from_kernel_thread+0x5c/0x64Peter pointed out that this is because do_patch_instruction() has disabled interrupts, but then map_patch_area() calls map_kernel_page() then hash__map_kernel_page() which does a sleeping memory allocation.
We only see the warning in KVM guests with SMT enabled, which is not particularly common, or on other platforms if CONFIG_KPROBES is disabled, also not common. The reason we don't see it in most configurations is that another path that happens to have interrupts enabled has allocated the required page tables for us, eg. there's a path in kprobes init that does that. That's just pure luck though.
As Christophe suggested, the simplest solution is to do a dummy map/unmap when we initialise the patching, so that any required page table levels are pre-allocated before the first call to do_patch_instruction(). This works because the unmap doesn't free any page tables that were allocated by the map, it just clears the PTE, leaving the page table levels there for the next map.
--- arch/powerpc/lib/code-patching.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/powerpc/lib/code-patching.c +14 -0
@@ -43,9 +43,14 @@ int raw_patch_instruction(u32 *addr, ppc_inst_t instr)#ifdef CONFIG_STRICT_KERNEL_RWX static DEFINE_PER_CPU(struct vm_struct *, text_poke_area); +static int map_patch_area (void *addr,unsigned long text_poke_addr); +static void unmap_patch_area (unsigned long addr); +static int text_area_cpu_up (unsigned int cpu) {struct vm_struct *area; +unsigned long addr; +int err; area =get_vm_area (PAGE_SIZE ,VM_ALLOC );if (!area) {
@@ -53,6 +58,15 @@ static int text_area_cpu_up(unsigned int cpu) cpu);return -1 ; } + +// Map/unmap the area to ensure all page tables are pre-allocated + addr = (unsigned long )area->addr; + err =map_patch_area (empty_zero_page, addr); +if (err) +return err; + +unmap_patch_area (addr); +this_cpu_write (text_poke_area, area);return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 129/343 powerpc/64e: Tie PPC_BOOK3E_64 to PPC_FSL_BOOK3E
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
[ Upstream commit 1a76e520ee1831a81dabf8a9a58c6453f700026e ]
Since the IBM A2 CPU support was removed, see commit fb5a515704d7 ("powerpc: Remove platforms/wsp and associated pieces"), the only 64-bit Book3E CPUs we support are Freescale (NXP) ones.
However our Kconfig still allows configurating a kernel that has 64-bit Book3E support, but no Freescale CPU support enabled. Such a kernel would never boot, it doesn't know about any CPUs.
It also causes build errors, as reported by lkp, because PPC_BARRIER_NOSPEC is not enabled in such a configuration:
powerpc64-linux-ld: arch/powerpc/net/bpf_jit_comp64.o:(.toc+0x0):
undefined reference to `powerpc_security_features'
To fix this, force PPC_FSL_BOOK3E to be selected whenever we are building a 64-bit Book3E kernel.
--- arch/powerpc/platforms/Kconfig.cputype | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/platforms/Kconfig.cputype +2 -1
@@ -107,6 +107,7 @@ config PPC_BOOK3S_64 config PPC_BOOK3E_64 bool "Embedded processors" + select PPC_FSL_BOOK3E select PPC_FPU # Make it a choice ? select PPC_SMP_MUXED_IPI select PPC_DOORBELL
@@ -295,7 +296,7 @@ config FSL_BOOKE config PPC_FSL_BOOK3E bool select ARCH_SUPPORTS_HUGETLBFS if PHYS_64BIT || PPC64 - select FSL_EMB_PERFMON + imply FSL_EMB_PERFMON select PPC_SMP_MUXED_IPI select PPC_DOORBELL select PPC_KUEP
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 141/343 net: sfp: add 2500base-X quirk for Lantech SFP module
In reply to Greg Kroah-HartmanFrom: Michael Walle <[email protected]>
[ Upstream commit 00eec9fe4f3b9588b4bfa8ef9dd0aae96407d5d7 ]
The Lantech 8330-262D-E module is 2500base-X capable, but it reports the nominal bitrate as 2500MBd instead of 3125MBd. Add a quirk for the module.
The following in an EEPROM dump of such a SFP with the serial number redacted:
00: 03 04 07 00 00 00 01 20 40 0c 05 01 19 00 00 00 ???...? @????...
10: 1e 0f 00 00 4c 61 6e 74 65 63 68 20 20 20 20 20 ??..Lantech
20: 20 20 20 20 00 00 00 00 38 33 33 30 2d 32 36 32 ....8330-262
30: 44 2d 45 20 20 20 20 20 56 31 2e 30 03 52 00 cb D-E V1.0?R.?
40: 00 1a 00 00 46 43 XX XX XX XX XX XX XX XX XX XX .?..FCXXXXXXXXXX
50: 20 20 20 20 32 32 30 32 31 34 20 20 68 b0 01 98 220214 h???
60: 45 58 54 52 45 4d 45 4c 59 20 43 4f 4d 50 41 54 EXTREMELY COMPAT
70: 49 42 4c 45 20 20 20 20 20 20 20 20 20 20 20 20 IBLE
--- drivers/net/phy/sfp-bus.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/phy/sfp-bus.c +6 -0
@@ -74,6 +74,12 @@ static const struct sfp_quirk sfp_quirks[] = { .vendor = "HUAWEI", .part = "MA5671A", .modes = sfp_quirk_2500basex, + }, { +// Lantech 8330-262D-E can operate at 2500base-X, but +// incorrectly report 2500MBd NRZ in their EEPROM + .vendor = "Lantech", + .part = "8330-262D-E", + .modes = sfp_quirk_2500basex, }, { .vendor = "UBNT", .part = "UF-INSTANT",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 159/343 staging: vchiq_core: handle NULL result of find_service_by_handle
In reply to Greg Kroah-HartmanFrom: Stefan Wahren <[email protected]>
[ Upstream commit ca225857faf237234d2fffe5d1919467dfadd822 ]
In case of an invalid handle the function find_servive_by_handle returns NULL. So take care of this and avoid a NULL pointer dereference.
--- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +6 -0
@@ -2306,6 +2306,9 @@ void vchiq_msg_queue_push(unsigned int handle, struct vchiq_header *header)struct vchiq_service *service =find_service_by_handle (handle);int pos; +if (!service) +return ; +while (service->msg_queue_write == service->msg_queue_read +VCHIQ_MAX_SLOTS ) {if (wait_for_completion_interruptible (&service->msg_queue_pop))
@@ -2326,6 +2329,9 @@ struct vchiq_header *vchiq_msg_hold(unsigned int handle)struct vchiq_header *header;int pos; +if (!service) +return NULL ; +if (service->msg_queue_write == service->msg_queue_read)return NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 116/343 net/smc: correct settings of RMB window update limit
In reply to Greg Kroah-HartmanFrom: Dust Li <[email protected]>
[ Upstream commit 6bf536eb5c8ca011d1ff57b5c5f7c57ceac06a37 ]
rmbe_update_limit is used to limit announcing receive window updating too frequently. RFC7609 request a minimal increase in the window size of 10% of the receive buffer space. But current implementation used:
min_t(int, rmbe_size / 10, SOCK_MIN_SNDBUF / 2)
and SOCK_MIN_SNDBUF / 2 == 2304 Bytes, which is almost always less then 10% of the receive buffer space.
This causes the receiver always sending CDC message to update its consumer cursor when it consumes more then 2K of data. And as a result, we may encounter something like "TCP silly window syndrome" when sending 2.5~8K message.
This patch fixes this using max(rmbe_size / 10, SOCK_MIN_SNDBUF / 2).
With this patch and SMC autocorking enabled, qperf 2K/4K/8K tcp_bw test shows 45%/75%/40% increase in throughput respectively.
--- net/smc/smc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/smc_core.c +1 -1
@@ -1989,7 +1989,7 @@ static struct smc_buf_desc *smc_buf_get_slot(int compressed_bufsize,*/ static inline int smc_rmb_wnd_update_limit (int rmbe_size) { -return min_t (int, rmbe_size /10 ,SOCK_MIN_SNDBUF /2 ); +return max_t (int, rmbe_size /10 ,SOCK_MIN_SNDBUF /2 ); }/* map an rmb buf to a link */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 222/343 bnxt_en: Synchronize tx when xdp redirects happen on same ring
In reply to Greg Kroah-HartmanFrom: Pavan Chebbi <[email protected]>
[ Upstream commit 4f81def272de17dc4bbd89ac38f49b2676c9b3d2 ]
If there are more CPUs than the number of TX XDP rings, multiple XDP redirects can select the same TX ring based on the CPU on which XDP redirect is called. Add locking when needed and use static key to decide whether to take the lock.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 +++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 8 ++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 2 ++ 4 files changed, 19 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +7 -0
@@ -3224,6 +3224,7 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp) } qidx = bp->tc_to_qidx[j]; ring->queue_id = bp->q_info[qidx].queue_id; +spin_lock_init (&txr->xdp_tx_lock);if (i < bp->tx_nr_rings_xdp)continue ;if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc -1 ))
@@ -10294,6 +10295,12 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)if (irq_re_init)udp_tunnel_nic_reset_ntf (bp->dev); +if (bp->tx_nr_rings_xdp <num_possible_cpus ()) { +if (!static_key_enabled (&bnxt_xdp_locking_key)) +static_branch_enable (&bnxt_xdp_locking_key); + }else if (static_key_enabled (&bnxt_xdp_locking_key)) { +static_branch_disable (&bnxt_xdp_locking_key); + }set_bit (BNXT_STATE_OPEN , &bp->state);bnxt_enable_int (bp);/* Enable TX queues */
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
@@ -800,6 +800,8 @@ struct bnxt_tx_ring_info {u32 dev_state;struct bnxt_ring_struct tx_ring_struct; +/* Synchronize simultaneous xdp_xmit on same ring */ +spinlock_t xdp_tx_lock; };#define BNXT_LEGACY_COAL_CMPL_PARAMS \
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +8 -0
@@ -20,6 +20,8 @@#include "bnxt.h" #include "bnxt_xdp.h" +DEFINE_STATIC_KEY_FALSE (bnxt_xdp_locking_key); +struct bnxt_sw_tx_bd *bnxt_xmit_bd (struct bnxt *bp,struct bnxt_tx_ring_info *txr,dma_addr_t mapping,u32 len)
@@ -227,6 +229,9 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames, ring =smp_processor_id () % bp->tx_nr_rings_xdp; txr = &bp->tx_ring[ring]; +if (static_branch_unlikely (&bnxt_xdp_locking_key)) +spin_lock (&txr->xdp_tx_lock); +for (i =0 ; i < num_frames; i++) {struct xdp_frame *xdp = frames[i];
@@ -250,6 +255,9 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames,bnxt_db_write (bp, &txr->tx_db, txr->tx_prod); } +if (static_branch_unlikely (&bnxt_xdp_locking_key)) +spin_unlock (&txr->xdp_tx_lock); +return nxmit; }
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +2 -0
@@ -10,6 +10,8 @@#ifndef BNXT_XDP_H #define BNXT_XDP_H +DECLARE_STATIC_KEY_FALSE (bnxt_xdp_locking_key); +struct bnxt_sw_tx_bd *bnxt_xmit_bd (struct bnxt *bp,struct bnxt_tx_ring_info *txr,dma_addr_t mapping,u32 len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 223/343 bnxt_en: reserve space inside receive page for skb_shared_info
In reply to Greg Kroah-HartmanFrom: Andy Gospodarek <[email protected]>
[ Upstream commit facc173cf700e55b2ad249ecbd3a7537f7315691 ]
Insufficient space was being reserved in the page used for packet reception, so the interface MTU could be set too large to still have room for the contents of the packet when doing XDP redirect. This resulted in the following message when redirecting a packet between 3520 and 3822 bytes with an MTU of 3822:
[311815.561880] XDP_WARN: xdp_update_frame_from_buff(line:200): Driver BUG: missing reserved tailroom
--- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -1
@@ -593,7 +593,8 @@ struct nqe_cn {#define BNXT_MAX_MTU 9500#define BNXT_MAX_PAGE_MODE_MTU \ ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \ - XDP_PACKET_HEADROOM) + XDP_PACKET_HEADROOM - \ + SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info)))#define BNXT_MIN_PKT_SIZE 52
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 269/343 mmc: renesas_sdhi: special 4tap settings only apply to HS400
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
commit 46d4820f949a3030b19ee482c68a50b06dd27590 upstream.
Previous documentation was vague, so we included SDR104 for slow SDnH clock settings. It turns out now, that it is only needed for HS400.
--- drivers/mmc/host/renesas_sdhi_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/renesas_sdhi_core.c +2 -2
@@ -144,9 +144,9 @@ static unsigned int renesas_sdhi_clk_updreturn clk_get_rate (priv->clk);if (priv->clkh) { +/* HS400 with 4TAP needs different clock settings */ bool use_4tap = priv->quirks && priv->quirks->hs400_4taps; -bool need_slow_clkh = (host->mmc->ios.timing ==MMC_TIMING_UHS_SDR104 ) || - (host->mmc->ios.timing ==MMC_TIMING_MMC_HS400 ); +bool need_slow_clkh = host->mmc->ios.timing ==MMC_TIMING_MMC_HS400 ; clkh_shift = use_4tap && need_slow_clkh ?1 :2 ; ref_clk = priv->clkh; }
Greg Kroah-Hartman
maintainerPATCH 342/343 io_uring: defer file assignment
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 6bf9c47a398911e0ab920e362115153596c80432 upstream.
If an application uses direct open or accept, it knows in advance what direct descriptor value it will get as it picks it itself. This allows combined requests such as:
sqe = io_uring_get_sqe(ring); io_uring_prep_openat_direct(sqe, ..., file_slot); sqe->flags |= IOSQE_IO_LINK | IOSQE_CQE_SKIP_SUCCESS;
sqe = io_uring_get_sqe(ring); io_uring_prep_read(sqe,file_slot, buf, buf_size, 0); sqe->flags |= IOSQE_FIXED_FILE;
io_uring_submit(ring);
where we prepare both a file open and read, and only get a completion event for the read when both have completed successfully.
Currently links are fully prepared before the head is issued, but that fails if the dependent link needs a file assigned that isn't valid until the head has completed.
Conversely, if the same chain is performed but the fixed file slot is already valid, then we would be unexpectedly returning data from the old file slot rather than the newly opened one. Make sure we're consistent here.
Allow deferral of file setup, which makes this documented case work.
--- fs/io-wq.h | 1 + fs/io_uring.c | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-)
fs/io-wq.h +1 -0
@@ -155,6 +155,7 @@ struct io_wq_work_node *wq_stack_extractstruct io_wq_work {struct io_wq_work_node list;unsigned flags; +int fd; };static inline struct io_wq_work *wq_next_work (struct io_wq_work *work)
fs/io_uring.c +29 -10
@@ -6745,6 +6745,23 @@ static void io_clean_op(struct io_kiocb req->flags &= ~IO_REQ_CLEAN_FLAGS ; } +static bool io_assign_file (struct io_kiocb *req,unsigned int issue_flags) +{ +if (req->file || !io_op_defs[req->opcode].needs_file) +return true; + +if (req->flags &REQ_F_FIXED_FILE ) + req->file =io_file_get_fixed (req, req->work.fd, issue_flags); +else + req->file =io_file_get_normal (req, req->work.fd); +if (req->file) +return true; + +req_set_fail (req); + req->result = -EBADF ; +return false; +} +static int io_issue_sqe (struct io_kiocb *req,unsigned int issue_flags) {const struct cred *creds =NULL ;
@@ -6755,6 +6772,8 @@ static int io_issue_sqe(struct io_kiocbif (!io_op_defs[req->opcode].audit_skip)audit_uring_entry (req->opcode); +if (unlikely (!io_assign_file (req, issue_flags))) +return -EBADF ;switch (req->opcode) {case IORING_OP_NOP :
@@ -6896,10 +6915,11 @@ static struct io_wq_work *io_wq_free_worstatic void io_wq_submit_work (struct io_wq_work *work) { struct io_kiocb *req = container_of(work, struct io_kiocb, work); +const struct io_op_def *def = &io_op_defs[req->opcode];unsigned int issue_flags =IO_URING_F_UNLOCKED ;bool needs_poll = false;struct io_kiocb *timeout; -int ret =0 ; +int ret =0 , err = -ECANCELED ;/* one will be dropped by ->io_free_work() after returning to io-wq */ if (!(req->flags &REQ_F_REFCOUNT ))
@@ -6911,14 +6931,18 @@ static void io_wq_submit_work(struct io_if (timeout)io_queue_linked_timeout (timeout); +if (!io_assign_file (req, issue_flags)) { + err = -EBADF ; + work->flags |=IO_WQ_WORK_CANCEL ; + } +/* either cancelled or io-wq is dying, so don't touch tctx->iowq */ if (work->flags &IO_WQ_WORK_CANCEL ) { -io_req_task_queue_fail (req, -ECANCELED ); +io_req_task_queue_fail (req, err);return ; }if (req->flags &REQ_F_FORCE_ASYNC ) { -const struct io_op_def *def = &io_op_defs[req->opcode];bool opcode_poll = def->pollin || def->pollout;if (opcode_poll &&file_can_poll (req->file)) {
@@ -7249,6 +7273,8 @@ static int io_init_req(struct io_ring_ctif (io_op_defs[opcode].needs_file) {struct io_submit_state *state = &ctx->submit_state; + req->work.fd =READ_ONCE (sqe->fd); +/* * Plug now if we have more than 2 IO left after this, and the * target is potentially a read/write to block based storage.
@@ -7258,13 +7284,6 @@ static int io_init_req(struct io_ring_ct state->need_plug = false;blk_start_plug_nr_ios (&state->plug, state->submit_nr); } - -if (req->flags &REQ_F_FIXED_FILE ) - req->file =io_file_get_fixed (req,READ_ONCE (sqe->fd),0 ); -else - req->file =io_file_get_normal (req,READ_ONCE (sqe->fd)); -if (unlikely (!req->file)) -return -EBADF ; } personality =READ_ONCE (sqe->personality);
Greg Kroah-Hartman
maintainerPATCH 282/343 perf/x86/intel: Update the FRONTEND MSR mask on Sapphire Rapids
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit e590928de7547454469693da9bc7ffd562e54b7e upstream.
On Sapphire Rapids, the FRONTEND_RETIRED.MS_FLOWS event requires the FRONTEND MSR value 0x8. However, the current FRONTEND MSR mask doesn't support it.
Update intel_spr_extra_regs[] to support it.
--- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/core.c +1 -1
@@ -281,7 +281,7 @@ static struct extra_reg intel_spr_extra_INTEL_UEVENT_EXTRA_REG (0x012a ,MSR_OFFCORE_RSP_0 ,0x3fffffffffull ,RSP_0 ),INTEL_UEVENT_EXTRA_REG (0x012b ,MSR_OFFCORE_RSP_1 ,0x3fffffffffull ,RSP_1 ),INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG (0x01cd ), -INTEL_UEVENT_EXTRA_REG (0x01c6 ,MSR_PEBS_FRONTEND ,0x7fff17 ,FE ), +INTEL_UEVENT_EXTRA_REG (0x01c6 ,MSR_PEBS_FRONTEND ,0x7fff1f ,FE ),INTEL_UEVENT_EXTRA_REG (0x40ad ,MSR_PEBS_FRONTEND ,0x7 ,FE ),INTEL_UEVENT_EXTRA_REG (0x04c2 ,MSR_PEBS_FRONTEND ,0x8 ,FE ),EVENT_EXTRA_END
Greg Kroah-Hartman
maintainerPATCH 319/343 bpf: Treat bpf_sk_lookup remote_port as a 2-byte field
In reply to Greg Kroah-HartmanFrom: Jakub Sitnicki <[email protected]>
commit 058ec4a7d9cf77238c73ad9f1e1a3ed9a29afcab upstream.
In commit 9a69e2b385f4 ("bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide") the remote_port field has been split up and re-declared from u32 to be16.
However, the accompanying changes to the context access converter have not been well thought through when it comes big-endian platforms.
Today 2-byte wide loads from offsetof(struct bpf_sk_lookup, remote_port) are handled as narrow loads from a 4-byte wide field.
This by itself is not enough to create a problem, but when we combine
1. 32-bit wide access to ->remote_port backed by a 16-wide wide load, with
2. inherent difference between litte- and big-endian in how narrow loads need have to be handled (see bpf_ctx_narrow_access_offset),
we get inconsistent results for a 2-byte loads from &ctx->remote_port on LE and BE architectures. This in turn makes BPF C code for the common case of 2-byte load from ctx->remote_port not portable.
To rectify it, inform the context access converter that remote_port is 2-byte wide field, and only 1-byte loads need to be treated as narrow loads.
At the same time, we special-case the 4-byte load from &ctx->remote_port to continue handling it the same way as do today, in order to keep the existing BPF programs working.
--- net/core/filter.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
net/core/filter.c +18 -2
@@ -10621,13 +10621,24 @@ static bool sk_lookup_is_valid_access(in case bpf_ctx_range(struct bpf_sk_lookup, local_ip4): case bpf_ctx_range_till(struct bpf_sk_lookup, remote_ip6[0], remote_ip6[3]): case bpf_ctx_range_till(struct bpf_sk_lookup, local_ip6[0], local_ip6[3]): - case offsetof(struct bpf_sk_lookup, remote_port) ... - offsetof(struct bpf_sk_lookup , local_ip4) -1 : case bpf_ctx_range(struct bpf_sk_lookup, local_port): case bpf_ctx_range(struct bpf_sk_lookup, ingress_ifindex):bpf_ctx_record_field_size (info,sizeof (__u32));return bpf_ctx_narrow_access_ok (off, size,sizeof (__u32)); + case bpf_ctx_range(struct bpf_sk_lookup, remote_port): +/* Allow 4-byte access to 2-byte field for backward compatibility */ +if (size ==sizeof (__u32)) +return true; +bpf_ctx_record_field_size (info,sizeof (__be16)); +return bpf_ctx_narrow_access_ok (off, size,sizeof (__be16)); + + case offsetofend(struct bpf_sk_lookup, remote_port) ... + offsetof(struct bpf_sk_lookup, local_ip4) - 1: +/* Allow access to zero padding for backward compatibility */ +bpf_ctx_record_field_size (info,sizeof (__u16)); +return bpf_ctx_narrow_access_ok (off, size,sizeof (__u16)); +default :return false; }
@@ -10709,6 +10720,11 @@ static u32 sk_lookup_convert_ctx_access( sport, 2, target_size));break ; + case offsetofend(struct bpf_sk_lookup, remote_port): + *target_size =2 ; + *insn++ =BPF_MOV32_IMM (si->dst_reg,0 ); +break ; +case offsetof(struct bpf_sk_lookup , local_port): *insn++ = BPF_LDX_MEM(BPF_H, si->dst_reg, si->src_reg, bpf_target_off(struct bpf_sk_lookup_kern,
Greg Kroah-Hartman
maintainerPATCH 336/343 powerpc/64: Fix build failure with allyesconfig in book3s_64_entry.S
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit af41d2866f7d75bbb38d487f6ec7770425d70e45 upstream.
Using conditional branches between two files is hasardous, they may get linked too far from each other.
arch/powerpc/kvm/book3s_64_entry.o:(.text+0x3ec): relocation truncated to fit: R_PPC64_REL14 (stub) against symbol `system_reset_common' defined in .text section in arch/powerpc/kernel/head_64.o
Reorganise the code to use non conditional branches.
--- arch/powerpc/kvm/book3s_64_entry.S | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_entry.S +8 -2
@@ -414,10 +414,16 @@ END_FTR_SECTION_IFSET(CPU_FTR_DAWR1) */ ld r10,HSTATE_SCRATCH0(r13) cmpwi r10,BOOK3S_INTERRUPT_MACHINE_CHECK - beq machine_check_common + beq .Lcall_machine_check_common cmpwi r10,BOOK3S_INTERRUPT_SYSTEM_RESET - beq system_reset_common + beq .Lcall_system_reset_common b . + +.Lcall_machine_check_common: + b machine_check_common + +.Lcall_system_reset_common: + b system_reset_common #endif
Greg Kroah-Hartman
maintainerPATCH 337/343 irqchip/gic, gic-v3: Prevent GSI to SGI translations
In reply to Greg Kroah-HartmanFrom: Andre Przywara <[email protected]>
commit 544808f7e21cb9ccdb8f3aa7de594c05b1419061 upstream.
At the moment the GIC IRQ domain translation routine happily converts ACPI table GSI numbers below 16 to GIC SGIs (Software Generated Interrupts aka IPIs). On the Devicetree side we explicitly forbid this translation, actually the function will never return HWIRQs below 16 when using a DT based domain translation.
We expect SGIs to be handled in the first part of the function, and any further occurrence should be treated as a firmware bug, so add a check and print to report this explicitly and avoid lengthy debug sessions.
--- drivers/irqchip/irq-gic-v3.c | 6 ++++++ drivers/irqchip/irq-gic.c | 6 ++++++ 2 files changed, 12 insertions(+)
drivers/irqchip/irq-gic-v3.c +6 -0
@@ -1466,6 +1466,12 @@ static int gic_irq_domain_translate(struif (fwspec->param_count !=2 )return -EINVAL ; +if (fwspec->param[0 ] <16 ) { +pr_err (FW_BUG "Illegal GSI%d translation request\n" , + fwspec->param[0 ]); +return -EINVAL ; + } + *hwirq = fwspec->param[0 ]; *type = fwspec->param[1 ];
drivers/irqchip/irq-gic.c +6 -0
@@ -1085,6 +1085,12 @@ static int gic_irq_domain_translate(struif (fwspec->param_count !=2 )return -EINVAL ; +if (fwspec->param[0 ] <16 ) { +pr_err (FW_BUG "Illegal GSI%d translation request\n" , + fwspec->param[0 ]); +return -EINVAL ; + } + *hwirq = fwspec->param[0 ]; *type = fwspec->param[1 ];
Greg Kroah-Hartman
maintainerPATCH 280/343 x86/pm: Save the MSR validity status at context setup
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 73924ec4d560257004d5b5116b22a3647661e364 upstream.
The mechanism to save/restore MSRs during S3 suspend/resume checks for the MSR validity during suspend, and only restores the MSR if its a valid MSR. This is not optimal, as an invalid MSR will unnecessarily throw an exception for every suspend cycle. The more invalid MSRs, higher the impact will be.
Check and save the MSR validity at setup. This ensures that only valid MSRs that are guaranteed to not throw an exception will be attempted during suspend.
--- arch/x86/power/cpu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/power/cpu.c +5 -2
@@ -40,7 +40,8 @@ static void msr_save_context(struct savestruct saved_msr *end = msr + ctxt->saved_msrs.num;while (msr < end) { - msr->valid = !rdmsrl_safe (msr->info.msr_no, &msr->info.reg.q); +if (msr->valid) +rdmsrl (msr->info.msr_no, msr->info.reg.q); msr++; } }
@@ -424,8 +425,10 @@ static int msr_build_context(const u32 * }for (i = saved_msrs->num, j =0 ; i < total_num; i++, j++) { +u64 dummy; + msr_array[i].info.msr_no = msr_id[j]; - msr_array[i].valid = false; + msr_array[i].valid = !rdmsrl_safe (msr_id[j], &dummy); msr_array[i].info.reg.q =0 ; } saved_msrs->num = total_num;
Greg Kroah-Hartman
maintainerPATCH 303/343 amd/display: set backlight only if required
In reply to Greg Kroah-HartmanFrom: Shirish S <[email protected]>
commit 4052287a75eb3fc0f487fcc5f768a38bede455c8 upstream.
[Why]
comparing pwm bl values (coverted) with user brightness(converted) levels in commit_tail leads to continuous setting of backlight via dmub as they don't to match.
This leads overdrive in queuing of commands to DMCU that sometimes lead to depending on load on DMCU fw:
"[drm:dc_dmub_srv_wait_idle] *ERROR* Error waiting for DMUB idle: status=3"
[How]
Store last successfully set backlight value and compare with it instead of pwm reads which is not what we should compare with.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 ++++--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -3
@@ -3951,7 +3951,7 @@ static u32 convert_brightness_to_user(co max - min); } -static int amdgpu_dm_backlight_set_level (struct amdgpu_display_manager *dm, +static void amdgpu_dm_backlight_set_level (struct amdgpu_display_manager *dm,int bl_idx,u32 user_brightness) {
@@ -3982,7 +3982,8 @@ static int amdgpu_dm_backlight_set_levelDRM_DEBUG ("DM: Failed to update backlight on eDP[%d]\n" , bl_idx); } -return rc ?0 :1 ; +if (rc) + dm->actual_brightness[bl_idx] = user_brightness; }static int amdgpu_dm_backlight_update_status (struct backlight_device *bd)
@@ -9914,7 +9915,7 @@ static void amdgpu_dm_atomic_commit_tail/* restore the backlight level */ for (i =0 ; i < dm->num_of_edps; i++) {if (dm->backlight_dev[i] && - (amdgpu_dm_backlight_get_level (dm, i) != dm->brightness[i])) + (dm->actual_brightness[i] != dm->brightness[i]))amdgpu_dm_backlight_set_level (dm, i, dm->brightness[i]); }#endif
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +6 -0
@@ -540,6 +540,12 @@ struct amdgpu_display_manager {* cached backlight values. */ u32 brightness[AMDGPU_DM_MAX_NUM_EDP ]; +/** +* @actual_brightness: +* +* last successfully applied backlight values. +*/ +u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP ]; };enum dsc_clock_force_state {
Greg Kroah-Hartman
maintainerPATCH 316/343 Revert "selftests: net: Add tls config dependency for tls selftests"
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
commit 20695e9a9fd39103d1b0669470ae74030b7aa196 upstream.
This reverts commit d9142e1cf3bbdaf21337767114ecab26fe702d47.
The test is supposed to run cleanly with TLS is disabled, to test compatibility with TCP behavior. I can't repro the failure [1], the problem should be debugged rather than papered over.
--- tools/testing/selftests/net/config | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/net/config +0 -1
@@ -43,6 +43,5 @@ CONFIG_NET_ACT_TUNNEL_KEY=m CONFIG_NET_ACT_MIRRED=m CONFIG_BAREUDP=m CONFIG_IPV6_IOAM6_LWTUNNEL=y -CONFIG_TLS=m CONFIG_CRYPTO_SM4=y CONFIG_AMT=m
Greg Kroah-Hartman
maintainerPATCH 300/343 perf/core: Inherit event_caps
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
commit e3265a4386428d3d157d9565bb520aabff8b4bf0 upstream.
It was reported that some perf event setup can make fork failed on ARM64. It was the case of a group of mixed hw and sw events and it failed in perf_event_init_task() due to armpmu_event_init().
The ARM PMU code checks if all the events in a group belong to the same PMU except for software events. But it didn't set the event_caps of inherited events and no longer identify them as software events. Therefore the test failed in a child process.
A simple reproducer is:
$ perf stat -e '{cycles,cs,instructions}' perf bench sched messaging
# Running 'sched/messaging' benchmark:
perf: fork(): Invalid argumentThe perf stat was fine but the perf bench failed in fork(). Let's inherit the event caps from the parent.
--- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/events/core.c +3 -0
@@ -11640,6 +11640,9 @@ perf_event_alloc(struct perf_event_attr event->state =PERF_EVENT_STATE_INACTIVE ; +if (parent_event) + event->event_caps = parent_event->event_caps; +if (event->attr.sigtrap)atomic_set (&event->event_limit,1 );
Greg Kroah-Hartman
maintainerPATCH 306/343 drm/amdgpu/display: change pipe policy for DCN 2.1
In reply to Greg Kroah-HartmanFrom: Benjamin Marty <[email protected]>
commit 879791ad8bf3dc5453061cad74776a617b6e3319 upstream.
Fixes crash on MST Hub disconnect.
--- drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c +1 -1
@@ -873,7 +873,7 @@ static const struct dc_debug_options deb .clock_trace = true, .disable_pplib_clock_request = true, .min_disp_clk_khz = 100000, - .pipe_split_policy = MPC_SPLIT_DYNAMIC, + .pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP, .force_single_disp_pipe_split = false, .disable_dcc = DCC_ENABLE, .vsr_support = true,
Greg Kroah-Hartman
maintainerPATCH 307/343 drm/amdgpu/smu10: fix SoC/fclk units in auto mode
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 2f25d8ce09b7ba5d769c132ba3d4eb84a941d2cb upstream.
SMU takes clock limits in Mhz units. socclk and fclk were using 10 khz units in some cases. Switch to Mhz units. Fixes higher than required SoC clocks.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +4 -4
@@ -773,13 +773,13 @@ static int smu10_dpm_force_dpm_level(strsmum_send_msg_to_smc_with_parameter (hwmgr, PPSMC_MSG_SetHardMinFclkByFreq, hwmgr->display_config->num_display >3 ? - data->clock_vol_info.vdd_dep_on_fclk->entries[0 ].clk : + (data->clock_vol_info.vdd_dep_on_fclk->entries[0 ].clk /100 ) : min_mclk,NULL );smum_send_msg_to_smc_with_parameter (hwmgr, PPSMC_MSG_SetHardMinSocclkByFreq, - data->clock_vol_info.vdd_dep_on_socclk->entries[0 ].clk, + data->clock_vol_info.vdd_dep_on_socclk->entries[0 ].clk /100 ,NULL ); smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetHardMinVcn,
@@ -792,11 +792,11 @@ static int smu10_dpm_force_dpm_level(str NULL);smum_send_msg_to_smc_with_parameter (hwmgr, PPSMC_MSG_SetSoftMaxFclkByFreq, - data->clock_vol_info.vdd_dep_on_fclk->entries[index_fclk].clk, + data->clock_vol_info.vdd_dep_on_fclk->entries[index_fclk].clk /100 ,NULL );smum_send_msg_to_smc_with_parameter (hwmgr, PPSMC_MSG_SetSoftMaxSocclkByFreq, - data->clock_vol_info.vdd_dep_on_socclk->entries[index_socclk].clk, + data->clock_vol_info.vdd_dep_on_socclk->entries[index_socclk].clk /100 ,NULL ); smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetSoftMaxVcn,
Greg Kroah-Hartman
maintainerPATCH 291/343 arm64: patch_text: Fixup last cpu should be master
In reply to Greg Kroah-HartmanFrom: Guo Ren <[email protected]>
commit 31a099dbd91e69fcab55eef4be15ed7a8c984918 upstream.
These patch_text implementations are using stop_machine_cpuslocked infrastructure with atomic cpu_count. The original idea: When the master CPU patch_text, the others should wait for it. But current implementation is using the first CPU as master, which couldn't guarantee the remaining CPUs are waiting. This patch changes the last CPU as the master to solve the potential risk.
--- arch/arm64/kernel/patching.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/patching.c +2 -2
@@ -117,8 +117,8 @@ static int __kprobes aarch64_insn_patch_int i, ret =0 ;struct aarch64_insn_patch *pp = arg; -/* The first CPU becomes master */ -if (atomic_inc_return (&pp->cpu_count) ==1 ) { +/* The last CPU becomes master */ +if (atomic_inc_return (&pp->cpu_count) ==num_online_cpus ()) {for (i =0 ; ret ==0 && i < pp->insn_cnt; i++) ret =aarch64_insn_patch_text_nosync (pp->text_addrs[i], pp->new_insns[i]);
Greg Kroah-Hartman
maintainerPATCH 292/343 RDMA/hfi1: Fix use-after-free bug for mm struct
In reply to Greg Kroah-HartmanFrom: Douglas Miller <[email protected]>
commit 2bbac98d0930e8161b1957dc0ec99de39ade1b3c upstream.
Under certain conditions, such as MPI_Abort, the hfi1 cleanup code may represent the last reference held on the task mm. hfi1_mmu_rb_unregister() then drops the last reference and the mm is freed before the final use in hfi1_release_user_pages(). A new task may allocate the mm structure while it is still being used, resulting in problems. One manifestation is corruption of the mmap_sem counter leading to a hang in down_write(). Another is corruption of an mm struct that is in use by another task.
--- drivers/infiniband/hw/hfi1/mmu_rb.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/infiniband/hw/hfi1/mmu_rb.c +6 -0
@@ -80,6 +80,9 @@ void hfi1_mmu_rb_unregister(struct mmu_runsigned long flags;struct list_head del_list; +/* Prevent freeing of mm until we are completely finished. */ +mmgrab (handler->mn.mm); +/* Unregister first so we don't get any more notifications. */ mmu_notifier_unregister (&handler->mn, handler->mn.mm);
@@ -102,6 +105,9 @@ void hfi1_mmu_rb_unregister(struct mmu_rdo_remove (handler, &del_list); +/* Now the mm may be freed. */ +mmdrop (handler->mn.mm); +kfree (handler); }
Greg Kroah-Hartman
maintainerPATCH 295/343 x86/msi: Fix msi message data shadow struct
In reply to Greg Kroah-HartmanFrom: Reto Buerki <[email protected]>
commit 59b18a1e65b7a2134814106d0860010e10babe18 upstream.
The x86 MSI message data is 32 bits in total and is either in compatibility or remappable format, see Intel Virtualization Technology for Directed I/O, section 5.1.2.
--- arch/x86/include/asm/msi.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
arch/x86/include/asm/msi.h +11 -8
@@ -12,14 +12,17 @@ int pci_msi_prepare(struct irq_domain *d/* Structs and defines for the X86 specific MSI message format */ typedef struct x86_msi_data { -u32 vector :8 , - delivery_mode :3 , - dest_mode_logical :1 , - reserved :2 , - active_low :1 , - is_level :1 ; - -u32 dmar_subhandle; +union { +struct { +u32 vector :8 , + delivery_mode :3 , + dest_mode_logical :1 , + reserved :2 , + active_low :1 , + is_level :1 ; + }; +u32 dmar_subhandle; + }; } __attribute__ ((packed))arch_msi_msg_data_t ;#define arch_msi_msg_data x86_msi_data
Greg Kroah-Hartman
maintainerPATCH 301/343 irqchip/gic-v3: Fix GICR_CTLR.RWP polling
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit 0df6664531a12cdd8fc873f0cac0dcb40243d3e9 upstream.
It turns out that our polling of RWP is totally wrong when checking for it in the redistributors, as we test the *distributor* bit index, whereas it is a different bit number in the RDs... Oopsie boo.
This is embarassing. Not only because it is wrong, but also because it took *8 years* to notice the blunder...
Just fix the damn thing.
--- drivers/irqchip/irq-gic-v3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3.c +4 -4
@@ -206,11 +206,11 @@ static inline void __iomem *gic_dist_bas } } -static void gic_do_wait_for_rwp (void __iomem *base) +static void gic_do_wait_for_rwp (void __iomem *base,u32 bit) {u32 count =1000000 ;/* 1s! */ -while (readl_relaxed (base +GICD_CTLR ) &GICD_CTLR_RWP ) { +while (readl_relaxed (base +GICD_CTLR ) & bit) { count--;if (!count) {pr_err_ratelimited ("RWP timeout, gone fishing\n" );
@@ -224,13 +224,13 @@ static void gic_do_wait_for_rwp(void __i/* Wait for completion of a distributor change */ static void gic_dist_wait_for_rwp (void ) { -gic_do_wait_for_rwp (gic_data.dist_base); +gic_do_wait_for_rwp (gic_data.dist_base,GICD_CTLR_RWP ); }/* Wait for completion of a redistributor change */ static void gic_redist_wait_for_rwp (void ) { -gic_do_wait_for_rwp (gic_data_rdist_rd_base ()); +gic_do_wait_for_rwp (gic_data_rdist_rd_base (),GICR_CTLR_RWP ); }#ifdef CONFIG_ARM64
Greg Kroah-Hartman
maintainerPATCH 277/343 io_uring: defer splice/tee file validity check until command issue
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit a3e4bc23d5470b2beb7cc42a86b6a3e75b704c15 upstream.
In preparation for not using the file at prep time, defer checking if this file refers to a valid io_uring instance until issue time.
This also means we can get rid of the cleanup flag for splice and tee.
--- fs/io_uring.c | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-)
fs/io_uring.c +21 -28
@@ -621,10 +621,10 @@ struct io_epoll {struct io_splice {struct file *file_out; -struct file *file_in;loff_t off_out;loff_t off_in;u64 len; +int splice_fd_in;unsigned int flags; };
@@ -1551,14 +1551,6 @@ static void io_prep_async_work(struct ioif (def->unbound_nonreg_file) req->work.flags |=IO_WQ_WORK_UNBOUND ; } - -switch (req->opcode) { -case IORING_OP_SPLICE : -case IORING_OP_TEE : -if (!S_ISREG (file_inode (req->splice.file_in)->i_mode)) - req->work.flags |=IO_WQ_WORK_UNBOUND ; -break ; - } }static void io_prep_async_link (struct io_kiocb *req)
@@ -4144,18 +4136,11 @@ static int __io_splice_prep(struct io_kiif (unlikely (req->ctx->flags &IORING_SETUP_IOPOLL ))return -EINVAL ; - sp->file_in =NULL ; sp->len =READ_ONCE (sqe->len); sp->flags =READ_ONCE (sqe->splice_flags); -if (unlikely (sp->flags & ~valid_flags))return -EINVAL ; - - sp->file_in =io_file_get (req->ctx, req,READ_ONCE (sqe->splice_fd_in), - (sp->flags &SPLICE_F_FD_IN_FIXED )); -if (!sp->file_in) -return -EBADF ; - req->flags |=REQ_F_NEED_CLEANUP ; + sp->splice_fd_in =READ_ONCE (sqe->splice_fd_in);return 0 ; }
@@ -4170,20 +4155,27 @@ static int io_tee_prep(struct io_kiocb *static int io_tee (struct io_kiocb *req,unsigned int issue_flags) {struct io_splice *sp = &req->splice; -struct file *in = sp->file_in;struct file *out = sp->file_out;unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED ; +struct file *in;long ret =0 ;if (issue_flags &IO_URING_F_NONBLOCK )return -EAGAIN ; + + in =io_file_get (req->ctx, req, sp->splice_fd_in, + (sp->flags &SPLICE_F_FD_IN_FIXED )); +if (!in) { + ret = -EBADF ; + goto done; + } +if (sp->len) ret =do_tee (in, out, sp->len, flags);if (!(sp->flags &SPLICE_F_FD_IN_FIXED ))io_put_file (in); - req->flags &= ~REQ_F_NEED_CLEANUP ; - +done:if (ret != sp->len)req_set_fail (req);io_req_complete (req, ret);
@@ -4202,15 +4194,22 @@ static int io_splice_prep(struct io_kiocstatic int io_splice (struct io_kiocb *req,unsigned int issue_flags) {struct io_splice *sp = &req->splice; -struct file *in = sp->file_in;struct file *out = sp->file_out;unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED ;loff_t *poff_in, *poff_out; +struct file *in;long ret =0 ;if (issue_flags &IO_URING_F_NONBLOCK )return -EAGAIN ; + in =io_file_get (req->ctx, req, sp->splice_fd_in, + (sp->flags &SPLICE_F_FD_IN_FIXED )); +if (!in) { + ret = -EBADF ; + goto done; + } + poff_in = (sp->off_in ==-1 ) ?NULL : &sp->off_in; poff_out = (sp->off_out ==-1 ) ?NULL : &sp->off_out;
@@ -4219,8 +4218,7 @@ static int io_splice(struct io_kiocb *reif (!(sp->flags &SPLICE_F_FD_IN_FIXED ))io_put_file (in); - req->flags &= ~REQ_F_NEED_CLEANUP ; - +done:if (ret != sp->len)req_set_fail (req);io_req_complete (req, ret);
@@ -6686,11 +6684,6 @@ static void io_clean_op(struct io_kiocbkfree (io->free_iov);break ; } -case IORING_OP_SPLICE : -case IORING_OP_TEE : -if (!(req->splice.flags &SPLICE_F_FD_IN_FIXED )) -io_put_file (req->splice.file_in); -break ;case IORING_OP_OPENAT :case IORING_OP_OPENAT2 :if (req->open.filename)
Greg Kroah-Hartman
maintainerPATCH 289/343 cifs: force new session setup and tcon for dfs
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit fb39d30e227233498c8debe6a9fe3e7cf575c85f upstream.
Do not reuse existing sessions and tcons in DFS failover as it might connect to different servers and shares.
--- fs/cifs/connect.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/cifs/connect.c +8 -5
@@ -453,9 +453,7 @@ static int reconnect_target_unlocked(strreturn rc; } -static int -reconnect_dfs_server (struct TCP_Server_Info *server, -bool mark_smb_session) +static int reconnect_dfs_server (struct TCP_Server_Info *server) {int rc =0 ;const char *refpath = server->current_fullpath +1 ;
@@ -479,7 +477,12 @@ reconnect_dfs_server(struct TCP_Server_Iif (!cifs_tcp_ses_needs_reconnect (server, num_targets))return 0 ; -cifs_mark_tcp_ses_conns_for_reconnect (server, mark_smb_session); +/* +* Unconditionally mark all sessions & tcons for reconnect as we might be connecting to a +* different server or share during failover. It could be improved by adding some logic to +* only do that in case it connects to a different server or share, though. +*/ +cifs_mark_tcp_ses_conns_for_reconnect (server, true);cifs_abort_connection (server);
@@ -537,7 +540,7 @@ int cifs_reconnect(struct TCP_Server_Inf }spin_unlock (&cifs_tcp_ses_lock); -return reconnect_dfs_server (server, mark_smb_session); +return reconnect_dfs_server (server); }#else int cifs_reconnect (struct TCP_Server_Info *server,bool mark_smb_session)
Greg Kroah-Hartman
maintainerPATCH 290/343 qed: fix ethtool register dump
In reply to Greg Kroah-HartmanFrom: Manish Chopra <[email protected]>
commit 20921c0c86092b4082c91bd7c88305da74e5520b upstream.
To fix a coverity complain, commit d5ac07dfbd2b ("qed: Initialize debug string array") removed "sw-platform" (one of the common global parameters) from the dump as this was used in the dump with an uninitialized string, however it did not reduce the number of common global parameters which caused the incorrect (unable to parse) register dump
this patch fixes it with reducing NUM_COMMON_GLOBAL_PARAMS bye one.
--- drivers/net/ethernet/qlogic/qed/qed_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -1
@@ -489,7 +489,7 @@ struct split_type_defs {#define STATIC_DEBUG_LINE_DWORDS 9 -#define NUM_COMMON_GLOBAL_PARAMS 11 +#define NUM_COMMON_GLOBAL_PARAMS 10#define MAX_RECURSION_DEPTH 10
Greg Kroah-Hartman
maintainerPATCH 274/343 mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 01e67e04c28170c47700c2c226d732bbfedb1ad0 upstream.
If an mremap() syscall with old_size=0 ends up in move_page_tables(), it will call invalidate_range_start()/invalidate_range_end() unnecessarily, i.e. with an empty range.
This causes a WARN in KVM's mmu_notifier. In the past, empty ranges have been diagnosed to be off-by-one bugs, hence the WARNing. Given the low (so far) number of unique reports, the benefits of detecting more buggy callers seem to outweigh the cost of having to fix cases such as this one, where userspace is doing something silly. In this particular case, an early return from move_page_tables() is enough to fix the issue.
--- mm/mremap.c | 3 +++ 1 file changed, 3 insertions(+)
mm/mremap.c +3 -0
@@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vmpmd_t *old_pmd, *new_pmd;pud_t *old_pud, *new_pud; +if (!len) +return 0 ; + old_end = old_addr + len;flush_cache_range (vma, old_addr, old_end);
Greg Kroah-Hartman
maintainerPATCH 275/343 mm/mempolicy: fix mpol_new leak in shared_policy_replace
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
commit 4ad099559b00ac01c3726e5c95dc3108ef47d03e upstream.
If mpol_new is allocated but not used in restart loop, mpol_new will be freed via mpol_put before returning to the caller. But refcnt is not initialized yet, so mpol_put could not do the right things and might leak the unused mpol_new. This would happen if mempolicy was updated on the shared shmem file while the sp->lock has been dropped during the memory allocation.
This issue could be triggered easily with the below code snippet if there are many processes doing the below work at the same time:
shmid = shmget((key_t)5566, 1024 * PAGE_SIZE, 0666|IPC_CREAT);
shm = shmat(shmid, 0, 0);
loop many times {
mbind(shm, 1024 * PAGE_SIZE, MPOL_LOCAL, mask, maxnode, 0);
mbind(shm + 128 * PAGE_SIZE, 128 * PAGE_SIZE, MPOL_DEFAULT, mask,
maxnode, 0);
}--- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+)
mm/mempolicy.c +1 -0
@@ -2736,6 +2736,7 @@ alloc_new: mpol_new =kmem_cache_alloc (policy_cache,GFP_KERNEL );if (!mpol_new) goto err_out; +atomic_set (&mpol_new->refcnt,1 ); goto restart; }
Greg Kroah-Hartman
maintainerPATCH 270/343 mmc: renesas_sdhi: dont overwrite TAP settings when HS400 tuning is complete
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
commit 03e59b1e2f56245163b14c69e0a830c24b1a3a47 upstream.
When HS400 tuning is complete and HS400 is going to be activated, we have to keep the current number of TAPs and should not overwrite them with a hardcoded value. This was probably a copy&paste mistake when upporting HS400 support from the BSP.
--- drivers/mmc/host/renesas_sdhi_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/renesas_sdhi_core.c +2 -2
@@ -396,10 +396,10 @@ static void renesas_sdhi_hs400_complete( SH_MOBILE_SDHI_SCC_TMPPORT2_HS400OSEL) | sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2)); -/* Set the sampling clock selection range of HS400 mode */ sd_scc_write32 (host, priv,SH_MOBILE_SDHI_SCC_DTCNTL ,SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN | -0x4 <<SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_SHIFT ); +sd_scc_read32 (host, priv, +SH_MOBILE_SDHI_SCC_DTCNTL ));/* Avoid bad TAP */ if (bad_taps &BIT (priv->tap_set)) {
Greg Kroah-Hartman
maintainerPATCH 273/343 highmem: fix checks in __kmap_local_sched_{in,out}
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit 66f133ceab7456c789f70a242991ed1b27ba1c3d upstream.
When CONFIG_DEBUG_KMAP_LOCAL is enabled __kmap_local_sched_{in,out} check that even slots in the tsk->kmap_ctrl.pteval are unmapped. The slots are initialized with 0 value, but the check is done with pte_none. 0 pte however does not necessarily mean that pte_none will return true. e.g. on xtensa it returns false, resulting in the following runtime warnings:
WARNING: CPU: 0 PID: 101 at mm/highmem.c:627 __kmap_local_sched_out+0x51/0x108 CPU: 0 PID: 101 Comm: touch Not tainted 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_out+0x51/0x108 __schedule+0x71a/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f WARNING: CPU: 0 PID: 101 at mm/highmem.c:664 __kmap_local_sched_in+0x50/0xe0 CPU: 0 PID: 101 Comm: touch Tainted: G W 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_in+0x50/0xe0 finish_task_switch$isra$0+0x1ce/0x2f8 __schedule+0x86e/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f
Fix it by replacing !pte_none(pteval) with pte_val(pteval) != 0.
--- mm/highmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/highmem.c +2 -2
@@ -624,7 +624,7 @@ void __kmap_local_sched_out(void)/* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED (CONFIG_DEBUG_KMAP_LOCAL ) && !(i &0x01 )) { -WARN_ON_ONCE (!pte_none (pteval)); +WARN_ON_ONCE (pte_val (pteval) !=0 );continue ; }if (WARN_ON_ONCE (pte_none (pteval)))
@@ -661,7 +661,7 @@ void __kmap_local_sched_in(void)/* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED (CONFIG_DEBUG_KMAP_LOCAL ) && !(i &0x01 )) { -WARN_ON_ONCE (!pte_none (pteval)); +WARN_ON_ONCE (pte_val (pteval) !=0 );continue ; }if (WARN_ON_ONCE (pte_none (pteval)))
Greg Kroah-Hartman
maintainerPATCH 265/343 scsi: ufs: ufs-pci: Add support for Intel MTL
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 4049f7acef3eb37c1ea0df45f3ffc29404f4e708 upstream.
Add PCI ID and callbacks to support Intel Meteor Lake (MTL).
--- drivers/scsi/ufs/ufshcd-pci.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/scsi/ufs/ufshcd-pci.c +17 -0
@@ -428,6 +428,12 @@ static int ufs_intel_adl_init(struct ufsreturn ufs_intel_common_init (hba); } +static int ufs_intel_mtl_init (struct ufs_hba *hba) +{ + hba->caps |=UFSHCD_CAP_CRYPTO |UFSHCD_CAP_WB_EN ; +return ufs_intel_common_init (hba); +} +static struct ufs_hba_variant_ops ufs_intel_cnl_hba_vops = { .name ="intel-pci" , .init = ufs_intel_common_init,
@@ -465,6 +471,16 @@ static struct ufs_hba_variant_ops ufs_in .device_reset = ufs_intel_device_reset, }; +static struct ufs_hba_variant_ops ufs_intel_mtl_hba_vops = { + .name ="intel-pci" , + .init = ufs_intel_mtl_init, + .exit = ufs_intel_common_exit, + .hce_enable_notify = ufs_intel_hce_enable_notify, + .link_startup_notify = ufs_intel_link_startup_notify, + .resume = ufs_intel_resume, + .device_reset = ufs_intel_device_reset, +}; +#ifdef CONFIG_PM_SLEEP static int ufshcd_pci_restore (struct device *dev) {
@@ -579,6 +595,7 @@ static const struct pci_device_id ufshcd { PCI_VDEVICE(INTEL, 0x98FA), (kernel_ulong_t)&ufs_intel_lkf_hba_vops }, { PCI_VDEVICE(INTEL, 0x51FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops }, { PCI_VDEVICE(INTEL, 0x54FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops }, + { PCI_VDEVICE(INTEL, 0x7E47), (kernel_ulong_t)&ufs_intel_mtl_hba_vops }, { } /* terminate list */ };
Greg Kroah-Hartman
maintainerPATCH 266/343 Revert "mmc: sdhci-xenon: fix annoying 1.8V regulator warning"
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 7e2646ed47542123168d43916b84b954532e5386 upstream.
This reverts commit bb32e1987bc55ce1db400faf47d85891da3c9b9f.
Commit 1a3ed0dc3594 ("mmc: sdhci-xenon: fix 1.8v regulator stabilization") contains proper fix for the issue described in commit bb32e1987bc5 ("mmc:
sdhci-xenon: fix annoying 1.8V regulator warning").
--- drivers/mmc/host/sdhci-xenon.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/mmc/host/sdhci-xenon.c +0 -10
@@ -241,16 +241,6 @@ static void xenon_voltage_switch(struct {/* Wait for 5ms after set 1.8V signal enable bit */ usleep_range (5000 ,5500 ); - -/* -* For some reason the controller's Host Control2 register reports -* the bit representing 1.8V signaling as 0 when read after it was -* written as 1. Subsequent read reports 1. -* -* Since this may cause some issues, do an empty read of the Host -* Control2 register here to circumvent this. -*/ -sdhci_readw (host,SDHCI_HOST_CONTROL2 ); }static unsigned int xenon_get_max_clock (struct sdhci_host *host)
Greg Kroah-Hartman
maintainerPATCH 267/343 mmc: block: Check for errors after write on SPI
In reply to Greg Kroah-HartmanFrom: Christian Löhle <[email protected]>
commit 5d435933376962b107bd76970912e7e80247dcc7 upstream.
Introduce a SEND_STATUS check for writes through SPI to not mark an unsuccessful write as successful.
Since SPI SD/MMC does not have states, after a write, the card will just hold the line LOW until it is ready again. The driver marks the write therefore as completed as soon as it reads something other than all zeroes.
The driver does not distinguish from a card no longer signalling busy and it being disconnected (and the line being pulled-up by the host). This lead to writes being marked as successful when disconnecting a busy card.
Now the card is ensured to be still connected by an additional CMD13, just like non-SPI is ensured to go back to TRAN state.
While at it and since we already poll for the post-write status anyway, we might as well check for SPIs error bits (any of them).
The disconnecting card problem is reproducable for me after continuous write activity and randomly disconnecting, around every 20-50 tries on SPI DS for some card.
--- drivers/mmc/core/block.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/mmc/core/block.c +33 -1
@@ -1880,6 +1880,31 @@ static inline bool mmc_blk_rq_error(stru brq->data.error || brq->cmd.resp[0 ] &CMD_ERRORS ; } +static int mmc_spi_err_check (struct mmc_card *card) +{ +u32 status =0 ; +int err; + +/* +* SPI does not have a TRAN state we have to wait on, instead the +* card is ready again when it no longer holds the line LOW. +* We still have to ensure two things here before we know the write +* was successful: +* 1. The card has not disconnected during busy and we actually read our +* own pull-up, thinking it was still connected, so ensure it +* still responds. +* 2. Check for any error bits, in particular R1_SPI_IDLE to catch a +* just reconnected card after being disconnected during busy. +*/ + err =__mmc_send_status (card, &status,0 ); +if (err) +return err; +/* All R1 and R2 bits of SPI are errors in our case */ +if (status) +return -EIO ; +return 0 ; +} +static int mmc_blk_busy_cb (void *cb_data,bool *busy) {struct mmc_blk_busy_data *data = cb_data;
@@ -1903,9 +1928,16 @@ static int mmc_blk_card_busy(struct mmc_struct mmc_blk_busy_data cb_data;int err; -if (mmc_host_is_spi (card->host) ||rq_data_dir (req) ==READ ) +if (rq_data_dir (req) ==READ )return 0 ; +if (mmc_host_is_spi (card->host)) { + err =mmc_spi_err_check (card); +if (err) + mqrq->brq.data.bytes_xfered =0 ; +return err; + } + cb_data.card = card; cb_data.status =0 ; err = __mmc_poll_for_busy(card->host, 0, MMC_BLK_TIMEOUT_MS,
Greg Kroah-Hartman
maintainerPATCH 238/343 ice: clear cmd_type_offset_bsz for TX rings
In reply to Greg Kroah-HartmanFrom: Maciej Fijalkowski <[email protected]>
[ Upstream commit e19778e6c911691856447c3bf9617f00b3e1347f ]
Currently when XDP rings are created, each descriptor gets its DD bit set, which turns out to be the wrong approach as it can lead to a situation where more descriptors get cleaned than it was supposed to, e.g. when AF_XDP busy poll is run with a large batch size. In this situation, the driver would request for more buffers than it is able to handle.
Fix this by not setting the DD bits in ice_xdp_alloc_setup_rings(). They should be initialized to zero instead.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -2546,7 +2546,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)spin_lock_init (&xdp_ring->tx_lock);for (j =0 ; j < xdp_ring->count; j++) { tx_desc =ICE_TX_DESC (xdp_ring, j); - tx_desc->cmd_type_offset_bsz =cpu_to_le64 (ICE_TX_DESC_DTYPE_DESC_DONE ); + tx_desc->cmd_type_offset_bsz =0 ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 261/343 perf tools: Fix perfs libperf_print callback
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit aeee9dc53ce405d2161f9915f553114e94e5b677 ]
eprintf() does not expect va_list as the type of the 4th parameter.
Use veprintf() because it does.
--- tools/perf/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/perf.c +1 -1
@@ -434,7 +434,7 @@ void pthread__unblock_sigwinch(void)static int libperf_print (enum libperf_print_level level,const char *fmt,va_list ap) { -return eprintf (level, verbose, fmt, ap); +return veprintf (level, verbose, fmt, ap); }int main (int argc,const char **argv)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 263/343 arm64: Add part number for Arm Cortex-A78AE
In reply to Greg Kroah-HartmanFrom: Chanho Park <[email protected]>
commit 83bea32ac7ed37bbda58733de61fc9369513f9f9 upstream.
Add the MIDR part number info for the Arm Cortex-A78AE[1] and add it to spectre-BHB affected list[2].
[1]: https://developer.arm.com/Processors/Cortex-A78AE
[2]: https://developer.arm.com/Arm%20Security%20Center/Spectre-BHB
--- arch/arm64/include/asm/cputype.h | 2 ++ arch/arm64/kernel/proton-pack.c | 1 + 2 files changed, 3 insertions(+)
arch/arm64/include/asm/cputype.h +2 -0
@@ -75,6 +75,7 @@#define ARM_CPU_PART_CORTEX_A77 0xD0D#define ARM_CPU_PART_NEOVERSE_V1 0xD40#define ARM_CPU_PART_CORTEX_A78 0xD41 +#define ARM_CPU_PART_CORTEX_A78AE 0xD42#define ARM_CPU_PART_CORTEX_X1 0xD44#define ARM_CPU_PART_CORTEX_A510 0xD46#define ARM_CPU_PART_CORTEX_A710 0xD47
@@ -123,6 +124,7 @@#define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77)#define MIDR_NEOVERSE_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V1)#define MIDR_CORTEX_A78 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78) +#define MIDR_CORTEX_A78AE MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78AE)#define MIDR_CORTEX_X1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X1)#define MIDR_CORTEX_A510 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A510)#define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710)
arch/arm64/kernel/proton-pack.c +1 -0
@@ -853,6 +853,7 @@ u8 spectre_bhb_loop_affected(int scope)if (scope ==SCOPE_LOCAL_CPU ) {static const struct midr_range spectre_bhb_k32_list[] = {MIDR_ALL_VERSIONS (MIDR_CORTEX_A78 ), +MIDR_ALL_VERSIONS (MIDR_CORTEX_A78AE ),MIDR_ALL_VERSIONS (MIDR_CORTEX_A78C ),MIDR_ALL_VERSIONS (MIDR_CORTEX_X1 ),MIDR_ALL_VERSIONS (MIDR_CORTEX_A710 ),
Greg Kroah-Hartman
maintainerPATCH 264/343 scsi: mpt3sas: Fix use after free in _scsih_expander_node_remove()
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
commit 87d663d40801dffc99a5ad3b0188ad3e2b4d1557 upstream.
The function mpt3sas_transport_port_remove() called in _scsih_expander_node_remove() frees the port field of the sas_expander structure, leading to the following use-after-free splat from KASAN when the ioc_info() call following that function is executed (e.g. when doing rmmod of the driver module):
[ 3479.371167] ================================================================== [ 3479.378496] BUG: KASAN: use-after-free in _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.386936] Read of size 1 at addr ffff8881c037691c by task rmmod/1531 [ 3479.393524] [ 3479.395035] CPU: 18 PID: 1531 Comm: rmmod Not tainted 5.17.0-rc8+ #1436 [ 3479.401712] Hardware name: Supermicro Super Server/H12SSL-NT, BIOS 2.1 06/02/2021 [ 3479.409263] Call Trace: [ 3479.411743] <TASK> [ 3479.413875] dump_stack_lvl+0x45/0x59 [ 3479.417582] print_address_description.constprop.0+0x1f/0x120 [ 3479.423389] ? _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.429469] kasan_report.cold+0x83/0xdf [ 3479.433438] ? _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.439514] _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.445411] ? _raw_spin_unlock_irqrestore+0x2d/0x40 [ 3479.452032] scsih_remove+0x525/0xc90 [mpt3sas] [ 3479.458212] ? mpt3sas_expander_remove+0x1d0/0x1d0 [mpt3sas] [ 3479.465529] ? down_write+0xde/0x150 [ 3479.470746] ? up_write+0x14d/0x460 [ 3479.475840] ? kernfs_find_ns+0x137/0x310 [ 3479.481438] pci_device_remove+0x65/0x110 [ 3479.487013] __device_release_driver+0x316/0x680 [ 3479.493180] driver_detach+0x1ec/0x2d0 [ 3479.498499] bus_remove_driver+0xe7/0x2d0 [ 3479.504081] pci_unregister_driver+0x26/0x250 [ 3479.510033] _mpt3sas_exit+0x2b/0x6cf [mpt3sas] [ 3479.516144] __x64_sys_delete_module+0x2fd/0x510 [ 3479.522315] ? free_module+0xaa0/0xaa0 [ 3479.527593] ? __cond_resched+0x1c/0x90 [ 3479.532951] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 3479.539607] ? syscall_enter_from_user_mode+0x21/0x70 [ 3479.546161] ? trace_hardirqs_on+0x1c/0x110 [ 3479.551828] do_syscall_64+0x35/0x80 [ 3479.556884] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 3479.563402] RIP: 0033:0x7f1fc482483b ... [ 3479.943087] ==================================================================
Fix this by introducing the local variable port_id to store the port ID value before executing mpt3sas_transport_port_remove(). This local variable is then used in the call to ioc_info() instead of dereferencing the freed port structure.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +4 -1
@@ -11035,6 +11035,7 @@ _scsih_expander_node_remove(struct MPT3S {struct _sas_port *mpt3sas_port, *next;unsigned long flags; +int port_id;/* remove sibling ports attached to this expander */ list_for_each_entry_safe(mpt3sas_port, next,
@@ -11055,6 +11056,8 @@ _scsih_expander_node_remove(struct MPT3S mpt3sas_port->hba_port); } + port_id = sas_expander->port->port_id; +mpt3sas_transport_port_remove (ioc, sas_expander->sas_address, sas_expander->sas_address_parent, sas_expander->port);
@@ -11062,7 +11065,7 @@ _scsih_expander_node_remove(struct MPT3S"expander_remove: handle(0x%04x), sas_addr(0x%016llx), port:%d\n" , sas_expander->handle, (unsigned long long ) sas_expander->sas_address, - sas_expander->port->port_id); + port_id);spin_lock_irqsave (&ioc->sas_node_lock, flags);list_del (&sas_expander->list);
Greg Kroah-Hartman
maintainerPATCH 259/343 perf unwind: Dont show unwind error messages when augmenting frame pointer stack
In reply to Greg Kroah-HartmanFrom: James Clark <[email protected]>
[ Upstream commit fa7095c5c3240bb2ecbc77f8b69be9b1d9e2cf60 ]
Commit Fixes: b9f6fbb3b2c29736 ("perf arm64: Inject missing frames when using 'perf record --call-graph=fp'") intended to add a 'best effort' DWARF unwind that improved the frame pointer stack in most scenarios.
It's expected that the unwind will fail sometimes, but this shouldn't be reported as an error. It only works when the return address can be determined from the contents of the link register alone.
Fix the error shown when the unwinder requires extra registers by adding a new flag that suppresses error messages. This flag is not set in the normal --call-graph=dwarf unwind mode so that behavior is not changed.
--- tools/perf/tests/dwarf-unwind.c | 2 +- .../perf/util/arm64-frame-pointer-unwind-support.c | 2 +- tools/perf/util/machine.c | 2 +- tools/perf/util/unwind-libdw.c | 10 +++++++--- tools/perf/util/unwind-libdw.h | 1 + tools/perf/util/unwind-libunwind-local.c | 10 +++++++--- tools/perf/util/unwind-libunwind.c | 6 ++++-- tools/perf/util/unwind.h | 13 ++++++++++--- 8 files changed, 32 insertions(+), 14 deletions(-)
tools/perf/tests/dwarf-unwind.c +1 -1
@@ -122,7 +122,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__thread(struct thread *thr } err =unwind__get_entries (unwind_entry, &cnt, thread, - &sample,MAX_STACK ); + &sample,MAX_STACK , false);if (err)pr_debug ("unwind failed\n" );else if (cnt !=MAX_STACK ) {
tools/perf/util/arm64-frame-pointer-unwind-support.c +1 -1
@@ -53,7 +53,7 @@ u64 get_leaf_frame_caller_aarch64(struct perf_sample *sample, struct thread *thr sample->user_regs.cache_regs[PERF_REG_ARM64_SP ] =0 ; } - ret =unwind__get_entries (add_entry, &entries, thread, sample,2 ); + ret =unwind__get_entries (add_entry, &entries, thread, sample,2 , true); sample->user_regs = old_regs;if (ret || entries.length !=2 )
tools/perf/util/machine.c +1 -1
@@ -2983,7 +2983,7 @@ static int thread__resolve_callchain_unwind(struct thread *thread,return 0 ;return unwind__get_entries (unwind_entry, cursor, - thread, sample, max_stack); + thread, sample, max_stack, false); } int thread__resolve_callchain(struct thread *thread,
tools/perf/util/unwind-libdw.c +7 -3
@@ -200,7 +200,8 @@ frame_callback(Dwfl_Frame *state, void *arg)bool isactivation;if (!dwfl_frame_pc (state, &pc,NULL )) { -pr_err ("%s" ,dwfl_errmsg (-1 )); +if (!ui->best_effort) +pr_err ("%s" ,dwfl_errmsg (-1 ));return DWARF_CB_ABORT ; }
@@ -208,7 +209,8 @@ frame_callback(Dwfl_Frame *state, void *arg)report_module (pc, ui);if (!dwfl_frame_pc (state, &pc, &isactivation)) { -pr_err ("%s" ,dwfl_errmsg (-1 )); +if (!ui->best_effort) +pr_err ("%s" ,dwfl_errmsg (-1 ));return DWARF_CB_ABORT ; }
@@ -222,7 +224,8 @@ frame_callback(Dwfl_Frame *state, void *arg)int unwind__get_entries (unwind_entry_cb_t cb,void *arg,struct thread *thread,struct perf_sample *data, -int max_stack) +int max_stack, +bool best_effort) {struct unwind_info *ui, ui_buf = { .sample = data,
@@ -231,6 +234,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, .cb = cb, .arg = arg, .max_stack = max_stack, + .best_effort = best_effort };Dwarf_Word ip;int err = -EINVAL , i;
tools/perf/util/unwind-libdw.h +1 -0
@@ -20,6 +20,7 @@ struct unwind_info {void *arg;int max_stack;int idx; +bool best_effort;struct unwind_entry entries[]; };
tools/perf/util/unwind-libunwind-local.c +7 -3
@@ -96,6 +96,7 @@ struct unwind_info {struct perf_sample *sample;struct machine *machine;struct thread *thread; +bool best_effort; };#define dw_read (ptr, type, end) ({ \
@@ -553,7 +554,8 @@ static int access_reg(unw_addr_space_t __maybe_unused as, ret =perf_reg_value (&val, &ui->sample->user_regs, id);if (ret) { -pr_err ("unwind: can't read reg %d\n" , regnum); +if (!ui->best_effort) +pr_err ("unwind: can't read reg %d\n" , regnum);return ret; }
@@ -666,7 +668,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,return -1 ; ret =unw_init_remote (&c, addr_space, ui); -if (ret) +if (ret && !ui->best_effort)display_error (ret);while (!ret && (unw_step (&c) >0 ) && i < max_stack) {
@@ -704,12 +706,14 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,static int _unwind__get_entries (unwind_entry_cb_t cb,void *arg,struct thread *thread, -struct perf_sample *data,int max_stack) +struct perf_sample *data,int max_stack, +bool best_effort) {struct unwind_info ui = { .sample = data, .thread = thread, .machine = thread->maps->machine, + .best_effort = best_effort };if (!data->user_regs.regs)
tools/perf/util/unwind-libunwind.c +4 -2
@@ -80,9 +80,11 @@ void unwind__finish_access(struct maps *maps)int unwind__get_entries (unwind_entry_cb_t cb,void *arg,struct thread *thread, -struct perf_sample *data,int max_stack) +struct perf_sample *data,int max_stack, +bool best_effort) {if (thread->maps->unwind_libunwind_ops) -return thread->maps->unwind_libunwind_ops->get_entries (cb, arg, thread, data, max_stack); +return thread->maps->unwind_libunwind_ops->get_entries (cb, arg, thread, data, + max_stack, best_effort);return 0 ; }
tools/perf/util/unwind.h +10 -3
@@ -23,13 +23,19 @@ struct unwind_libunwind_ops {void (*finish_access)(struct maps *maps);int (*get_entries)(unwind_entry_cb_t cb,void *arg,struct thread *thread, -struct perf_sample *data,int max_stack); +struct perf_sample *data,int max_stack,bool best_effort); };#ifdef HAVE_DWARF_UNWIND_SUPPORT +/* +* When best_effort is set, don't report errors and fail silently. This could +* be expanded in the future to be more permissive about things other than +* error messages. +*/ int unwind__get_entries (unwind_entry_cb_t cb,void *arg,struct thread *thread, -struct perf_sample *data,int max_stack); +struct perf_sample *data,int max_stack, +bool best_effort);/* libunwind specific */ #ifdef HAVE_LIBUNWIND_SUPPORT #ifndef LIBUNWIND__ARCH_REG_ID
@@ -65,7 +71,8 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,void *arg__maybe_unused , struct thread *thread __maybe_unused, struct perf_sample *data __maybe_unused, - int max_stack __maybe_unused) + int max_stack __maybe_unused, + bool best_effort __maybe_unused) { return 0; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 237/343 ice: xsk: fix VSI state check in ice_xsk_wakeup()
In reply to Greg Kroah-HartmanFrom: Maciej Fijalkowski <[email protected]>
[ Upstream commit 72b915a2b444e9247c9d424a840e94263db07c27 ]
ICE_DOWN is dedicated for pf->state. Check for ICE_VSI_DOWN being set on vsi->state in ice_xsk_wakeup().
--- drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_xsk.c +1 -1
@@ -765,7 +765,7 @@ ice_xsk_wakeup(struct net_device *netdev, u32 queue_id,struct ice_vsi *vsi = np->vsi;struct ice_tx_ring *ring; -if (test_bit (ICE_DOWN , vsi->state)) +if (test_bit (ICE_VSI_DOWN , vsi->state))return -ENETDOWN ;if (!ice_is_xdp_ena_vsi (vsi))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 255/343 SUNRPC: Handle ENOMEM in call_transmit_status()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit d3c15033b240767d0287f1c4a529cbbe2d5ded8a ]
Both call_transmit() and call_bc_transmit() can now return ENOMEM, so let's make sure that we handle the errors gracefully.
--- net/sunrpc/clnt.c | 2 ++ 1 file changed, 2 insertions(+)
net/sunrpc/clnt.c +2 -0
@@ -2197,6 +2197,7 @@ call_transmit_status(struct rpc_task *task)* socket just returned a connection error, * then hold onto the transport lock. */ +case -ENOMEM :case -ENOBUFS :rpc_delay (task,HZ >>2 ); fallthrough;
@@ -2280,6 +2281,7 @@ call_bc_transmit_status(struct rpc_task *task)case -ENOTCONN :case -EPIPE :break ; +case -ENOMEM :case -ENOBUFS :rpc_delay (task,HZ >>2 ); fallthrough;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 256/343 SUNRPC: Handle low memory situations in call_status()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 9d82819d5b065348ce623f196bf601028e22ed00 ]
We need to handle ENFILE, ENOBUFS, and ENOMEM, because xprt_wake_pending_tasks() can be called with any one of these due to socket creation failures.
--- net/sunrpc/clnt.c | 5 +++++ 1 file changed, 5 insertions(+)
net/sunrpc/clnt.c +5 -0
@@ -2364,6 +2364,11 @@ call_status(struct rpc_task *task)case -EPIPE :case -EAGAIN :break ; +case -ENFILE : +case -ENOBUFS : +case -ENOMEM : +rpc_delay (task,HZ >>2 ); +break ;case -EIO :/* shutdown or soft timeout */ goto out_exit;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 254/343 io_uring: dont touch scm_fp_list after queueing skb
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ Upstream commit a07211e3001435fe8591b992464cd8d5e3c98c5a ]
It's safer to not touch scm_fp_list after we queued an skb to which it was assigned, there might be races lurking if we screw subtle sync guarantees on the io_uring side.
--- fs/io_uring.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/io_uring.c +6 -2
@@ -8237,8 +8237,12 @@ static int __io_sqe_files_scm(struct io_ring_ctx *ctx, int nr, int offset)refcount_add (skb->truesize, &sk->sk_wmem_alloc);skb_queue_head (&sk->sk_receive_queue, skb); -for (i =0 ; i < nr_files; i++) -fput (fpl->fp[i]); +for (i =0 ; i < nr; i++) { +struct file *file =io_file_from_index (ctx, i + offset); + +if (file) +fput (file); + } }else {kfree_skb (skb);free_uid (fpl->user);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 246/343 spi: bcm-qspi: fix MSPI only access with bcm_qspi_exec_mem_op()
In reply to Greg Kroah-HartmanFrom: Kamal Dasu <[email protected]>
[ Upstream commit 2c7d1b281286c46049cd22b43435cecba560edde ]
This fixes case where MSPI controller is used to access spi-nor flash and BSPI block is not present.
--- drivers/spi/spi-bcm-qspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-bcm-qspi.c +2 -2
@@ -1205,7 +1205,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem, addr = op->addr.val; len = op->data.nbytes; -if (bcm_qspi_bspi_ver_three (qspi) == true) { +if (has_bspi (qspi) &&bcm_qspi_bspi_ver_three (qspi) == true) {/* * The address coming into this function is a raw flash offset. * But for BSPI <= V3, we need to convert it to a remapped BSPI
@@ -1224,7 +1224,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem, len < 4) mspi_read = true; -if (mspi_read) +if (!has_bspi (qspi) || mspi_read)return bcm_qspi_mspi_exec_mem_op (spi, op); ret =bcm_qspi_bspi_set_mode (qspi, op,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 247/343 drm/amd/display: Fix for dmub outbox notification enable
In reply to Greg Kroah-HartmanFrom: Meenakshikumar Somasundaram <[email protected]>
[ Upstream commit ed7208706448953c6f15009cf139135776c15713 ]
[Why]
Currently driver enables dmub outbox notification before oubox ISR is registered. During boot scenario, sometimes dmub issues hpd outbox message before driver registers ISR and those messages are missed.
[How]
Enable dmub outbox notification after outbox ISR is registered. Also, restructured outbox enable code to call from dm layer and renamed APIs.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 66 +++++++++++++++++-- drivers/gpu/drm/amd/display/dc/dc.h | 3 + .../gpu/drm/amd/display/dc/dce/dmub_outbox.c | 25 +++---- .../gpu/drm/amd/display/dc/dce/dmub_outbox.h | 4 +- .../amd/display/dc/dcn10/dcn10_hw_sequencer.c | 4 -- .../drm/amd/display/dc/dcn31/dcn31_hwseq.c | 2 +- 6 files changed, 80 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +60 -6
@@ -76,6 +76,8 @@#include "dc_trace.h" +#include "dce/dmub_outbox.h" +#define CTX \ dc->ctx
@@ -3707,13 +3709,23 @@ void dc_hardware_release(struct dc *dc) }#endif -/** -* dc_enable_dmub_notifications - Returns whether dmub notification can be enabled -* @dc: dc structure +/* +***************************************************************************** +* Function: dc_is_dmub_outbox_supported - +* +* @brief +* Checks whether DMUB FW supports outbox notifications, if supported +* DM should register outbox interrupt prior to actually enabling interrupts +* via dc_enable_dmub_outbox * -* Returns: True to enable dmub notifications, False otherwise +* @param +* [in] dc: dc structure +* +* @return +* True if DMUB FW supports outbox notifications, False otherwise +***************************************************************************** */ -bool dc_enable_dmub_notifications (struct dc *dc) +bool dc_is_dmub_outbox_supported (struct dc *dc) {#if defined(CONFIG_DRM_AMD_DC_DCN )/* YELLOW_CARP B0 USB4 DPIA needs dmub notifications for interrupts */
@@ -3728,6 +3740,48 @@ bool dc_enable_dmub_notifications(struct dc *dc)/** * dc_process_dmub_aux_transfer_async - Submits aux command to dmub via inbox message +* Function: dc_enable_dmub_notifications +* +* @brief +* Calls dc_is_dmub_outbox_supported to check if dmub fw supports outbox +* notifications. All DMs shall switch to dc_is_dmub_outbox_supported. +* This API shall be removed after switching. +* +* @param +* [in] dc: dc structure +* +* @return +* True if DMUB FW supports outbox notifications, False otherwise +***************************************************************************** +*/ +bool dc_enable_dmub_notifications (struct dc *dc) +{ +return dc_is_dmub_outbox_supported (dc); +} + +/** +***************************************************************************** +* Function: dc_enable_dmub_outbox +* +* @brief +* Enables DMUB unsolicited notifications to x86 via outbox +* +* @param +* [in] dc: dc structure +* +* @return +* None +***************************************************************************** +*/ +void dc_enable_dmub_outbox (struct dc *dc) +{ +struct dc_context *dc_ctx = dc->ctx; + +dmub_enable_outbox_notification (dc_ctx->dmub_srv); +} + +/** +***************************************************************************** * Sets port index appropriately for legacy DDC * @dc: dc structure * @link_index: link index
@@ -3829,7 +3883,7 @@ uint8_t get_link_index_from_dpia_port_index(const struct dc *dc,* [in] payload: aux payload * [out] notify: set_config immediate reply * -* @return +* @return * True if successful, False if failure ***************************************************************************** */
drivers/gpu/drm/amd/display/dc/dc.h +3 -0
@@ -1448,8 +1448,11 @@ void dc_z10_restore(const struct dc *dc);void dc_z10_save_init (struct dc *dc);#endif +bool dc_is_dmub_outbox_supported (struct dc *dc);bool dc_enable_dmub_notifications (struct dc *dc); +void dc_enable_dmub_outbox (struct dc *dc); +bool dc_process_dmub_aux_transfer_async (struct dc *dc,uint32_t link_index,struct aux_payload *payload);
drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.c +14 -11
@@ -22,20 +22,23 @@* Authors: AMD */ -#include "dmub_outbox.h" +#include "dc.h" #include "dc_dmub_srv.h" +#include "dmub_outbox.h" #include "dmub/inc/dmub_cmd.h" -/** -* dmub_enable_outbox_notification - Sends inbox cmd to dmub to enable outbox1 -* messages with interrupt. Dmub sends outbox1 -* message and triggers outbox1 interrupt. -* @dc: dc structure +/* +* Function: dmub_enable_outbox_notification +* +* @brief +* Sends inbox cmd to dmub for enabling outbox notifications to x86. +* +* @param +* [in] dmub_srv: dmub_srv structure */ -void dmub_enable_outbox_notification (struct dc *dc) +void dmub_enable_outbox_notification (struct dc_dmub_srv *dmub_srv) {union dmub_rb_cmd cmd; -struct dc_context *dc_ctx = dc->ctx;memset (&cmd,0x0 ,sizeof (cmd)); cmd.outbox1_enable.header.type =DMUB_CMD__OUTBOX1_ENABLE ;
@@ -45,7 +48,7 @@ void dmub_enable_outbox_notification(struct dc *dc)sizeof (cmd.outbox1_enable.header); cmd.outbox1_enable.enable = true; -dc_dmub_srv_cmd_queue (dc_ctx->dmub_srv, &cmd); -dc_dmub_srv_cmd_execute (dc_ctx->dmub_srv); -dc_dmub_srv_wait_idle (dc_ctx->dmub_srv); +dc_dmub_srv_cmd_queue (dmub_srv, &cmd); +dc_dmub_srv_cmd_execute (dmub_srv); +dc_dmub_srv_wait_idle (dmub_srv); }
drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.h +2 -2
@@ -26,8 +26,8 @@#ifndef _DMUB_OUTBOX_H_#define _DMUB_OUTBOX_H_ -#include "dc.h" +struct dc_dmub_srv ; -void dmub_enable_outbox_notification (struct dc *dc); +void dmub_enable_outbox_notification (struct dc_dmub_srv *dmub_srv);#endif /* _DMUB_OUTBOX_H_ */
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +0 -4
@@ -1500,10 +1500,6 @@ void dcn10_init_hw(struct dc *dc) hws->funcs.dsc_pg_control (hws, res_pool->dscs[i]->inst, false); } -/* Enable outbox notification feature of dmub */ -if (dc->debug.enable_dmub_aux_for_legacy_ddc) -dmub_enable_outbox_notification (dc); -/* we want to turn off all dp displays before doing detection */ if (dc->config.power_down_display_on_boot)dc_link_blank_all_dp_displays (dc);
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c +1 -1
@@ -194,7 +194,7 @@ void dcn31_init_hw(struct dc *dc)/* Enables outbox notifications for usb4 dpia */ if (dc->res_pool->usb4_dpia_count) -dmub_enable_outbox_notification (dc); +dmub_enable_outbox_notification (dc->ctx->dmub_srv);/* we want to turn off all dp displays before doing detection */ if (dc->config.power_down_display_on_boot)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 245/343 qede: confirm skb is allocated before using
In reply to Greg Kroah-HartmanFrom: Jamie Bainbridge <[email protected]>
[ Upstream commit 4e910dbe36508654a896d5735b318c0b88172570 ]
qede_build_skb() assumes build_skb() always works and goes straight to skb_reserve(). However, build_skb() can fail under memory pressure. This results in a kernel panic because the skb to reserve is NULL.
Add a check in case build_skb() failed to allocate and return NULL.
The NULL return is handled correctly in callers to qede_build_skb().
--- drivers/net/ethernet/qlogic/qede/qede_fp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/qlogic/qede/qede_fp.c +3 -0
@@ -748,6 +748,9 @@ qede_build_skb(struct qede_rx_queue *rxq, buf =page_address (bd->data) + bd->page_offset; skb =build_skb (buf, rxq->rx_buf_seg_size); +if (unlikely (!skb)) +return NULL ; +skb_reserve (skb, pad);skb_put (skb, len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 198/343 NFSv4: fix open failure with O_ACCMODE flag
In reply to Greg Kroah-HartmanFrom: ChenXiaoSong <[email protected]>
[ Upstream commit b243874f6f9568b2daf1a00e9222cacdc15e159c ]
open() with O_ACCMODE|O_DIRECT flags secondly will fail.
Reproducer:
1. mount -t nfs -o vers=4.2 $server_ip:/ /mnt/
2. fd = open("/mnt/file", O_ACCMODE|O_DIRECT|O_CREAT)
3. close(fd)
4. fd = open("/mnt/file", O_ACCMODE|O_DIRECT)
Server nfsd4_decode_share_access() will fail with error nfserr_bad_xdr when client use incorrect share access mode of 0.
Fix this by using NFS4_SHARE_ACCESS_BOTH share access mode in client, just like firstly opening.
--- fs/nfs/dir.c | 10 ---------- fs/nfs/internal.h | 10 ++++++++++ fs/nfs/nfs4file.c | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-)
fs/nfs/dir.c +0 -10
@@ -1853,16 +1853,6 @@ const struct dentry_operations nfs4_dentry_operations = { };EXPORT_SYMBOL_GPL (nfs4_dentry_operations); -static fmode_t flags_to_mode (int flags) -{ -fmode_t res = (__force fmode_t )flags &FMODE_EXEC ; -if ((flags &O_ACCMODE ) !=O_WRONLY ) - res |=FMODE_READ ; -if ((flags &O_ACCMODE ) !=O_RDONLY ) - res |=FMODE_WRITE ; -return res; -} -static struct nfs_open_context *create_nfs_open_context (struct dentry *dentry,int open_flags,struct file *filp) {return alloc_nfs_open_context (dentry,flags_to_mode (open_flags), filp);
fs/nfs/internal.h +10 -0
@@ -42,6 +42,16 @@ static inline bool nfs_lookup_is_soft_revalidate(const struct dentry *dentry)return true; } +static inline fmode_t flags_to_mode (int flags) +{ +fmode_t res = (__force fmode_t )flags &FMODE_EXEC ; +if ((flags &O_ACCMODE ) !=O_WRONLY ) + res |=FMODE_READ ; +if ((flags &O_ACCMODE ) !=O_RDONLY ) + res |=FMODE_WRITE ; +return res; +} +/* * Note: RFC 1813 doesn't limit the number of auth flavors that * a server can return, so make something up.
fs/nfs/nfs4file.c +4 -2
@@ -32,6 +32,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)struct dentry *parent =NULL ;struct inode *dir;unsigned openflags = filp->f_flags; +fmode_t f_mode;struct iattr attr;int err;
@@ -50,8 +51,9 @@ nfs4_file_open(struct inode *inode, struct file *filp)if (err)return err; + f_mode = filp->f_mode;if ((openflags &O_ACCMODE ) ==3 ) - openflags--; + f_mode |=flags_to_mode (openflags);/* We can't create new files here */ openflags &= ~(O_CREAT |O_EXCL );
@@ -59,7 +61,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) parent =dget_parent (dentry); dir =d_inode (parent); - ctx =alloc_nfs_open_context (file_dentry (filp), filp->f_mode, filp); + ctx =alloc_nfs_open_context (file_dentry (filp), f_mode, filp); err =PTR_ERR (ctx);if (IS_ERR (ctx)) goto out;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 232/343 dpaa2-ptp: Fix refcount leak in dpaa2_ptp_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 2b04bd4f03bba021959ca339314f6739710f0954 ]
This node pointer is returned by of_find_compatible_node() with refcount incremented. Calling of_node_put() to aovid the refcount leak.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +3 -1
@@ -167,7 +167,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) base =of_iomap (node,0 );if (!base) { err = -ENOMEM ; - goto err_close; + goto err_put; } err =fsl_mc_allocate_irqs (mc_dev);
@@ -210,6 +210,8 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)fsl_mc_free_irqs (mc_dev); err_unmap:iounmap (base); +err_put: +of_node_put (node); err_close:dprtc_close (mc_dev->mc_io,0 , mc_dev->mc_handle); err_free_mcp:
Signature · 1 line
2.35.1