6.1.64-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 142/372 net: ethernet: cortina: Fix max RX frame define
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 510e35fb931ffc3b100e5d5ae4595cd3beca9f1a ]
Enumerator 3 is 1548 bytes according to the datasheet. Not 1542.
--- drivers/net/ethernet/cortina/gemini.c | 4 ++-- drivers/net/ethernet/cortina/gemini.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/cortina/gemini.c +2 -2
@@ -432,8 +432,8 @@ static const struct gmac_max_framelen gmac_maxlens[] = { .val = CONFIG0_MAXLEN_1536, }, { - .max_l3_len = 1542, - .val = CONFIG0_MAXLEN_1542, + .max_l3_len = 1548, + .val = CONFIG0_MAXLEN_1548, }, { .max_l3_len = 9212,
drivers/net/ethernet/cortina/gemini.h +1 -1
@@ -787,7 +787,7 @@ union gmac_config0 {#define CONFIG0_MAXLEN_1536 0#define CONFIG0_MAXLEN_1518 1#define CONFIG0_MAXLEN_1522 2 -#define CONFIG0_MAXLEN_1542 3 +#define CONFIG0_MAXLEN_1548 3#define CONFIG0_MAXLEN_9k 4/* 9212 */ #define CONFIG0_MAXLEN_10k 5/* 10236 */ #define CONFIG0_MAXLEN_1518__6 6
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 143/372 net: ethernet: cortina: Handle large frames
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit d4d0c5b4d279bfe3585fbd806efefd3e51c82afa ]
The Gemini ethernet controller provides hardware checksumming for frames up to 1514 bytes including ethernet headers but not FCS.
If we start sending bigger frames (after first bumping up the MTU on both interfaces sending and receiving the frames), truncated packets start to appear on the target such as in this tcpdump resulting from ping -s 1474:
23:34:17.241983 14:d6:4d:a8:3c:4f (oui Unknown) > bc:ae:c5:6b:a8:3d (oui Unknown), ethertype IPv4 (0x0800), length 1514: truncated-ip - 2 bytes missing! (tos 0x0, ttl 64, id 32653, offset 0, flags [DF], proto ICMP (1), length 1502) OpenWrt.lan > Fecusia: ICMP echo request, id 1672, seq 50, length 1482
If we bypass the hardware checksumming and provide a software fallback, everything starts working fine up to the max TX MTU of 2047 bytes, for example ping -s2000 192.168.1.2:
00:44:29.587598 bc:ae:c5:6b:a8:3d (oui Unknown) > 14:d6:4d:a8:3c:4f (oui Unknown), ethertype IPv4 (0x0800), length 2042:
(tos 0x0, ttl 64, id 51828, offset 0, flags [none], proto ICMP (1), length 2028) Fecusia > OpenWrt.lan: ICMP echo reply, id 1683, seq 4, length 2008
The bit enabling to bypass hardware checksum (or any of the "TSS" bits) are undocumented in the hardware reference manual. The entire hardware checksum unit appears undocumented. The conclusion that we need to use the "bypass" bit was found by trial-and-error.
Since no hardware checksum will happen, we slot in a software checksum fallback.
Check for the condition where we need to compute checksum on the skb with either hardware or software using == CHECKSUM_PARTIAL instead of != CHECKSUM_NONE which is an incomplete check according to <linux/skbuff.h>.
On the D-Link DIR-685 router this fixes a bug on the conduit interface to the RTL8366RB DSA switch: as the switch needs to add space for its tag it increases the MTU on the conduit interface to 1504 and that means that when the router sends packages of 1500 bytes these get an extra 4 bytes of DSA tag and the transfer fails because of the erroneous hardware checksumming, affecting such basic functionality as the LuCI web interface.
--- drivers/net/ethernet/cortina/gemini.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/net/ethernet/cortina/gemini.c +23 -1
@@ -1145,6 +1145,7 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb,dma_addr_t mapping;unsigned short mtu;void *buffer; +int ret; mtu =ETH_HLEN ; mtu += netdev->mtu;
@@ -1159,9 +1160,30 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, word3 |= mtu; } -if (skb->ip_summed !=CHECKSUM_NONE ) { +if (skb->len >=ETH_FRAME_LEN ) { +/* Hardware offloaded checksumming isn't working on frames +* bigger than 1514 bytes. A hypothesis about this is that the +* checksum buffer is only 1518 bytes, so when the frames get +* bigger they get truncated, or the last few bytes get +* overwritten by the FCS. +* +* Just use software checksumming and bypass on bigger frames. +*/ +if (skb->ip_summed ==CHECKSUM_PARTIAL ) { + ret =skb_checksum_help (skb); +if (ret) +return ret; + } + word1 |=TSS_BYPASS_BIT ; + }else if (skb->ip_summed ==CHECKSUM_PARTIAL ) {int tcp =0 ; +/* We do not switch off the checksumming on non TCP/UDP +* frames: as is shown from tests, the checksumming engine +* is smart enough to see that a frame is not actually TCP +* or UDP and then just pass it through without any changes +* to the frame. +*/ if (skb->protocol ==htons (ETH_P_IP )) { word1 |=TSS_IP_CHKSUM_BIT ; tcp =ip_hdr (skb)->protocol ==IPPROTO_TCP ;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 144/372 net: ethernet: cortina: Fix MTU max setting
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit dc6c0bfbaa947dd7976e30e8c29b10c868b6fa42 ]
The RX max frame size is over 10000 for the Gemini ethernet, but the TX max frame size is actually just 2047 (0x7ff after checking the datasheet). Reflect this in what we offer to Linux, cap the MTU at the TX max frame minus ethernet headers.
We delete the code disabling the hardware checksum for large MTUs as netdev->mtu can no longer be larger than netdev->max_mtu meaning the if()-clause in gmac_fix_features() is never true.
--- drivers/net/ethernet/cortina/gemini.c | 17 ++++------------- drivers/net/ethernet/cortina/gemini.h | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-)
drivers/net/ethernet/cortina/gemini.c +4 -13
@@ -2000,15 +2000,6 @@ static int gmac_change_mtu(struct net_device *netdev, int new_mtu)return 0 ; } -static netdev_features_t gmac_fix_features (struct net_device *netdev, -netdev_features_t features) -{ -if (netdev->mtu +ETH_HLEN +VLAN_HLEN >MTU_SIZE_BIT_MASK ) - features &= ~GMAC_OFFLOAD_FEATURES ; - -return features; -} -static int gmac_set_features (struct net_device *netdev,netdev_features_t features) {
@@ -2234,7 +2225,6 @@ static const struct net_device_ops gmac_351x_ops = { .ndo_set_mac_address = gmac_set_mac_address, .ndo_get_stats64 = gmac_get_stats64, .ndo_change_mtu = gmac_change_mtu, - .ndo_fix_features = gmac_fix_features, .ndo_set_features = gmac_set_features, };
@@ -2486,11 +2476,12 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) netdev->hw_features =GMAC_OFFLOAD_FEATURES ; netdev->features |=GMAC_OFFLOAD_FEATURES |NETIF_F_GRO ; -/* We can handle jumbo frames up to 10236 bytes so, let's accept -* payloads of 10236 bytes minus VLAN and ethernet header +/* We can receive jumbo frames up to 10236 bytes but only +* transmit 2047 bytes so, let's accept payloads of 2047 +* bytes minus VLAN and ethernet header */ netdev->min_mtu =ETH_MIN_MTU ; - netdev->max_mtu =10236 -VLAN_ETH_HLEN ; + netdev->max_mtu =MTU_SIZE_BIT_MASK -VLAN_ETH_HLEN ; port->freeq_refill =0 ;netif_napi_add (netdev, &port->napi, gmac_napi_poll);
drivers/net/ethernet/cortina/gemini.h +1 -1
@@ -502,7 +502,7 @@ union gmac_txdesc_3 {#define SOF_BIT 0x80000000#define EOF_BIT 0x40000000#define EOFIE_BIT BIT(29) -#define MTU_SIZE_BIT_MASK 0x1fff +#define MTU_SIZE_BIT_MASK 0x7ff/* Max MTU 2047 bytes */ /* GMAC Tx Descriptor */ struct gmac_txdesc {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 145/372 af_unix: fix use-after-free in unix_stream_read_actor()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 4b7b492615cf3017190f55444f7016812b66611d ]
syzbot reported the following crash [1]
After releasing unix socket lock, u->oob_skb can be changed by another thread. We must temporarily increase skb refcount to make sure this other thread will not free the skb under us.
[1]
BUG: KASAN: slab-use-after-free in unix_stream_read_actor+0xa7/0xc0 net/unix/af_unix.c:2866 Read of size 4 at addr ffff88801f3b9cc4 by task syz-executor107/5297 CPU: 1 PID: 5297 Comm: syz-executor107 Not tainted 6.6.0-syzkaller-15910-gb8e3a87a627b #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0xc4/0x620 mm/kasan/report.c:475 kasan_report+0xda/0x110 mm/kasan/report.c:588 unix_stream_read_actor+0xa7/0xc0 net/unix/af_unix.c:2866 unix_stream_recv_urg net/unix/af_unix.c:2587 [inline] unix_stream_read_generic+0x19a5/0x2480 net/unix/af_unix.c:2666 unix_stream_recvmsg+0x189/0x1b0 net/unix/af_unix.c:2903 sock_recvmsg_nosec net/socket.c:1044 [inline] sock_recvmsg+0xe2/0x170 net/socket.c:1066 ____sys_recvmsg+0x21f/0x5c0 net/socket.c:2803 ___sys_recvmsg+0x115/0x1a0 net/socket.c:2845 __sys_recvmsg+0x114/0x1e0 net/socket.c:2875 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b RIP: 0033:0x7fc67492c559 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 18 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fc6748ab228 EFLAGS: 00000246 ORIG_RAX: 000000000000002f RAX: ffffffffffffffda RBX: 000000000000001c RCX: 00007fc67492c559 RDX: 0000000040010083 RSI: 0000000020000140 RDI: 0000000000000004 RBP: 00007fc6749b6348 R08: 00007fc6748ab6c0 R09: 00007fc6748ab6c0 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fc6749b6340 R13: 00007fc6749b634c R14: 00007ffe9fac52a0 R15: 00007ffe9fac5388 </TASK> Allocated by task 5295: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 __kasan_slab_alloc+0x81/0x90 mm/kasan/common.c:328 kasan_slab_alloc include/linux/kasan.h:188 [inline] slab_post_alloc_hook mm/slab.h:763 [inline] slab_alloc_node mm/slub.c:3478 [inline] kmem_cache_alloc_node+0x180/0x3c0 mm/slub.c:3523 __alloc_skb+0x287/0x330 net/core/skbuff.c:641 alloc_skb include/linux/skbuff.h:1286 [inline] alloc_skb_with_frags+0xe4/0x710 net/core/skbuff.c:6331 sock_alloc_send_pskb+0x7e4/0x970 net/core/sock.c:2780 sock_alloc_send_skb include/net/sock.h:1884 [inline] queue_oob net/unix/af_unix.c:2147 [inline] unix_stream_sendmsg+0xb5f/0x10a0 net/unix/af_unix.c:2301 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0xd5/0x180 net/socket.c:745 ____sys_sendmsg+0x6ac/0x940 net/socket.c:2584 ___sys_sendmsg+0x135/0x1d0 net/socket.c:2638 __sys_sendmsg+0x117/0x1e0 net/socket.c:2667 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b Freed by task 5295: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x15b/0x1b0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:164 [inline] slab_free_hook mm/slub.c:1800 [inline] slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826 slab_free mm/slub.c:3809 [inline] kmem_cache_free+0xf8/0x340 mm/slub.c:3831 kfree_skbmem+0xef/0x1b0 net/core/skbuff.c:1015 __kfree_skb net/core/skbuff.c:1073 [inline] consume_skb net/core/skbuff.c:1288 [inline] consume_skb+0xdf/0x170 net/core/skbuff.c:1282 queue_oob net/unix/af_unix.c:2178 [inline] unix_stream_sendmsg+0xd49/0x10a0 net/unix/af_unix.c:2301 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0xd5/0x180 net/socket.c:745 ____sys_sendmsg+0x6ac/0x940 net/socket.c:2584 ___sys_sendmsg+0x135/0x1d0 net/socket.c:2638 __sys_sendmsg+0x117/0x1e0 net/socket.c:2667 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b The buggy address belongs to the object at ffff88801f3b9c80
which belongs to the cache skbuff_head_cache of size 240 The buggy address is located 68 bytes inside of freed 240-byte region [ffff88801f3b9c80, ffff88801f3b9d70)
The buggy address belongs to the physical page: page:ffffea00007cee40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1f3b9 flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000800 ffff888142a60640 dead000000000122 0000000000000000 raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 5299, tgid 5283 (syz-executor107), ts 103803840339, free_ts 103600093431 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1537 prep_new_page mm/page_alloc.c:1544 [inline] get_page_from_freelist+0xa25/0x36c0 mm/page_alloc.c:3312 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4568 alloc_pages_mpol+0x258/0x5f0 mm/mempolicy.c:2133 alloc_slab_page mm/slub.c:1870 [inline] allocate_slab+0x251/0x380 mm/slub.c:2017 new_slab mm/slub.c:2070 [inline] ___slab_alloc+0x8c7/0x1580 mm/slub.c:3223 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322 __slab_alloc_node mm/slub.c:3375 [inline] slab_alloc_node mm/slub.c:3468 [inline] kmem_cache_alloc_node+0x132/0x3c0 mm/slub.c:3523 __alloc_skb+0x287/0x330 net/core/skbuff.c:641 alloc_skb include/linux/skbuff.h:1286 [inline] alloc_skb_with_frags+0xe4/0x710 net/core/skbuff.c:6331 sock_alloc_send_pskb+0x7e4/0x970 net/core/sock.c:2780 sock_alloc_send_skb include/net/sock.h:1884 [inline] queue_oob net/unix/af_unix.c:2147 [inline] unix_stream_sendmsg+0xb5f/0x10a0 net/unix/af_unix.c:2301 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0xd5/0x180 net/socket.c:745 ____sys_sendmsg+0x6ac/0x940 net/socket.c:2584 ___sys_sendmsg+0x135/0x1d0 net/socket.c:2638 __sys_sendmsg+0x117/0x1e0 net/socket.c:2667 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1137 [inline] free_unref_page_prepare+0x4f8/0xa90 mm/page_alloc.c:2347 free_unref_page+0x33/0x3b0 mm/page_alloc.c:2487 __unfreeze_partials+0x21d/0x240 mm/slub.c:2655 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x18e/0x1d0 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x65/0x90 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:188 [inline] slab_post_alloc_hook mm/slab.h:763 [inline] slab_alloc_node mm/slub.c:3478 [inline] slab_alloc mm/slub.c:3486 [inline] __kmem_cache_alloc_lru mm/slub.c:3493 [inline] kmem_cache_alloc+0x15d/0x380 mm/slub.c:3502 vm_area_dup+0x21/0x2f0 kernel/fork.c:500 __split_vma+0x17d/0x1070 mm/mmap.c:2365 split_vma mm/mmap.c:2437 [inline] vma_modify+0x25d/0x450 mm/mmap.c:2472 vma_modify_flags include/linux/mm.h:3271 [inline] mprotect_fixup+0x228/0xc80 mm/mprotect.c:635 do_mprotect_pkey+0x852/0xd60 mm/mprotect.c:809 __do_sys_mprotect mm/mprotect.c:830 [inline] __se_sys_mprotect mm/mprotect.c:827 [inline] __x64_sys_mprotect+0x78/0xb0 mm/mprotect.c:827 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b Memory state around the buggy address: ffff88801f3b9b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88801f3b9c00: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc >ffff88801f3b9c80: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^ffff88801f3b9d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fcffff88801f3b9d80: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
--- net/unix/af_unix.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/unix/af_unix.c +5 -4
@@ -2641,15 +2641,16 @@ static int unix_stream_recv_urg(struct unix_stream_read_state *state)if (!(state->flags &MSG_PEEK ))WRITE_ONCE (u->oob_skb,NULL ); - +else +skb_get (oob_skb);unix_state_unlock (sk); chunk = state->recv_actor (oob_skb,0 , chunk, state); -if (!(state->flags &MSG_PEEK )) { +if (!(state->flags &MSG_PEEK ))UNIXCB (oob_skb).consumed +=1 ; -kfree_skb (oob_skb); - } + +consume_skb (oob_skb);mutex_unlock (&u->iolock);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 146/372 netfilter: nf_conntrack_bridge: initialize err to 0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkui Xiao <[email protected]>
[ Upstream commit a44af08e3d4d7566eeea98d7a29fe06e7b9de944 ]
K2CI reported a problem:
consume_skb(skb); return err;
[nf_br_ip_fragment() error] uninitialized symbol 'err'.
err is not initialized, because returning 0 is expected, initialize err to 0.
--- net/bridge/netfilter/nf_conntrack_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bridge/netfilter/nf_conntrack_bridge.c +1 -1
@@ -37,7 +37,7 @@ static int nf_br_ip_fragment(struct net *net, struct sock *sk,ktime_t tstamp = skb->tstamp;struct ip_frag_state state;struct iphdr *iph; -int err; +int err =0 ;/* for offloaded checksums cleanup checksum before fragmentation */ if (skb->ip_summed == CHECKSUM_PARTIAL &&
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 147/372 netfilter: nf_tables: fix pointer math issue in nft_byteorder_eval()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit c301f0981fdd3fd1ffac6836b423c4d7a8e0eb63 ]
The problem is in nft_byteorder_eval() where we are iterating through a loop and writing to dst[0], dst[1], dst[2] and so on... On each iteration we are writing 8 bytes. But dst[] is an array of u32 so each element only has space for 4 bytes. That means that every iteration overwrites part of the previous element.
I spotted this bug while reviewing commit caf3ef7468f7 ("netfilter:nf_tables: prevent OOB access in nft_byteorder_eval") which is a related issue. I think that the reason we have not detected this bug in testing is that most of time we only write one element.
--- include/net/netfilter/nf_tables.h | 4 ++-- net/netfilter/nft_byteorder.c | 5 +++-- net/netfilter/nft_meta.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)
include/net/netfilter/nf_tables.h +2 -2
@@ -177,9 +177,9 @@ static inline __be32 nft_reg_load_be32(const u32 *sreg)return *(__force __be32 *)sreg; } -static inline void nft_reg_store64 (u32 *dreg,u64 val) +static inline void nft_reg_store64 (u64 *dreg,u64 val) { -put_unaligned (val, (u64 *)dreg); +put_unaligned (val, dreg); }static inline u64 nft_reg_load64 (const u32 *sreg)
net/netfilter/nft_byteorder.c +3 -2
@@ -38,13 +38,14 @@ void nft_byteorder_eval(const struct nft_expr *expr,switch (priv->size) {case 8 : { +u64 *dst64 = (void *)dst;u64 src64;switch (priv->op) {case NFT_BYTEORDER_NTOH :for (i =0 ; i < priv->len /8 ; i++) { src64 =nft_reg_load64 (&src[i]); -nft_reg_store64 (&dst[i], +nft_reg_store64 (&dst64[i],be64_to_cpu ((__force __be64 )src64)); }break ;
@@ -52,7 +53,7 @@ void nft_byteorder_eval(const struct nft_expr *expr,for (i =0 ; i < priv->len /8 ; i++) { src64 = (__force __u64 )cpu_to_be64 (nft_reg_load64 (&src[i])); -nft_reg_store64 (&dst[i], src64); +nft_reg_store64 (&dst64[i], src64); }break ; }
net/netfilter/nft_meta.c +1 -1
@@ -63,7 +63,7 @@ nft_meta_get_eval_time(enum nft_meta_keys key, {switch (key) {case NFT_META_TIME_NS : -nft_reg_store64 (dest,ktime_get_real_ns ()); +nft_reg_store64 ((u64 *)dest,ktime_get_real_ns ());break ;case NFT_META_TIME_DAY :nft_reg_store8 (dest,nft_meta_weekday ());
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 148/372 net: stmmac: fix rx budget limit check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baruch Siach <[email protected]>
[ Upstream commit fa02de9e75889915b554eda1964a631fd019973b ]
The while loop condition verifies 'count < limit'. Neither value change before the 'count >= limit' check. As is this check is dead code. But code inspection reveals a code path that modifies 'count' and then goto 'drain_data' and back to 'read_again'. So there is a need to verify count value sanity after 'read_again'.
Move 'read_again' up to fix the count limit check.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -5233,10 +5233,10 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) len =0 ; } +read_again:if (count >= limit)break ; -read_again: buf1_len =0 ; buf2_len =0 ; entry = next_entry;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 149/372 net: stmmac: avoid rx queue overrun
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baruch Siach <[email protected]>
[ Upstream commit b6cb4541853c7ee512111b0e7ddf3cb66c99c137 ]
dma_rx_size can be set as low as 64. Rx budget might be higher than that. Make sure to not overrun allocated rx buffers when budget is larger.
Leave one descriptor unused to avoid wrap around of 'dirty_rx' vs 'cur_rx'.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -0
@@ -5198,6 +5198,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) dma_dir =page_pool_get_dma_dir (rx_q->page_pool); buf_sz =DIV_ROUND_UP (priv->dma_conf.dma_buf_sz,PAGE_SIZE ) *PAGE_SIZE ; + limit =min (priv->dma_conf.dma_rx_size -1 , (unsigned int )limit);if (netif_msg_rx_status (priv)) {void *rx_head;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 150/372 net/mlx5e: fix double free of encap_header
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dust Li <[email protected]>
[ Upstream commit 6f9b1a0731662648949a1c0587f6acb3b7f8acf1 ]
When mlx5_packet_reformat_alloc() fails, the encap_header allocated in mlx5e_tc_tun_create_header_ipv4{6} will be released within it. However, e->encap_header is already set to the previously freed encap_header before mlx5_packet_reformat_alloc(). As a result, the later mlx5e_encap_put() will free e->encap_header again, causing a double free issue.
mlx5e_encap_put()
--> mlx5e_encap_dealloc()
--> kfree(e->encap_header)This happens when cmd: MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT fail.
This patch fix it by not setting e->encap_header until mlx5_packet_reformat_alloc() success.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +4 -6
@@ -300,9 +300,6 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,if (err) goto destroy_neigh_entry; - e->encap_size = ipv4_encap_size; - e->encap_header = encap_header; -if (!(nud_state &NUD_VALID )) {neigh_event_send (attr.n,NULL );/* the encap entry will be made valid on neigh update event
@@ -322,6 +319,8 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, goto destroy_neigh_entry; } + e->encap_size = ipv4_encap_size; + e->encap_header = encap_header; e->flags |=MLX5_ENCAP_ENTRY_VALID ;mlx5e_rep_queue_neigh_stats_work (netdev_priv (attr.out_dev));mlx5e_route_lookup_ipv4_put (&attr);
@@ -568,9 +567,6 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,if (err) goto destroy_neigh_entry; - e->encap_size = ipv6_encap_size; - e->encap_header = encap_header; -if (!(nud_state &NUD_VALID )) {neigh_event_send (attr.n,NULL );/* the encap entry will be made valid on neigh update event
@@ -590,6 +586,8 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, goto destroy_neigh_entry; } + e->encap_size = ipv6_encap_size; + e->encap_header = encap_header; e->flags |=MLX5_ENCAP_ENTRY_VALID ;mlx5e_rep_queue_neigh_stats_work (netdev_priv (attr.out_dev));mlx5e_route_lookup_ipv6_put (&attr);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 151/372 net/mlx5e: fix double free of encap_header in update funcs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gavin Li <[email protected]>
[ Upstream commit 3a4aa3cb83563df942be49d145ee3b7ddf17d6bb ]
Follow up to the previous patch to fix the same issue for mlx5e_tc_tun_update_header_ipv4{6} when mlx5_packet_reformat_alloc() fails.
When mlx5_packet_reformat_alloc() fails, the encap_header allocated in mlx5e_tc_tun_update_header_ipv4{6} will be released within it. However, e->encap_header is already set to the previously freed encap_header before mlx5_packet_reformat_alloc(). As a result, the later mlx5e_encap_put() will free e->encap_header again, causing a double free issue.
mlx5e_encap_put()
--> mlx5e_encap_dealloc()
--> kfree(e->encap_header)This patch fix it by not setting e->encap_header until mlx5_packet_reformat_alloc() success.
--- .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +10 -10
@@ -403,16 +403,12 @@ int mlx5e_tc_tun_update_header_ipv4(struct mlx5e_priv *priv,if (err) goto free_encap; - e->encap_size = ipv4_encap_size; -kfree (e->encap_header); - e->encap_header = encap_header; -if (!(nud_state &NUD_VALID )) {neigh_event_send (attr.n,NULL );/* the encap entry will be made valid on neigh update event * and not used before that. */ - goto release_neigh; + goto free_encap; }memset (&reformat_params,0 ,sizeof (reformat_params));
@@ -426,6 +422,10 @@ int mlx5e_tc_tun_update_header_ipv4(struct mlx5e_priv *priv, goto free_encap; } + e->encap_size = ipv4_encap_size; +kfree (e->encap_header); + e->encap_header = encap_header; + e->flags |=MLX5_ENCAP_ENTRY_VALID ;mlx5e_rep_queue_neigh_stats_work (netdev_priv (attr.out_dev));mlx5e_route_lookup_ipv4_put (&attr);
@@ -669,16 +669,12 @@ int mlx5e_tc_tun_update_header_ipv6(struct mlx5e_priv *priv,if (err) goto free_encap; - e->encap_size = ipv6_encap_size; -kfree (e->encap_header); - e->encap_header = encap_header; -if (!(nud_state &NUD_VALID )) {neigh_event_send (attr.n,NULL );/* the encap entry will be made valid on neigh update event * and not used before that. */ - goto release_neigh; + goto free_encap; }memset (&reformat_params,0 ,sizeof (reformat_params));
@@ -692,6 +688,10 @@ int mlx5e_tc_tun_update_header_ipv6(struct mlx5e_priv *priv, goto free_encap; } + e->encap_size = ipv6_encap_size; +kfree (e->encap_header); + e->encap_header = encap_header; + e->flags |=MLX5_ENCAP_ENTRY_VALID ;mlx5e_rep_queue_neigh_stats_work (netdev_priv (attr.out_dev));mlx5e_route_lookup_ipv6_put (&attr);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 152/372 net/mlx5e: Fix pedit endianness
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlad Buslov <[email protected]>
[ Upstream commit 0c101a23ca7eaf00eef1328eefb04b3a93401cc8 ]
Referenced commit addressed endianness issue in mlx5 pedit implementation in ad hoc manner instead of systematically treating integer values according to their types which left pedit fields of sizes not equal to 4 and where the bytes being modified are not least significant ones broken on big endian machines since wrong bits will be consumed during parsing which leads to following example error when applying pedit to source and destination MAC addresses:
[Wed Oct 18 12:52:42 2023] mlx5_core 0001:00:00.1 p1v3_r: attempt to offload an unsupported field (cmd 0) [Wed Oct 18 12:52:42 2023] mask: 00000000330c5b68: 00 00 00 00 ff ff 00 00 00 00 ff ff 00 00 00 00 ................ [Wed Oct 18 12:52:42 2023] mask: 0000000017d22fd9: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [Wed Oct 18 12:52:42 2023] mask: 000000008186d717: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [Wed Oct 18 12:52:42 2023] mask: 0000000029eb6149: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [Wed Oct 18 12:52:42 2023] mask: 000000007ed103e4: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [Wed Oct 18 12:52:42 2023] mask: 00000000db8101a6: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [Wed Oct 18 12:52:42 2023] mask: 00000000ec3c08a9: 00 00 00 00 00 00 00 00 00 00 00 00 ............
Treat masks and values of pedit and filter match as network byte order, refactor pointers to them to void pointers instead of confusing u32 pointers and only cast to pointer-to-integer when reading a value from them. Treat pedit mlx5_fields->field_mask as host byte order according to its type u32, change the constants in fields array accordingly.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +32 -28
@@ -3102,7 +3102,7 @@ static struct mlx5_fields fields[] = {OFFLOAD (DIPV6_31_0 ,32 ,U32_MAX , ip6.daddr.s6_addr32[3 ],0 , dst_ipv4_dst_ipv6.ipv6_layout.ipv6[12 ]),OFFLOAD (IPV6_HOPLIMIT ,8 ,U8_MAX , ip6.hop_limit,0 , ttl_hoplimit), -OFFLOAD (IP_DSCP ,16 ,0xc00f , ip6,0 , ip_dscp), +OFFLOAD (IP_DSCP ,16 ,0x0fc0 , ip6,0 , ip_dscp),OFFLOAD (TCP_SPORT ,16 ,U16_MAX , tcp.source,0 , tcp_sport), OFFLOAD(TCP_DPORT, 16, U16_MAX, tcp.dest, 0, tcp_dport),
@@ -3113,21 +3113,31 @@ static struct mlx5_fields fields[] = { OFFLOAD(UDP_DPORT, 16, U16_MAX, udp.dest, 0, udp_dport), }; -static unsigned long mask_to_le (unsigned long mask,int size) +static u32 mask_field_get (void *mask,struct mlx5_fields *f) { -__be32 mask_be32; -__be16 mask_be16; - -if (size ==32 ) { - mask_be32 = (__force __be32)(mask); - mask = (__force unsigned long )cpu_to_le32 (be32_to_cpu (mask_be32)); - }else if (size ==16 ) { - mask_be32 = (__force __be32)(mask); - mask_be16 = *(__be16 *)&mask_be32; - mask = (__force unsigned long )cpu_to_le16 (be16_to_cpu (mask_be16)); +switch (f->field_bsize) { +case 32 : +return be32_to_cpu (*(__be32 *)mask) & f->field_mask; +case 16 : +return be16_to_cpu (*(__be16 *)mask) & (u16 )f->field_mask; +default : +return *(u8 *)mask & (u8 )f->field_mask; } +} -return mask; +static void mask_field_clear (void *mask,struct mlx5_fields *f) +{ +switch (f->field_bsize) { +case 32 : + *(__be32 *)mask &= ~cpu_to_be32 (f->field_mask); +break ; +case 16 : + *(__be16 *)mask &= ~cpu_to_be16 ((u16 )f->field_mask); +break ; +default : + *(u8 *)mask &= ~(u8 )f->field_mask; +break ; + } } static int offload_pedit_fields(struct mlx5e_priv *priv,
@@ -3139,11 +3149,12 @@ static int offload_pedit_fields(struct mlx5e_priv *priv,struct pedit_headers *set_masks, *add_masks, *set_vals, *add_vals;struct pedit_headers_action *hdrs = parse_attr->hdrs;void *headers_c, *headers_v, *action, *vals_p; -u32 *s_masks_p, *a_masks_p, s_mask, a_mask;struct mlx5e_tc_mod_hdr_acts *mod_acts; -unsigned long mask, field_mask; +void *s_masks_p, *a_masks_p;int i, first, last, next_z;struct mlx5_fields *f; +unsigned long mask; +u32 s_mask, a_mask;u8 cmd; mod_acts = &parse_attr->mod_hdr_acts;
@@ -3159,15 +3170,11 @@ static int offload_pedit_fields(struct mlx5e_priv *priv,bool skip; f = &fields[i]; -/* avoid seeing bits set from previous iterations */ - s_mask =0 ; - a_mask =0 ; - s_masks_p = (void *)set_masks + f->offset; a_masks_p = (void *)add_masks + f->offset; - s_mask = *s_masks_p & f->field_mask; - a_mask = *a_masks_p & f->field_mask; + s_mask =mask_field_get (s_masks_p, f); + a_mask =mask_field_get (a_masks_p, f);if (!s_mask && !a_mask)/* nothing to offload here */ continue ;
@@ -3194,22 +3201,20 @@ static int offload_pedit_fields(struct mlx5e_priv *priv, match_mask, f->field_bsize)) skip = true;/* clear to denote we consumed this field */ - *s_masks_p &= ~f->field_mask; +mask_field_clear (s_masks_p, f); }else { cmd =MLX5_ACTION_TYPE_ADD ; mask = a_mask; vals_p = (void *)add_vals + f->offset;/* add 0 is no change */ -if ((*(u32 *)vals_p & f->field_mask) ==0 ) +if (!mask_field_get (vals_p, f)) skip = true;/* clear to denote we consumed this field */ - *a_masks_p &= ~f->field_mask; +mask_field_clear (a_masks_p, f); }if (skip)continue ; - mask =mask_to_le (mask, f->field_bsize); - first =find_first_bit (&mask, f->field_bsize); next_z =find_next_zero_bit (&mask, f->field_bsize, first); last =find_last_bit (&mask, f->field_bsize);
@@ -3236,10 +3241,9 @@ static int offload_pedit_fields(struct mlx5e_priv *priv,MLX5_SET (set_action_in, action, field, f->field);if (cmd ==MLX5_ACTION_TYPE_SET ) { +unsigned long field_mask = f->field_mask;int start; - field_mask =mask_to_le (f->field_mask, f->field_bsize); -/* if field is bit sized it can start not from first bit */ start =find_first_bit (&field_mask, f->field_bsize);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 153/372 net/mlx5e: Reduce the size of icosq_str
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saeed Mahameed <[email protected]>
[ Upstream commit dce94142842e119b982c27c1b62bd20890c7fd21 ]
icosq_str size is unnecessarily too long, and it causes a build warning -Wformat-truncation with W=1. Looking closely, It doesn't need to be 255B, hence this patch reduces the size to 32B which should be more than enough to host the string: "ICOSQ: 0x%x, ".
While here, add a missing space in the formatted string.
This fixes the following build warning:
$ KCFLAGS='-Wall -Werror' $ make O=/tmp/kbuild/linux W=1 -s -j12 drivers/net/ethernet/mellanox/mlx5/core/
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c: In function 'mlx5e_reporter_rx_timeout':drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c:718:56:
error: ', CQ: 0x' directive output may be truncated writing 8 bytes into a region of size between 0 and 255 [-Werror=format-truncation=]
718 | "RX timeout on channel: %d, %sRQ: 0x%x, CQ: 0x%x",
| ^~~~~~~~drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c:717:9: note: 'snprintf' output between 43 and 322 bytes into a destination of size 288
717 | snprintf(err_str, sizeof(err_str),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
718 | "RX timeout on channel: %d, %sRQ: 0x%x, CQ: 0x%x",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
719 | rq->ix, icosq_str, rq->rqn, rq->cq.mcq.cqn);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--- drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +2 -2
@@ -668,11 +668,11 @@ static int mlx5e_rx_reporter_dump(struct devlink_health_reporter *reporter,void mlx5e_reporter_rx_timeout (struct mlx5e_rq *rq) { -char icosq_str[MLX5E_REPORTER_PER_Q_MAX_LEN ] = {};char err_str[MLX5E_REPORTER_PER_Q_MAX_LEN ];struct mlx5e_icosq *icosq = rq->icosq;struct mlx5e_priv *priv = rq->priv;struct mlx5e_err_ctx err_ctx = {}; +char icosq_str[32 ] = {}; err_ctx.ctx = rq; err_ctx.recover = mlx5e_rx_reporter_timeout_recover;
@@ -681,7 +681,7 @@ void mlx5e_reporter_rx_timeout(struct mlx5e_rq *rq)if (icosq)snprintf (icosq_str,sizeof (icosq_str),"ICOSQ: 0x%x, " , icosq->sqn);snprintf (err_str,sizeof (err_str), -"RX timeout on channel: %d, %sRQ: 0x%x, CQ: 0x%x" , +"RX timeout on channel: %d, %s RQ: 0x%x, CQ: 0x%x" , rq->ix, icosq_str, rq->rqn, rq->cq.mcq.cqn);mlx5e_health_report (priv, priv->rx_reporter, err_str, &err_ctx);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 154/372 net/mlx5e: Check return value of snprintf writing to fw_version buffer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rahul Rameshbabu <[email protected]>
[ Upstream commit 41e63c2baa11dc2aa71df5dd27a5bd87d11b6bbb ]
Treat the operation as an error case when the return value is equivalent to the size of the name buffer. Failed to write null terminator to the name buffer, making the string malformed and should not be used. Provide a string with only the firmware version when forming the string with the board id fails.
Without check, will trigger -Wformat-truncation with W=1.
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c: In function 'mlx5e_ethtool_get_drvinfo':
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c:49:31: warning: '%.16s' directive output may be truncated writing up to 16 bytes into a region of size between 13 and 22 [-Wformat-truncation=]
49 | "%d.%d.%04d (%.16s)",
| ^~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c:48:9: note: 'snprintf' output between 12 and 37 bytes into a destination of size 32
48 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49 | "%d.%d.%04d (%.16s)",
| ~~~~~~~~~~~~~~~~~~~~~
50 | fw_rev_maj(mdev), fw_rev_min(mdev), fw_rev_sub(mdev),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51 | mdev->board_id);
| ~~~~~~~~~~~~~~~--- .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +9 -4
@@ -43,12 +43,17 @@ void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv, struct ethtool_drvinfo *drvinfo) {struct mlx5_core_dev *mdev = priv->mdev; +int count;strscpy (drvinfo->driver,KBUILD_MODNAME ,sizeof (drvinfo->driver)); -snprintf (drvinfo->fw_version,sizeof (drvinfo->fw_version), -"%d.%d.%04d (%.16s)" , -fw_rev_maj (mdev),fw_rev_min (mdev),fw_rev_sub (mdev), - mdev->board_id); + count =snprintf (drvinfo->fw_version,sizeof (drvinfo->fw_version), +"%d.%d.%04d (%.16s)" ,fw_rev_maj (mdev), +fw_rev_min (mdev),fw_rev_sub (mdev), mdev->board_id); +if (count ==sizeof (drvinfo->fw_version)) +snprintf (drvinfo->fw_version,sizeof (drvinfo->fw_version), +"%d.%d.%04d" ,fw_rev_maj (mdev), +fw_rev_min (mdev),fw_rev_sub (mdev)); +strscpy (drvinfo->bus_info,dev_name (mdev->device),sizeof (drvinfo->bus_info)); }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 155/372 net/mlx5e: Check return value of snprintf writing to fw_version buffer for representors
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rahul Rameshbabu <[email protected]>
[ Upstream commit 1b2bd0c0264febcd8d47209079a6671c38e6558b ]
Treat the operation as an error case when the return value is equivalent to the size of the name buffer. Failed to write null terminator to the name buffer, making the string malformed and should not be used. Provide a string with only the firmware version when forming the string with the board id fails. This logic for representors is identical to normal flow with ethtool.
Without check, will trigger -Wformat-truncation with W=1.
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c: In function 'mlx5e_rep_get_drvinfo':
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:78:31: warning: '%.16s' directive output may be truncated writing up to 16 bytes into a region of size between 13 and 22 [-Wformat-truncation=]
78 | "%d.%d.%04d (%.16s)",
| ^~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:77:9: note: 'snprintf' output between 12 and 37 bytes into a destination of size 32
77 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78 | "%d.%d.%04d (%.16s)",
| ~~~~~~~~~~~~~~~~~~~~~
79 | fw_rev_maj(mdev), fw_rev_min(mdev),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80 | fw_rev_sub(mdev), mdev->board_id);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +8 -4
@@ -69,13 +69,17 @@ static void mlx5e_rep_get_drvinfo(struct net_device *dev, {struct mlx5e_priv *priv =netdev_priv (dev);struct mlx5_core_dev *mdev = priv->mdev; +int count;strscpy (drvinfo->driver, mlx5e_rep_driver_name,sizeof (drvinfo->driver)); -snprintf (drvinfo->fw_version,sizeof (drvinfo->fw_version), -"%d.%d.%04d (%.16s)" , -fw_rev_maj (mdev),fw_rev_min (mdev), -fw_rev_sub (mdev), mdev->board_id); + count =snprintf (drvinfo->fw_version,sizeof (drvinfo->fw_version), +"%d.%d.%04d (%.16s)" ,fw_rev_maj (mdev), +fw_rev_min (mdev),fw_rev_sub (mdev), mdev->board_id); +if (count ==sizeof (drvinfo->fw_version)) +snprintf (drvinfo->fw_version,sizeof (drvinfo->fw_version), +"%d.%d.%04d" ,fw_rev_maj (mdev), +fw_rev_min (mdev),fw_rev_sub (mdev)); }static const struct counter_desc sw_rep_stats_desc[] = {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 156/372 macvlan: Dont propagate promisc change to lower dev in passthru
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlad Buslov <[email protected]>
[ Upstream commit 7e1caeace0418381f36b3aa8403dfd82fc57fc53 ]
Macvlan device in passthru mode sets its lower device promiscuous mode according to its MACVLAN_FLAG_NOPROMISC flag instead of synchronizing it to its own promiscuity setting. However, macvlan_change_rx_flags() function doesn't check the mode before propagating such changes to the lower device which can cause net_device->promiscuity counter overflow as illustrated by reproduction example [0] and resulting dmesg log [1]. Fix the issue by first verifying the mode in macvlan_change_rx_flags() function before propagating promiscuous mode change to the lower device.
[0]:
ip link add macvlan1 link enp8s0f0 type macvlan mode passthru ip link set macvlan1 promisc on
ip l set dev macvlan1 up
ip link set macvlan1 promisc off
ip l set dev macvlan1 down
ip l set dev macvlan1 up
[1]:
[ 5156.281724] macvlan1: entered promiscuous mode [ 5156.285467] mlx5_core 0000:08:00.0 enp8s0f0: entered promiscuous mode [ 5156.287639] macvlan1: left promiscuous mode [ 5156.288339] mlx5_core 0000:08:00.0 enp8s0f0: left promiscuous mode [ 5156.290907] mlx5_core 0000:08:00.0 enp8s0f0: entered promiscuous mode [ 5156.317197] mlx5_core 0000:08:00.0 enp8s0f0: promiscuity touches roof, set promiscuity failed. promiscuity feature of device might be broken.
--- drivers/net/macvlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macvlan.c +1 -1
@@ -771,7 +771,7 @@ static void macvlan_change_rx_flags(struct net_device *dev, int change)if (dev->flags &IFF_UP ) {if (change &IFF_ALLMULTI )dev_set_allmulti (lowerdev, dev->flags &IFF_ALLMULTI ?1 :-1 ); -if (change &IFF_PROMISC ) +if (!macvlan_passthru (vlan->port) && change &IFF_PROMISC )dev_set_promiscuity (lowerdev, dev->flags &IFF_PROMISC ?1 :-1 );
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 157/372 tools/power/turbostat: Fix a knl bug
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Rui <[email protected]>
[ Upstream commit 137f01b3529d292a68d22e9681e2f903c768f790 ]
MSR_KNL_CORE_C6_RESIDENCY should be evaluated only if
1. this is KNL platform
AND
2. need to get C6 residency or need to calculate C1 residency
Fix the broken logic introduced by commit 1e9042b9c8d4 ("tools/power
turbostat: Fix CPU%C1 display value").
--- tools/power/x86/turbostat/turbostat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +1 -1
@@ -2180,7 +2180,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)if ((DO_BIC (BIC_CPU_c6) ||soft_c1_residency_display (BIC_CPU_c6)) && !do_knl_cstates) {if (get_msr (cpu,MSR_CORE_C6_RESIDENCY , &c->c6))return -7 ; - }else if (do_knl_cstates ||soft_c1_residency_display (BIC_CPU_c6)) { + }else if (do_knl_cstates &&soft_c1_residency_display (BIC_CPU_c6)) {if (get_msr (cpu,MSR_KNL_CORE_C6_RESIDENCY , &c->c6))return -7 ; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 158/372 tools/power/turbostat: Enable the C-state Pre-wake printing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Yu <[email protected]>
[ Upstream commit b61b7d8c4c22c4298a50ae5d0ee88facb85ce665 ]
Currently the C-state Pre-wake will not be printed due to the probe has not been invoked. Invoke the probe function accordingly.
--- tools/power/x86/turbostat/turbostat.c | 1 + 1 file changed, 1 insertion(+)
tools/power/x86/turbostat/turbostat.c +1 -0
@@ -5790,6 +5790,7 @@ void process_cpuid()rapl_probe (family, model);perf_limit_reasons_probe (family, model);automatic_cstate_conversion_probe (family, model); +prewake_cstate_probe (family, model);check_tcc_offset (model_orig);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 159/372 cifs: spnego: add ; in HOST_KEY_LEN
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anastasia Belova <[email protected]>
[ Upstream commit ff31ba19d732efb9aca3633935d71085e68d5076 ]
"host=" should start with ';' (as in cifs_get_spnego_key) So its length should be 6.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/smb/client/cifs_spnego.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/cifs_spnego.c +2 -2
@@ -64,8 +64,8 @@ struct key_type cifs_spnego_key_type = {* strlen(";sec=ntlmsspi") */ #define MAX_MECH_STR_LEN 13 -/* strlen of "host=" */ -#define HOST_KEY_LEN 5 +/* strlen of ";host=" */ +#define HOST_KEY_LEN 6/* strlen of ";ip4=" or ";ip6=" */ #define IP_KEY_LEN 5
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 160/372 cifs: fix check of rc in function generate_smb3signingkey
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ekaterina Esina <[email protected]>
[ Upstream commit 181724fc72486dec2bec8803459be05b5162aaa8 ]
Remove extra check after condition, add check after generating key for encryption. The check is needed to return non zero rc before rewriting it with generating key for decryption.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/smb/client/smb2transport.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/smb/client/smb2transport.c +2 -3
@@ -451,6 +451,8 @@ generate_smb3signingkey(struct cifs_ses *ses, ptriplet->encryption.context, ses->smb3encryptionkey, SMB3_ENC_DEC_KEY_SIZE); +if (rc) +return rc; rc = generate_key(ses, ptriplet->decryption.label, ptriplet->decryption.context, ses->smb3decryptionkey,
@@ -459,9 +461,6 @@ generate_smb3signingkey(struct cifs_ses *ses,return rc; } -if (rc) -return rc; -#ifdef CONFIG_CIFS_DEBUG_DUMP_KEYS cifs_dbg (VFS ,"%s: dumping generated AES session keys\n" , __func__);/*
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 161/372 i915/perf: Fix NULL deref bugs with drm_dbg() calls
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harshit Mogalapalli <[email protected]>
commit 471aa951bf1206d3c10d0daa67005b8e4db4ff83 upstream.
When i915 perf interface is not available dereferencing it will lead to NULL dereferences.
As returning -ENOTSUPP is pretty clear return when perf interface is not available.
--- drivers/gpu/drm/i915/i915_perf.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +3 -12
@@ -3809,11 +3809,8 @@ int i915_perf_open_ioctl(struct drm_deviu32 known_open_flags;int ret; -if (!perf->i915) { -drm_dbg (&perf->i915->drm, -"i915 perf interface not available for this system\n" ); +if (!perf->i915)return -ENOTSUPP ; - } known_open_flags =I915_PERF_FLAG_FD_CLOEXEC | I915_PERF_FLAG_FD_NONBLOCK |
@@ -4140,11 +4137,8 @@ int i915_perf_add_config_ioctl(struct drstruct i915_oa_reg *regs;int err, id; -if (!perf->i915) { -drm_dbg (&perf->i915->drm, -"i915 perf interface not available for this system\n" ); +if (!perf->i915)return -ENOTSUPP ; - }if (!perf->metrics_kobj) { drm_dbg(&perf->i915->drm,
@@ -4306,11 +4300,8 @@ int i915_perf_remove_config_ioctl(structstruct i915_oa_config *oa_config;int ret; -if (!perf->i915) { -drm_dbg (&perf->i915->drm, -"i915 perf interface not available for this system\n" ); +if (!perf->i915)return -ENOTSUPP ; - }if (i915_perf_stream_paranoid && !perfmon_capable ()) { drm_dbg(&perf->i915->drm,
Greg Kroah-Hartman
maintainerPATCH 162/372 drivers: perf: Check find_first_bit() return value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Ghiti <[email protected]>
commit c6e316ac05532febb0c966fa9b55f5258ed037be upstream.
We must check the return value of find_first_bit() before using the return value as an index array since it happens to overflow the array and then panic:
[ 107.318430] Kernel BUG [#1] [ 107.319434] CPU: 3 PID: 1238 Comm: kill Tainted: G E 6.6.0-rc6ubuntu-defconfig #2 [ 107.319465] Hardware name: riscv-virtio,qemu (DT) [ 107.319551] epc : pmu_sbi_ovf_handler+0x3a4/0x3ae [ 107.319840] ra : pmu_sbi_ovf_handler+0x52/0x3ae [ 107.319868] epc : ffffffff80a0a77c ra : ffffffff80a0a42a sp : ffffaf83fecda350 [ 107.319884] gp : ffffffff823961a8 tp : ffffaf8083db1dc0 t0 : ffffaf83fecda480 [ 107.319899] t1 : ffffffff80cafe62 t2 : 000000000000ff00 s0 : ffffaf83fecda520 [ 107.319921] s1 : ffffaf83fecda380 a0 : 00000018fca29df0 a1 : ffffffffffffffff [ 107.319936] a2 : 0000000001073734 a3 : 0000000000000004 a4 : 0000000000000000 [ 107.319951] a5 : 0000000000000040 a6 : 000000001d1c8774 a7 : 0000000000504d55 [ 107.319965] s2 : ffffffff82451f10 s3 : ffffffff82724e70 s4 : 000000000000003f [ 107.319980] s5 : 0000000000000011 s6 : ffffaf8083db27c0 s7 : 0000000000000000 [ 107.319995] s8 : 0000000000000001 s9 : 00007fffb45d6558 s10: 00007fffb45d81a0 [ 107.320009] s11: ffffaf7ffff60000 t3 : 0000000000000004 t4 : 0000000000000000 [ 107.320023] t5 : ffffaf7f80000000 t6 : ffffaf8000000000 [ 107.320037] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003 [ 107.320081] [<ffffffff80a0a77c>] pmu_sbi_ovf_handler+0x3a4/0x3ae [ 107.320112] [<ffffffff800b42d0>] handle_percpu_devid_irq+0x9e/0x1a0 [ 107.320131] [<ffffffff800ad92c>] generic_handle_domain_irq+0x28/0x36 [ 107.320148] [<ffffffff8065f9f8>] riscv_intc_irq+0x36/0x4e [ 107.320166] [<ffffffff80caf4a0>] handle_riscv_irq+0x54/0x86 [ 107.320189] [<ffffffff80cb0036>] do_irq+0x64/0x96 [ 107.320271] Code: 85a6 855e b097 ff7f 80e7 9220 b709 9002 4501 bbd9 (9002) 6097 [ 107.320585] ---[ end trace 0000000000000000 ]--- [ 107.320704] Kernel panic - not syncing: Fatal exception in interrupt [ 107.320775] SMP: stopping secondary CPUs [ 107.321219] Kernel Offset: 0x0 from 0xffffffff80000000 [ 107.333051] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
--- drivers/perf/riscv_pmu_sbi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/perf/riscv_pmu_sbi.c +5 -0
@@ -578,6 +578,11 @@ static irqreturn_t pmu_sbi_ovf_handler(i/* Firmware counter don't support overflow yet */ fidx =find_first_bit (cpu_hw_evt->used_hw_ctrs,RISCV_MAX_COUNTERS ); +if (fidx ==RISCV_MAX_COUNTERS ) { +csr_clear (CSR_SIP ,BIT (riscv_pmu_irq_num)); +return IRQ_NONE ; + } + event = cpu_hw_evt->events[fidx];if (!event) {csr_clear (CSR_SIP ,SIP_LCOFIP );
Re: [PATCH 6.1 162/372] drivers: perf: Check find_first_bit() return value
Quoted 42 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Ghiti <[email protected]>
commit
c6e316ac05532febb0c966fa9b55f5258ed037beupstream.We must check the return value of
find_first_bit()before using the return value as an index array since it happens to overflow the array and then panic:[ 107.318430] Kernel BUG [#1] [ 107.319434] CPU: 3 PID: 1238 Comm: kill Tainted: G E 6.6.0-rc6ubuntu-defconfig #2 [ 107.319465] Hardware name: riscv-virtio,qemu (DT) [ 107.319551] epc : pmu_sbi_ovf_handler+0x3a4/0x3ae [ 107.319840] ra : pmu_sbi_ovf_handler+0x52/0x3ae [ 107.319868] epc : ffffffff80a0a77c ra : ffffffff80a0a42a sp : ffffaf83fecda350 [ 107.319884] gp : ffffffff823961a8 tp : ffffaf8083db1dc0 t0 : ffffaf83fecda480 [ 107.319899] t1 : ffffffff80cafe62 t2 : 000000000000ff00 s0 : ffffaf83fecda520 [ 107.319921] s1 : ffffaf83fecda380 a0 : 00000018fca29df0 a1 : ffffffffffffffff [ 107.319936] a2 : 0000000001073734 a3 : 0000000000000004 a4 : 0000000000000000 [ 107.319951] a5 : 0000000000000040 a6 : 000000001d1c8774 a7 : 0000000000504d55 [ 107.319965] s2 : ffffffff82451f10 s3 : ffffffff82724e70 s4 : 000000000000003f [ 107.319980] s5 : 0000000000000011 s6 : ffffaf8083db27c0 s7 : 0000000000000000 [ 107.319995] s8 : 0000000000000001 s9 : 00007fffb45d6558 s10: 00007fffb45d81a0 [ 107.320009] s11: ffffaf7ffff60000 t3 : 0000000000000004 t4 : 0000000000000000 [ 107.320023] t5 : ffffaf7f80000000 t6 : ffffaf8000000000 [ 107.320037] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003 [ 107.320081] [<ffffffff80a0a77c>] pmu_sbi_ovf_handler+0x3a4/0x3ae [ 107.320112] [<ffffffff800b42d0>] handle_percpu_devid_irq+0x9e/0x1a0 [ 107.320131] [<ffffffff800ad92c>] generic_handle_domain_irq+0x28/0x36 [ 107.320148] [<ffffffff8065f9f8>] riscv_intc_irq+0x36/0x4e [ 107.320166] [<ffffffff80caf4a0>] handle_riscv_irq+0x54/0x86 [ 107.320189] [<ffffffff80cb0036>] do_irq+0x64/0x96 [ 107.320271] Code: 85a6 855e b097 ff7f 80e7 9220 b709 9002 4501 bbd9 (9002) 6097 [ 107.320585] ---[ end trace 0000000000000000 ]--- [ 107.320704] Kernel panic - not syncing: Fatal exception in interrupt [ 107.320775] SMP: stopping secondary CPUs [ 107.321219] Kernel Offset: 0x0 from 0xffffffff80000000 [ 107.333051] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
Quoted 6 lines
Fixes 4905ec2fb7e6 ("RISC-V: Add sscofpmf extension support")Signed-off-by Alexandre Ghiti <[email protected]>Signed-off-by Palmer Dabbelt <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
This patch causes build failure with riscv64 defconfig, as reported in:
https://lore.kernel.org/stable/[email protected]/
Reverting this, and everything build and boot fine (qemu riscv64)
Best regards,
Nam
Greg Kroah-Hartman
maintainerRe: [PATCH 6.1 162/372] drivers: perf: Check find_first_bit() return value
Quoted 50 lines · Nam Cao
Quoted 42 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Ghiti <[email protected]>
commit
c6e316ac05532febb0c966fa9b55f5258ed037beupstream.We must check the return value of
find_first_bit()before using the return value as an index array since it happens to overflow the array and then panic:[ 107.318430] Kernel BUG [#1] [ 107.319434] CPU: 3 PID: 1238 Comm: kill Tainted: G E 6.6.0-rc6ubuntu-defconfig #2 [ 107.319465] Hardware name: riscv-virtio,qemu (DT) [ 107.319551] epc : pmu_sbi_ovf_handler+0x3a4/0x3ae [ 107.319840] ra : pmu_sbi_ovf_handler+0x52/0x3ae [ 107.319868] epc : ffffffff80a0a77c ra : ffffffff80a0a42a sp : ffffaf83fecda350 [ 107.319884] gp : ffffffff823961a8 tp : ffffaf8083db1dc0 t0 : ffffaf83fecda480 [ 107.319899] t1 : ffffffff80cafe62 t2 : 000000000000ff00 s0 : ffffaf83fecda520 [ 107.319921] s1 : ffffaf83fecda380 a0 : 00000018fca29df0 a1 : ffffffffffffffff [ 107.319936] a2 : 0000000001073734 a3 : 0000000000000004 a4 : 0000000000000000 [ 107.319951] a5 : 0000000000000040 a6 : 000000001d1c8774 a7 : 0000000000504d55 [ 107.319965] s2 : ffffffff82451f10 s3 : ffffffff82724e70 s4 : 000000000000003f [ 107.319980] s5 : 0000000000000011 s6 : ffffaf8083db27c0 s7 : 0000000000000000 [ 107.319995] s8 : 0000000000000001 s9 : 00007fffb45d6558 s10: 00007fffb45d81a0 [ 107.320009] s11: ffffaf7ffff60000 t3 : 0000000000000004 t4 : 0000000000000000 [ 107.320023] t5 : ffffaf7f80000000 t6 : ffffaf8000000000 [ 107.320037] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003 [ 107.320081] [<ffffffff80a0a77c>] pmu_sbi_ovf_handler+0x3a4/0x3ae [ 107.320112] [<ffffffff800b42d0>] handle_percpu_devid_irq+0x9e/0x1a0 [ 107.320131] [<ffffffff800ad92c>] generic_handle_domain_irq+0x28/0x36 [ 107.320148] [<ffffffff8065f9f8>] riscv_intc_irq+0x36/0x4e [ 107.320166] [<ffffffff80caf4a0>] handle_riscv_irq+0x54/0x86 [ 107.320189] [<ffffffff80cb0036>] do_irq+0x64/0x96 [ 107.320271] Code: 85a6 855e b097 ff7f 80e7 9220 b709 9002 4501 bbd9 (9002) 6097 [ 107.320585] ---[ end trace 0000000000000000 ]--- [ 107.320704] Kernel panic - not syncing: Fatal exception in interrupt [ 107.320775] SMP: stopping secondary CPUs [ 107.321219] Kernel Offset: 0x0 from 0xffffffff80000000 [ 107.333051] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---Quoted 6 lines
Fixes 4905ec2fb7e6 ("RISC-V: Add sscofpmf extension support")Signed-off-by Alexandre Ghiti <[email protected]>Signed-off-by Palmer Dabbelt <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 4 lines
This patch causes build failure with riscv64 defconfig, as reported in:
https://lore.kernel.org/stable/[email protected]/Reverting this, and everything build and boot fine (qemu riscv64)
Thanks, now dropped.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 163/372 media: venus: hfi: add checks to perform sanity on queue pointers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit 5e538fce33589da6d7cb2de1445b84d3a8a692f7 upstream.
Read and write pointers are used to track the packet index in the memory shared between video driver and firmware. There is a possibility of OOB access if the read or write pointer goes beyond the queue memory size. Add checks for the read and write pointer to avoid OOB access.
--- drivers/media/platform/qcom/venus/hfi_venus.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/media/platform/qcom/venus/hfi_venus.c +10 -0
@@ -205,6 +205,11 @@ static int venus_write_queue(struct venu new_wr_idx = wr_idx + dwords; wr_ptr = (u32 *)(queue->qmem.kva + (wr_idx <<2 )); + +if (wr_ptr < (u32 *)queue->qmem.kva || + wr_ptr > (u32 *)(queue->qmem.kva + queue->qmem.size -sizeof (*wr_ptr))) +return -EINVAL ; +if (new_wr_idx < qsize) {memcpy (wr_ptr, packet, dwords <<2 ); }else {
@@ -272,6 +277,11 @@ static int venus_read_queue(struct venus } rd_ptr = (u32 *)(queue->qmem.kva + (rd_idx <<2 )); + +if (rd_ptr < (u32 *)queue->qmem.kva || + rd_ptr > (u32 *)(queue->qmem.kva + queue->qmem.size -sizeof (*rd_ptr))) +return -EINVAL ; + dwords = *rd_ptr >>2 ;if (!dwords)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 164/372 perf intel-pt: Fix async branch flags
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit f2d87895cbc4af80649850dcf5da36de6b2ed3dd upstream.
Ensure PERF_IP_FLAG_ASYNC is set always for asynchronous branches (i.e. interrupts etc).
--- tools/perf/util/intel-pt.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/intel-pt.c +2 -0
@@ -1483,9 +1483,11 @@ static void intel_pt_sample_flags(struct }else if (ptq->state->flags &INTEL_PT_ASYNC ) {if (!ptq->state->to_ip) ptq->flags =PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_ASYNC |PERF_IP_FLAG_TRACE_END ;else if (ptq->state->from_nr && !ptq->state->to_nr) ptq->flags =PERF_IP_FLAG_BRANCH |PERF_IP_FLAG_CALL | +PERF_IP_FLAG_ASYNC |PERF_IP_FLAG_VMEXIT ;else ptq->flags = PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL |
Greg Kroah-Hartman
maintainerPATCH 165/372 powerpc/perf: Fix disabling BHRB and instruction sampling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
commit ea142e590aec55ba40c5affb4d49e68c713c63dc upstream.
When the PMU is disabled, MMCRA is not updated to disable BHRB and instruction sampling. This can lead to those features remaining enabled, which can slow down a real or emulated CPU.
--- arch/powerpc/perf/core-book3s.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/perf/core-book3s.c +2 -3
@@ -1371,8 +1371,7 @@ static void power_pmu_disable(struct pmu/* * Disable instruction sampling if it was enabled */ -if (cpuhw->mmcr.mmcra &MMCRA_SAMPLE_ENABLE ) - val &= ~MMCRA_SAMPLE_ENABLE ; + val &= ~MMCRA_SAMPLE_ENABLE ;/* Disable BHRB via mmcra (BHRBRD) for p10 */ if (ppmu->flags &PPMU_ARCH_31 )
@@ -1383,7 +1382,7 @@ static void power_pmu_disable(struct pmu* instruction sampling or BHRB. */ if (val != mmcra) { -mtspr (SPRN_MMCRA , mmcra); +mtspr (SPRN_MMCRA , val);mb ();isync (); }
Greg Kroah-Hartman
maintainerPATCH 166/372 randstruct: Fix gcc-plugin performance mode to stay in group
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 381fdb73d1e2a48244de7260550e453d1003bb8e upstream.
The performance mode of the gcc-plugin randstruct was shuffling struct members outside of the cache-line groups. Limit the range to the specified group indexes.
--- scripts/gcc-plugins/randomize_layout_plugin.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
scripts/gcc-plugins/randomize_layout_plugin.c +8 -3
@@ -191,12 +191,14 @@ static void partition_struct(tree *fieldstatic void performance_shuffle (tree *newtree,unsigned long length,ranctx *prng_state) { -unsigned long i, x; +unsigned long i, x, index;struct partition_group size_group[length];unsigned long num_groups =0 ;unsigned long randnum;partition_struct (newtree, length, (struct partition_group *)&size_group, &num_groups); + +/* FIXME: this group shuffle is currently a no-op. */ for (i = num_groups -1 ; i >0 ; i--) {struct partition_group tmp; randnum =ranval (prng_state) % (i +1 );
@@ -206,11 +208,14 @@ static void performance_shuffle(tree *ne }for (x =0 ; x < num_groups; x++) { -for (i = size_group[x].start + size_group[x].length -1 ; i > size_group[x].start; i--) { +for (index = size_group[x].length -1 ; index >0 ; index--) {tree tmp; + + i = size_group[x].start + index;if (DECL_BIT_FIELD_TYPE (newtree[i]))continue ; - randnum =ranval (prng_state) % (i +1 ); + randnum =ranval (prng_state) % (index +1 ); + randnum += size_group[x].start;// we could handle this case differently if desired if (DECL_BIT_FIELD_TYPE (newtree[randnum]))continue ;
Greg Kroah-Hartman
maintainerPATCH 167/372 bpf: Fix check_stack_write_fixed_off() to correctly spill imm
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hao Sun <[email protected]>
commit 811c363645b33e6e22658634329e95f383dfc705 upstream.
In check_stack_write_fixed_off(), imm value is cast to u32 before being spilled to the stack. Therefore, the sign information is lost, and the range information is incorrect when load from the stack again.
For the following prog:
0: r2 = r10
1: *(u64*)(r2 -40) = -44
2: r0 = *(u64*)(r2 - 40)
3: if r0 s<= 0xa goto +2
4: r0 = 1
5: exit
6: r0 = 0
7: exit
The verifier gives:
func#0 @0
0: R1=ctx(off=0,imm=0) R10=fp0
0: (bf) r2 = r10 ; R2_w=fp0 R10=fp0 1: (7a) *(u64 *)(r2 -40) = -44 ; R2_w=fp0 fp-40_w=4294967252 2: (79) r0 = *(u64 *)(r2 -40) ; R0_w=4294967252 R2_w=fp0
fp-40_w=4294967252
3: (c5) if r0 s< 0xa goto pc+2mark_precise: frame0: last_idx 3 first_idx 0 subseq_idx -1mark_precise: frame0: regs=r0 stack= before 2: (79) r0 = *(u64 *)(r2 -40) 3: R0_w=4294967252
4: (b7) r0 = 1 ; R0_w=1
5: (95) exit
verification time 7971 usec
stack depth 40
processed 6 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
So remove the incorrect cast, since imm field is declared as s32, and __mark_reg_known() takes u64, so imm would be correctly sign extended by compiler.
--- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +1 -1
@@ -3292,7 +3292,7 @@ static int check_stack_write_fixed_off(s insn->imm != 0 && env->bpf_capable) {struct bpf_reg_state fake_reg = {}; -__mark_reg_known (&fake_reg, (u32 )insn->imm); +__mark_reg_known (&fake_reg, insn->imm); fake_reg.type =SCALAR_VALUE ;save_register_state (state, spi, &fake_reg, size); } else if (reg && is_spillable_regtype(reg->type)) {
Greg Kroah-Hartman
maintainerPATCH 168/372 bpf: Fix precision tracking for BPF_ALU | BPF_TO_BE | BPF_END
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shung-Hsi Yu <[email protected]>
commit 291d044fd51f8484066300ee42afecf8c8db7b3a upstream.
BPF_END and BPF_NEG has a different specification for the source bit in the opcode compared to other ALU/ALU64 instructions, and is either reserved or use to specify the byte swap endianness. In both cases the source bit does not encode source operand location, and src_reg is a reserved field.
backtrack_insn() currently does not differentiate BPF_END and BPF_NEG from other ALU/ALU64 instructions, which leads to r0 being incorrectly marked as precise when processing BPF_ALU | BPF_TO_BE | BPF_END instructions. This commit teaches backtrack_insn() to correctly mark precision for such case.
While precise tracking of BPF_NEG and other BPF_END instructions are correct and does not need fixing, this commit opt to process all BPF_NEG and BPF_END instructions within the same if-clause to better align with current convention used in the verifier (e.g. check_alu_op).
--- kernel/bpf/verifier.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/bpf/verifier.c +6 -1
@@ -2596,7 +2596,12 @@ static int backtrack_insn(struct bpf_verif (class ==BPF_ALU || class ==BPF_ALU64 ) {if (!(*reg_mask & dreg))return 0 ; -if (opcode ==BPF_MOV ) { +if (opcode ==BPF_END || opcode ==BPF_NEG ) { +/* sreg is reserved and unused +* dreg still need precision before this insn +*/ +return 0 ; + }else if (opcode ==BPF_MOV ) {if (BPF_SRC (insn->code) ==BPF_X ) {/* dreg = sreg * dreg needs precision after this insn
Greg Kroah-Hartman
maintainerPATCH 169/372 scsi: mpt3sas: Fix loop logic
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ranjan Kumar <[email protected]>
commit 3c978492c333f0c08248a8d51cecbe5eb5f617c9 upstream.
The retry loop continues to iterate until the count reaches 30, even after receiving the correct value. Exit loop when a non-zero value is read.
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -2
@@ -224,8 +224,8 @@ _base_readl_ext_retry(const volatile voifor (i =0 ; i <30 ; i++) { ret_val =readl (addr); -if (ret_val ==0 ) -continue ; +if (ret_val !=0 ) +break ; }return ret_val;
Greg Kroah-Hartman
maintainerPATCH 170/372 scsi: megaraid_sas: Increase register read retry rount from 3 to 30 for selected registers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth patil <[email protected]>
commit 8e3ed9e786511ad800c33605ed904b9de49323cf upstream.
In BMC environments with concurrent access to multiple registers, certain registers occasionally yield a value of 0 even after 3 retries due to hardware errata. As a fix, we have extended the retry count from 3 to 30.
The same errata applies to the mpt3sas driver, and a similar patch has been accepted. Please find more details in the mpt3sas patch reference link.
--- drivers/scsi/megaraid/megaraid_sas_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +2 -2
@@ -263,13 +263,13 @@ u32 megasas_readl(struct megasas_instanc* Fusion registers could intermittently return all zeroes. * This behavior is transient in nature and subsequent reads will * return valid value. As a workaround in driver, retry readl for -* upto three times until a non-zero value is read. +* up to thirty times until a non-zero value is read. */ if (instance->adapter_type ==AERO_SERIES ) {do { ret_val =readl (addr); i++; - }while (ret_val ==0 && i <3 ); + }while (ret_val ==0 && i <30 );return ret_val; }else {return readl (addr);
Greg Kroah-Hartman
maintainerPATCH 171/372 scsi: qla2xxx: Fix system crash due to bad pointer access
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 19597cad64d608aa8ac2f8aef50a50187a565223 upstream.
User experiences system crash when running AER error injection. The perturbation causes the abort-all-I/O path to trigger. The driver assumes all I/O on this path is FCP only. If there is both NVMe & FCP traffic, a system crash happens. Add additional check to see if I/O is FCP or not before access.
PID: 999019 TASK: ff35d769f24722c0 CPU: 53 COMMAND: "kworker/53:1"
0 [ff3f78b964847b58] machine_kexec at ffffffffae86973d
1 [ff3f78b964847ba8] __crash_kexec at ffffffffae9be29d
2 [ff3f78b964847c70] crash_kexec at ffffffffae9bf528
3 [ff3f78b964847c78] oops_end at ffffffffae8282ab
4 [ff3f78b964847c98] exc_page_fault at ffffffffaf2da502
5 [ff3f78b964847cc0] asm_exc_page_fault at ffffffffaf400b62
[exception RIP: qla2x00_abort_srb+444]
RIP: ffffffffc07b5f8c RSP: ff3f78b964847d78 RFLAGS: 00010046 RAX: 0000000000000282 RBX: ff35d74a0195a200 RCX: ff35d76886fd03a0 RDX: 0000000000000001 RSI: ffffffffc07c5ec8 RDI: ff35d74a0195a200 RBP: ff35d76913d22080 R8: ff35d7694d103200 R9: ff35d7694d103200 R10: 0000000100000000 R11: ffffffffb05d6630 R12: 0000000000010000 R13: ff3f78b964847df8 R14: ff35d768d8754000 R15: ff35d768877248e0 ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 6 [ff3f78b964847d70] qla2x00_abort_srb at ffffffffc07b5f84 [qla2xxx] 7 [ff3f78b964847de0] __qla2x00_abort_all_cmds at ffffffffc07b6238 [qla2xxx] 8 [ff3f78b964847e38] qla2x00_abort_all_cmds at ffffffffc07ba635 [qla2xxx] 9 [ff3f78b964847e58] qla2x00_terminate_rport_io at ffffffffc08145eb [qla2xxx]
10 [ff3f78b964847e70] fc_terminate_rport_io at ffffffffc045987e [scsi_transport_fc] 11 [ff3f78b964847e88] process_one_work at ffffffffae914f15
12 [ff3f78b964847ed0] worker_thread at ffffffffae9154c0
13 [ff3f78b964847f10] kthread at ffffffffae91c456
14 [ff3f78b964847f50] ret_from_fork at ffffffffae8036ef
--- drivers/scsi/qla2xxx/qla_os.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +10 -2
@@ -1831,8 +1831,16 @@ static void qla2x00_abort_srb(struct qla }spin_lock_irqsave (qp->qp_lock_ptr, *flags); -if (ret_cmd &&blk_mq_request_started (scsi_cmd_to_rq (cmd))) - sp->done (sp, res); +switch (sp->type) { +case SRB_SCSI_CMD : +if (ret_cmd &&blk_mq_request_started (scsi_cmd_to_rq (cmd))) + sp->done (sp, res); +break ; +default : +if (ret_cmd) + sp->done (sp, res); +break ; + } }else { sp->done (sp, res); }
Greg Kroah-Hartman
maintainerPATCH 172/372 crypto: x86/sha - load modules based on CPU features
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roxana Nicolescu <[email protected]>
commit 1c43c0f1f84aa59dfc98ce66f0a67b2922aa7f9d upstream.
x86 optimized crypto modules are built as modules rather than build-in and they are not loaded when the crypto API is initialized, resulting in the generic builtin module (sha1-generic) being used instead.
It was discovered when creating a sha1/sha256 checksum of a 2Gb file by using kcapi-tools because it would take significantly longer than creating a sha512 checksum of the same file. trace-cmd showed that for sha1/256 the generic module was used, whereas for sha512 the optimized module was used instead.
Add module aliases() for these x86 optimized crypto modules based on CPU feature bits so udev gets a chance to load them later in the boot process. This resulted in ~3x decrease in the real-time execution of kcapi-dsg.
Fix is inspired from commitaa031b8f702e ("crypto: x86/sha512 - load based on CPU features") where a similar fix was done for sha512.
--- arch/x86/crypto/sha1_ssse3_glue.c | 12 ++++++++++++ arch/x86/crypto/sha256_ssse3_glue.c | 12 ++++++++++++ 2 files changed, 24 insertions(+)
arch/x86/crypto/sha1_ssse3_glue.c +12 -0
@@ -24,8 +24,17 @@#include <linux/types.h> #include <crypto/sha1.h> #include <crypto/sha1_base.h> +#include <asm/cpu_device_id.h> #include <asm/simd.h> +static const struct x86_cpu_id module_cpu_ids[] = { +X86_MATCH_FEATURE (X86_FEATURE_AVX2 ,NULL ), +X86_MATCH_FEATURE (X86_FEATURE_AVX ,NULL ), +X86_MATCH_FEATURE (X86_FEATURE_SSSE3 ,NULL ), + {} +}; +MODULE_DEVICE_TABLE (x86cpu, module_cpu_ids); +static int sha1_update (struct shash_desc *desc,const u8 *data,unsigned int len,sha1_block_fn *sha1_xform) {
@@ -301,6 +310,9 @@ static inline void unregister_sha1_ni(vostatic int __init sha1_ssse3_mod_init (void ) { +if (!x86_match_cpu (module_cpu_ids)) +return -ENODEV ; +if (register_sha1_ssse3 ()) goto fail;
arch/x86/crypto/sha256_ssse3_glue.c +12 -0
@@ -38,11 +38,20 @@#include <crypto/sha2.h> #include <crypto/sha256_base.h> #include <linux/string.h> +#include <asm/cpu_device_id.h> #include <asm/simd.h> asmlinkage void sha256_transform_ssse3(struct sha256_state *state,const u8 *data,int blocks); +static const struct x86_cpu_id module_cpu_ids[] = { +X86_MATCH_FEATURE (X86_FEATURE_AVX2 ,NULL ), +X86_MATCH_FEATURE (X86_FEATURE_AVX ,NULL ), +X86_MATCH_FEATURE (X86_FEATURE_SSSE3 ,NULL ), + {} +}; +MODULE_DEVICE_TABLE (x86cpu, module_cpu_ids); +static int _sha256_update (struct shash_desc *desc,const u8 *data,unsigned int len,sha256_block_fn *sha256_xform) {
@@ -366,6 +375,9 @@ static inline void unregister_sha256_ni(static int __init sha256_ssse3_mod_init (void ) { +if (!x86_match_cpu (module_cpu_ids)) +return -ENODEV ; +if (register_sha256_ssse3 ()) goto fail;
Greg Kroah-Hartman
maintainerPATCH 173/372 x86/cpu/hygon: Fix the CPU topology evaluation for real
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Wen <[email protected]>
commit ee545b94d39a00c93dc98b1dbcbcf731d2eadeb4 upstream.
Hygon processors with a model ID > 3 have CPUID leaf 0xB correctly populated and don't need the fixed package ID shift workaround. The fixup is also incorrect when running in a guest.
--- arch/x86/kernel/cpu/hygon.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/hygon.c +6 -2
@@ -86,8 +86,12 @@ static void hygon_get_topology(struct cpif (!err) c->x86_coreid_bits =get_count_order (c->x86_max_cores); -/* Socket ID is ApicId[6] for these processors. */ - c->phys_proc_id = c->apicid >>APICID_SOCKET_ID_BIT ; +/* +* Socket ID is ApicId[6] for the processors with model <= 0x3 +* when running on host. +*/ +if (!boot_cpu_has (X86_FEATURE_HYPERVISOR ) && c->x86_model <=0x3 ) + c->phys_proc_id = c->apicid >>APICID_SOCKET_ID_BIT ;cacheinfo_hygon_init_llc_id (c, cpu); }else if (cpu_has (c,X86_FEATURE_NODEID_MSR )) {
Greg Kroah-Hartman
maintainerPATCH 174/372 KVM: x86: hyper-v: Dont auto-enable stimer on write from user-space
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Saenz Julienne <[email protected]>
commit d6800af51c76b6dae20e6023bbdc9b3da3ab5121 upstream.
Don't apply the stimer's counter side effects when modifying its value from user-space, as this may trigger spurious interrupts.
For example:
- The stimer is configured in auto-enable mode.
- The stimer's count is set and the timer enabled.
- The stimer expires, an interrupt is injected.
- The VM is live migrated.
- The stimer config and count are deserialized, auto-enable is ON, the stimer is re-enabled.
- The stimer expires right away, and injects an unwarranted interrupt.
--- arch/x86/kvm/hyperv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kvm/hyperv.c +6 -4
@@ -705,10 +705,12 @@ static int stimer_set_count(struct kvm_vstimer_cleanup (stimer); stimer->count = count; -if (stimer->count ==0 ) - stimer->config.enable =0 ; -else if (stimer->config.auto_enable) - stimer->config.enable =1 ; +if (!host) { +if (stimer->count ==0 ) + stimer->config.enable =0 ; +else if (stimer->config.auto_enable) + stimer->config.enable =1 ; + }if (stimer->config.enable)stimer_mark_pending (stimer, false);
Greg Kroah-Hartman
maintainerPATCH 175/372 KVM: x86: Ignore MSR_AMD64_TW_CFG access
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej S. Szmigiero <[email protected]>
commit 2770d4722036d6bd24bcb78e9cd7f6e572077d03 upstream.
Hyper-V enabled Windows Server 2022 KVM VM cannot be started on Zen1 Ryzen since it crashes at boot with SYSTEM_THREAD_EXCEPTION_NOT_HANDLED + STATUS_PRIVILEGED_INSTRUCTION (in other words, because of an unexpected #GP in the guest kernel).
This is because Windows tries to set bit 8 in MSR_AMD64_TW_CFG and can't handle receiving a #GP when doing so.
Give this MSR the same treatment that commit 2e32b7190641 ("x86, kvm: Add MSR_AMD64_BU_CFG2 to the list of ignored MSRs") gave MSR_AMD64_BU_CFG2 under justification that this MSR is baremetal-relevant only.
Although apparently it was then needed for Linux guests, not Windows as in this case.
With this change, the aforementioned guest setup is able to finish booting successfully.
This issue can be reproduced either on a Summit Ridge Ryzen (with just "-cpu host") or on a Naples EPYC (with "-cpu host,stepping=1" since EPYC is ordinarily stepping 2).
Alternatively, userspace could solve the problem by using MSR filters, but forcing every userspace to define a filter isn't very friendly and doesn't add much, if any, value. The only potential hiccup is if one of these "baremetal-only" MSRs ever requires actual emulation and/or has F/M/S specific behavior. But if that happens, then KVM can still punt *that* handling to userspace since userspace MSR filters "win" over KVM's default handling.
--- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kvm/x86.c | 2 ++ 2 files changed, 3 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
@@ -551,6 +551,7 @@#define MSR_AMD64_CPUID_FN_1 0xc0011004#define MSR_AMD64_LS_CFG 0xc0011020#define MSR_AMD64_DC_CFG 0xc0011022 +#define MSR_AMD64_TW_CFG 0xc0011023#define MSR_AMD64_DE_CFG 0xc0011029#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT 1
arch/x86/kvm/x86.c +2 -0
@@ -3582,6 +3582,7 @@ int kvm_set_msr_common(struct kvm_vcpu *case MSR_AMD64_PATCH_LOADER :case MSR_AMD64_BU_CFG2 :case MSR_AMD64_DC_CFG : +case MSR_AMD64_TW_CFG :case MSR_F15H_EX_CFG :break ;
@@ -3982,6 +3983,7 @@ int kvm_get_msr_common(struct kvm_vcpu *case MSR_AMD64_BU_CFG2 :case MSR_IA32_PERF_CTL :case MSR_AMD64_DC_CFG : +case MSR_AMD64_TW_CFG :case MSR_F15H_EX_CFG :/* * Intel Sandy Bridge CPUs must support the RAPL (running average power
Greg Kroah-Hartman
maintainerPATCH 176/372 KVM: x86: Clear bit12 of ICR after APIC-write VM-exit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Su <[email protected]>
commit 629d3698f6958ee6f8131ea324af794f973b12ac upstream.
When IPI virtualization is enabled, a WARN is triggered if bit12 of ICR MSR is set after APIC-write VM-exit. The reason is kvm_apic_send_ipi() thinks the APIC_ICR_BUSY bit should be cleared because KVM has no delay, but kvm_apic_write_nodecode() doesn't clear the APIC_ICR_BUSY bit.
Under the x2APIC section, regarding ICR, the SDM says:
It remains readable only to aid in debugging; however, software should not assume the value returned by reading the ICR is the last written value.
I.e. the guest is allowed to set bit 12. However, the SDM also gives KVM free reign to do whatever it wants with the bit, so long as KVM's behavior doesn't confuse userspace or break KVM's ABI.
Clear bit 12 so that it reads back as '0'. This approach is safer than "do nothing" and is consistent with the case where IPI virtualization is disabled or not supported, i.e.,
handle_fastpath_set_x2apic_icr_irqoff() -> kvm_x2apic_icr_write()
Opportunistically replace the TODO with a comment calling out that eating the write is likely faster than a conditional branch around the busy bit.
--- arch/x86/kvm/lapic.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
arch/x86/kvm/lapic.c +13 -13
@@ -2294,22 +2294,22 @@ EXPORT_SYMBOL_GPL(kvm_lapic_set_eoi);void kvm_apic_write_nodecode (struct kvm_vcpu *vcpu,u32 offset) {struct kvm_lapic *apic = vcpu->arch.apic; -u64 val;/* -* ICR is a single 64-bit register when x2APIC is enabled. For legacy -* xAPIC, ICR writes need to go down the common (slightly slower) path -* to get the upper half from ICR2. +* ICR is a single 64-bit register when x2APIC is enabled, all others +* registers hold 32-bit values. For legacy xAPIC, ICR writes need to +* go down the common path to get the upper half from ICR2. +* +* Note, using the write helpers may incur an unnecessary write to the +* virtual APIC state, but KVM needs to conditionally modify the value +* in certain cases, e.g. to clear the ICR busy bit. The cost of extra +* conditional branches is likely a wash relative to the cost of the +* maybe-unecessary write, and both are in the noise anyways. */ -if (apic_x2apic_mode (apic) && offset ==APIC_ICR ) { - val =kvm_lapic_get_reg64 (apic,APIC_ICR ); -kvm_apic_send_ipi (apic, (u32 )val, (u32)(val >>32 )); -trace_kvm_apic_write (APIC_ICR , val); - }else { -/* TODO: optimize to just emulate side effect w/o one more write */ - val =kvm_lapic_get_reg (apic, offset); -kvm_lapic_reg_write (apic, offset, (u32 )val); - } +if (apic_x2apic_mode (apic) && offset ==APIC_ICR ) +kvm_x2apic_icr_write (apic,kvm_lapic_get_reg64 (apic,APIC_ICR )); +else +kvm_lapic_reg_write (apic, offset,kvm_lapic_get_reg (apic, offset)); }EXPORT_SYMBOL_GPL (kvm_apic_write_nodecode);
Greg Kroah-Hartman
maintainerPATCH 177/372 audit: dont take task_lock() in audit_exe_compare() code path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moore <[email protected]>
commit 47846d51348dd62e5231a83be040981b17c955fa upstream.
The get_task_exe_file() function locks the given task with task_lock() which when used inside audit_exe_compare() can cause deadlocks on systems that generate audit records when the task_lock() is held. We resolve this problem with two changes: ignoring those cases where the task being audited is not the current task, and changing our approach to obtaining the executable file struct to not require task_lock().
With the intent of the audit exe filter being to filter on audit events generated by processes started by the specified executable, it makes sense that we would only want to use the exe filter on audit records associated with the currently executing process, e.g. @current. If we are asked to filter records using a non-@current task_struct we can safely ignore the exe filter without negatively impacting the admin's expectations for the exe filter.
Knowing that we only have to worry about filtering the currently executing task in audit_exe_compare() we can do away with the task_lock() and call get_mm_exe_file() with @current->mm directly.
--- kernel/audit_watch.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/audit_watch.c +8 -1
@@ -527,11 +527,18 @@ int audit_exe_compare(struct task_structunsigned long ino;dev_t dev; - exe_file =get_task_exe_file (tsk); +/* only do exe filtering if we are recording @current events/records */ +if (tsk != current) +return 0 ; + +if (WARN_ON_ONCE (!current->mm)) +return 0 ; + exe_file =get_mm_exe_file (current->mm);if (!exe_file)return 0 ; ino =file_inode (exe_file)->i_ino; dev =file_inode (exe_file)->i_sb->s_dev;fput (exe_file); +return audit_mark_compare (mark, ino, dev); }
Greg Kroah-Hartman
maintainerPATCH 178/372 audit: dont WARN_ON_ONCE(!current->mm) in audit_exe_compare()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moore <[email protected]>
commit 969d90ec212bae4b45bf9d21d7daa30aa6cf055e upstream.
eBPF can end up calling into the audit code from some odd places, and some of these places don't have @current set properly so we end up tripping the WARN_ON_ONCE(!current->mm) near the top of audit_exe_compare(). While the basic !current->mm check is good, the WARN_ON_ONCE() results in some scary console messages so let's drop that and just do the regular !current->mm check to avoid problems.
--- kernel/audit_watch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/audit_watch.c +1 -1
@@ -531,7 +531,7 @@ int audit_exe_compare(struct task_structif (tsk != current)return 0 ; -if (WARN_ON_ONCE (!current->mm)) +if (!current->mm)return 0 ; exe_file =get_mm_exe_file (current->mm);if (!exe_file)
Greg Kroah-Hartman
maintainerPATCH 179/372 proc: sysctl: prevent aliased sysctls from getting passed to init
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krister Johansen <[email protected]>
commit 8001f49394e353f035306a45bcf504f06fca6355 upstream.
The code that checks for unknown boot options is unaware of the sysctl alias facility, which maps bootparams to sysctl values. If a user sets an old value that has a valid alias, a message about an invalid parameter will be printed during boot, and the parameter will get passed to init. Fix by checking for the existence of aliased parameters in the unknown boot parameter code. If an alias exists, don't return an error or pass the value to init.
--- fs/proc/proc_sysctl.c | 7 +++++++ include/linux/sysctl.h | 6 ++++++ init/main.c | 4 ++++ 3 files changed, 17 insertions(+)
fs/proc/proc_sysctl.c +7 -0
@@ -1830,6 +1830,13 @@ static const char *sysctl_find_alias(chareturn NULL ; } +bool sysctl_is_alias (char *param) +{ +const char *alias =sysctl_find_alias (param); + +return alias !=NULL ; +} +/* Set sysctl value passed on kernel command line. */ static int process_sysctl_arg (char *param,char *val,const char *unused,void *arg)
include/linux/sysctl.h +6 -0
@@ -238,6 +238,7 @@ extern void __register_sysctl_init(constextern struct ctl_table_header *register_sysctl_mount_point (const char *path);void do_sysctl_args (void ); +bool sysctl_is_alias (char *param); int do_proc_douintvec(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos, int (*conv)(unsigned long *lvalp,
@@ -301,6 +302,11 @@ static inline void setup_sysctl_set(strustatic inline void do_sysctl_args (void ) { } + +static inline bool sysctl_is_alias (char *param) +{ +return false; +}#endif /* CONFIG_SYSCTL */ int sysctl_max_threads(struct ctl_table *table, int write, void *buffer,
init/main.c +4 -0
@@ -533,6 +533,10 @@ static int __init unknown_bootoption(cha {size_t len =strlen (param); +/* Handle params aliased to sysctls */ +if (sysctl_is_alias (param)) +return 0 ; +repair_env_string (param, val);/* Handle obsolete-style parameters */
Greg Kroah-Hartman
maintainerPATCH 180/372 tty/sysrq: replace smp_processor_id() with get_cpu()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
commit dd976a97d15b47656991e185a94ef42a0fa5cfd4 upstream.
The smp_processor_id() shouldn't be called from preemptible code. Instead use get_cpu() and put_cpu() which disables preemption in addition to getting the processor id. Enable preemption back after calling schedule_work() to make sure that the work gets scheduled on all cores other than the current core. We want to avoid a scenario where current core's stack trace is printed multiple times and one core's stack trace isn't printed because of scheduling of current task.
This fixes the following bug:
[ 119.143590] sysrq: Show backtrace of all active CPUs [ 119.143902] BUG: using smp_processor_id() in preemptible [00000000] code: bash/873 [ 119.144586] caller is debug_smp_processor_id+0x20/0x30 [ 119.144827] CPU: 6 PID: 873 Comm: bash Not tainted 5.10.124-dirty #3 [ 119.144861] Hardware name: QEMU QEMU Virtual Machine, BIOS 2023.05-1 07/22/2023 [ 119.145053] Call trace: [ 119.145093] dump_backtrace+0x0/0x1a0 [ 119.145122] show_stack+0x18/0x70 [ 119.145141] dump_stack+0xc4/0x11c [ 119.145159] check_preemption_disabled+0x100/0x110 [ 119.145175] debug_smp_processor_id+0x20/0x30 [ 119.145195] sysrq_handle_showallcpus+0x20/0xc0 [ 119.145211] __handle_sysrq+0x8c/0x1a0 [ 119.145227] write_sysrq_trigger+0x94/0x12c [ 119.145247] proc_reg_write+0xa8/0xe4 [ 119.145266] vfs_write+0xec/0x280 [ 119.145282] ksys_write+0x6c/0x100 [ 119.145298] __arm64_sys_write+0x20/0x30 [ 119.145315] el0_svc_common.constprop.0+0x78/0x1e4 [ 119.145332] do_el0_svc+0x24/0x8c [ 119.145348] el0_svc+0x10/0x20 [ 119.145364] el0_sync_handler+0x134/0x140 [ 119.145381] el0_sync+0x180/0x1c0
--- drivers/tty/sysrq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/sysrq.c +2 -1
@@ -263,13 +263,14 @@ static void sysrq_handle_showallcpus(intif (in_hardirq ()) regs =get_irq_regs (); -pr_info ("CPU%d:\n" ,smp_processor_id ()); +pr_info ("CPU%d:\n" ,get_cpu ());if (regs)show_regs (regs);else show_stack (NULL ,NULL ,KERN_INFO );schedule_work (&sysrq_showallcpus); +put_cpu (); } }
Greg Kroah-Hartman
maintainerPATCH 181/372 tty: serial: meson: fix hard LOCKUP on crtscts mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Krasavin <[email protected]>
commit 2a1d728f20edeee7f26dc307ed9df4e0d23947ab upstream.
There might be hard lockup if we set crtscts mode on port without RTS/CTS configured:
# stty -F /dev/ttyAML6 crtscts; echo 1 > /dev/ttyAML6; echo 2 > /dev/ttyAML6 [ 95.890386] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: [ 95.890857] rcu: 3-...0: (201 ticks this GP) idle=e33c/1/0x4000000000000000 softirq=5844/5846 fqs=4984 [ 95.900212] rcu: (detected by 2, t=21016 jiffies, g=7753, q=296 ncpus=4) [ 95.906972] Task dump for CPU 3: [ 95.910178] task:bash state:R running task stack:0 pid:205 ppid:1 flags:0x00000202 [ 95.920059] Call trace: [ 95.922485] __switch_to+0xe4/0x168 [ 95.925951] 0xffffff8003477508 [ 95.974379] watchdog: Watchdog detected hard LOCKUP on cpu 3 [ 95.974424] Modules linked in: 88x2cs(O) rtc_meson_vrtc
Possible solution would be to not allow to setup crtscts on such port.
Tested on S905X3 based board.
--- drivers/tty/serial/meson_uart.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/tty/serial/meson_uart.c +11 -3
@@ -380,10 +380,14 @@ static void meson_uart_set_termios(strucelse val |=AML_UART_STOP_BIT_1SB ; -if (cflags &CRTSCTS ) - val &= ~AML_UART_TWO_WIRE_EN ; -else +if (cflags &CRTSCTS ) { +if (port->flags &UPF_HARD_FLOW ) + val &= ~AML_UART_TWO_WIRE_EN ; +else + termios->c_cflag &= ~CRTSCTS ; + }else { val |=AML_UART_TWO_WIRE_EN ; + }writel (val, port->membase +AML_UART_CONTROL );
@@ -698,6 +702,7 @@ static int meson_uart_probe(struct platfu32 fifosize =64 ;/* Default is 64, 128 for EE UART_0 */ int ret =0 ;int irq; +bool has_rtscts;if (pdev->dev.of_node) pdev->id =of_alias_get_id (pdev->dev.of_node,"serial" );
@@ -725,6 +730,7 @@ static int meson_uart_probe(struct platfreturn irq;of_property_read_u32 (pdev->dev.of_node,"fifo-size" , &fifosize); + has_rtscts =of_property_read_bool (pdev->dev.of_node,"uart-has-rtscts" );if (meson_ports[pdev->id]) {dev_err (&pdev->dev,"port %d already allocated\n" , pdev->id);
@@ -744,6 +750,8 @@ static int meson_uart_probe(struct platf port->mapsize =resource_size (res_mem); port->irq = irq; port->flags =UPF_BOOT_AUTOCONF |UPF_LOW_LATENCY ; +if (has_rtscts) + port->flags |=UPF_HARD_FLOW ; port->has_sysrq =IS_ENABLED (CONFIG_SERIAL_MESON_CONSOLE ); port->dev = &pdev->dev; port->line = pdev->id;
Greg Kroah-Hartman
maintainerPATCH 182/372 hvc/xen: fix console unplug
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit a30badfd7c13fc8763a9e10c5a12ba7f81515a55 upstream.
On unplug of a Xen console, xencons_disconnect_backend() unconditionally calls free_irq() via unbind_from_irqhandler(), causing a warning of freeing an already-free IRQ:
(qemu) device_del con1
[ 32.050919] ------------[ cut here ]------------ [ 32.050942] Trying to free already-free IRQ 33 [ 32.050990] WARNING: CPU: 0 PID: 51 at kernel/irq/manage.c:1895 __free_irq+0x1d4/0x330
It should be using evtchn_put() to tear down the event channel binding, and let the Linux IRQ side of it be handled by notifier_del_irq() through the HVC code.
On which topic... xencons_disconnect_backend() should call hvc_remove() *first*, rather than tearing down the event channel and grant mapping while they are in use. And then the IRQ is guaranteed to be freed by the time it's torn down by evtchn_put().
Since evtchn_put() also closes the actual event channel, avoid calling xenbus_free_evtchn() except in the failure path where the IRQ was not successfully set up.
However, calling hvc_remove() at the start of xencons_disconnect_backend() still isn't early enough. An unplug request is indicated by the backend setting its state to XenbusStateClosing, which triggers a notification to xencons_backend_changed(), which... does nothing except set its own frontend state directly to XenbusStateClosed without *actually* tearing down the HVC device or, you know, making sure it isn't actively in use.
So the backend sees the guest frontend set its state to XenbusStateClosed and stops servicing the interrupt... and the guest spins for ever in the domU_write_console() function waiting for the ring to drain.
Fix that one by calling hvc_remove() from xencons_backend_changed() before signalling to the backend that it's OK to proceed with the removal.
Tested with 'dd if=/dev/zero of=/dev/hvc1' while telling Qemu to remove the console device.
--- drivers/tty/hvc/hvc_xen.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
drivers/tty/hvc/hvc_xen.c +24 -8
@@ -377,18 +377,21 @@ void xen_console_resume(void)#ifdef CONFIG_HVC_XEN_FRONTEND static void xencons_disconnect_backend (struct xencons_info *info) { -if (info->irq >0 ) -unbind_from_irqhandler (info->irq,NULL ); - info->irq =0 ; +if (info->hvc !=NULL ) +hvc_remove (info->hvc); + info->hvc =NULL ; +if (info->irq >0 ) { +evtchn_put (info->evtchn); + info->irq =0 ; + info->evtchn =0 ; + } +/* evtchn_put() will also close it so this is only an error path */ if (info->evtchn >0 )xenbus_free_evtchn (info->xbdev, info->evtchn); info->evtchn =0 ;if (info->gntref >0 )gnttab_free_grant_references (info->gntref); info->gntref =0 ; -if (info->hvc !=NULL ) -hvc_remove (info->hvc); - info->hvc =NULL ; }static void xencons_free (struct xencons_info *info)
@@ -553,10 +556,23 @@ static void xencons_backend_changed(struif (dev->state == XenbusStateClosed)break ; fallthrough;/* Missed the backend's CLOSING state */ -case XenbusStateClosing: +case XenbusStateClosing: { +struct xencons_info *info =dev_get_drvdata (&dev->dev);; + +/* +* Don't tear down the evtchn and grant ref before the other +* end has disconnected, but do stop userspace from trying +* to use the device before we allow the backend to close. +*/ +if (info->hvc) { +hvc_remove (info->hvc); + info->hvc =NULL ; + } +xenbus_frontend_closed (dev);break ; } + } }static const struct xenbus_device_id xencons_ids[] = {
@@ -616,7 +632,7 @@ static int __init xen_hvc_init(void)list_del (&info->list);spin_unlock_irqrestore (&xencons_lock, flags);if (info->irq) -unbind_from_irqhandler (info->irq,NULL ); +evtchn_put (info->evtchn);kfree (info);return r; }
Greg Kroah-Hartman
maintainerPATCH 183/372 hvc/xen: fix error path in xen_hvc_init() to always register frontend driver
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 2704c9a5593f4a47620c12dad78838ca62b52f48 upstream.
The xen_hvc_init() function should always register the frontend driver, even when there's no primary console — as there may be secondary consoles. (Qemu can always add secondary consoles, but only the toolstack can add the primary because it's special.)
--- drivers/tty/hvc/hvc_xen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/hvc/hvc_xen.c +3 -2
@@ -604,7 +604,7 @@ static int __init xen_hvc_init(void) ops = &dom0_hvc_ops; r =xen_initial_domain_console_init ();if (r <0 ) -return r; + goto register_fe; info =vtermno_to_xencons (HVC_COOKIE ); }else { ops = &domU_hvc_ops;
@@ -613,7 +613,7 @@ static int __init xen_hvc_init(void)else r =xen_pv_console_init ();if (r <0 ) -return r; + goto register_fe; info =vtermno_to_xencons (HVC_COOKIE ); info->irq =bind_evtchn_to_irq_lateeoi (info->evtchn);
@@ -638,6 +638,7 @@ static int __init xen_hvc_init(void) } r =0 ; + register_fe: #ifdef CONFIG_HVC_XEN_FRONTEND r =xenbus_register_frontend (&xencons_driver);#endif
Greg Kroah-Hartman
maintainerPATCH 184/372 hvc/xen: fix event channel handling for secondary consoles
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit ef5dd8ec88ac11e8e353164407d55b73c988b369 upstream.
The xencons_connect_backend() function allocates a local interdomain event channel with xenbus_alloc_evtchn(), then calls bind_interdomain_evtchn_to_irq_lateeoi() to bind to that port# on the *remote* domain.
That doesn't work very well:
(qemu) device_add xen-console,id=con1,chardev=pty0
[ 44.323872] xenconsole console-1: 2 xenbus_dev_probe on device/console/1 [ 44.323995] xenconsole: probe of console-1 failed with error -2
Fix it to use bind_evtchn_to_irq_lateeoi(), which does the right thing by just binding that *local* event channel to an irq. The backend will do the interdomain binding.
This didn't affect the primary console because the setup for that is special — the toolstack allocates the guest event channel and the guest discovers it with HVMOP_get_param.
--- drivers/tty/hvc/hvc_xen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/hvc/hvc_xen.c +1 -1
@@ -436,7 +436,7 @@ static int xencons_connect_backend(strucif (ret)return ret; info->evtchn = evtchn; - irq =bind_interdomain_evtchn_to_irq_lateeoi (dev, evtchn); + irq =bind_evtchn_to_irq_lateeoi (evtchn);if (irq <0 )return irq; info->irq = irq;
Greg Kroah-Hartman
maintainerPATCH 185/372 PCI/sysfs: Protect drivers D3cold preference from user space
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 70b70a4307cccebe91388337b1c85735ce4de6ff upstream.
struct pci_dev contains two flags which govern whether the device may suspend to D3cold:
* no_d3cold provides an opt-out for drivers (e.g. if a device is known to not wake from D3cold)
* d3cold_allowed provides an opt-out for user space (default is true, user space may set to false)
Since commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend"), the user space setting overwrites the driver setting. Essentially user space is trusted to know better than the driver whether D3cold is working.
That feels unsafe and wrong. Assume that the change was introduced inadvertently and do not overwrite no_d3cold when d3cold_allowed is modified. Instead, consider d3cold_allowed in addition to no_d3cold when choosing a suspend state for the device.
That way, user space may opt out of D3cold if the driver hasn't, but it may no longer force an opt in if the driver has opted out.
--- drivers/pci/pci-acpi.c | 2 +- drivers/pci/pci-sysfs.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/pci/pci-acpi.c +1 -1
@@ -911,7 +911,7 @@ pci_power_t acpi_pci_choose_state(struct {int acpi_state, d_max; -if (pdev->no_d3cold) +if (pdev->no_d3cold || !pdev->d3cold_allowed) d_max =ACPI_STATE_D3_HOT ;else d_max =ACPI_STATE_D3_COLD ;
drivers/pci/pci-sysfs.c +1 -4
@@ -529,10 +529,7 @@ static ssize_t d3cold_allowed_store(strureturn -EINVAL ; pdev->d3cold_allowed = !!val; -if (pdev->d3cold_allowed) -pci_d3cold_enable (pdev); -else -pci_d3cold_disable (pdev); +pci_bridge_d3_update (pdev);pm_runtime_resume (dev);
Greg Kroah-Hartman
maintainerPATCH 186/372 mm/damon/sysfs: remove requested targets when online-commit inputs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 19467a950b49432a84bf6dbadbbb17bdf89418b7 upstream.
damon_sysfs_set_targets(), which updates the targets of the context for online commitment, do not remove targets that removed from the corresponding sysfs files. As a result, more than intended targets of the context can exist and hence consume memory and monitoring CPU resource more than expected.
Fix it by removing all targets of the context and fill up again using the user input. This could cause unnecessary memory dealloc and realloc operations, but this is not a hot code path. Also, note that damon_target is stateless, and hence no data is lost.
--- mm/damon/sysfs.c | 68 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 33 deletions(-)
mm/damon/sysfs.c +35 -33
@@ -2188,58 +2188,60 @@ destroy_targets_out:return err; } -/* -* Search a target in a context that corresponds to the sysfs target input. -* -* Return: pointer to the target if found, NULL if not found, or negative -* error code if the search failed. -*/ -static struct damon_target *damon_sysfs_existing_target ( -struct damon_sysfs_target *sys_target,struct damon_ctx *ctx) +static int damon_sysfs_update_target (struct damon_target *target, +struct damon_ctx *ctx, +struct damon_sysfs_target *sys_target) {struct pid *pid; -struct damon_target *t; +struct damon_region *r, *next; -if (!damon_target_has_pid (ctx)) { -/* Up to only one target for paddr could exist */ -damon_for_each_target (t, ctx) -return t; -return NULL ; - } +if (!damon_target_has_pid (ctx)) +return 0 ; -/* ops.id should be DAMON_OPS_VADDR or DAMON_OPS_FVADDR */ pid =find_get_pid (sys_target->pid);if (!pid) -return ERR_PTR (-EINVAL ); -damon_for_each_target (t, ctx) { -if (t->pid == pid) { -put_pid (pid); -return t; - } +return -EINVAL ; + +/* no change to the target */ +if (pid == target->pid) { +put_pid (pid); +return 0 ; } -put_pid (pid); -return NULL ; + +/* remove old monitoring results and update the target's pid */ +damon_for_each_region_safe (r, next, target) +damon_destroy_region (r, target); +put_pid (target->pid); + target->pid = pid; +return 0 ; }static int damon_sysfs_set_targets (struct damon_ctx *ctx,struct damon_sysfs_targets *sysfs_targets) { -int i, err; +struct damon_target *t, *next; +int i =0 , err;/* Multiple physical address space monitoring targets makes no sense */ if (ctx->ops.id ==DAMON_OPS_PADDR && sysfs_targets->nr >1 )return -EINVAL ; -for (i =0 ; i < sysfs_targets->nr; i++) { +damon_for_each_target_safe (t, next, ctx) { +if (i < sysfs_targets->nr) { +damon_sysfs_update_target (t, ctx, + sysfs_targets->targets_arr[i]); + }else { +if (damon_target_has_pid (ctx)) +put_pid (t->pid); +damon_destroy_target (t); + } + i++; + } + +for (; i < sysfs_targets->nr; i++) {struct damon_sysfs_target *st = sysfs_targets->targets_arr[i]; -struct damon_target *t =damon_sysfs_existing_target (st, ctx); -if (IS_ERR (t)) -return PTR_ERR (t); -if (!t) - err =damon_sysfs_add_target (st, ctx); -else - err =damon_sysfs_set_regions (t, st->regions); + err =damon_sysfs_add_target (st, ctx);if (err)return err; }
Greg Kroah-Hartman
maintainerPATCH 187/372 mm/damon/sysfs: update monitoring target regions for online input commit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 9732336006764e2ee61225387e3c70eae9139035 upstream.
When user input is committed online, DAMON sysfs interface is ignoring the user input for the monitoring target regions. Such request is valid and useful for fixed monitoring target regions-based monitoring ops like 'paddr' or 'fvaddr'.
Update the region boundaries as user specified, too. Note that the monitoring results of the regions that overlap between the latest monitoring target regions and the new target regions are preserved.
Treat empty monitoring target regions user request as a request to just make no change to the monitoring target regions. Otherwise, users should set the monitoring target regions same to current one for every online input commit, and it could be challenging for dynamic monitoring target regions update DAMON ops like 'vaddr'. If the user really need to remove all monitoring target regions, they can simply remove the target and then create the target again with empty target regions.
--- mm/damon/sysfs.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-)
mm/damon/sysfs.c +30 -17
@@ -2188,34 +2188,47 @@ destroy_targets_out:return err; } -static int damon_sysfs_update_target (struct damon_target *target, -struct damon_ctx *ctx, -struct damon_sysfs_target *sys_target) +static int damon_sysfs_update_target_pid (struct damon_target *target,int pid) { -struct pid *pid; -struct damon_region *r, *next; - -if (!damon_target_has_pid (ctx)) -return 0 ; +struct pid *pid_new; - pid =find_get_pid (sys_target->pid); -if (!pid) + pid_new =find_get_pid (pid); +if (!pid_new)return -EINVAL ; -/* no change to the target */ -if (pid == target->pid) { -put_pid (pid); +if (pid_new == target->pid) { +put_pid (pid_new);return 0 ; } -/* remove old monitoring results and update the target's pid */ -damon_for_each_region_safe (r, next, target) -damon_destroy_region (r, target);put_pid (target->pid); - target->pid = pid; + target->pid = pid_new;return 0 ; } +static int damon_sysfs_update_target (struct damon_target *target, +struct damon_ctx *ctx, +struct damon_sysfs_target *sys_target) +{ +int err; + +if (damon_target_has_pid (ctx)) { + err =damon_sysfs_update_target_pid (target, sys_target->pid); +if (err) +return err; + } + +/* +* Do monitoring target region boundary update only if one or more +* regions are set by the user. This is for keeping current monitoring +* target results and range easier, especially for dynamic monitoring +* target regions update ops like 'vaddr'. +*/ +if (sys_target->regions->nr) + err =damon_sysfs_set_regions (target, sys_target->regions); +return err; +} +static int damon_sysfs_set_targets (struct damon_ctx *ctx,struct damon_sysfs_targets *sysfs_targets) {
Greg Kroah-Hartman
maintainerPATCH 188/372 watchdog: move softlockup_panic back to early_param
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krister Johansen <[email protected]>
commit 8b793bcda61f6c3ed4f5b2ded7530ef6749580cb upstream.
Setting softlockup_panic from do_sysctl_args() causes it to take effect later in boot. The lockup detector is enabled before SMP is brought online, but do_sysctl_args runs afterwards. If a user wants to set softlockup_panic on boot and have it trigger should a softlockup occur during onlining of the non-boot processors, they could do this prior to commit f117955a2255 ("kernel/watchdog.c: convert {soft/hard}lockup boot parameters to sysctl aliases"). However, after this commit the value of softlockup_panic is set too late to be of help for this type of problem. Restore the prior behavior.
--- fs/proc/proc_sysctl.c | 1 - kernel/watchdog.c | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
fs/proc/proc_sysctl.c +0 -1
@@ -1814,7 +1814,6 @@ static const struct sysctl_alias sysctl_ {"hung_task_panic", "kernel.hung_task_panic" }, {"numa_zonelist_order", "vm.numa_zonelist_order" }, {"softlockup_all_cpu_backtrace", "kernel.softlockup_all_cpu_backtrace" }, - {"softlockup_panic", "kernel.softlockup_panic" }, { } };
kernel/watchdog.c +7 -0
@@ -183,6 +183,13 @@ static DEFINE_PER_CPU(unsigned long, hrt static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved);static unsigned long soft_lockup_nmi_warn; +static int __init softlockup_panic_setup (char *str) +{ + softlockup_panic =simple_strtoul (str,NULL ,0 ); +return 1 ; +} +__setup ("softlockup_panic=" , softlockup_panic_setup); +static int __init nowatchdog_setup (char *str) { watchdog_user_enabled =0 ;
Greg Kroah-Hartman
maintainerPATCH 189/372 mm/damon/lru_sort: avoid divide-by-zero in hot threshold calculation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 44063f125af4bb4efd1d500d8091fa33a98af325 upstream.
When calculating the hotness threshold for lru_prio scheme of DAMON_LRU_SORT, the module divides some values by the maximum nr_accesses. However, due to the type of the related variables, simple division-based calculation of the divisor can return zero. As a result, divide-by-zero is possible. Fix it by using damon_max_nr_accesses(), which handles the case.
--- mm/damon/lru_sort.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
mm/damon/lru_sort.c +1 -3
@@ -195,9 +195,7 @@ static int damon_lru_sort_apply_parameteif (err)return err; -/* aggr_interval / sample_interval is the maximum nr_accesses */ - hot_thres = damon_lru_sort_mon_attrs.aggr_interval / - damon_lru_sort_mon_attrs.sample_interval * + hot_thres =damon_max_nr_accesses (&damon_lru_sort_mon_attrs) * hot_thres_access_freq /1000 ; scheme =damon_lru_sort_new_hot_scheme (hot_thres);if (!scheme)
Greg Kroah-Hartman
maintainerPATCH 190/372 mm/damon/ops-common: avoid divide-by-zero during region hotness calculation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 3bafc47d3c4a2fc4d3b382aeb3c087f8fc84d9fd upstream.
When calculating the hotness of each region for the under-quota regions prioritization, DAMON divides some values by the maximum nr_accesses. However, due to the type of the related variables, simple division-based calculation of the divisor can return zero. As a result, divide-by-zero is possible. Fix it by using damon_max_nr_accesses(), which handles the case.
--- mm/damon/ops-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
mm/damon/ops-common.c +2 -3
@@ -87,7 +87,6 @@ void damon_pmdp_mkold(pmd_t *pmd, structint damon_hot_score (struct damon_ctx *c,struct damon_region *r,struct damos *s) { -unsigned int max_nr_accesses;int freq_subscore;unsigned int age_in_sec;int age_in_log, age_subscore;
@@ -95,8 +94,8 @@ int damon_hot_score(struct damon_ctx *c,unsigned int age_weight = s->quota.weight_age;int hotness; - max_nr_accesses = c->attrs.aggr_interval / c->attrs.sample_interval; - freq_subscore = r->nr_accesses *DAMON_MAX_SUBSCORE / max_nr_accesses; + freq_subscore = r->nr_accesses *DAMON_MAX_SUBSCORE / +damon_max_nr_accesses (&c->attrs); age_in_sec = (unsigned long )r->age * c->attrs.aggr_interval /1000000 ; for (age_in_log = 0; age_in_log < DAMON_MAX_AGE_IN_LOG && age_in_sec;
Greg Kroah-Hartman
maintainerPATCH 191/372 mm/damon: implement a function for max nr_accesses safe calculation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 35f5d94187a6a3a8df2cba54beccca1c2379edb8 upstream.
Patch series "avoid divide-by-zero due to max_nr_accesses overflow".
The maximum nr_accesses of given DAMON context can be calculated by dividing the aggregation interval by the sampling interval. Some logics in DAMON uses the maximum nr_accesses as a divisor. Hence, the value shouldn't be zero. Such case is avoided since DAMON avoids setting the agregation interval as samller than the sampling interval. However, since nr_accesses is unsigned int while the intervals are unsigned long, the maximum nr_accesses could be zero while casting.
Avoid the divide-by-zero by implementing a function that handles the corner case (first patch), and replaces the vulnerable direct max nr_accesses calculations (remaining patches).
Note that the patches for the replacements are divided for broken commits, to make backporting on required tres easier. Especially, the last patch is for a patch that not yet merged into the mainline but in mm tree.
This patch (of 4):
The maximum nr_accesses of given DAMON context can be calculated by dividing the aggregation interval by the sampling interval. Some logics in DAMON uses the maximum nr_accesses as a divisor. Hence, the value shouldn't be zero. Such case is avoided since DAMON avoids setting the agregation interval as samller than the sampling interval. However, since nr_accesses is unsigned int while the intervals are unsigned long, the maximum nr_accesses could be zero while casting. Implement a function that handles the corner case.
Note that this commit is not fixing the real issue since this is only introducing the safe function that will replaces the problematic divisions. The replacements will be made by followup commits, to make backporting on stable series easier.
--- include/linux/damon.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/linux/damon.h +7 -0
@@ -559,6 +559,13 @@ static inline bool damon_target_has_pid(return ctx->ops.id ==DAMON_OPS_VADDR || ctx->ops.id ==DAMON_OPS_FVADDR ; } +static inline unsigned int damon_max_nr_accesses (const struct damon_attrs *attrs) +{ +/* {aggr,sample}_interval are unsigned long, hence could overflow */ +return min (attrs->aggr_interval / attrs->sample_interval, + (unsigned long )UINT_MAX ); +} +int damon_start (struct damon_ctx **ctxs,int nr_ctxs,bool exclusive);int damon_stop (struct damon_ctx **ctxs,int nr_ctxs);
Greg Kroah-Hartman
maintainerPATCH 192/372 mm/damon/sysfs: check error from damon_sysfs_update_target()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit b4936b544b08ed44949055b92bd25f77759ebafc upstream.
Patch series "mm/damon/sysfs: fix unhandled return values".
Some of DAMON sysfs interface code is not handling return values from some functions. As a result, confusing user input handling or NULL-dereference is possible. Check those properly.
This patch (of 3):
damon_sysfs_update_target() returns error code for failures, but its caller, damon_sysfs_set_targets() is ignoring that. The update function seems making no critical change in case of such failures, but the behavior will look like DAMON sysfs is silently ignoring or only partially accepting the user input. Fix it.
--- mm/damon/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/damon/sysfs.c +3 -1
@@ -2241,8 +2241,10 @@ static int damon_sysfs_set_targets(strucdamon_for_each_target_safe (t, next, ctx) {if (i < sysfs_targets->nr) { -damon_sysfs_update_target (t, ctx, + err =damon_sysfs_update_target (t, ctx, sysfs_targets->targets_arr[i]); +if (err) +return err; }else {if (damon_target_has_pid (ctx))put_pid (t->pid);
Greg Kroah-Hartman
maintainerPATCH 193/372 ACPI: resource: Do IRQ override on TongFang GMxXGxx
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Werner Sembach <[email protected]>
commit 0da9eccde3270b832c059ad618bf66e510c75d33 upstream.
The TongFang GMxXGxx/TUXEDO Stellaris/Pollaris Gen5 needs IRQ overriding for the keyboard to work.
Adding an entry for this laptop to the override_table makes the internal keyboard functional.
--- drivers/acpi/resource.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/acpi/resource.c +12 -0
@@ -500,6 +500,18 @@ static const struct dmi_system_id mainge } }, { +/* TongFang GMxXGxx/TUXEDO Polaris 15 Gen5 AMD */ + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GMxXGxx"), + }, + }, + { +/* TongFang GM6XGxX/TUXEDO Stellaris 16 Gen5 AMD */ + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GM6XGxX"), + }, + }, + { .ident = "MAINGEAR Vector Pro 2 17", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Micro Electronics Inc"),
Greg Kroah-Hartman
maintainerPATCH 194/372 regmap: Ensure range selector registers are updated after cache sync
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 0ec7731655de196bc1e4af99e495b38778109d22 upstream.
When we sync the register cache we do so with the cache bypassed in order to avoid overhead from writing the synced values back into the cache. If the regmap has ranges and the selector register for those ranges is in a register which is cached this has the unfortunate side effect of meaning that the physical and cached copies of the selector register can be out of sync after a cache sync. The cache will have whatever the selector was when the sync started and the hardware will have the selector for the register that was synced last.
Fix this by rewriting all cached selector registers after every sync, ensuring that the hardware and cache have the same content. This will result in extra writes that wouldn't otherwise be needed but is simple so hopefully robust. We don't read from the hardware since not all devices have physical read support.
Given that nobody noticed this until now it is likely that we are rarely if ever hitting this case.
--- drivers/base/regmap/regcache.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/base/regmap/regcache.c +30 -0
@@ -331,6 +331,11 @@ static int regcache_default_sync(structreturn 0 ; } +static int rbtree_all (const void *key,const struct rb_node *node) +{ +return 0 ; +} +/** * regcache_sync - Sync the register cache with the hardware. *
@@ -348,6 +353,7 @@ int regcache_sync(struct regmap *map)unsigned int i;const char *name;bool bypass; +struct rb_node *node;if (WARN_ON (map->cache_type ==REGCACHE_NONE ))return -EINVAL ;
@@ -392,6 +398,30 @@ out: map->async = false; map->cache_bypass = bypass; map->no_sync_defaults = false; + +/* +* If we did any paging with cache bypassed and a cached +* paging register then the register and cache state might +* have gone out of sync, force writes of all the paging +* registers. +*/ +rb_for_each (node,0 , &map->range_tree, rbtree_all) { +struct regmap_range_node *this = + rb_entry(node, struct regmap_range_node, node); + +/* If there's nothing in the cache there's nothing to sync */ + ret =regcache_read (map, this->selector_reg, &i); +if (ret !=0 ) +continue ; + + ret =_regmap_write (map, this->selector_reg, i); +if (ret !=0 ) { +dev_err (map->dev,"Failed to write %x = %x: %d\n" , + this->selector_reg, i, ret); +break ; + } + } + map->unlock (map->lock_arg);regmap_async_complete (map);
Greg Kroah-Hartman
maintainerPATCH 195/372 wifi: ath11k: fix temperature event locking
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 1a5352a81b4720ba43d9c899974e3bddf7ce0ce8 upstream.
The ath11k active pdevs are protected by RCU but the temperature event handling code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a read-side critical section as reported by RCU lockdep:
============================= WARNING: suspicious RCU usage 6.6.0-rc6 #7 Not tainted ----------------------------- drivers/net/wireless/ath/ath11k/mac.c:638 suspicious rcu_dereference_check() usage! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 no locks held by swapper/0/0. ... Call trace: ... lockdep_rcu_suspicious+0x16c/0x22c ath11k_mac_get_ar_by_pdev_id+0x194/0x1b0 [ath11k] ath11k_wmi_tlv_op_rx+0xa84/0x2c1c [ath11k] ath11k_htc_rx_completion_handler+0x388/0x510 [ath11k]
Mark the code in question as an RCU read-side critical section to avoid any potential use-after-free issues.
Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23
--- drivers/net/wireless/ath/ath11k/wmi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.c +6 -2
@@ -7775,15 +7775,19 @@ ath11k_wmi_pdev_temperature_event(structath11k_dbg (ab,ATH11K_DBG_WMI ,"pdev temperature ev temp %d pdev_id %d\n" , ev->temp, ev->pdev_id); +rcu_read_lock (); + ar =ath11k_mac_get_ar_by_pdev_id (ab, ev->pdev_id);if (!ar) {ath11k_warn (ab,"invalid pdev id in pdev temperature ev %d" , ev->pdev_id); -kfree (tb); -return ; + goto exit; }ath11k_thermal_event_temperature (ar, ev->temp); +exit: +rcu_read_unlock (); +kfree (tb); }
Greg Kroah-Hartman
maintainerPATCH 196/372 wifi: ath11k: fix dfs radar event locking
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 3b6c14833165f689cc5928574ebafe52bbce5f1e upstream.
The ath11k active pdevs are protected by RCU but the DFS radar event handling code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a read-side critical section.
Mark the code in question as an RCU read-side critical section to avoid any potential use-after-free issues.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath11k/wmi.c +4 -0
@@ -7729,6 +7729,8 @@ ath11k_wmi_pdev_dfs_radar_detected_event ev->detector_id, ev->segment_id, ev->timestamp, ev->is_chirp, ev->freq_offset, ev->sidx); +rcu_read_lock (); + ar =ath11k_mac_get_ar_by_pdev_id (ab, ev->pdev_id);if (!ar) {
@@ -7746,6 +7748,8 @@ ath11k_wmi_pdev_dfs_radar_detected_eventieee80211_radar_detected (ar->hw); exit: +rcu_read_unlock (); +kfree (tb); }
Greg Kroah-Hartman
maintainerPATCH 197/372 wifi: ath11k: fix htt pktlog locking
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 3f77c7d605b29df277d77e9ee75d96e7ad145d2d upstream.
The ath11k active pdevs are protected by RCU but the htt pktlog handling code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a read-side critical section.
Mark the code in question as an RCU read-side critical section to avoid any potential use-after-free issues.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +7 -1
@@ -1621,14 +1621,20 @@ static void ath11k_htt_pktlog(struct athu8 pdev_id; pdev_id =FIELD_GET (HTT_T2H_PPDU_STATS_INFO_PDEV_ID , data->hdr); + +rcu_read_lock (); + ar =ath11k_mac_get_ar_by_pdev_id (ab, pdev_id);if (!ar) {ath11k_warn (ab,"invalid pdev id %d on htt pktlog\n" , pdev_id); -return ; + goto out; }trace_ath11k_htt_pktlog (ar, data->payload, hdr->size, ar->ab->pktlog_defs_checksum); + +out: +rcu_read_unlock (); } static void ath11k_htt_backpressure_event_handler(struct ath11k_base *ab,
Greg Kroah-Hartman
maintainerPATCH 198/372 wifi: ath11k: fix gtk offload status event locking
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 1dea3c0720a146bd7193969f2847ccfed5be2221 upstream.
The ath11k active pdevs are protected by RCU but the gtk offload status event handling code calling ath11k_mac_get_arvif_by_vdev_id() was not marked as a read-side critical section.
Mark the code in question as an RCU read-side critical section to avoid any potential use-after-free issues.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.c +5 -2
@@ -8001,12 +8001,13 @@ static void ath11k_wmi_gtk_offload_statureturn ; } +rcu_read_lock (); + arvif =ath11k_mac_get_arvif_by_vdev_id (ab, ev->vdev_id);if (!arvif) {ath11k_warn (ab,"failed to get arvif for vdev_id:%d\n" , ev->vdev_id); -kfree (tb); -return ; + goto exit; } ath11k_dbg(ab, ATH11K_DBG_WMI, "wmi gtk offload event refresh_cnt %d\n",
@@ -8023,6 +8024,8 @@ static void ath11k_wmi_gtk_offload_statuieee80211_gtk_rekey_notify (arvif->vif, arvif->bssid, (void *)&replay_ctr_be,GFP_ATOMIC ); +exit: +rcu_read_unlock ();kfree (tb); }
Greg Kroah-Hartman
maintainerPATCH 199/372 mmc: meson-gx: Remove setting of CMD_CFG_ERROR
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rong Chen <[email protected]>
commit 57925e16c9f7d18012bcf45bfa658f92c087981a upstream.
For the t7 and older SoC families, the CMD_CFG_ERROR has no effect. Starting from SoC family C3, setting this bit without SG LINK data address will cause the controller to generate an IRQ and stop working.
To fix it, don't set the bit CMD_CFG_ERROR anymore.
--- drivers/mmc/host/meson-gx-mmc.c | 1 - 1 file changed, 1 deletion(-)
drivers/mmc/host/meson-gx-mmc.c +0 -1
@@ -817,7 +817,6 @@ static void meson_mmc_start_cmd(struct m cmd_cfg |=FIELD_PREP (CMD_CFG_CMD_INDEX_MASK , cmd->opcode); cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ - cmd_cfg |=CMD_CFG_ERROR ;/* stop in case of error */ meson_mmc_set_response_bits (cmd, &cmd_cfg);
Greg Kroah-Hartman
maintainerPATCH 200/372 genirq/generic_chip: Make irq_remove_generic_chip() irqdomain aware
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herve Codina <[email protected]>
commit 5e7afb2eb7b2a7c81e9f608cbdf74a07606fd1b5 upstream.
irq_remove_generic_chip() calculates the Linux interrupt number for removing the handler and interrupt chip based on gc::irq_base as a linear function of the bit positions of set bits in the @msk argument.
When the generic chip is present in an irq domain, i.e. created with a call to irq_alloc_domain_generic_chips(), gc::irq_base contains not the base Linux interrupt number. It contains the base hardware interrupt for this chip. It is set to 0 for the first chip in the domain, 0 + N for the next chip, where $N is the number of hardware interrupts per chip.
That means the Linux interrupt number cannot be calculated based on gc::irq_base for irqdomain based chips without a domain map lookup, which is currently missing.
Rework the code to take the irqdomain case into account and calculate the Linux interrupt number by a irqdomain lookup of the domain specific hardware interrupt number.
[ tglx: Massage changelog. Reshuffle the logic and add a proper comment. ]
--- kernel/irq/generic-chip.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
kernel/irq/generic-chip.c +19 -6
@@ -544,21 +544,34 @@ EXPORT_SYMBOL_GPL(irq_setup_alt_chip);void irq_remove_generic_chip (struct irq_chip_generic *gc,u32 msk,unsigned int clr,unsigned int set) { -unsigned int i = gc->irq_base; +unsigned int i, virq;raw_spin_lock (&gc_lock);list_del (&gc->list);raw_spin_unlock (&gc_lock); -for (; msk; msk >>=1 , i++) { +for (i =0 ; msk; msk >>=1 , i++) {if (!(msk &0x01 ))continue ; +/* +* Interrupt domain based chips store the base hardware +* interrupt number in gc::irq_base. Otherwise gc::irq_base +* contains the base Linux interrupt number. +*/ +if (gc->domain) { + virq =irq_find_mapping (gc->domain, gc->irq_base + i); +if (!virq) +continue ; + }else { + virq = gc->irq_base + i; + } +/* Remove handler first. That will mask the irq line */ -irq_set_handler (i,NULL ); -irq_set_chip (i, &no_irq_chip); -irq_set_chip_data (i,NULL ); -irq_modify_status (i, clr, set); +irq_set_handler (virq,NULL ); +irq_set_chip (virq, &no_irq_chip); +irq_set_chip_data (virq,NULL ); +irq_modify_status (virq, clr, set); } }EXPORT_SYMBOL_GPL (irq_remove_generic_chip);
Greg Kroah-Hartman
maintainerPATCH 201/372 KEYS: trusted: tee: Refactor register SHM usage
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumit Garg <[email protected]>
commit c745cd1718b7825d69315fe7127e2e289e617598 upstream.
The OP-TEE driver using the old SMC based ABI permits overlapping shared buffers, but with the new FF-A based ABI each physical page may only be registered once.
As the key and blob buffer are allocated adjancently, there is no need for redundant register shared memory invocation. Also, it is incompatibile with FF-A based ABI limitation. So refactor register shared memory implementation to use only single invocation to register both key and blob buffers.
--- security/keys/trusted-keys/trusted_tee.c | 64 +++++++++---------------------- 1 file changed, 20 insertions(+), 44 deletions(-)
security/keys/trusted-keys/trusted_tee.c +20 -44
@@ -65,24 +65,16 @@ static int trusted_tee_seal(struct trustint ret;struct tee_ioctl_invoke_arg inv_arg;struct tee_param param[4 ]; -struct tee_shm *reg_shm_in =NULL , *reg_shm_out =NULL ; +struct tee_shm *reg_shm =NULL ;memset (&inv_arg,0 ,sizeof (inv_arg));memset (¶m,0 ,sizeof (param)); - reg_shm_in =tee_shm_register_kernel_buf (pvt_data.ctx, p->key, - p->key_len); -if (IS_ERR (reg_shm_in)) { -dev_err (pvt_data.dev,"key shm register failed\n" ); -return PTR_ERR (reg_shm_in); - } - - reg_shm_out =tee_shm_register_kernel_buf (pvt_data.ctx, p->blob, -sizeof (p->blob)); -if (IS_ERR (reg_shm_out)) { -dev_err (pvt_data.dev,"blob shm register failed\n" ); - ret =PTR_ERR (reg_shm_out); - goto out; + reg_shm =tee_shm_register_kernel_buf (pvt_data.ctx, p->key, +sizeof (p->key) +sizeof (p->blob)); +if (IS_ERR (reg_shm)) { +dev_err (pvt_data.dev,"shm register failed\n" ); +return PTR_ERR (reg_shm); } inv_arg.func =TA_CMD_SEAL ;
@@ -90,13 +82,13 @@ static int trusted_tee_seal(struct trust inv_arg.num_params =4 ; param[0 ].attr =TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT ; - param[0 ].u.memref.shm = reg_shm_in; + param[0 ].u.memref.shm = reg_shm; param[0 ].u.memref.size = p->key_len; param[0 ].u.memref.shm_offs =0 ; param[1 ].attr =TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT ; - param[1 ].u.memref.shm = reg_shm_out; + param[1 ].u.memref.shm = reg_shm; param[1 ].u.memref.size =sizeof (p->blob); - param[1 ].u.memref.shm_offs =0 ; + param[1 ].u.memref.shm_offs =sizeof (p->key); ret =tee_client_invoke_func (pvt_data.ctx, &inv_arg, param);if ((ret <0 ) || (inv_arg.ret !=0 )) {
@@ -107,11 +99,7 @@ static int trusted_tee_seal(struct trust p->blob_len = param[1 ].u.memref.size; } -out: -if (reg_shm_out) -tee_shm_free (reg_shm_out); -if (reg_shm_in) -tee_shm_free (reg_shm_in); +tee_shm_free (reg_shm);return ret; }
@@ -124,24 +112,16 @@ static int trusted_tee_unseal(struct truint ret;struct tee_ioctl_invoke_arg inv_arg;struct tee_param param[4 ]; -struct tee_shm *reg_shm_in =NULL , *reg_shm_out =NULL ; +struct tee_shm *reg_shm =NULL ;memset (&inv_arg,0 ,sizeof (inv_arg));memset (¶m,0 ,sizeof (param)); - reg_shm_in =tee_shm_register_kernel_buf (pvt_data.ctx, p->blob, - p->blob_len); -if (IS_ERR (reg_shm_in)) { -dev_err (pvt_data.dev,"blob shm register failed\n" ); -return PTR_ERR (reg_shm_in); - } - - reg_shm_out =tee_shm_register_kernel_buf (pvt_data.ctx, p->key, -sizeof (p->key)); -if (IS_ERR (reg_shm_out)) { -dev_err (pvt_data.dev,"key shm register failed\n" ); - ret =PTR_ERR (reg_shm_out); - goto out; + reg_shm =tee_shm_register_kernel_buf (pvt_data.ctx, p->key, +sizeof (p->key) +sizeof (p->blob)); +if (IS_ERR (reg_shm)) { +dev_err (pvt_data.dev,"shm register failed\n" ); +return PTR_ERR (reg_shm); } inv_arg.func =TA_CMD_UNSEAL ;
@@ -149,11 +129,11 @@ static int trusted_tee_unseal(struct tru inv_arg.num_params =4 ; param[0 ].attr =TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT ; - param[0 ].u.memref.shm = reg_shm_in; + param[0 ].u.memref.shm = reg_shm; param[0 ].u.memref.size = p->blob_len; - param[0 ].u.memref.shm_offs =0 ; + param[0 ].u.memref.shm_offs =sizeof (p->key); param[1 ].attr =TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT ; - param[1 ].u.memref.shm = reg_shm_out; + param[1 ].u.memref.shm = reg_shm; param[1 ].u.memref.size =sizeof (p->key); param[1 ].u.memref.shm_offs =0 ;
@@ -166,11 +146,7 @@ static int trusted_tee_unseal(struct tru p->key_len = param[1 ].u.memref.size; } -out: -if (reg_shm_out) -tee_shm_free (reg_shm_out); -if (reg_shm_in) -tee_shm_free (reg_shm_in); +tee_shm_free (reg_shm);return ret; }
Greg Kroah-Hartman
maintainerPATCH 202/372 KEYS: trusted: Rollback init_trusted() consistently
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
commit 31de287345f41bbfaec36a5c8cbdba035cf76442 upstream.
Do bind neither static calls nor trusted_key_exit() before a successful init, in order to maintain a consistent state. In addition, depart the init_trusted() in the case of a real error (i.e. getting back something else than -ENODEV).
--- security/keys/trusted-keys/trusted_core.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
security/keys/trusted-keys/trusted_core.c +10 -10
@@ -358,17 +358,17 @@ static int __init init_trusted(void)if (!get_random) get_random = kernel_get_random; -static_call_update (trusted_key_seal, - trusted_key_sources[i].ops->seal); -static_call_update (trusted_key_unseal, - trusted_key_sources[i].ops->unseal); -static_call_update (trusted_key_get_random, - get_random); - trusted_key_exit = trusted_key_sources[i].ops->exit; - migratable = trusted_key_sources[i].ops->migratable; - ret = trusted_key_sources[i].ops->init (); -if (!ret) +if (!ret) { +static_call_update (trusted_key_seal, trusted_key_sources[i].ops->seal); +static_call_update (trusted_key_unseal, trusted_key_sources[i].ops->unseal); +static_call_update (trusted_key_get_random, get_random); + + trusted_key_exit = trusted_key_sources[i].ops->exit; + migratable = trusted_key_sources[i].ops->migratable; + } + +if (!ret || ret != -ENODEV )break ; }
Greg Kroah-Hartman
maintainerPATCH 203/372 PCI: keystone: Dont discard .remove() callback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
commit 200bddbb3f5202bbce96444fdc416305de14f547 upstream.
With CONFIG_PCIE_KEYSTONE=y and ks_pcie_remove() marked with __exit, the function is discarded from the driver. In this case a bound device can still get unbound, e.g via sysfs. Then no cleanup code is run resulting in resource leaks or worse.
The right thing to do is do always have the remove callback available. Note that this driver cannot be compiled as a module, so ks_pcie_remove() was always discarded before this change and modpost couldn't warn about this issue. Furthermore the __ref annotation also prevents a warning.
--- drivers/pci/controller/dwc/pci-keystone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-keystone.c +2 -2
@@ -1303,7 +1303,7 @@ err_link:return ret; } -static int __exit ks_pcie_remove(struct platform_device *pdev) +static int ks_pcie_remove (struct platform_device *pdev) {struct keystone_pcie *ks_pcie =platform_get_drvdata (pdev);struct device_link **link = ks_pcie->link;
@@ -1321,7 +1321,7 @@ static int __exit ks_pcie_remove(structstatic struct platform_driver ks_pcie_driver__refdata = { .probe = ks_pcie_probe, - .remove =__exit_p (ks_pcie_remove), + .remove = ks_pcie_remove, .driver = { .name ="keystone-pcie" , .of_match_table = ks_pcie_of_match,
Greg Kroah-Hartman
maintainerPATCH 204/372 PCI: keystone: Dont discard .probe() callback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
commit 7994db905c0fd692cf04c527585f08a91b560144 upstream.
The __init annotation makes the ks_pcie_probe() function disappear after booting completes. However a device can also be bound later. In that case, we try to call ks_pcie_probe(), but the backing memory is likely already overwritten.
The right thing to do is do always have the probe callback available. Note that the (wrong) __refdata annotation prevented this issue to be noticed by modpost.
--- drivers/pci/controller/dwc/pci-keystone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-keystone.c +2 -2
@@ -1101,7 +1101,7 @@ static const struct of_device_id ks_pcie { }, }; -static int __init ks_pcie_probe (struct platform_device *pdev) +static int ks_pcie_probe (struct platform_device *pdev) {const struct dw_pcie_host_ops *host_ops;const struct dw_pcie_ep_ops *ep_ops;
@@ -1319,7 +1319,7 @@ static int ks_pcie_remove(struct platforreturn 0 ; } -static struct platform_driver ks_pcie_driver__refdata = { +static struct platform_driver ks_pcie_driver = { .probe = ks_pcie_probe, .remove = ks_pcie_remove, .driver = {
Greg Kroah-Hartman
maintainerPATCH 205/372 arm64: Restrict CPU_BIG_ENDIAN to GNU as or LLVM IAS 15.x or newer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 146a15b873353f8ac28dc281c139ff611a3c4848 upstream.
Prior to LLVM 15.0.0, LLVM's integrated assembler would incorrectly byte-swap NOP when compiling for big-endian, and the resulting series of bytes happened to match the encoding of FNMADD S21, S30, S0, S0.
This went unnoticed until commit:
34f66c4c4d5518c1 ("arm64: Use a positive cpucap for FP/SIMD")
Prior to that commit, the kernel would always enable the use of FPSIMD early in boot when __cpu_setup() initialized CPACR_EL1, and so usage of FNMADD within the kernel was not detected, but could result in the corruption of user or kernel FPSIMD state.
After that commit, the instructions happen to trap during boot prior to FPSIMD being detected and enabled, e.g.
| Unhandled 64-bit el1h sync exception on CPU0, ESR 0x000000001fe00000 -- ASIMD | CPU: 0 PID: 0 Comm: swapper Not tainted 6.6.0-rc3-00013-g34f66c4c4d55 #1 | Hardware name: linux,dummy-virt (DT) | pstate: 400000c9 (nZcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) | pc : __pi_strcmp+0x1c/0x150 | lr : populate_properties+0xe4/0x254 | sp : ffffd014173d3ad0 | x29: ffffd014173d3af0 x28: fffffbfffddffcb8 x27: 0000000000000000 | x26: 0000000000000058 x25: fffffbfffddfe054 x24: 0000000000000008 | x23: fffffbfffddfe000 x22: fffffbfffddfe000 x21: fffffbfffddfe044 | x20: ffffd014173d3b70 x19: 0000000000000001 x18: 0000000000000005 | x17: 0000000000000010 x16: 0000000000000000 x15: 00000000413e7000 | x14: 0000000000000000 x13: 0000000000001bcc x12: 0000000000000000 | x11: 00000000d00dfeed x10: ffffd414193f2cd0 x9 : 0000000000000000 | x8 : 0101010101010101 x7 : ffffffffffffffc0 x6 : 0000000000000000 | x5 : 0000000000000000 x4 : 0101010101010101 x3 : 000000000000002a | x2 : 0000000000000001 x1 : ffffd014171f2988 x0 : fffffbfffddffcb8 | Kernel panic - not syncing: Unhandled exception | CPU: 0 PID: 0 Comm: swapper Not tainted 6.6.0-rc3-00013-g34f66c4c4d55 #1 | Hardware name: linux,dummy-virt (DT) | Call trace: | dump_backtrace+0xec/0x108 | show_stack+0x18/0x2c | dump_stack_lvl+0x50/0x68 | dump_stack+0x18/0x24 | panic+0x13c/0x340 | el1t_64_irq_handler+0x0/0x1c | el1_abort+0x0/0x5c | el1h_64_sync+0x64/0x68 | __pi_strcmp+0x1c/0x150 | unflatten_dt_nodes+0x1e8/0x2d8 | __unflatten_device_tree+0x5c/0x15c | unflatten_device_tree+0x38/0x50 | setup_arch+0x164/0x1e0 | start_kernel+0x64/0x38c | __primary_switched+0xbc/0xc4
Restrict CONFIG_CPU_BIG_ENDIAN to a known good assembler, which is either GNU as or LLVM's IAS 15.0.0 and newer, which contains the linked commit.
--- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/Kconfig +2 -0
@@ -1304,6 +1304,8 @@ choice config CPU_BIG_ENDIAN bool "Build big-endian kernel" depends on !LD_IS_LLD || LLD_VERSION >= 130000 + # https://github.com/llvm/llvm-project/commit/1379b150991f70a5782e9a143c2ba5308da1161c + depends on AS_IS_GNU || AS_VERSION >= 150000 help Say Y if you plan on running a kernel with a big-endian userspace.
Greg Kroah-Hartman
maintainerPATCH 206/372 parisc/pdc: Add width field to struct pdc_model
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 6240553b52c475d9fc9674de0521b77e692f3764 upstream.
PDC2.0 specifies the additional PSW-bit field.
--- arch/parisc/include/uapi/asm/pdc.h | 1 + 1 file changed, 1 insertion(+)
arch/parisc/include/uapi/asm/pdc.h +1 -0
@@ -472,6 +472,7 @@ struct pdc_model { /* for PDC_MODEL */unsigned long arch_rev;unsigned long pot_key;unsigned long curr_key; +unsigned long width;/* default of PSW_W bit (1=enabled) */ };struct pdc_cache_cf {/* for PDC_CACHE (I/D-caches) */
Greg Kroah-Hartman
maintainerPATCH 207/372 parisc/power: Add power soft-off when running on qemu
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit d0c219472980d15f5cbc5c8aec736848bda3f235 upstream.
--- drivers/parisc/power.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/parisc/power.c +15 -1
@@ -197,6 +197,14 @@ static struct notifier_block parisc_pani .priority = INT_MAX, }; +/* qemu soft power-off function */ +static int qemu_power_off (struct sys_off_data *data) +{ +/* this turns the system off via SeaBIOS */ + *(int *)data->cb_data =0 ; +pdc_soft_power_button (1 ); +return NOTIFY_DONE ; +}static int __init power_init (void ) {
@@ -226,7 +234,13 @@ static int __init power_init(void) soft_power_reg); } - power_task =kthread_run (kpowerswd, (void *)soft_power_reg,KTHREAD_NAME ); + power_task =NULL ; +if (running_on_qemu && soft_power_reg) +register_sys_off_handler (SYS_OFF_MODE_POWER_OFF ,SYS_OFF_PRIO_DEFAULT , + qemu_power_off, (void *)soft_power_reg); +else + power_task =kthread_run (kpowerswd, (void *)soft_power_reg, +KTHREAD_NAME );if (IS_ERR (power_task)) { printk(KERN_ERR DRIVER_NAME ": thread creation failed. Driver not loaded.\n");pdc_soft_power_button (0 );
Greg Kroah-Hartman
maintainerPATCH 208/372 clk: socfpga: Fix undefined behavior bug in struct stratix10_clock_data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
commit d761bb01c85b22d5b44abe283eb89019693f6595 upstream.
struct clk_hw_onecell_data is a flexible structure, which means that it contains flexible-array member at the bottom, in this case array hws:
include/linux/clk-provider.h:
1380 struct clk_hw_onecell_data {
1381 unsigned int num;
1382 struct clk_hw *hws[] __counted_by(num);
1383 };
This could potentially lead to an overwrite of the objects following clk_data in struct stratix10_clock_data, in this case void __iomem *base; at run-time:
drivers/clk/socfpga/stratix10-clk.h:
9 struct stratix10_clock_data {
10 struct clk_hw_onecell_data clk_data;
11 void __iomem *base;
12 };
There are currently three different places where memory is allocated for struct stratix10_clock_data, including the flex-array hws in struct clk_hw_onecell_data:
drivers/clk/socfpga/clk-agilex.c:
469 clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
470 num_clks), GFP_KERNEL);
drivers/clk/socfpga/clk-agilex.c:
509 clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
510 num_clks), GFP_KERNEL);
drivers/clk/socfpga/clk-s10.c:
400 clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
401 num_clks), GFP_KERNEL);
I'll use just one of them to describe the issue. See below.
Notice that a total of 440 bytes are allocated for flexible-array member hws at line 469:
include/dt-bindings/clock/agilex-clock.h:
70 #define AGILEX_NUM_CLKS 55
drivers/clk/socfpga/clk-agilex.c:
459 struct stratix10_clock_data *clk_data;
460 void __iomem *base;
...
466
467 num_clks = AGILEX_NUM_CLKS;
468
469 clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
470 num_clks), GFP_KERNEL);
struct_size(clk_data, clk_data.hws, num_clks) above translates tosizeof(struct stratix10_clock_data) + sizeof(struct clk_hw *) * 55 == 16 + 8 * 55 == 16 + 440
^^^ | allocated bytes for flex-array `hws`
474 for (i = 0; i < num_clks; i++)
475 clk_data->clk_data.hws[i] = ERR_PTR(-ENOENT);
476
477 clk_data->base = base;
and then some data is written into both hws and base objects.
Fix this by placing the declaration of object clk_data at the end of struct stratix10_clock_data. Also, add a comment to make it clear that this object must always be last in the structure.
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting ready to enable it globally.
--- drivers/clk/socfpga/stratix10-clk.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/socfpga/stratix10-clk.h +3 -1
@@ -7,8 +7,10 @@#define __STRATIX10_CLK_Hstruct stratix10_clock_data { -struct clk_hw_onecell_data clk_data;void __iomem *base; + +/* Must be last */ +struct clk_hw_onecell_data clk_data; };struct stratix10_pll_clock {
Greg Kroah-Hartman
maintainerPATCH 209/372 clk: qcom: ipq8074: drop the CLK_SET_RATE_PARENT flag from PLL clocks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kathiravan Thirumoorthy <[email protected]>
commit e641a070137dd959932c7c222e000d9d941167a2 upstream.
GPLL, NSS crypto PLL clock rates are fixed and shouldn't be scaled based on the request from dependent clocks. Doing so will result in the unexpected behaviour. So drop the CLK_SET_RATE_PARENT flag from the PLL clocks.
--- drivers/clk/qcom/gcc-ipq8074.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/clk/qcom/gcc-ipq8074.c +0 -6
@@ -419,7 +419,6 @@ static struct clk_fixed_factor gpll0_out }, .num_parents = 1, .ops = &clk_fixed_factor_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -466,7 +465,6 @@ static struct clk_alpha_pll_postdiv gpll }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -499,7 +497,6 @@ static struct clk_alpha_pll_postdiv gpll }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -533,7 +530,6 @@ static struct clk_alpha_pll_postdiv gpll }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -547,7 +543,6 @@ static struct clk_fixed_factor gpll6_out }, .num_parents = 1, .ops = &clk_fixed_factor_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -612,7 +607,6 @@ static struct clk_alpha_pll_postdiv nss_ }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
Greg Kroah-Hartman
maintainerPATCH 210/372 clk: qcom: ipq6018: drop the CLK_SET_RATE_PARENT flag from PLL clocks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kathiravan Thirumoorthy <[email protected]>
commit 99cd4935cb972d0aafb16838bb2aeadbcaf196ce upstream.
GPLL, NSS crypto PLL clock rates are fixed and shouldn't be scaled based on the request from dependent clocks. Doing so will result in the unexpected behaviour. So drop the CLK_SET_RATE_PARENT flag from the PLL clocks.
--- drivers/clk/qcom/gcc-ipq6018.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/clk/qcom/gcc-ipq6018.c +0 -6
@@ -75,7 +75,6 @@ static struct clk_fixed_factor gpll0_out &gpll0_main.clkr.hw }, .num_parents = 1, .ops = &clk_fixed_factor_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -89,7 +88,6 @@ static struct clk_alpha_pll_postdiv gpll &gpll0_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -164,7 +162,6 @@ static struct clk_alpha_pll_postdiv gpll &gpll6_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -195,7 +192,6 @@ static struct clk_alpha_pll_postdiv gpll &gpll4_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -246,7 +242,6 @@ static struct clk_alpha_pll_postdiv gpll &gpll2_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -277,7 +272,6 @@ static struct clk_alpha_pll_postdiv nss_ &nss_crypto_pll_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
Greg Kroah-Hartman
maintainerPATCH 211/372 ksmbd: handle malformed smb1 message
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 5a5409d90bd05f87fe5623a749ccfbf3f7c7d400 upstream.
If set_smb1_rsp_status() is not implemented, It will cause NULL pointer dereferece error when client send malformed smb1 message. This patch add set_smb1_rsp_status() to ignore malformed smb1 message.
--- fs/smb/server/smb_common.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/smb/server/smb_common.c +11 -0
@@ -372,11 +372,22 @@ static int smb1_allocate_rsp_buf(structreturn 0 ; } +/** +* set_smb1_rsp_status() - set error type in smb response header +* @work: smb work containing smb response header +* @err: error code to set in response +*/ +static void set_smb1_rsp_status (struct ksmbd_work *work,__le32 err) +{ + work->send_no_response =1 ; +} +static struct smb_version_ops smb1_server_ops = { .get_cmd_val = get_smb1_cmd_val, .init_rsp_hdr = init_smb1_rsp_hdr, .allocate_rsp_buf = smb1_allocate_rsp_buf, .check_user_session = smb1_check_user_session, + .set_rsp_status = set_smb1_rsp_status, };static int smb1_negotiate (struct ksmbd_work *work)
Greg Kroah-Hartman
maintainerPATCH 212/372 ksmbd: fix slab out of bounds write in smb_inherit_dacl()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit eebff19acaa35820cb09ce2ccb3d21bee2156ffb upstream.
slab out-of-bounds write is caused by that offsets is bigger than pntsd allocation size. This patch add the check to validate 3 offsets using allocation size.
--- fs/smb/server/smbacl.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
fs/smb/server/smbacl.c +26 -3
@@ -1107,6 +1107,7 @@ pass:struct smb_acl *pdacl;struct smb_sid *powner_sid =NULL , *pgroup_sid =NULL ;int powner_sid_size =0 , pgroup_sid_size =0 , pntsd_size; +int pntsd_alloc_size;if (parent_pntsd->osidoffset) { powner_sid = (struct smb_sid *)((char *)parent_pntsd +
@@ -1119,9 +1120,10 @@ pass: pgroup_sid_size =1 +1 +6 + (pgroup_sid->num_subauth *4 ); } - pntsd =kzalloc (sizeof (struct smb_ntsd ) + powner_sid_size + - pgroup_sid_size +sizeof (struct smb_acl ) + - nt_size,GFP_KERNEL ); + pntsd_alloc_size =sizeof (struct smb_ntsd ) + powner_sid_size + + pgroup_sid_size +sizeof (struct smb_acl ) + nt_size; + + pntsd =kzalloc (pntsd_alloc_size,GFP_KERNEL );if (!pntsd) { rc = -ENOMEM ; goto free_aces_base;
@@ -1136,6 +1138,27 @@ pass: pntsd->gsidoffset = parent_pntsd->gsidoffset; pntsd->dacloffset = parent_pntsd->dacloffset; +if ((u64 )le32_to_cpu (pntsd->osidoffset) + powner_sid_size > + pntsd_alloc_size) { + rc = -EINVAL ; +kfree (pntsd); + goto free_aces_base; + } + +if ((u64 )le32_to_cpu (pntsd->gsidoffset) + pgroup_sid_size > + pntsd_alloc_size) { + rc = -EINVAL ; +kfree (pntsd); + goto free_aces_base; + } + +if ((u64 )le32_to_cpu (pntsd->dacloffset) +sizeof (struct smb_acl ) + nt_size > + pntsd_alloc_size) { + rc = -EINVAL ; +kfree (pntsd); + goto free_aces_base; + } +if (pntsd->osidoffset) {struct smb_sid *owner_sid = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->osidoffset));
Greg Kroah-Hartman
maintainerPATCH 213/372 mmc: vub300: fix an error code
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit b44f9da81783fda72632ef9b0d05ea3f3ca447a5 upstream.
This error path should return -EINVAL instead of success.
--- drivers/mmc/host/vub300.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/vub300.c +1 -0
@@ -2311,6 +2311,7 @@ static int vub300_probe(struct usb_inter vub300->read_only = (0x0010 & vub300->system_port_status.port_flags) ?1 :0 ; }else { + retval = -EINVAL ; goto error5; }usb_set_intfdata (interface, vub300);
Greg Kroah-Hartman
maintainerPATCH 214/372 mmc: sdhci_am654: fix start loop index for TAP value parsing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nitin Yadav <[email protected]>
commit 71956d0cb56c1e5f9feeb4819db87a076418e930 upstream.
ti,otap-del-sel-legacy/ti,itap-del-sel-legacy passed from DT are currently ignored for all SD/MMC and eMMC modes. Fix this by making start loop index to MMC_TIMING_LEGACY.
--- drivers/mmc/host/sdhci_am654.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci_am654.c +1 -1
@@ -597,7 +597,7 @@ static int sdhci_am654_get_otap_delay(streturn 0 ; } -for (i =MMC_TIMING_MMC_HS ; i <=MMC_TIMING_MMC_HS400 ; i++) { +for (i =MMC_TIMING_LEGACY ; i <=MMC_TIMING_MMC_HS400 ; i++) { ret =device_property_read_u32 (dev, td[i].otap_binding, &sdhci_am654->otap_del_sel[i]);
Greg Kroah-Hartman
maintainerPATCH 215/372 mmc: Add quirk MMC_QUIRK_BROKEN_CACHE_FLUSH for Micron eMMC Q2J54A
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bean Huo <[email protected]>
commit ed9009ad300c0f15a3ecfe9613547b1962bde02c upstream.
Micron MTFC4GACAJCN eMMC supports cache but requires that flush cache operation be allowed only after a write has occurred. Otherwise, the cache flush command or subsequent commands will time out.
--- drivers/mmc/core/block.c | 4 +++- drivers/mmc/core/card.h | 4 ++++ drivers/mmc/core/mmc.c | 8 ++++++-- drivers/mmc/core/quirks.h | 7 ++++--- include/linux/mmc/card.h | 2 ++ 5 files changed, 19 insertions(+), 6 deletions(-)
drivers/mmc/core/block.c +3 -1
@@ -2404,8 +2404,10 @@ enum mmc_issued mmc_blk_mq_issue_rq(stru } ret =mmc_blk_cqe_issue_flush (mq, req);break ; -case REQ_OP_READ :case REQ_OP_WRITE : + card->written_flag = true; + fallthrough; +case REQ_OP_READ :if (host->cqe_enabled) ret =mmc_blk_cqe_issue_rw_rq (mq, req);else
drivers/mmc/core/card.h +4 -0
@@ -280,4 +280,8 @@ static inline int mmc_card_broken_sd_cac return c->quirks & MMC_QUIRK_BROKEN_SD_CACHE; } +static inline int mmc_card_broken_cache_flush (const struct mmc_card *c) +{ +return c->quirks &MMC_QUIRK_BROKEN_CACHE_FLUSH ; +}#endif
drivers/mmc/core/mmc.c +6 -2
@@ -2081,13 +2081,17 @@ static int _mmc_flush_cache(struct mmc_h {int err =0 ; +if (mmc_card_broken_cache_flush (host->card) && !host->card->written_flag) +return 0 ; +if (_mmc_cache_enabled (host)) { err =mmc_switch (host->card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_FLUSH_CACHE ,1 ,CACHE_FLUSH_TIMEOUT_MS );if (err) -pr_err ("%s: cache flush error %d\n" , -mmc_hostname (host), err); +pr_err ("%s: cache flush error %d\n" ,mmc_hostname (host), err); +else + host->card->written_flag = false; }return err;
drivers/mmc/core/quirks.h +4 -3
@@ -117,11 +117,12 @@ static const struct mmc_fixup __maybe_un MMC_QUIRK_TRIM_BROKEN),/* -* Micron MTFC4GACAJCN-1M advertises TRIM but it does not seems to -* support being used to offload WRITE_ZEROES. +* Micron MTFC4GACAJCN-1M supports TRIM but does not appear to support +* WRITE_ZEROES offloading. It also supports caching, but the cache can +* only be flushed after a write has occurred. */ MMC_FIXUP ("Q2J54A" ,CID_MANFID_MICRON ,0x014e , add_quirk_mmc, - MMC_QUIRK_TRIM_BROKEN), + MMC_QUIRK_TRIM_BROKEN | MMC_QUIRK_BROKEN_CACHE_FLUSH),/* * Some SD cards reports discard support while they don't
include/linux/mmc/card.h +2 -0
@@ -295,7 +295,9 @@ struct mmc_card {#define MMC_QUIRK_BROKEN_HPI (1<<13)/* Disable broken HPI support */ #define MMC_QUIRK_BROKEN_SD_DISCARD (1<<14)/* Disable broken SD discard support */ #define MMC_QUIRK_BROKEN_SD_CACHE (1<<15)/* Disable broken SD cache support */ +#define MMC_QUIRK_BROKEN_CACHE_FLUSH (1<<16)/* Don't flush cache until the write has occurred */ +bool written_flag;/* Indicates eMMC has been written since power on */ bool reenable_cmdq;/* Re-enable Command Queue */ unsigned int erase_size;/* erase size in sectors */
Greg Kroah-Hartman
maintainerPATCH 216/372 PCI/ASPM: Fix L1 substate handling in aspm_attr_store_common()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit 8e37372ad0bea4c9b4712d9943f6ae96cff9491f upstream.
aspm_attr_store_common(), which handles sysfs control of ASPM, has the same problem as fb097dcd5a28 ("PCI/ASPM: Disable only ASPM_STATE_L1 when driver disables L1"): disabling L1 adds only ASPM_L1 (but not any of the L1.x substates) to the "aspm_disable" mask.
Enabling one substate, e.g., L1.1, via sysfs removes ASPM_L1 from the disable mask. Since disabling L1 via sysfs doesn't add any of the substates to the disable mask, enabling L1.1 actually enables *all* the substates.
In this scenario:
- Write 0 to "l1_aspm" to disable L1
- Write 1 to "l1_1_aspm" to enable L1.1
the intention is to disable L1 and all L1.x substates, then enable just L1.1, but in fact, *all* L1.x substates are enabled.
Fix this by explicitly disabling all the L1.x substates when disabling L1.
--- drivers/pci/pcie/aspm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/pcie/aspm.c +2 -0
@@ -1248,6 +1248,8 @@ static ssize_t aspm_attr_store_common(st link->aspm_disable &= ~ASPM_STATE_L1 ; }else { link->aspm_disable |= state; +if (state &ASPM_STATE_L1 ) + link->aspm_disable |=ASPM_STATE_L1SS ; }pcie_config_aspm_link (link,policy_to_aspm_state (link));
Greg Kroah-Hartman
maintainerPATCH 217/372 PCI: kirin: Dont discard .remove() callback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
commit 3064ef2e88c1629c1e67a77d7bc20020b35846f2 upstream.
With CONFIG_PCIE_KIRIN=y and kirin_pcie_remove() marked with __exit, the function is discarded from the driver. In this case a bound device can still get unbound, e.g via sysfs. Then no cleanup code is run resulting in resource leaks or worse.
The right thing to do is do always have the remove callback available. This fixes the following warning by modpost:
drivers/pci/controller/dwc/pcie-kirin: section mismatch in reference: kirin_pcie_driver+0x8 (section: .data) -> kirin_pcie_remove (section: .exit.text)
(with ARCH=x86_64 W=1 allmodconfig).
--- drivers/pci/controller/dwc/pcie-kirin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-kirin.c +2 -2
@@ -742,7 +742,7 @@ err:return ret; } -static int __exit kirin_pcie_remove(struct platform_device *pdev) +static int kirin_pcie_remove (struct platform_device *pdev) {struct kirin_pcie *kirin_pcie =platform_get_drvdata (pdev);
@@ -819,7 +819,7 @@ static int kirin_pcie_probe(struct platfstatic struct platform_driver kirin_pcie_driver = { .probe = kirin_pcie_probe, - .remove =__exit_p (kirin_pcie_remove), + .remove = kirin_pcie_remove, .driver = { .name ="kirin-pcie" , .of_match_table = kirin_pcie_match,
Greg Kroah-Hartman
maintainerPATCH 218/372 PCI: exynos: Dont discard .remove() callback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
commit 83a939f0fdc208ff3639dd3d42ac9b3c35607fd2 upstream.
With CONFIG_PCI_EXYNOS=y and exynos_pcie_remove() marked with __exit, the function is discarded from the driver. In this case a bound device can still get unbound, e.g via sysfs. Then no cleanup code is run resulting in resource leaks or worse.
The right thing to do is do always have the remove callback available. This fixes the following warning by modpost:
WARNING: modpost: drivers/pci/controller/dwc/pci-exynos: section mismatch in reference: exynos_pcie_driver+0x8 (section: .data) -> exynos_pcie_remove (section: .exit.text)
(with ARCH=x86_64 W=1 allmodconfig).
--- drivers/pci/controller/dwc/pci-exynos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-exynos.c +2 -2
@@ -375,7 +375,7 @@ fail_probe:return ret; } -static int __exit exynos_pcie_remove(struct platform_device *pdev) +static int exynos_pcie_remove (struct platform_device *pdev) {struct exynos_pcie *ep =platform_get_drvdata (pdev);
@@ -431,7 +431,7 @@ static const struct of_device_id exynos_static struct platform_driver exynos_pcie_driver = { .probe = exynos_pcie_probe, - .remove =__exit_p (exynos_pcie_remove), + .remove = exynos_pcie_remove, .driver = { .name ="exynos-pcie" , .of_match_table = exynos_pcie_of_match,
Greg Kroah-Hartman
maintainerPATCH 219/372 wifi: wilc1000: use vmm_table as array in wilc struct
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ajay Singh <[email protected]>
commit 05ac1a198a63ad66bf5ae8b7321407c102d40ef3 upstream.
Enabling KASAN and running some iperf tests raises some memory issues with vmm_table:
BUG: KASAN: slab-out-of-bounds in wilc_wlan_handle_txq+0x6ac/0xdb4 Write of size 4 at addr c3a61540 by task wlan0-tx/95
KASAN detects that we are writing data beyond range allocated to vmm_table. There is indeed a mismatch between the size passed to allocator in wilc_wlan_init, and the range of possible indexes used later: allocation size is missing a multiplication by sizeof(u32)
--- drivers/net/wireless/microchip/wilc1000/wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/microchip/wilc1000/wlan.c +1 -1
@@ -1492,7 +1492,7 @@ int wilc_wlan_init(struct net_device *de }if (!wilc->vmm_table) - wilc->vmm_table =kzalloc (WILC_VMM_TBL_SIZE ,GFP_KERNEL ); + wilc->vmm_table =kcalloc (WILC_VMM_TBL_SIZE ,sizeof (u32),GFP_KERNEL );if (!wilc->vmm_table) { ret = -ENOBUFS ;
Greg Kroah-Hartman
maintainerPATCH 220/372 svcrdma: Drop connection after an RDMA Read error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
commit 197115ebf358cb440c73e868b2a0a5ef728decc6 upstream.
When an RPC Call message cannot be pulled from the client, that is a message loss, by definition. Close the connection to trigger the client to resend.
--- net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +2 -1
@@ -857,7 +857,8 @@ out_readfail:if (ret == -EINVAL )svc_rdma_send_error (rdma_xprt, ctxt, ret);svc_rdma_recv_ctxt_put (rdma_xprt, ctxt); -return ret; +svc_xprt_deferred_close (xprt); +return -ENOTCONN ; out_backchannel:svc_rdma_handle_bc_reply (rqstp, ctxt);
Greg Kroah-Hartman
maintainerPATCH 221/372 rcu/tree: Defer setting of jiffies during stall reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joel Fernandes (Google) <[email protected]>
commit b96e7a5fa0ba9cda32888e04f8f4bac42d49a7f8 upstream.
There are instances where rcu_cpu_stall_reset() is called when jiffies did not get a chance to update for a long time. Before jiffies is updated, the CPU stall detector can go off triggering false-positives where a just-started grace period appears to be ages old. In the past, we disabled stall detection in rcu_cpu_stall_reset() however this got changed [1]. This is resulting in false-positives in KGDB usecase [2].
Fix this by deferring the update of jiffies to the third run of the FQS loop. This is more robust, as, even if rcu_cpu_stall_reset() is called just before jiffies is read, we would end up pushing out the jiffies read by 3 more FQS loops. Meanwhile the CPU stall detection will be delayed and we will not get any false positives.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Tested with rcutorture.cpu_stall option as well to verify stall behavior with/without patch.
--- kernel/rcu/tree.c | 12 ++++++++++++ kernel/rcu/tree.h | 4 ++++ kernel/rcu/tree_stall.h | 20 ++++++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-)
kernel/rcu/tree.c +12 -0
@@ -1604,10 +1604,22 @@ static bool rcu_gp_fqs_check_wake(int *g*/ static void rcu_gp_fqs (bool first_time) { +int nr_fqs =READ_ONCE (rcu_state.nr_fqs_jiffies_stall);struct rcu_node *rnp =rcu_get_root ();WRITE_ONCE (rcu_state.gp_activity, jiffies);WRITE_ONCE (rcu_state.n_force_qs, rcu_state.n_force_qs +1 ); + +WARN_ON_ONCE (nr_fqs >3 ); +/* Only countdown nr_fqs for stall purposes if jiffies moves. */ +if (nr_fqs) { +if (nr_fqs ==1 ) { +WRITE_ONCE (rcu_state.jiffies_stall, + jiffies +rcu_jiffies_till_stall_check ()); + } +WRITE_ONCE (rcu_state.nr_fqs_jiffies_stall, --nr_fqs); + } +if (first_time) {/* Collect dyntick-idle snapshots. */ force_qs_rnp (dyntick_save_progress_counter);
kernel/rcu/tree.h +4 -0
@@ -365,6 +365,10 @@ struct rcu_state {/* in jiffies. */ unsigned long jiffies_stall;/* Time at which to check */ /* for CPU stalls. */ +int nr_fqs_jiffies_stall;/* Number of fqs loops after +* which read jiffies and set +* jiffies_stall. Stall +* warnings disabled if !0. */ unsigned long jiffies_resched;/* Time at which to resched */ /* a reluctant CPU. */ unsigned long n_force_qs_gpstart;/* Snapshot of n_force_qs at */
kernel/rcu/tree_stall.h +18 -2
@@ -149,12 +149,17 @@ static void panic_on_rcu_stall(void)/** * rcu_cpu_stall_reset - restart stall-warning timeout for current grace period * +* To perform the reset request from the caller, disable stall detection until +* 3 fqs loops have passed. This is required to ensure a fresh jiffies is +* loaded. It should be safe to do from the fqs loop as enough timer +* interrupts and context switches should have passed. +* * The caller must disable hard irqs. */ void rcu_cpu_stall_reset (void ) { -WRITE_ONCE (rcu_state.jiffies_stall, - jiffies +rcu_jiffies_till_stall_check ()); +WRITE_ONCE (rcu_state.nr_fqs_jiffies_stall,3 ); +WRITE_ONCE (rcu_state.jiffies_stall,ULONG_MAX ); }//////////////////////////////////////////////////////////////////////////////
@@ -170,6 +175,7 @@ static void record_gp_stall_check_time(vWRITE_ONCE (rcu_state.gp_start, j); j1 =rcu_jiffies_till_stall_check ();smp_mb ();// ->gp_start before ->jiffies_stall and caller's ->gp_seq. +WRITE_ONCE (rcu_state.nr_fqs_jiffies_stall,0 );WRITE_ONCE (rcu_state.jiffies_stall, j + j1); rcu_state.jiffies_resched = j + j1 /2 ; rcu_state.n_force_qs_gpstart =READ_ONCE (rcu_state.n_force_qs);
@@ -694,6 +700,16 @@ static void check_cpu_stall(struct rcu_d !rcu_gp_in_progress())return ;rcu_stall_kick_kthreads (); + +/* +* Check if it was requested (via rcu_cpu_stall_reset()) that the FQS +* loop has to set jiffies to ensure a non-stale jiffies value. This +* is required to have good jiffies value after coming out of long +* breaks of jiffies updates. Not doing so can cause false positives. +*/ +if (READ_ONCE (rcu_state.nr_fqs_jiffies_stall) >0 ) +return ; + j = jiffies;/*
Greg Kroah-Hartman
maintainerPATCH 222/372 arm64: dts: qcom: ipq6018: Fix hwlock index for SMEM
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh Viswanathan <[email protected]>
commit 95d97b111e1e184b0c8656137033ed64f2cf21e4 upstream.
SMEM uses lock index 3 of the TCSR Mutex hwlock for allocations in SMEM region shared by the Host and FW.
Fix the SMEM hwlock index to 3 for IPQ6018.
--- arch/arm64/boot/dts/qcom/ipq6018.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/ipq6018.dtsi +1 -1
@@ -169,7 +169,7 @@ smem { compatible = "qcom,smem"; memory-region = <&smem_region>; - hwlocks = <&tcsr_mutex 0>; + hwlocks = <&tcsr_mutex 3>; }; soc: soc {
Greg Kroah-Hartman
maintainerPATCH 223/372 PM: hibernate: Use __get_safe_page() rather than touching the list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Geffon <[email protected]>
commit f0c7183008b41e92fa676406d87f18773724b48b upstream.
We found at least one situation where the safe pages list was empty and get_buffer() would gladly try to use a NULL pointer.
--- kernel/power/snapshot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
kernel/power/snapshot.c +6 -4
@@ -2418,8 +2418,9 @@ static void *get_highmem_page_buffer(str pbe->copy_page = tmp; }else {/* Copy of the page will be stored in normal memory */ - kaddr = safe_pages_list; - safe_pages_list = safe_pages_list->next; + kaddr =__get_safe_page (ca->gfp_mask); +if (!kaddr) +return ERR_PTR (-ENOMEM ); pbe->copy_page =virt_to_page (kaddr); } pbe->next = highmem_pblist;
@@ -2599,8 +2600,9 @@ static void *get_buffer(struct memory_bireturn ERR_PTR (-ENOMEM ); } pbe->orig_address =page_address (page); - pbe->address = safe_pages_list; - safe_pages_list = safe_pages_list->next; + pbe->address =__get_safe_page (ca->gfp_mask); +if (!pbe->address) +return ERR_PTR (-ENOMEM ); pbe->next = restore_pblist; restore_pblist = pbe;return pbe->address;
Greg Kroah-Hartman
maintainerPATCH 224/372 PM: hibernate: Clean up sync_read handling in snapshot_write_next()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Geffon <[email protected]>
commit d08970df1980476f27936e24d452550f3e9e92e1 upstream.
In snapshot_write_next(), sync_read is set and unset in three different spots unnecessiarly. As a result there is a subtle bug where the first page after the meta data has been loaded unconditionally sets sync_read to 0. If this first PFN was actually a highmem page, then the returned buffer will be the global "buffer," and the page needs to be loaded synchronously.
That is, I'm not sure we can always assume the following to be safe:
handle->buffer = get_buffer(&orig_bm, &ca); handle->sync_read = 0;
Because get_buffer() can call get_highmem_page_buffer() which can return 'buffer'.
The easiest way to address this is just set sync_read before snapshot_write_next() returns if handle->buffer == buffer.
--- kernel/power/snapshot.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
kernel/power/snapshot.c +1 -5
@@ -2633,8 +2633,6 @@ int snapshot_write_next(struct snapshot_if (handle->cur >1 && handle->cur > nr_meta_pages + nr_copy_pages)return 0 ; - handle->sync_read =1 ; -if (!handle->cur) {if (!buffer)/* This makes the buffer be freed by swsusp_free() */
@@ -2670,7 +2668,6 @@ int snapshot_write_next(struct snapshot_memory_bm_position_reset (&orig_bm); restore_pblist =NULL ; handle->buffer =get_buffer (&orig_bm, &ca); - handle->sync_read =0 ;if (IS_ERR (handle->buffer))return PTR_ERR (handle->buffer); }
@@ -2680,9 +2677,8 @@ int snapshot_write_next(struct snapshot_ handle->buffer =get_buffer (&orig_bm, &ca);if (IS_ERR (handle->buffer))return PTR_ERR (handle->buffer); -if (handle->buffer != buffer) - handle->sync_read =0 ; } + handle->sync_read = (handle->buffer == buffer); handle->cur++;return PAGE_SIZE ; }
Greg Kroah-Hartman
maintainerPATCH 225/372 rcu: kmemleak: Ignore kmemleak false positives when RCU-freeing objects
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit 5f98fd034ca6fd1ab8c91a3488968a0e9caaabf6 upstream.
Since the actual slab freeing is deferred when calling kvfree_rcu(), so is the kmemleak_free() callback informing kmemleak of the object deletion. From the perspective of the kvfree_rcu() caller, the object is freed and it may remove any references to it. Since kmemleak does not scan RCU internal data storing the pointer, it will report such objects as leaks during the grace period.
Tell kmemleak to ignore such objects on the kvfree_call_rcu() path. Note that the tiny RCU implementation does not have such issue since the objects can be tracked from the rcu_ctrlblk structure.
--- kernel/rcu/tree.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/rcu/tree.c +9 -0
@@ -31,6 +31,7 @@#include <linux/bitops.h> #include <linux/export.h> #include <linux/completion.h> +#include <linux/kmemleak.h> #include <linux/moduleparam.h> #include <linux/panic.h> #include <linux/panic_notifier.h>
@@ -3382,6 +3383,14 @@ void kvfree_call_rcu(struct rcu_head *heWRITE_ONCE (krcp->count, krcp->count +1 ); +/* +* The kvfree_rcu() caller considers the pointer freed at this point +* and likely removes any references to it. Since the actual slab +* freeing (and kmemleak_free()) is deferred, tell kmemleak to ignore +* this object (no scanning or false positives reporting). +*/ +kmemleak_ignore (ptr); +// Set timer to drain after KFREE_DRAIN_JIFFIES. if (rcu_scheduler_active ==RCU_SCHEDULER_RUNNING )schedule_delayed_monitor_work (krcp);
Greg Kroah-Hartman
maintainerPATCH 226/372 btrfs: dont arbitrarily slow down delalloc if were committing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 11aeb97b45ad2e0040cbb2a589bc403152526345 upstream.
We have a random schedule_timeout() if the current transaction is committing, which seems to be a holdover from the original delalloc reservation code.
Remove this, we have the proper flushing stuff, we shouldn't be hoping for random timing things to make everything work. This just induces latency for no reason.
--- fs/btrfs/delalloc-space.c | 3 --- 1 file changed, 3 deletions(-)
fs/btrfs/delalloc-space.c +0 -3
@@ -320,9 +320,6 @@ int btrfs_delalloc_reserve_metadata(stru }else {if (current->journal_info) flush =BTRFS_RESERVE_FLUSH_LIMIT ; - -if (btrfs_transaction_in_commit (fs_info)) -schedule_timeout (1 ); } num_bytes =ALIGN (num_bytes, fs_info->sectorsize);
Greg Kroah-Hartman
maintainerPATCH 227/372 arm64: dts: qcom: ipq8074: Fix hwlock index for SMEM
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh Viswanathan <[email protected]>
commit 8a781d04e580705d36f7db07f5c80e748100b69d upstream.
SMEM uses lock index 3 of the TCSR Mutex hwlock for allocations in SMEM region shared by the Host and FW.
Fix the SMEM hwlock index to 3 for IPQ8074.
--- arch/arm64/boot/dts/qcom/ipq8074.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/ipq8074.dtsi +1 -1
@@ -90,7 +90,7 @@ reg = <0x0 0x4ab00000 0x0 0x00100000>; no-map; - hwlocks = <&tcsr_mutex 0>; + hwlocks = <&tcsr_mutex 3>; }; memory@4ac00000 {
Greg Kroah-Hartman
maintainerPATCH 228/372 firmware: qcom_scm: use 64-bit calling convention only when client is 64-bit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kathiravan Thirumoorthy <[email protected]>
commit 3337a6fea25370d3d244ec6bb38c71ee86fcf837 upstream.
Per the "SMC calling convention specification", the 64-bit calling convention can only be used when the client is 64-bit. Whereas the 32-bit calling convention can be used by either a 32-bit or a 64-bit client.
Currently during SCM probe, irrespective of the client, 64-bit calling convention is made, which is incorrect and may lead to the undefined behaviour when the client is 32-bit. Let's fix it.
--- drivers/firmware/qcom_scm.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/firmware/qcom_scm.c +7 -0
@@ -165,6 +165,12 @@ static enum qcom_scm_convention __get_coreturn qcom_scm_convention;/* +* Per the "SMC calling convention specification", the 64-bit calling +* convention can only be used when the client is 64-bit, otherwise +* system will encounter the undefined behaviour. +*/ +#if IS_ENABLED (CONFIG_ARM64 ) +/* * Device isn't required as there is only one argument - no device * needed to dma_map_single to secure world */
@@ -184,6 +190,7 @@ static enum qcom_scm_convention __get_co forced = true; goto found; } +#endif probed_convention =SMC_CONVENTION_ARM_32 ; ret =__scm_smc_call (NULL , &desc, probed_convention, &res, true);
Greg Kroah-Hartman
maintainerPATCH 229/372 ACPI: FPDT: properly handle invalid FPDT subtables
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasily Khoruzhick <[email protected]>
commit a83c68a3bf7c418c9a46693c63c638852b0c1f4e upstream.
Buggy BIOSes may have invalid FPDT subtables, e.g. on my hardware:
S3PT subtable:
7F20FE30: 53 33 50 54 24 00 00 00-00 00 00 00 00 00 18 01 *S3PT$...........* 7F20FE40: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................* 7F20FE50: 00 00 00 00
Here the first record has zero length.
FBPT subtable:
7F20FE50: 46 42 50 54-3C 00 00 00 46 42 50 54 *....FBPT<...FBPT* 7F20FE60: 02 00 30 02 00 00 00 00-00 00 00 00 00 00 00 00 *..0.............* 7F20FE70: 2A A6 BC 6E 0B 00 00 00-1A 44 41 70 0B 00 00 00 **..n.....DAp....* 7F20FE80: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
And here FBPT table has FBPT signature repeated instead of the first record.
Current code will be looping indefinitely due to zero length records, so break out of the loop if record length is zero.
While we are here, add proper handling for fpdt_process_subtable() failures.
--- drivers/acpi/acpi_fpdt.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-)
drivers/acpi/acpi_fpdt.c +37 -8
@@ -194,12 +194,19 @@ static int fpdt_process_subtable(u64 add record_header = (void *)subtable_header + offset; offset += record_header->length; +if (!record_header->length) { +pr_err (FW_BUG "Zero-length record found in FPTD.\n" ); + result = -EINVAL ; + goto err; + } +switch (record_header->type) {case RECORD_S3_RESUME :if (subtable_type !=SUBTABLE_S3PT ) {pr_err (FW_BUG "Invalid record %d for subtable %s\n" , record_header->type, signature); -return -EINVAL ; + result = -EINVAL ; + goto err; }if (record_resume) {pr_err ("Duplicate resume performance record found.\n" );
@@ -208,7 +215,7 @@ static int fpdt_process_subtable(u64 add record_resume = (struct resume_performance_record *)record_header; result =sysfs_create_group (fpdt_kobj, &resume_attr_group);if (result) -return result; + goto err;break ;case RECORD_S3_SUSPEND :if (subtable_type !=SUBTABLE_S3PT ) {
@@ -223,13 +230,14 @@ static int fpdt_process_subtable(u64 add record_suspend = (struct suspend_performance_record *)record_header; result =sysfs_create_group (fpdt_kobj, &suspend_attr_group);if (result) -return result; + goto err;break ;case RECORD_BOOT :if (subtable_type !=SUBTABLE_FBPT ) {pr_err (FW_BUG "Invalid %d for subtable %s\n" , record_header->type, signature); -return -EINVAL ; + result = -EINVAL ; + goto err; }if (record_boot) {pr_err ("Duplicate boot performance record found.\n" );
@@ -238,7 +246,7 @@ static int fpdt_process_subtable(u64 add record_boot = (struct boot_performance_record *)record_header; result =sysfs_create_group (fpdt_kobj, &boot_attr_group);if (result) -return result; + goto err;break ;default :
@@ -247,6 +255,18 @@ static int fpdt_process_subtable(u64 add } }return 0 ; + +err: +if (record_boot) +sysfs_remove_group (fpdt_kobj, &boot_attr_group); + +if (record_suspend) +sysfs_remove_group (fpdt_kobj, &suspend_attr_group); + +if (record_resume) +sysfs_remove_group (fpdt_kobj, &resume_attr_group); + +return result; }static int __init acpi_init_fpdt (void )
@@ -255,6 +275,7 @@ static int __init acpi_init_fpdt(void)struct acpi_table_header *header;struct fpdt_subtable_entry *subtable;u32 offset =sizeof (*header); +int result; status =acpi_get_table (ACPI_SIG_FPDT ,0 , &header);
@@ -263,8 +284,8 @@ static int __init acpi_init_fpdt(void) fpdt_kobj =kobject_create_and_add ("fpdt" , acpi_kobj);if (!fpdt_kobj) { -acpi_put_table (header); -return -ENOMEM ; + result = -ENOMEM ; + goto err_nomem; }while (offset < header->length) {
@@ -272,8 +293,10 @@ static int __init acpi_init_fpdt(void)switch (subtable->type) {case SUBTABLE_FBPT :case SUBTABLE_S3PT : -fpdt_process_subtable (subtable->address, + result =fpdt_process_subtable (subtable->address, subtable->type); +if (result) + goto err_subtable;break ;default :/* Other types are reserved in ACPI 6.4 spec. */
@@ -282,6 +305,12 @@ static int __init acpi_init_fpdt(void) offset +=sizeof (*subtable); }return 0 ; +err_subtable: +kobject_put (fpdt_kobj); + +err_nomem: +acpi_put_table (header); +return result; }fs_initcall (acpi_init_fpdt);
Greg Kroah-Hartman
maintainerPATCH 230/372 arm64: dts: qcom: ipq6018: Fix tcsr_mutex register size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh Viswanathan <[email protected]>
commit 72fc3d58b87b0d622039c6299b89024fbb7b420f upstream.
IPQ6018's TCSR Mutex HW lock register has 32 locks of size 4KB each. Total size of the TCSR Mutex registers is 128KB.
Fix size of the tcsr_mutex hwlock register to 0x20000.
Changes in v2:
- Drop change to remove qcom,ipq6018-tcsr-mutex compatible string
- Added Fixes and stable tags
--- arch/arm64/boot/dts/qcom/ipq6018.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/ipq6018.dtsi +1 -1
@@ -248,7 +248,7 @@ tcsr_mutex: hwlock@1905000 { compatible = "qcom,ipq6018-tcsr-mutex", "qcom,tcsr-mutex"; - reg = <0x0 0x01905000 0x0 0x1000>; + reg = <0x0 0x01905000 0x0 0x20000>; #hwlock-cells = <1>; };
Greg Kroah-Hartman
maintainerPATCH 231/372 mfd: qcom-spmi-pmic: Fix reference leaks in revid helper
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit a0fa44c261e448c531f9adb3a5189a3520f3e316 upstream.
The Qualcomm SPMI PMIC revid implementation is broken in multiple ways.
First, it totally ignores struct device_node reference counting and leaks references to the parent bus node as well as each child it iterates over using an open-coded for_each_child_of_node().
Second, it leaks references to each spmi device on the bus that it iterates over by failing to drop the reference taken by the spmi_device_from_of() helper.
Fix the struct device_node leaks by reimplementing the lookup using for_each_child_of_node() and adding the missing reference count decrements. Fix the sibling struct device leaks by dropping the unnecessary lookups of devices with the wrong USID.
Note that this still leaves one struct device reference leak in case a base device is found but it is not the parent of the device used for the lookup. This will be addressed in a follow-on patch.
--- drivers/mfd/qcom-spmi-pmic.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
drivers/mfd/qcom-spmi-pmic.c +19 -13
@@ -81,7 +81,7 @@ static struct spmi_device *qcom_pmic_get_base_usid(struct device *dev)struct spmi_device *sdev;struct qcom_spmi_dev *ctx;struct device_node *spmi_bus; -struct device_node *other_usid =NULL ; +struct device_node *child;int function_parent_usid, ret;u32 pmic_addr;
@@ -105,28 +105,34 @@ static struct spmi_device *qcom_pmic_get_base_usid(struct device *dev)* device for USID 2. */ spmi_bus =of_get_parent (sdev->dev.of_node); -do { - other_usid =of_get_next_child (spmi_bus, other_usid); - - ret =of_property_read_u32_index (other_usid,"reg" ,0 , &pmic_addr); -if (ret) -return ERR_PTR (ret); + sdev =ERR_PTR (-ENODATA ); +for_each_child_of_node (spmi_bus, child) { + ret =of_property_read_u32_index (child,"reg" ,0 , &pmic_addr); +if (ret) { +of_node_put (child); + sdev =ERR_PTR (ret); +break ; + } - sdev =spmi_device_from_of (other_usid);if (pmic_addr == function_parent_usid - (ctx->num_usids -1 )) { -if (!sdev) + sdev =spmi_device_from_of (child); +if (!sdev) {/* * If the base USID for this PMIC hasn't probed yet * but the secondary USID has, then we need to defer * the function driver so that it will attempt to * probe again when the base USID is ready. */ -return ERR_PTR (-EPROBE_DEFER ); -return sdev; + sdev =ERR_PTR (-EPROBE_DEFER ); + } +of_node_put (child); +break ; } - }while (other_usid->sibling); + } + +of_node_put (spmi_bus); -return ERR_PTR (-ENODATA ); +return sdev; } static int pmic_spmi_load_revid(struct regmap *map, struct device *dev,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 232/372 mfd: qcom-spmi-pmic: Fix revid implementation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 7b439aaa62fee474a0d84d67a25f4984467e7b95 upstream.
The Qualcomm SPMI PMIC revid implementation is broken in multiple ways.
First, it assumes that just because the sibling base device has been registered that means that it is also bound to a driver, which may not be the case (e.g. due to probe deferral or asynchronous probe). This could trigger a NULL-pointer dereference when attempting to access the driver data of the unbound device.
Second, it accesses driver data of a sibling device directly and without any locking, which means that the driver data may be freed while it is being accessed (e.g. on driver unbind).
Third, it leaks a struct device reference to the sibling device which is looked up using the spmi_device_from_of() every time a function (child) device is calling the revid function (e.g. on probe).
Fix this mess by reimplementing the revid lookup so that it is done only at probe of the PMIC device; the base device fetches the revid info from the hardware, while any secondary SPMI device fetches the information from the base device and caches it so that it can be accessed safely from its children. If the base device has not been probed yet then probe of a secondary device is deferred.
--- drivers/mfd/qcom-spmi-pmic.c | 69 +++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 16 deletions(-)
drivers/mfd/qcom-spmi-pmic.c +53 -16
@@ -30,6 +30,8 @@ struct qcom_spmi_dev {struct qcom_spmi_pmic pmic; }; +static DEFINE_MUTEX (pmic_spmi_revid_lock); +#define N_USIDS (n) ((void *)n)static const struct of_device_id pmic_spmi_id_table[] = {
@@ -76,24 +78,21 @@ static const struct of_device_id pmic_sp* * This only supports PMICs with 1 or 2 USIDs. */ -static struct spmi_device *qcom_pmic_get_base_usid (struct device *dev) +static struct spmi_device *qcom_pmic_get_base_usid (struct spmi_device *sdev,struct qcom_spmi_dev *ctx) { -struct spmi_device *sdev; -struct qcom_spmi_dev *ctx;struct device_node *spmi_bus;struct device_node *child;int function_parent_usid, ret;u32 pmic_addr; - sdev =to_spmi_device (dev); - ctx =dev_get_drvdata (&sdev->dev); -/* * Quick return if the function device is already in the base * USID. This will always be hit for PMICs with only 1 USID. */ -if (sdev->usid % ctx->num_usids ==0 ) +if (sdev->usid % ctx->num_usids ==0 ) { +get_device (&sdev->dev);return sdev; + } function_parent_usid = sdev->usid;
@@ -118,10 +117,8 @@ static struct spmi_device *qcom_pmic_get sdev =spmi_device_from_of (child);if (!sdev) {/* -* If the base USID for this PMIC hasn't probed yet -* but the secondary USID has, then we need to defer -* the function driver so that it will attempt to -* probe again when the base USID is ready. +* If the base USID for this PMIC hasn't been +* registered yet then we need to defer. */ sdev =ERR_PTR (-EPROBE_DEFER ); }
@@ -135,6 +132,35 @@ static struct spmi_device *qcom_pmic_getreturn sdev; } +static int pmic_spmi_get_base_revid (struct spmi_device *sdev,struct qcom_spmi_dev *ctx) +{ +struct qcom_spmi_dev *base_ctx; +struct spmi_device *base; +int ret =0 ; + + base =qcom_pmic_get_base_usid (sdev, ctx); +if (IS_ERR (base)) +return PTR_ERR (base); + +/* +* Copy revid info from base device if it has probed and is still +* bound to its driver. +*/ +mutex_lock (&pmic_spmi_revid_lock); + base_ctx =spmi_device_get_drvdata (base); +if (!base_ctx) { + ret = -EPROBE_DEFER ; + goto out_unlock; + } +memcpy (&ctx->pmic, &base_ctx->pmic,sizeof (ctx->pmic)); +out_unlock: +mutex_unlock (&pmic_spmi_revid_lock); + +put_device (&base->dev); + +return ret; +} +static int pmic_spmi_load_revid (struct regmap *map,struct device *dev,struct qcom_spmi_pmic *pmic) {
@@ -210,11 +236,7 @@ const struct qcom_spmi_pmic *qcom_pmic_gif (!of_match_device (pmic_spmi_id_table, dev->parent))return ERR_PTR (-EINVAL ); - sdev =qcom_pmic_get_base_usid (dev->parent); - -if (IS_ERR (sdev)) -return ERR_CAST (sdev); - + sdev =to_spmi_device (dev->parent); spmi =dev_get_drvdata (&sdev->dev);return &spmi->pmic;
@@ -249,16 +271,31 @@ static int pmic_spmi_probe(struct spmi_d ret =pmic_spmi_load_revid (regmap, &sdev->dev, &ctx->pmic);if (ret <0 )return ret; + }else { + ret =pmic_spmi_get_base_revid (sdev, ctx); +if (ret) +return ret; } + +mutex_lock (&pmic_spmi_revid_lock);spmi_device_set_drvdata (sdev, ctx); +mutex_unlock (&pmic_spmi_revid_lock);return devm_of_platform_populate (&sdev->dev); } +static void pmic_spmi_remove (struct spmi_device *sdev) +{ +mutex_lock (&pmic_spmi_revid_lock); +spmi_device_set_drvdata (sdev,NULL ); +mutex_unlock (&pmic_spmi_revid_lock); +} +MODULE_DEVICE_TABLE (of, pmic_spmi_id_table);static struct spmi_driver pmic_spmi_driver = { .probe = pmic_spmi_probe, + .remove = pmic_spmi_remove, .driver = { .name ="pmic-spmi" , .of_match_table = pmic_spmi_id_table,
Greg Kroah-Hartman
maintainerPATCH 233/372 ima: annotate iint mutex to avoid lockdep false positive warnings
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
commit e044374a8a0a99e46f4e6d6751d3042b6d9cc12e upstream.
It is not clear that IMA should be nested at all, but as long is it measures files both on overlayfs and on underlying fs, we need to annotate the iint mutex to avoid lockdep false positives related to IMA + overlayfs, same as overlayfs annotates the inode mutex.
--- security/integrity/iint.c | 48 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-)
security/integrity/iint.c +37 -11
@@ -66,9 +66,32 @@ struct integrity_iint_cache *integrity_ireturn iint; } -static void iint_free (struct integrity_iint_cache *iint) +#define IMA_MAX_NESTING (FILESYSTEM_MAX_STACK_DEPTH+1) + +/* +* It is not clear that IMA should be nested at all, but as long is it measures +* files both on overlayfs and on underlying fs, we need to annotate the iint +* mutex to avoid lockdep false positives related to IMA + overlayfs. +* See ovl_lockdep_annotate_inode_mutex_key() for more details. +*/ +static inline void iint_lockdep_annotate (struct integrity_iint_cache *iint, +struct inode *inode) +{ +#ifdef CONFIG_LOCKDEP +static struct lock_class_key iint_mutex_key[IMA_MAX_NESTING ]; + +int depth = inode->i_sb->s_stack_depth; + +if (WARN_ON_ONCE (depth <0 || depth >=IMA_MAX_NESTING )) + depth =0 ; + +lockdep_set_class (&iint->mutex, &iint_mutex_key[depth]); +#endif +} + +static void iint_init_always (struct integrity_iint_cache *iint, +struct inode *inode) { -kfree (iint->ima_hash); iint->ima_hash =NULL ; iint->version =0 ; iint->flags =0UL ;
@@ -80,6 +103,14 @@ static void iint_free(struct integrity_i iint->ima_creds_status =INTEGRITY_UNKNOWN ; iint->evm_status =INTEGRITY_UNKNOWN ; iint->measured_pcrs =0 ; +mutex_init (&iint->mutex); +iint_lockdep_annotate (iint, inode); +} + +static void iint_free (struct integrity_iint_cache *iint) +{ +kfree (iint->ima_hash); +mutex_destroy (&iint->mutex);kmem_cache_free (iint_cache, iint); }
@@ -112,6 +143,8 @@ struct integrity_iint_cache *integrity_iif (!iint)return NULL ; +iint_init_always (iint, inode); +write_lock (&integrity_iint_lock); p = &integrity_iint_tree.rb_node;
@@ -161,25 +194,18 @@ void integrity_inode_free(struct inode *iint_free (iint); } -static void init_once (void *foo) +static void iint_init_once (void *foo) {struct integrity_iint_cache *iint = (struct integrity_iint_cache *) foo;memset (iint,0 ,sizeof (*iint)); - iint->ima_file_status =INTEGRITY_UNKNOWN ; - iint->ima_mmap_status =INTEGRITY_UNKNOWN ; - iint->ima_bprm_status =INTEGRITY_UNKNOWN ; - iint->ima_read_status =INTEGRITY_UNKNOWN ; - iint->ima_creds_status =INTEGRITY_UNKNOWN ; - iint->evm_status =INTEGRITY_UNKNOWN ; -mutex_init (&iint->mutex); }static int __init integrity_iintcache_init (void ) { iint_cache =kmem_cache_create ("iint_cache" ,sizeof (struct integrity_iint_cache ), -0 ,SLAB_PANIC , init_once); +0 ,SLAB_PANIC , iint_init_once);return 0 ; }DEFINE_LSM (integrity) = {
Greg Kroah-Hartman
maintainerPATCH 234/372 ima: detect changes to the backing overlay file
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mimi Zohar <[email protected]>
commit b836c4d29f2744200b2af41e14bf50758dddc818 upstream.
Commit 18b44bc5a672 ("ovl: Always reevaluate the file signature for IMA") forced signature re-evaulation on every file access.
Instead of always re-evaluating the file's integrity, detect a change to the backing file, by comparing the cached file metadata with the backing file's metadata. Verifying just the i_version has not changed is insufficient. In addition save and compare the i_ino and s_dev as well.
--- fs/overlayfs/super.c | 2 +- security/integrity/ima/ima_api.c | 5 +++++ security/integrity/ima/ima_main.c | 16 +++++++++++++++- security/integrity/integrity.h | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-)
fs/overlayfs/super.c +1 -1
@@ -2155,7 +2155,7 @@ static int ovl_fill_super(struct super_b ovl_trusted_xattr_handlers; sb->s_fs_info = ofs; sb->s_flags |=SB_POSIXACL ; - sb->s_iflags |=SB_I_SKIP_SYNC |SB_I_IMA_UNVERIFIABLE_SIGNATURE ; + sb->s_iflags |=SB_I_SKIP_SYNC ; err = -ENOMEM ; root_dentry =ovl_get_root (sb, upperpath.dentry, oe);
security/integrity/ima/ima_api.c +5 -0
@@ -243,6 +243,7 @@ int ima_collect_measurement(struct integ {const char *audit_cause ="failed" ;struct inode *inode =file_inode (file); +struct inode *real_inode =d_real_inode (file_dentry (file));const char *filename = file->f_path.dentry->d_name.name;struct ima_max_digest_data hash;int result =0 ;
@@ -305,6 +306,10 @@ int ima_collect_measurement(struct integ iint->ima_hash = tmpbuf;memcpy (iint->ima_hash, &hash, length); iint->version = i_version; +if (real_inode != inode) { + iint->real_ino = real_inode->i_ino; + iint->real_dev = real_inode->i_sb->s_dev; + }/* Possibly temporary failure due to type of read (eg. O_DIRECT) */ if (!result)
security/integrity/ima/ima_main.c +15 -1
@@ -26,6 +26,7 @@#include <linux/ima.h> #include <linux/iversion.h> #include <linux/fs.h> +#include <linux/iversion.h> #include "ima.h"
@@ -202,7 +203,7 @@ static int process_measurement(struct fi u32 secid, char *buf, loff_t size, int mask, enum ima_hooks func) { - struct inode *inode = file_inode(file); + struct inode *backing_inode, *inode = file_inode(file);struct integrity_iint_cache *iint =NULL ;struct ima_template_desc *template_desc =NULL ;char *pathbuf =NULL ;
@@ -278,6 +279,19 @@ static int process_measurement(struct fi iint->measured_pcrs =0 ; } +/* Detect and re-evaluate changes made to the backing file. */ + backing_inode =d_real_inode (file_dentry (file)); +if (backing_inode != inode && + (action &IMA_DO_MASK ) && (iint->flags &IMA_DONE_MASK )) { +if (!IS_I_VERSION (backing_inode) || + backing_inode->i_sb->s_dev != iint->real_dev || + backing_inode->i_ino != iint->real_ino || + !inode_eq_iversion (backing_inode, iint->version)) { + iint->flags &= ~IMA_DONE_MASK ; + iint->measured_pcrs =0 ; + } + } +/* Determine if already appraised/measured based on bitmask * (IMA_MEASURE, IMA_MEASURED, IMA_XXXX_APPRAISE, IMA_XXXX_APPRAISED, * IMA_AUDIT, IMA_AUDITED)
security/integrity/integrity.h +2 -0
@@ -164,6 +164,8 @@ struct integrity_iint_cache {unsigned long flags;unsigned long measured_pcrs;unsigned long atomic_flags; +unsigned long real_ino; +dev_t real_dev; enum integrity_status ima_file_status:4; enum integrity_status ima_mmap_status:4; enum integrity_status ima_bprm_status:4;
Greg Kroah-Hartman
maintainerPATCH 235/372 netfilter: nf_tables: remove catchall element in GC sync path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 93995bf4af2c5a99e2a87f0cd5ce547d31eb7630 ]
The expired catchall element is not deactivated and removed from GC sync path. This path holds mutex so just call nft_setelem_data_deactivate() and nft_setelem_catchall_remove() before queueing the GC work.
--- net/netfilter/nf_tables_api.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
net/netfilter/nf_tables_api.c +21 -5
@@ -6194,6 +6194,12 @@ static int nft_setelem_deactivate(const struct net *net,return ret; } +static void nft_setelem_catchall_destroy (struct nft_set_elem_catchall *catchall) +{ +list_del_rcu (&catchall->list); +kfree_rcu (catchall, rcu); +} +static void nft_setelem_catchall_remove (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem)
@@ -6202,8 +6208,7 @@ static void nft_setelem_catchall_remove(const struct net *net,list_for_each_entry_safe (catchall, next, &set->catchall_list, list) {if (catchall->elem == elem->priv) { -list_del_rcu (&catchall->list); -kfree_rcu (catchall, rcu); +nft_setelem_catchall_destroy (catchall);break ; } }
@@ -9270,11 +9275,12 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc, unsigned int gc_seq, bool sync) { -struct nft_set_elem_catchall *catchall; +struct nft_set_elem_catchall *catchall, *next;const struct nft_set *set = gc->set; +struct nft_elem_priv *elem_priv;struct nft_set_ext *ext; -list_for_each_entry_rcu (catchall, &set->catchall_list, list) { +list_for_each_entry_safe (catchall, next, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem);if (!nft_set_elem_expired (ext))
@@ -9292,7 +9298,17 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,if (!gc)return NULL ; -nft_trans_gc_elem_add (gc, catchall->elem); + elem_priv = catchall->elem; +if (sync) { +struct nft_set_elem elem = { + .priv = elem_priv, + }; + +nft_setelem_data_deactivate (gc->net, gc->set, &elem); +nft_setelem_catchall_destroy (catchall); + } + +nft_trans_gc_elem_add (gc, elem_priv); }return gc;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 236/372 netfilter: nf_tables: split async and sync catchall in two functions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 8837ba3e58ea1e3d09ae36db80b1e80853aada95 ]
list_for_each_entry_safe() does not work for the async case which runs under RCU, therefore, split GC logic for catchall in two functions instead, one for each of the sync and async GC variants.
The catchall sync GC variant never sees a _DEAD bit set on ever, thus, this handling is removed in such case, moreover, allocate GC sync batch via GFP_KERNEL.
--- net/netfilter/nf_tables_api.c | 61 ++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 29 deletions(-)
net/netfilter/nf_tables_api.c +32 -29
@@ -9271,16 +9271,14 @@ void nft_trans_gc_queue_sync_done(struct nft_trans_gc *trans)call_rcu (&trans->rcu, nft_trans_gc_trans_free); } -static struct nft_trans_gc *nft_trans_gc_catchall (struct nft_trans_gc *gc, -unsigned int gc_seq, -bool sync) +struct nft_trans_gc *nft_trans_gc_catchall_async (struct nft_trans_gc *gc, +unsigned int gc_seq) { -struct nft_set_elem_catchall *catchall, *next; +struct nft_set_elem_catchall *catchall;const struct nft_set *set = gc->set; -struct nft_elem_priv *elem_priv;struct nft_set_ext *ext; -list_for_each_entry_safe (catchall, next, &set->catchall_list, list) { +list_for_each_entry_rcu (catchall, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem);if (!nft_set_elem_expired (ext))
@@ -9290,39 +9288,44 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,nft_set_elem_dead (ext); dead_elem: -if (sync) - gc =nft_trans_gc_queue_sync (gc,GFP_ATOMIC ); -else - gc =nft_trans_gc_queue_async (gc, gc_seq,GFP_ATOMIC ); - + gc =nft_trans_gc_queue_async (gc, gc_seq,GFP_ATOMIC );if (!gc)return NULL ; - elem_priv = catchall->elem; -if (sync) { -struct nft_set_elem elem = { - .priv = elem_priv, - }; - -nft_setelem_data_deactivate (gc->net, gc->set, &elem); -nft_setelem_catchall_destroy (catchall); - } - -nft_trans_gc_elem_add (gc, elem_priv); +nft_trans_gc_elem_add (gc, catchall->elem); }return gc; } -struct nft_trans_gc *nft_trans_gc_catchall_async (struct nft_trans_gc *gc, -unsigned int gc_seq) -{ -return nft_trans_gc_catchall (gc, gc_seq, false); -} -struct nft_trans_gc *nft_trans_gc_catchall_sync (struct nft_trans_gc *gc) { -return nft_trans_gc_catchall (gc,0 , true); +struct nft_set_elem_catchall *catchall, *next; +const struct nft_set *set = gc->set; +struct nft_set_elem elem; +struct nft_set_ext *ext; + +WARN_ON_ONCE (!lockdep_commit_lock_is_held (gc->net)); + +list_for_each_entry_safe (catchall, next, &set->catchall_list, list) { + ext =nft_set_elem_ext (set, catchall->elem); + +if (!nft_set_elem_expired (ext)) +continue ; + + gc =nft_trans_gc_queue_sync (gc,GFP_KERNEL ); +if (!gc) +return NULL ; + +memset (&elem,0 ,sizeof (elem)); + elem.priv = catchall->elem; + +nft_setelem_data_deactivate (gc->net, gc->set, &elem); +nft_setelem_catchall_destroy (catchall); +nft_trans_gc_elem_add (gc, elem.priv); + } + +return gc; }static void nf_tables_module_autoload_cleanup (struct net *net)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 237/372 selftests/resctrl: Remove duplicate feature check from CMT test
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit 030b48fb2cf045dead8ee2c5ead560930044c029 upstream.
The test runner run_cmt_test() in resctrl_tests.c checks for CMT feature and does not run cmt_resctrl_val() if CMT is not supported. Then cmt_resctrl_val() also check is CMT is supported.
Remove the duplicated feature check for CMT from cmt_resctrl_val().
--- tools/testing/selftests/resctrl/cmt_test.c | 3 --- 1 file changed, 3 deletions(-)
tools/testing/selftests/resctrl/cmt_test.c +0 -3
@@ -91,9 +91,6 @@ int cmt_resctrl_val(int cpu_no, int n, cif (ret)return ret; -if (!validate_resctrl_feature_request (CMT_STR )) -return -1 ; - ret =get_cbm_mask ("L3" , cbm_mask);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 238/372 selftests/resctrl: Move _GNU_SOURCE define into Makefile
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit 3a1e4a91aa454a1c589a9824d54179fdbfccde45 upstream.
_GNU_SOURCE is defined in resctrl.h. Defining _GNU_SOURCE has a large impact on what gets defined when including headers either before or after it. This can result in compile failures if .c file decides to include a standard header file before resctrl.h.
It is safer to define _GNU_SOURCE in Makefile so it is always defined regardless of in which order includes are done.
--- tools/testing/selftests/resctrl/Makefile | 2 +- tools/testing/selftests/resctrl/resctrl.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/resctrl/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2 +CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE CFLAGS += $(KHDR_INCLUDES) TEST_GEN_PROGS := resctrl_tests
tools/testing/selftests/resctrl/resctrl.h +0 -1
@@ -1,5 +1,4 @@/* SPDX-License-Identifier: GPL-2.0 */ -#define _GNU_SOURCE#ifndef RESCTRL_H #define RESCTRL_H #include <stdio.h>
Greg Kroah-Hartman
maintainerPATCH 239/372 selftests/resctrl: Reduce failures due to outliers in MBA/MBM tests
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit ef43c30858754d99373a63dff33280a9969b49bc upstream.
The initial value of 5% chosen for the maximum allowed percentage difference between resctrl mbm value and IMC mbm value in
commit 06bd03a57f8c ("selftests/resctrl: Fix MBA/MBM results reporting
format") was "randomly chosen value" (as admitted by the changelog).
When running tests in our lab across a large number platforms, 5% difference upper bound for success seems a bit on the low side for the MBA and MBM tests. Some platforms produce outliers that are slightly above that, typically 6-7%, which leads MBA/MBM test frequently failing.
Replace the "randomly chosen value" with a success bound that is based on those measurements across large number of platforms by relaxing the MBA/MBM success bound to 8%. The relaxed bound removes the failures due the frequent outliers.
Fixed commit description style error during merge:
Shuah Khan <[email protected]>
--- tools/testing/selftests/resctrl/mba_test.c | 2 +- tools/testing/selftests/resctrl/mbm_test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/resctrl/mba_test.c +1 -1
@@ -12,7 +12,7 @@#define RESULT_FILE_NAME "result_mba"#define NUM_OF_RUNS 5 -#define MAX_DIFF_PERCENT 5 +#define MAX_DIFF_PERCENT 8#define ALLOCATION_MAX 100#define ALLOCATION_MIN 10#define ALLOCATION_STEP 10
tools/testing/selftests/resctrl/mbm_test.c +1 -1
@@ -11,7 +11,7 @@#include "resctrl.h" #define RESULT_FILE_NAME "result_mbm" -#define MAX_DIFF_PERCENT 5 +#define MAX_DIFF_PERCENT 8#define NUM_OF_RUNS 5 static int
Greg Kroah-Hartman
maintainerPATCH 240/372 hid: lenovo: Resend all settings on reset_resume for compact keyboards
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamie Lentin <[email protected]>
commit 2f2bd7cbd1d1548137b351040dc4e037d18cdfdc upstream.
The USB Compact Keyboard variant requires a reset_resume function to restore keyboard configuration after a suspend in some situations. Move configuration normally done on probe to lenovo_features_set_cptkbd(), then recycle this for use on reset_resume.
Without, the keyboard and driver would end up in an inconsistent state, breaking middle-button scrolling amongst other problems, and twiddling sysfs values wouldn't help as the middle-button mode won't be set until the driver is reloaded.
Tested on a USB and Bluetooth Thinkpad Compact Keyboard.
--- drivers/hid/hid-lenovo.c | 50 +++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-)
drivers/hid/hid-lenovo.c +34 -16
@@ -526,6 +526,19 @@ static void lenovo_features_set_cptkbd(sint ret;struct lenovo_drvdata *cptkbd_data =hid_get_drvdata (hdev); +/* +* Tell the keyboard a driver understands it, and turn F7, F9, F11 into +* regular keys +*/ + ret =lenovo_send_cmd_cptkbd (hdev,0x01 ,0x03 ); +if (ret) +hid_warn (hdev,"Failed to switch F7/9/11 mode: %d\n" , ret); + +/* Switch middle button to native mode */ + ret =lenovo_send_cmd_cptkbd (hdev,0x09 ,0x01 ); +if (ret) +hid_warn (hdev,"Failed to switch middle button: %d\n" , ret); + ret =lenovo_send_cmd_cptkbd (hdev,0x05 , cptkbd_data->fn_lock);if (ret)hid_err (hdev,"Fn-lock setting failed: %d\n" , ret);
@@ -1148,22 +1161,6 @@ static int lenovo_probe_cptkbd(struct hi }hid_set_drvdata (hdev, cptkbd_data); -/* -* Tell the keyboard a driver understands it, and turn F7, F9, F11 into -* regular keys (Compact only) -*/ -if (hdev->product ==USB_DEVICE_ID_LENOVO_CUSBKBD || - hdev->product ==USB_DEVICE_ID_LENOVO_CBTKBD ) { - ret =lenovo_send_cmd_cptkbd (hdev,0x01 ,0x03 ); -if (ret) -hid_warn (hdev,"Failed to switch F7/9/11 mode: %d\n" , ret); - } - -/* Switch middle button to native mode */ - ret =lenovo_send_cmd_cptkbd (hdev,0x09 ,0x01 ); -if (ret) -hid_warn (hdev,"Failed to switch middle button: %d\n" , ret); -/* Set keyboard settings to known state */ cptkbd_data->middlebutton_state =0 ; cptkbd_data->fn_lock = true;
@@ -1286,6 +1283,24 @@ err:return ret; } +#ifdef CONFIG_PM +static int lenovo_reset_resume (struct hid_device *hdev) +{ +switch (hdev->product) { +case USB_DEVICE_ID_LENOVO_CUSBKBD : +case USB_DEVICE_ID_LENOVO_TPIIUSBKBD : +if (hdev->type ==HID_TYPE_USBMOUSE ) +lenovo_features_set_cptkbd (hdev); + +break ; +default : +break ; + } + +return 0 ; +} +#endif +static void lenovo_remove_tpkbd (struct hid_device *hdev) {struct lenovo_drvdata *data_pointer =hid_get_drvdata (hdev);
@@ -1402,6 +1417,9 @@ static struct hid_driver lenovo_driver = .raw_event = lenovo_raw_event, .event = lenovo_event, .report_fixup = lenovo_report_fixup, +#ifdef CONFIG_PM + .reset_resume = lenovo_reset_resume, +#endif };module_hid_driver (lenovo_driver);
Greg Kroah-Hartman
maintainerPATCH 241/372 ASoC: codecs: wsa-macro: fix uninitialized stack variables with name prefix
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 72151ad0cba8a07df90130ff62c979520d71f23b upstream.
Driver compares widget name in wsa_macro_spk_boost_event() widget event callback, however it does not handle component's name prefix. This leads to using uninitialized stack variables as registers and register values. Handle gracefully such case.
--- sound/soc/codecs/lpass-wsa-macro.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/lpass-wsa-macro.c +3 -0
@@ -1682,6 +1682,9 @@ static int wsa_macro_spk_boost_event(str boost_path_cfg1 =CDC_WSA_RX1_RX_PATH_CFG1 ; reg =CDC_WSA_RX1_RX_PATH_CTL ; reg_mix =CDC_WSA_RX1_RX_PATH_MIX_CTL ; + }else { +dev_warn (component->dev,"Incorrect widget name in the driver\n" ); +return -EINVAL ; }switch (event) {
Greg Kroah-Hartman
maintainerPATCH 242/372 jbd2: fix potential data lost in recovering journal raced with synchronizing fs bdev
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
commit 61187fce8600e8ef90e601be84f9d0f3222c1206 upstream.
JBD2 makes sure journal data is fallen on fs device by sync_blockdev(), however, other process could intercept the EIO information from bdev's mapping, which leads journal recovering successful even EIO occurs during data written back to fs device.
We found this problem in our product, iscsi + multipath is chosen for block device of ext4. Unstable network may trigger kpartx to rescan partitions in device mapper layer. Detailed process is shown as following:
mount kpartx irqjbd2_journal_recover
do_one_pass
memcpy(nbh->b_data, obh->b_data) // copy data to fs dev from journal mark_buffer_dirty // mark bh dirty
vfs_read
generic_file_read_iter // dio
filemap_write_and_wait_range
__filemap_fdatawrite_range
do_writepages
block_write_full_folio
submit_bh_wbc
>> EIO occurs in disk <<
end_buffer_async_write
mark_buffer_write_io_error
mapping_set_error
set_bit(AS_EIO, &mapping->flags) // set!
filemap_check_errors
test_and_clear_bit(AS_EIO, &mapping->flags) // clear!
err2 = sync_blockdev
filemap_write_and_wait
filemap_check_errors
test_and_clear_bit(AS_EIO, &mapping->flags) // false
err2 = 0
Filesystem is mounted successfully even data from journal is failed written into disk, and ext4/ocfs2 could become corrupted.
Fix it by comparing the wb_err state in fs block device before recovering and after recovering.
A reproducer can be found in the kernel bugzilla referenced below.
--- fs/jbd2/recovery.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/jbd2/recovery.c +8 -0
@@ -288,6 +288,8 @@ int jbd2_journal_recover(journal_t *jourjournal_superblock_t * sb;struct recovery_info info; +errseq_t wb_err; +struct address_space *mapping;memset (&info,0 ,sizeof (info)); sb = journal->j_superblock;
@@ -305,6 +307,9 @@ int jbd2_journal_recover(journal_t *jourreturn 0 ; } + wb_err =0 ; + mapping = journal->j_fs_dev->bd_inode->i_mapping; +errseq_check_and_advance (&mapping->wb_err, &wb_err); err =do_one_pass (journal, &info,PASS_SCAN );if (!err) err =do_one_pass (journal, &info,PASS_REVOKE );
@@ -325,6 +330,9 @@ int jbd2_journal_recover(journal_t *jour err2 =sync_blockdev (journal->j_fs_dev);if (!err) err = err2; + err2 =errseq_check_and_advance (&mapping->wb_err, &wb_err); +if (!err) + err = err2;/* Make sure all replayed data is on permanent storage */ if (journal->j_flags &JBD2_BARRIER ) { err2 =blkdev_issue_flush (journal->j_fs_dev);
Greg Kroah-Hartman
maintainerPATCH 243/372 quota: explicitly forbid quota files from being encrypted
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit d3cc1b0be258191d6360c82ea158c2972f8d3991 upstream.
Since commit d7e7b9af104c ("fscrypt: stop using keyrings subsystem for fscrypt_master_key"), xfstest generic/270 causes a WARNING when run on f2fs with test_dummy_encryption in the mount options:
$ kvm-xfstests -c f2fs/encrypt generic/270 [...] WARNING: CPU: 1 PID: 2453 at fs/crypto/keyring.c:240 fscrypt_destroy_keyring+0x1f5/0x260
The cause of the WARNING is that not all encrypted inodes have been evicted before fscrypt_destroy_keyring() is called, which violates an assumption. This happens because the test uses an external quota file, which gets automatically encrypted due to test_dummy_encryption.
Encryption of quota files has never really been supported. On ext4, ext4_quota_read() does not decrypt the data, so encrypted quota files are always considered invalid on ext4. On f2fs, f2fs_quota_read() uses the pagecache, so trying to use an encrypted quota file gets farther, resulting in the issue described above being possible. But this was never intended to be possible, and there is no use case for it.
Therefore, make the quota support layer explicitly reject using IS_ENCRYPTED inodes when quotaon is attempted.
Message-Id: <[email protected]>
--- fs/quota/dquot.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/quota/dquot.c +14 -0
@@ -2403,6 +2403,20 @@ static int vfs_setup_quota_inode(structif (sb_has_quota_loaded (sb, type))return -EBUSY ; +/* +* Quota files should never be encrypted. They should be thought of as +* filesystem metadata, not user data. New-style internal quota files +* cannot be encrypted by users anyway, but old-style external quota +* files could potentially be incorrectly created in an encrypted +* directory, hence this explicit check. Some reasons why encrypted +* quota files don't work include: (1) some filesystems that support +* encryption don't handle it in their quota_read and quota_write, and +* (2) cleaning up encrypted quota files at unmount would need special +* consideration, as quota files are cleaned up later than user files. +*/ +if (IS_ENCRYPTED (inode)) +return -EINVAL ; + dqopt->files[type] =igrab (inode);if (!dqopt->files[type])return -EIO ;
Greg Kroah-Hartman
maintainerPATCH 244/372 kernel/reboot: emergency_restart: Set correct system_state
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Bara <[email protected]>
commit 60466c067927abbcaff299845abd4b7069963139 upstream.
As the emergency restart does not call kernel_restart_prepare(), the system_state stays in SYSTEM_RUNNING.
Since bae1d3a05a8b, this hinders i2c_in_atomic_xfer_mode() from becoming active, and therefore might lead to avoidable warnings in the restart handlers, e.g.:
[ 12.667612] WARNING: CPU: 1 PID: 1 at kernel/rcu/tree_plugin.h:318 rcu_note_context_switch+0x33c/0x6b0 [ 12.676926] Voluntary context switch within RCU read-side critical section! ... [ 12.742376] schedule_timeout from wait_for_completion_timeout+0x90/0x114 [ 12.749179] wait_for_completion_timeout from tegra_i2c_wait_completion+0x40/0x70 ... [ 12.994527] atomic_notifier_call_chain from machine_restart+0x34/0x58 [ 13.001050] machine_restart from panic+0x2a8/0x32c
Avoid these by setting the correct system_state.
--- kernel/reboot.c | 1 + 1 file changed, 1 insertion(+)
kernel/reboot.c +1 -0
@@ -74,6 +74,7 @@ void __weak (*pm_power_off)(void);void emergency_restart (void ) {kmsg_dump (KMSG_DUMP_EMERG ); + system_state =SYSTEM_RESTART ;machine_emergency_restart (); }EXPORT_SYMBOL_GPL (emergency_restart);
Greg Kroah-Hartman
maintainerPATCH 245/372 i2c: core: Run atomic i2c xfer when !preemptible
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Bara <[email protected]>
commit aa49c90894d06e18a1ee7c095edbd2f37c232d02 upstream.
Since bae1d3a05a8b, i2c transfers are non-atomic if preemption is disabled. However, non-atomic i2c transfers require preemption (e.g. in wait_for_completion() while waiting for the DMA).
panic() calls preempt_disable_notrace() before calling emergency_restart(). Therefore, if an i2c device is used for the restart, the xfer should be atomic. This avoids warnings like:
[ 12.667612] WARNING: CPU: 1 PID: 1 at kernel/rcu/tree_plugin.h:318 rcu_note_context_switch+0x33c/0x6b0 [ 12.676926] Voluntary context switch within RCU read-side critical section! ... [ 12.742376] schedule_timeout from wait_for_completion_timeout+0x90/0x114 [ 12.749179] wait_for_completion_timeout from tegra_i2c_wait_completion+0x40/0x70 ... [ 12.994527] atomic_notifier_call_chain from machine_restart+0x34/0x58 [ 13.001050] machine_restart from panic+0x2a8/0x32c
Use !preemptible() instead, which is basically the same check as pre-v5.2.
--- drivers/i2c/i2c-core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core.h +1 -1
@@ -29,7 +29,7 @@ int i2c_dev_irq_from_resources(const str*/ static inline bool i2c_in_atomic_xfer_mode (void ) { -return system_state >SYSTEM_RUNNING &&irqs_disabled (); +return system_state >SYSTEM_RUNNING && !preemptible (); }static inline int __i2c_lock_bus_helper (struct i2c_adapter *adap)
Greg Kroah-Hartman
maintainerPATCH 246/372 tracing: Have the user copy of synthetic event address use correct context
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
commit 4f7969bcd6d33042d62e249b41b5578161e4c868 upstream.
A synthetic event is created by the synthetic event interface that can read both user or kernel address memory. In reality, it reads any arbitrary memory location from within the kernel. If the address space is in USER (where CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE is set) then it uses strncpy_from_user_nofault() to copy strings otherwise it uses strncpy_from_kernel_nofault().
But since both functions use the same variable there's no annotation to what that variable is (ie. __user). This makes sparse complain.
Quiet sparse by typecasting the strncpy_from_user_nofault() variable to a __user pointer.
--- kernel/trace/trace_events_synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
@@ -473,7 +473,7 @@ static unsigned int trace_string(struct#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE if ((unsigned long )str_val <TASK_SIZE ) - ret =strncpy_from_user_nofault (str_field, str_val,STR_VAR_LEN_MAX ); + ret =strncpy_from_user_nofault (str_field, (const void __user *)str_val,STR_VAR_LEN_MAX ); else#endif ret =strncpy_from_kernel_nofault (str_field, str_val,STR_VAR_LEN_MAX );
Greg Kroah-Hartman
maintainerPATCH 247/372 driver core: Release all resources during unbind before updating device links
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saravana Kannan <[email protected]>
commit 2e84dc37920012b458e9458b19fc4ed33f81bc74 upstream.
This commit fixes a bug in commit 9ed9895370ae ("driver core: Functional dependencies tracking support") where the device link status was incorrectly updated in the driver unbind path before all the device's resources were released.
--- drivers/base/dd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/dd.c +1 -1
@@ -1262,8 +1262,8 @@ static void __device_release_driver(struif (dev->bus && dev->bus->dma_cleanup) dev->bus->dma_cleanup (dev); -device_links_driver_cleanup (dev);device_unbind_cleanup (dev); +device_links_driver_cleanup (dev);klist_remove (&dev->p->knode_driver);device_pm_check_callbacks (dev);
Greg Kroah-Hartman
maintainerPATCH 248/372 mcb: fix error handling for different scenarios when parsing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanjuán García, Jorge <[email protected]>
commit 63ba2d07b4be72b94216d20561f43e1150b25d98 upstream.
chameleon_parse_gdd() may fail for different reasons and end up in the err tag. Make sure we at least always free the mcb_device allocated with mcb_alloc_dev().
If mcb_device_register() fails, make sure to give up the reference in the same place the device was added.
--- drivers/mcb/mcb-core.c | 1 + drivers/mcb/mcb-parse.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mcb/mcb-core.c +1 -0
@@ -246,6 +246,7 @@ int mcb_device_register(struct mcb_bus *return 0 ; out: +put_device (&dev->dev);return ret; }
drivers/mcb/mcb-parse.c +1 -1
@@ -106,7 +106,7 @@ static int chameleon_parse_gdd(struct mcreturn 0 ; err: -put_device (&mdev->dev); +mcb_free_dev (mdev);return ret; }
Greg Kroah-Hartman
maintainerPATCH 249/372 powerpc/pseries/iommu: enable_ddw incorrectly returns direct mapping for SR-IOV device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gaurav Batra <[email protected]>
commit 3bf983e4e93ce8e6d69e9d63f52a66ec0856672e upstream.
When a device is initialized, the driver invokes dma_supported() twice - first for streaming mappings followed by coherent mappings. For an SR-IOV device, default window is deleted and DDW created. With vPMEM enabled, TCE mappings are dynamically created for both vPMEM and SR-IOV device. There are no direct mappings.
First time when dma_supported() is called with 64 bit mask, DDW is created and marked as dynamic window. The second time dma_supported() is called, enable_ddw() finds existing window for the device and incorrectly returns it as "direct mapping".
This only happens when size of DDW is big enough to map max LPAR memory.
This results in streaming TCEs to not get dynamically mapped, since code incorrently assumes these are already pre-mapped. The adapter initially comes up but goes down due to EEH.
--- arch/powerpc/platforms/pseries/iommu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +4 -4
@@ -909,7 +909,8 @@ static int remove_ddw(struct device_nodereturn 0 ; } -static bool find_existing_ddw (struct device_node *pdn,u64 *dma_addr,int *window_shift) +static bool find_existing_ddw (struct device_node *pdn,u64 *dma_addr,int *window_shift, +bool *direct_mapping) {struct dma_win *window;const struct dynamic_dma_window_prop *dma64;
@@ -922,6 +923,7 @@ static bool find_existing_ddw(struct dev dma64 = window->prop; *dma_addr =be64_to_cpu (dma64->dma_base); *window_shift =be32_to_cpu (dma64->window_shift); + *direct_mapping = window->direct; found = true;break ; }
@@ -1275,10 +1277,8 @@ static bool enable_ddw(struct pci_dev *dmutex_lock (&dma_win_init_mutex); -if (find_existing_ddw (pdn, &dev->dev.archdata.dma_offset, &len)) { - direct_mapping = (len >= max_ram_len); +if (find_existing_ddw (pdn, &dev->dev.archdata.dma_offset, &len, &direct_mapping)) goto out_unlock; - }/* * If we already went through this for a previous function of
Greg Kroah-Hartman
maintainerPATCH 250/372 dmaengine: stm32-mdma: correct desc prep when channel running
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alain Volmat <[email protected]>
commit 03f25d53b145bc2f7ccc82fc04e4482ed734f524 upstream.
In case of the prep descriptor while the channel is already running, the CCR register value stored into the channel could already have its EN bit set. This would lead to a bad transfer since, at start transfer time, enabling the channel while other registers aren't yet properly set. To avoid this, ensure to mask the CCR_EN bit when storing the ccr value into the mdma channel structure.
--- drivers/dma/stm32-mdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/stm32-mdma.c +2 -2
@@ -490,7 +490,7 @@ static int stm32_mdma_set_xfer_param(str src_maxburst = chan->dma_config.src_maxburst; dst_maxburst = chan->dma_config.dst_maxburst; - ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)); + ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)) & ~STM32_MDMA_CCR_EN ; ctcr =stm32_mdma_read (dmadev,STM32_MDMA_CTCR (chan->id)); ctbr =stm32_mdma_read (dmadev,STM32_MDMA_CTBR (chan->id));
@@ -966,7 +966,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chif (!desc)return NULL ; - ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)); + ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)) & ~STM32_MDMA_CCR_EN ; ctcr =stm32_mdma_read (dmadev,STM32_MDMA_CTCR (chan->id)); ctbr =stm32_mdma_read (dmadev,STM32_MDMA_CTBR (chan->id)); cbndtr =stm32_mdma_read (dmadev,STM32_MDMA_CBNDTR (chan->id));
Greg Kroah-Hartman
maintainerPATCH 251/372 s390/cmma: fix initial kernel address space page table walk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 16ba44826a04834d3eeeda4b731c2ea3481062b7 upstream.
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. The initial loop however does not cover the complete kernel address space. This can result in pages being marked as not being used for dynamic address translation, even though they are. In turn guest TLB entries incorrectly may not be purged.
Fix this by adjusting the end address of the kernel address range being walked.
--- arch/s390/mm/page-states.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/s390/mm/page-states.c +10 -3
@@ -162,15 +162,22 @@ static void mark_kernel_p4d(pgd_t *pgd,static void mark_kernel_pgd (void ) { -unsigned long addr, next; +unsigned long addr, next, max_addr;struct page *page;pgd_t *pgd;int i; addr =0 ; +/* +* Figure out maximum virtual address accessible with the +* kernel ASCE. This is required to keep the page table walker +* from accessing non-existent entries. +*/ + max_addr = (S390_lowcore.kernel_asce.val & _ASCE_TYPE_MASK) >>2 ; + max_addr =1UL << (max_addr *11 +31 ); pgd =pgd_offset_k (addr); do { - next = pgd_addr_end(addr, MODULES_END); + next = pgd_addr_end(addr, max_addr); if (pgd_none(*pgd)) continue; if (!pgd_folded(*pgd)) {
@@ -179,7 +186,7 @@ static void mark_kernel_pgd(void)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_p4d (pgd, addr, next); - }while (pgd++, addr = next, addr !=MODULES_END ); + }while (pgd++, addr = next, addr != max_addr); }void __init cmma_init_nodat (void )
Greg Kroah-Hartman
maintainerPATCH 252/372 s390/cmma: fix detection of DAT pages
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 44d93045247661acbd50b1629e62f415f2747577 upstream.
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. The initial loop however is
incorrect: only the first three of the four pages which belong to segment and region tables will be marked as being used for DAT. The last page is incorrectly marked as no-dat.
This can result in incorrect guest TLB flushes.
Fix this by simply marking all four pages.
--- arch/s390/mm/page-states.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/mm/page-states.c +3 -3
@@ -132,7 +132,7 @@ static void mark_kernel_pud(p4d_t *p4d,continue ;if (!pud_folded (*pud)) { page =phys_to_page (pud_val (*pud)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_pmd (pud, addr, next);
@@ -153,7 +153,7 @@ static void mark_kernel_p4d(pgd_t *pgd,continue ;if (!p4d_folded (*p4d)) { page =phys_to_page (p4d_val (*p4d)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_pud (p4d, addr, next);
@@ -182,7 +182,7 @@ static void mark_kernel_pgd(void)continue ;if (!pgd_folded (*pgd)) { page =phys_to_page (pgd_val (*pgd)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_p4d (pgd, addr, next);
Greg Kroah-Hartman
maintainerPATCH 253/372 s390/cmma: fix handling of swapper_pg_dir and invalid_pg_dir
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 84bb41d5df48868055d159d9247b80927f1f70f9 upstream.
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. All pages used for swapper_pg_dir and invalid_pg_dir are incorrectly marked as no-dat, which in turn can result in incorrect guest TLB flushes.
Fix this by marking those pages correctly as being used for DAT.
--- arch/s390/mm/page-states.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/s390/mm/page-states.c +6 -0
@@ -199,6 +199,12 @@ void __init cmma_init_nodat(void)return ;/* Mark pages used in kernel page tables */ mark_kernel_pgd (); + page =virt_to_page (&swapper_pg_dir); +for (i =0 ; i <4 ; i++) +set_bit (PG_arch_1, &page[i].flags); + page =virt_to_page (&invalid_pg_dir); +for (i =0 ; i <4 ; i++) +set_bit (PG_arch_1, &page[i].flags);/* Set all kernel pages not used for page tables to stable/no-dat */ for_each_mem_pfn_range (i,MAX_NUMNODES , &start, &end,NULL ) {
Greg Kroah-Hartman
maintainerPATCH 254/372 mm/cma: use nth_page() in place of direct struct page manipulation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <[email protected]>
commit 2e7cfe5cd5b6b0b98abf57a3074885979e187c1c upstream.
Patch series "Use nth_page() in place of direct struct page manipulation", v3.
On SPARSEMEM without VMEMMAP, struct page is not guaranteed to be contiguous, since each memory section's memmap might be allocated independently. hugetlb pages can go beyond a memory section size, thus direct struct page manipulation on hugetlb pages/subpages might give wrong struct page. Kernel provides nth_page() to do the manipulation properly. Use that whenever code can see hugetlb pages.
This patch (of 5):
When dealing with hugetlb pages, manipulating struct page pointers directly can get to wrong struct page, since struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use nth_page() to handle it properly.
Without the fix, page_kasan_tag_reset() could reset wrong page tags, causing a wrong kasan result. No related bug is reported. The fix comes from code inspection.
--- mm/cma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +1 -1
@@ -500,7 +500,7 @@ struct page *cma_alloc(struct cma *cma,*/ if (page) {for (i =0 ; i < count; i++) -page_kasan_tag_reset (page + i); +page_kasan_tag_reset (nth_page (page, i)); }if (ret && !no_warn) {
Greg Kroah-Hartman
maintainerPATCH 255/372 mm/memory_hotplug: use pfn math in place of direct struct page manipulation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <[email protected]>
commit 1640a0ef80f6d572725f5b0330038c18e98ea168 upstream.
When dealing with hugetlb pages, manipulating struct page pointers directly can get to wrong struct page, since struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use pfn calculation to handle it properly.
Without the fix, a wrong number of page might be skipped. Since skip cannot be negative, scan_movable_page() will end early and might miss a movable page with -ENOENT. This might fail offline_pages(). No bug is reported. The fix comes from code inspection.
--- mm/memory_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory_hotplug.c +1 -1
@@ -1611,7 +1611,7 @@ static int scan_movable_pages(unsigned l*/ if (HPageMigratable (head)) goto found; - skip =compound_nr (head) - (page - head); + skip =compound_nr (head) - (pfn -page_to_pfn (head)); pfn += skip -1 ; }return -ENOENT ;
Greg Kroah-Hartman
maintainerPATCH 256/372 mtd: cfi_cmdset_0001: Byte swap OTP info
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit 565fe150624ee77dc63a735cc1b3bff5101f38a3 upstream.
Currently the offset into the device when looking for OTP bits can go outside of the address of the MTD NOR devices, and if that memory isn't readable, bad things happen on the IXP4xx (added prints that illustrate the problem before the crash):
cfi_intelext_otp_walk walk OTP on chip 0 start at reg_prot_offset 0x00000100 ixp4xx_copy_from copy from 0x00000100 to 0xc880dd78 cfi_intelext_otp_walk walk OTP on chip 0 start at reg_prot_offset 0x12000000 ixp4xx_copy_from copy from 0x12000000 to 0xc880dd78
8<--- cut here ---
Unable to handle kernel paging request at virtual address db000000
[db000000] *pgd=00000000
(...)
This happens in this case because the IXP4xx is big endian and the 32- and 16-bit fields in the struct cfi_intelext_otpinfo are not properly byteswapped. Compare to how the code in read_pri_intelext() byteswaps the fields in struct cfi_pri_intelext.
Adding a small byte swapping loop for the OTP in read_pri_intelext() and the crash goes away.
The problem went unnoticed for many years until I enabled CONFIG_MTD_OTP on the IXP4xx as well, triggering the bug.
--- drivers/mtd/chips/cfi_cmdset_0001.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/mtd/chips/cfi_cmdset_0001.c +18 -2
@@ -421,9 +421,25 @@ read_pri_intelext(struct map_info *map, extra_size =0 ;/* Protection Register info */ -if (extp->NumProtectionFields) +if (extp->NumProtectionFields) { +struct cfi_intelext_otpinfo *otp = + (struct cfi_intelext_otpinfo *)&extp->extra[0 ]; + extra_size += (extp->NumProtectionFields -1 ) * -sizeof (struct cfi_intelext_otpinfo ); +sizeof (struct cfi_intelext_otpinfo ); + +if (extp_size >=sizeof (*extp) + extra_size) { +int i; + +/* Do some byteswapping if necessary */ +for (i =0 ; i < extp->NumProtectionFields -1 ; i++) { + otp->ProtRegAddr =le32_to_cpu (otp->ProtRegAddr); + otp->FactGroups =le16_to_cpu (otp->FactGroups); + otp->UserGroups =le16_to_cpu (otp->UserGroups); + otp++; + } + } + } }if (extp->MinorVersion >='1' ) {
Greg Kroah-Hartman
maintainerPATCH 257/372 i3c: master: cdns: Fix reading status register
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Yeong <[email protected]>
commit 4bd8405257da717cd556f99e5fb68693d12c9766 upstream.
IBIR_DEPTH and CMDR_DEPTH should read from status0 instead of status1.
--- drivers/i3c/master/i3c-master-cdns.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/i3c-master-cdns.c +3 -3
@@ -192,7 +192,7 @@#define SLV_STATUS1_HJ_DIS BIT(18)#define SLV_STATUS1_MR_DIS BIT(17)#define SLV_STATUS1_PROT_ERR BIT(16) -#define SLV_STATUS1_DA (x) (((s) & GENMASK(15, 9)) >> 9) +#define SLV_STATUS1_DA (s) (((s) & GENMASK(15, 9)) >> 9)#define SLV_STATUS1_HAS_DA BIT(8)#define SLV_STATUS1_DDR_RX_FULL BIT(7)#define SLV_STATUS1_DDR_TX_FULL BIT(6)
@@ -1624,13 +1624,13 @@ static int cdns_i3c_master_probe(struct/* Device ID0 is reserved to describe this master. */ master->maxdevs =CONF_STATUS0_DEVS_NUM (val); master->free_rr_slots =GENMASK (master->maxdevs,1 ); + master->caps.ibirfifodepth =CONF_STATUS0_IBIR_DEPTH (val); + master->caps.cmdrfifodepth =CONF_STATUS0_CMDR_DEPTH (val); val =readl (master->regs +CONF_STATUS1 ); master->caps.cmdfifodepth =CONF_STATUS1_CMD_DEPTH (val); master->caps.rxfifodepth =CONF_STATUS1_RX_DEPTH (val); master->caps.txfifodepth =CONF_STATUS1_TX_DEPTH (val); - master->caps.ibirfifodepth =CONF_STATUS0_IBIR_DEPTH (val); - master->caps.cmdrfifodepth =CONF_STATUS0_CMDR_DEPTH (val);spin_lock_init (&master->ibi.lock); master->ibi.num_slots =CONF_STATUS1_IBI_HW_RES (val);
Greg Kroah-Hartman
maintainerPATCH 258/372 i3c: master: svc: fix race condition in ibi work thread
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 6bf3fc268183816856c96b8794cd66146bc27b35 upstream.
The ibi work thread operates asynchronously with other transfers, such as svc_i3c_master_priv_xfers(). Introduce mutex protection to ensure the completion of the entire i3c/i2c transaction.
--- drivers/i3c/master/svc-i3c-master.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/i3c/master/svc-i3c-master.c +14 -0
@@ -168,6 +168,7 @@ struct svc_i3c_xfer {* @ibi.slots: Available IBI slots * @ibi.tbq_slot: To be queued IBI slot * @ibi.lock: IBI lock +* @lock: Transfer lock, protect between IBI work thread and callbacks from master */ struct svc_i3c_master {struct i3c_master_controller base;
@@ -195,6 +196,7 @@ struct svc_i3c_master {/* Prevent races within IBI handlers */ spinlock_t lock; } ibi; +struct mutex lock; };/**
@@ -376,6 +378,7 @@ static void svc_i3c_master_ibi_work(struu32 status, val;int ret; +mutex_lock (&master->lock);/* Acknowledge the incoming interrupt with the AUTOIBI mechanism */ writel(SVC_I3C_MCTRL_REQUEST_AUTO_IBI | SVC_I3C_MCTRL_IBIRESP_AUTO,
@@ -452,6 +455,7 @@ static void svc_i3c_master_ibi_work(stru reenable_ibis:svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); +mutex_unlock (&master->lock); }static irqreturn_t svc_i3c_master_irq_handler (int irq,void *dev_id)
@@ -1191,9 +1195,11 @@ static int svc_i3c_master_send_bdcast_cc cmd->read_len =0 ; cmd->continued = false; +mutex_lock (&master->lock);svc_i3c_master_enqueue_xfer (master, xfer);if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +mutex_unlock (&master->lock); ret = xfer->ret;kfree (buf);
@@ -1237,9 +1243,11 @@ static int svc_i3c_master_send_direct_cc cmd->read_len = read_len; cmd->continued = false; +mutex_lock (&master->lock);svc_i3c_master_enqueue_xfer (master, xfer);if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +mutex_unlock (&master->lock);if (cmd->read_len != xfer_len) ccc->dests[0 ].payload.len = cmd->read_len;
@@ -1296,9 +1304,11 @@ static int svc_i3c_master_priv_xfers(str cmd->continued = (i +1 ) < nxfers; } +mutex_lock (&master->lock);svc_i3c_master_enqueue_xfer (master, xfer);if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +mutex_unlock (&master->lock); ret = xfer->ret;svc_i3c_master_free_xfer (xfer);
@@ -1334,9 +1344,11 @@ static int svc_i3c_master_i2c_xfers(stru cmd->continued = (i +1 < nxfers); } +mutex_lock (&master->lock);svc_i3c_master_enqueue_xfer (master, xfer);if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +mutex_unlock (&master->lock); ret = xfer->ret;svc_i3c_master_free_xfer (xfer);
@@ -1527,6 +1539,8 @@ static int svc_i3c_master_probe(struct pINIT_WORK (&master->hj_work, svc_i3c_master_hj_work);INIT_WORK (&master->ibi_work, svc_i3c_master_ibi_work); +mutex_init (&master->lock); + ret =devm_request_irq (dev, master->irq, svc_i3c_master_irq_handler,IRQF_NO_SUSPEND ,"svc-i3c-irq" , master);if (ret)
Greg Kroah-Hartman
maintainerPATCH 259/372 i3c: master: svc: fix wrong data return when IBI happen during start frame
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 5e5e3c92e748a6d859190e123b9193cf4911fcca upstream.
┌─────┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┌─────
SCL: ┘ └─────┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┘
───┐ ┌─────┐ ┌─────┐ ┌───────────┐
SDA: └───────────────────────┘ └─────┘ └─────┘ └─────
xxx╱ ╲╱ ╲╱ ╲╱ ╲╱ ╲
: xxx╲IBI ╱╲ Addr(0x0a) ╱╲ RW ╱╲NACK╱╲ S ╱If an In-Band Interrupt (IBI) occurs and IBI work thread is not immediately scheduled, when svc_i3c_master_priv_xfers() initiates the I3C transfer and attempts to send address 0x7e, the target interprets it as an IBI handler and returns the target address 0x0a.
However, svc_i3c_master_priv_xfers() does not handle this case and proceeds with other transfers, resulting in incorrect data being returned.
Add IBIWON check in svc_i3c_master_xfer(). In case this situation occurs, return a failure to the driver.
--- drivers/i3c/master/svc-i3c-master.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/i3c/master/svc-i3c-master.c +20 -0
@@ -1003,6 +1003,9 @@ static int svc_i3c_master_xfer(struct svu32 reg;int ret; +/* clean SVC_I3C_MINT_IBIWON w1c bits */ +writel (SVC_I3C_MINT_IBIWON , master->regs +SVC_I3C_MSTATUS ); + writel(SVC_I3C_MCTRL_REQUEST_START_ADDR | xfer_type | SVC_I3C_MCTRL_IBIRESP_NACK |
@@ -1023,6 +1026,23 @@ static int svc_i3c_master_xfer(struct svif (ret <0 ) goto emit_stop; +/* +* According to I3C spec ver 1.1.1, 5.1.2.2.3 Consequence of Controller Starting a Frame +* with I3C Target Address. +* +* The I3C Controller normally should start a Frame, the Address may be arbitrated, and so +* the Controller shall monitor to see whether an In-Band Interrupt request, a Controller +* Role Request (i.e., Secondary Controller requests to become the Active Controller), or +* a Hot-Join Request has been made. +* +* If missed IBIWON check, the wrong data will be return. When IBIWON happen, return failure +* and yield the above events handler. +*/ +if (SVC_I3C_MSTATUS_IBIWON (reg)) { + ret = -ENXIO ; + goto emit_stop; + } +if (rnw) *read_len = ret;
Greg Kroah-Hartman
maintainerPATCH 260/372 i3c: master: svc: fix ibi may not return mandatory data byte
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit c85e209b799f12d18a90ae6353b997b1bb1274a5 upstream.
MSTATUS[RXPEND] is only updated after the data transfer cycle started. This creates an issue when the I3C clock is slow, and the CPU is running fast enough that MSTATUS[RXPEND] may not be updated when the code reaches checking point. As a result, mandatory data can be missed.
Add a wait for MSTATUS[COMPLETE] to ensure that all mandatory data is already in FIFO. It also works without mandatory data.
--- drivers/i3c/master/svc-i3c-master.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/i3c/master/svc-i3c-master.c +8 -0
@@ -325,6 +325,7 @@ static int svc_i3c_master_handle_ibi(strstruct i3c_ibi_slot *slot;unsigned int count;u32 mdatactrl; +int ret, val;u8 *buf; slot =i3c_generic_ibi_get_free_slot (data->ibi_pool);
@@ -334,6 +335,13 @@ static int svc_i3c_master_handle_ibi(str slot->len =0 ; buf = slot->data; + ret =readl_relaxed_poll_timeout (master->regs +SVC_I3C_MSTATUS , val, +SVC_I3C_MSTATUS_COMPLETE (val),0 ,1000 ); +if (ret) { +dev_err (master->dev,"Timeout when polling for COMPLETE\n" ); +return ret; + } +while (SVC_I3C_MSTATUS_RXPEND (readl (master->regs +SVC_I3C_MSTATUS )) && slot->len <SVC_I3C_FIFO_SIZE ) { mdatactrl =readl (master->regs +SVC_I3C_MDATACTRL );
Greg Kroah-Hartman
maintainerPATCH 261/372 i3c: master: svc: fix check wrong status register in irq handler
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 225d5ef048c4ed01a475c95d94833bd7dd61072d upstream.
svc_i3c_master_irq_handler() wrongly checks register SVC_I3C_MINTMASKED. It should be SVC_I3C_MSTATUS.
--- drivers/i3c/master/svc-i3c-master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/svc-i3c-master.c +1 -1
@@ -469,7 +469,7 @@ reenable_ibis:static irqreturn_t svc_i3c_master_irq_handler (int irq,void *dev_id) {struct svc_i3c_master *master = (struct svc_i3c_master *)dev_id; -u32 active =readl (master->regs +SVC_I3C_MINTMASKED ); +u32 active =readl (master->regs +SVC_I3C_MSTATUS );if (!SVC_I3C_MSTATUS_SLVSTART (active))return IRQ_NONE ;
Greg Kroah-Hartman
maintainerPATCH 262/372 i3c: master: svc: fix SDA keep low when polling IBIWON timeout happen
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit dfd7cd6aafdb1f5ba93828e97e56b38304b23a05 upstream.
Upon IBIWON timeout, the SDA line will always be kept low if we don't emit a stop. Calling svc_i3c_master_emit_stop() there will let the bus return to idle state.
--- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -0
@@ -397,6 +397,7 @@ static void svc_i3c_master_ibi_work(stru SVC_I3C_MSTATUS_IBIWON(val), 0, 1000);if (ret) {dev_err (master->dev,"Timeout when polling for IBIWON\n" ); +svc_i3c_master_emit_stop (master); goto reenable_ibis; }
Greg Kroah-Hartman
maintainerPATCH 263/372 parisc: Prevent booting 64-bit kernels on PA1.x machines
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit a406b8b424fa01f244c1aab02ba186258448c36b upstream.
Bail out early with error message when trying to boot a 64-bit kernel on 32-bit machines. This fixes the previous commit to include the check for true 64-bit kernels as well.
--- arch/parisc/kernel/head.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/parisc/kernel/head.S +2 -3
@@ -70,9 +70,8 @@ $bss_loop: stw,ma %arg2,4(%r1) stw,ma %arg3,4(%r1) -#if !defined(CONFIG_64BIT) && defined(CONFIG_PA20) - /* This 32-bit kernel was compiled for PA2.0 CPUs. Check current CPU - * and halt kernel if we detect a PA1.x CPU. */ +#if defined(CONFIG_PA20) + /* check for 64-bit capable CPU as required by current kernel */ ldi 32,%r10 mtctl %r10,%cr11 .level 2.0
Greg Kroah-Hartman
maintainerPATCH 264/372 parisc/pgtable: Do not drop upper 5 address bits of physical address
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 166b0110d1ee53290bd11618df6e3991c117495a upstream.
When calculating the pfn for the iitlbt/idtlbt instruction, do not drop the upper 5 address bits. This doesn't seem to have an effect on physical hardware which uses less physical address bits, but in qemu the missing bits are visible.
--- arch/parisc/kernel/entry.S | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/parisc/kernel/entry.S +3 -4
@@ -462,13 +462,13 @@ * to a CPU TLB 4k PFN (4k => 12 bits to shift) */ #define PAGE_ADD_SHIFT (PAGE_SHIFT-12) #define PAGE_ADD_HUGE_SHIFT (REAL_HPAGE_SHIFT-12) + #define PFN_START_BIT (63-ASM_PFN_PTE_SHIFT+(63-58)-PAGE_ADD_SHIFT) /* Drop prot bits and convert to page addr for iitlbt and idtlbt */ .macro convert_for_tlb_insert20 pte,tmp #ifdef CONFIG_HUGETLB_PAGE copy \pte,\tmp - extrd,u \tmp,(63-ASM_PFN_PTE_SHIFT)+(63-58)+PAGE_ADD_SHIFT,\ - 64-PAGE_SHIFT-PAGE_ADD_SHIFT,\pte + extrd,u \tmp,PFN_START_BIT,PFN_START_BIT+1,\pte depdi _PAGE_SIZE_ENCODING_DEFAULT,63,\ (63-58)+PAGE_ADD_SHIFT,\pte
@@ -476,8 +476,7 @@ depdi _HUGE_PAGE_SIZE_ENCODING_DEFAULT,63,\ (63-58)+PAGE_ADD_HUGE_SHIFT,\pte #else /* Huge pages disabled */ - extrd,u \pte,(63-ASM_PFN_PTE_SHIFT)+(63-58)+PAGE_ADD_SHIFT,\ - 64-PAGE_SHIFT-PAGE_ADD_SHIFT,\pte + extrd,u \pte,PFN_START_BIT,PFN_START_BIT+1,\pte depdi _PAGE_SIZE_ENCODING_DEFAULT,63,\ (63-58)+PAGE_ADD_SHIFT,\pte #endif
Greg Kroah-Hartman
maintainerPATCH 265/372 parisc/power: Fix power soft-off when running on qemu
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 6ad6e15a9c46b8f0932cd99724f26f3db4db1cdf upstream.
Firmware returns the physical address of the power switch, so need to use gsc_writel() instead of direct memory access.
--- drivers/parisc/power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/parisc/power.c +1 -1
@@ -201,7 +201,7 @@ static struct notifier_block parisc_panistatic int qemu_power_off (struct sys_off_data *data) {/* this turns the system off via SeaBIOS */ - *(int *)data->cb_data =0 ; +gsc_writel (0 , (unsigned long ) data->cb_data);pdc_soft_power_button (1 );return NOTIFY_DONE ; }
Greg Kroah-Hartman
maintainerPATCH 266/372 xhci: Enable RPM on controllers that support low-power states
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Basavaraj Natikar <[email protected]>
commit a5d6264b638efeca35eff72177fd28d149e0764b upstream.
Use the low-power states of the underlying platform to enable runtime PM. If the platform doesn't support runtime D3, then enabling default RPM will result in the controller malfunctioning, as in the case of hotplug devices not being detected because of a failed interrupt generation.
--- drivers/usb/host/xhci-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +3 -1
@@ -508,7 +508,9 @@ static int xhci_pci_probe(struct pci_dev/* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */ pm_runtime_put_noidle (&dev->dev); -if (xhci->quirks &XHCI_DEFAULT_PM_RUNTIME_ALLOW ) +if (pci_choose_state (dev,PMSG_SUSPEND ) ==PCI_D0 ) +pm_runtime_forbid (&dev->dev); +else if (xhci->quirks &XHCI_DEFAULT_PM_RUNTIME_ALLOW )pm_runtime_allow (&dev->dev);dma_set_max_seg_size (&dev->dev,UINT_MAX );
Greg Kroah-Hartman
maintainerPATCH 267/372 fs: add ctime accessors infrastructure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
commit 9b6304c1d53745c300b86f202d0dcff395e2d2db upstream.
struct timespec64 has unused bits in the tv_nsec field that can be used for other purposes. In future patches, we're going to change how the inode->i_ctime is accessed in certain inodes in order to make use of them. In order to do that safely though, we'll need to eradicate raw accesses of the inode->i_ctime field from the kernel.
Add new accessor functions for the ctime that we use to replace them.
Message-Id: <[email protected]>
--- fs/inode.c | 16 ++++++++++++++++ include/linux/fs.h | 45 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)
fs/inode.c +16 -0
@@ -2502,6 +2502,22 @@ struct timespec64 current_time(struct inEXPORT_SYMBOL (current_time);/** +* inode_set_ctime_current - set the ctime to current_time +* @inode: inode +* +* Set the inode->i_ctime to the current value for the inode. Returns +* the current value that was assigned to i_ctime. +*/ +struct timespec64 inode_set_ctime_current (struct inode *inode) +{ +struct timespec64 now =current_time (inode); + +inode_set_ctime (inode, now.tv_sec, now.tv_nsec); +return now; +} +EXPORT_SYMBOL (inode_set_ctime_current); + +/** * in_group_or_capable - check whether caller is CAP_FSETID privileged * @mnt_userns: user namespace of the mount @inode was found from * @inode: inode to check
include/linux/fs.h +44 -1
51 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 268/372 smb3: fix creating FIFOs when mounting with "sfu" mount option
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 72bc63f5e23a38b65ff2a201bdc11401d4223fa9 upstream.
Fixes some xfstests including generic/564 and generic/157
The "sfu" mount option can be useful for creating special files (character and block devices in particular) but could not create FIFOs. It did recognize existing empty files with the "system" attribute flag as FIFOs but this is too general, so to support creating FIFOs more safely use a new tag (but the same length as those for char and block devices ie "IntxLNK" and "IntxBLK") "LnxFIFO" to indicate that the file should be treated as a
FIFO (when mounted with the "sfu"). For some additional context note that
"sfu" followed the way that "Services for Unix" on Windows handled these special files (at least for character and block devices and symlinks), which is different than newer Windows which can handle special files as reparse points (which isn't an option to many servers).
--- fs/smb/client/cifspdu.h | 2 +- fs/smb/client/inode.c | 4 ++++ fs/smb/client/smb2ops.c | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-)
fs/smb/client/cifspdu.h +1 -1
@@ -2570,7 +2570,7 @@ typedef struct {struct win_dev { -unsigned char type[8 ];/* IntxCHR or IntxBLK */ +unsigned char type[8 ];/* IntxCHR or IntxBLK or LnxFIFO*/ __le64 major;__le64 minor; } __attribute__((packed));
fs/smb/client/inode.c +4 -0
@@ -567,6 +567,10 @@ cifs_sfu_type(struct cifs_fattr *fattr,cifs_dbg (FYI ,"Symlink\n" ); fattr->cf_mode |=S_IFLNK ; fattr->cf_dtype =DT_LNK ; + }else if (memcmp ("LnxFIFO" , pbuf,8 ) ==0 ) { +cifs_dbg (FYI ,"FIFO\n" ); + fattr->cf_mode |=S_IFIFO ; + fattr->cf_dtype =DT_FIFO ; }else { fattr->cf_mode |=S_IFREG ;/* file? */ fattr->cf_dtype =DT_REG ;
fs/smb/client/smb2ops.c +7 -1
@@ -5215,7 +5215,7 @@ smb2_make_node(unsigned int xid, struct* over SMB2/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions */ -if (!S_ISCHR (mode) && !S_ISBLK (mode)) +if (!S_ISCHR (mode) && !S_ISBLK (mode) && !S_ISFIFO (mode))return rc;cifs_dbg (FYI ,"sfu compat create special file\n" );
@@ -5263,6 +5263,12 @@ smb2_make_node(unsigned int xid, struct pdev->minor =cpu_to_le64 (MINOR (dev)); rc = tcon->ses->server->ops->sync_write (xid, &fid, &io_parms, &bytes_written, iov,1 ); + }else if (S_ISFIFO (mode)) { +memcpy (pdev->type,"LnxFIFO" ,8 ); + pdev->major =0 ; + pdev->minor =0 ; + rc = tcon->ses->server->ops->sync_write (xid, &fid, &io_parms, + &bytes_written, iov,1 ); } tcon->ses->server->ops->close (xid, tcon, &fid);d_drop (dentry);
Greg Kroah-Hartman
maintainerPATCH 269/372 smb3: fix touch -h of symlink
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 475efd9808a3094944a56240b2711349e433fb66 upstream.
For example:
touch -h -t 02011200 testfile
where testfile is a symlink would not change the timestamp, but
touch -t 02011200 testfiledoes work to change the timestamp of the target
--- fs/smb/client/cifsfs.c | 1 + 1 file changed, 1 insertion(+)
fs/smb/client/cifsfs.c +1 -0
@@ -1186,6 +1186,7 @@ const char *cifs_get_link(struct dentryconst struct inode_operations cifs_symlink_inode_ops = { .get_link = cifs_get_link, + .setattr = cifs_setattr, .permission = cifs_permission, .listxattr = cifs_listxattr, };
Greg Kroah-Hartman
maintainerPATCH 270/372 smb3: fix caching of ctime on setxattr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 5923d6686a100c2b4cabd4c2ca9d5a12579c7614 upstream.
Fixes xfstest generic/728 which had been failing due to incorrect ctime after setxattr and removexattr
Update ctime on successful set of xattr
--- fs/smb/client/xattr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/smb/client/xattr.c +4 -1
@@ -150,10 +150,13 @@ static int cifs_xattr_set(const struct xif (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR ) goto out; -if (pTcon->ses->server->ops->set_EA) +if (pTcon->ses->server->ops->set_EA) { rc = pTcon->ses->server->ops->set_EA (xid, pTcon, full_path, name, value, (__u16 )size, cifs_sb->local_nls, cifs_sb); +if (rc ==0 ) +inode_set_ctime_current (inode); + }break ;case XATTR_CIFS_ACL :
Greg Kroah-Hartman
maintainerPATCH 271/372 smb: client: fix use-after-free bug in cifs_debug_data_proc_show()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit d328c09ee9f15ee5a26431f5aad7c9239fa85e62 upstream.
Skip SMB sessions that are being teared down
(e.g. @ses->ses_status == SES_EXITING) in cifs_debug_data_proc_show() to avoid use-after-free in @ses.
This fixes the following GPF when reading from /proc/fs/cifs/DebugData while mounting and umounting
[ 816.251274] general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6d81: 0000 [#1] PREEMPT SMP NOPTI ... [ 816.260138] Call Trace: [ 816.260329] <TASK> [ 816.260499] ? die_addr+0x36/0x90 [ 816.260762] ? exc_general_protection+0x1b3/0x410 [ 816.261126] ? asm_exc_general_protection+0x26/0x30 [ 816.261502] ? cifs_debug_tcon+0xbd/0x240 [cifs] [ 816.261878] ? cifs_debug_tcon+0xab/0x240 [cifs] [ 816.262249] cifs_debug_data_proc_show+0x516/0xdb0 [cifs] [ 816.262689] ? seq_read_iter+0x379/0x470 [ 816.262995] seq_read_iter+0x118/0x470 [ 816.263291] proc_reg_read_iter+0x53/0x90 [ 816.263596] ? srso_alias_return_thunk+0x5/0x7f [ 816.263945] vfs_read+0x201/0x350 [ 816.264211] ksys_read+0x75/0x100 [ 816.264472] do_syscall_64+0x3f/0x90 [ 816.264750] entry_SYSCALL_64_after_hwframe+0x6e/0xd8 [ 816.265135] RIP: 0033:0x7fd5e669d381
--- fs/smb/client/cifs_debug.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/smb/client/cifs_debug.c +6 -0
@@ -380,6 +380,11 @@ skip_rdma:seq_printf (m,"\n\n\tSessions: " ); i =0 ;list_for_each_entry (ses, &server->smb_ses_list, smb_ses_list) { +spin_lock (&ses->ses_lock); +if (ses->ses_status ==SES_EXITING ) { +spin_unlock (&ses->ses_lock); +continue ; + } i++; if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
@@ -400,6 +405,7 @@ skip_rdma: ses->ses_count, ses->serverOS, ses->serverNOS, ses->capabilities, ses->ses_status); } +spin_unlock (&ses->ses_lock);seq_printf (m,"\n\tSecurity type: %s " ,get_security_type_str (server->ops->select_sectype (server, ses->sectype)));
Greg Kroah-Hartman
maintainerPATCH 272/372 smb: client: fix potential deadlock when releasing mids
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit e6322fd177c6885a21dd4609dc5e5c973d1a2eb7 upstream.
All release_mid() callers seem to hold a reference of @mid so there is no need to call kref_put(&mid->refcount, __release_mid) under @server->mid_lock spinlock. If they don't, then an use-after-free bug would have occurred anyways.
By getting rid of such spinlock also fixes a potential deadlock as shown below
CPU 0 CPU 1
------------------------------------------------------------------cifs_demultiplex_thread() cifs_debug_data_proc_show()
release_mid()
spin_lock(&server->mid_lock);
spin_lock(&cifs_tcp_ses_lock)
spin_lock(&server->mid_lock) __release_mid()
smb2_find_smb_tcon()
spin_lock(&cifs_tcp_ses_lock) *deadlock*
--- fs/smb/client/cifsproto.h | 7 ++++++- fs/smb/client/smb2misc.c | 2 +- fs/smb/client/transport.c | 11 +---------- 3 files changed, 8 insertions(+), 12 deletions(-)
fs/smb/client/cifsproto.h +6 -1
@@ -79,7 +79,7 @@ extern char *cifs_compose_mount_options( const char *fullpath, const struct dfs_info3_param *ref, char **devname);extern void delete_mid (struct mid_q_entry *mid); -extern void release_mid (struct mid_q_entry *mid); +void __release_mid (struct kref *refcount);extern void cifs_wake_up_task (struct mid_q_entry *mid);extern int cifs_handle_standard (struct TCP_Server_Info *server,struct mid_q_entry *mid);
@@ -694,4 +694,9 @@ struct super_block *cifs_get_tcon_super(void cifs_put_tcon_super (struct super_block *sb);int cifs_wait_for_server_reconnect (struct TCP_Server_Info *server,bool retry); +static inline void release_mid (struct mid_q_entry *mid) +{ +kref_put (&mid->refcount, __release_mid); +} +#endif /* _CIFSPROTO_H */
fs/smb/client/smb2misc.c +1 -1
@@ -787,7 +787,7 @@ __smb2_handle_cancelled_cmd(struct cifs_ {struct close_cancelled_open *cancelled; - cancelled =kzalloc (sizeof (*cancelled),GFP_ATOMIC ); + cancelled =kzalloc (sizeof (*cancelled),GFP_KERNEL );if (!cancelled)return -ENOMEM ;
fs/smb/client/transport.c +1 -10
@@ -76,7 +76,7 @@ alloc_mid(const struct smb_hdr *smb_buffreturn temp; } -static void __release_mid (struct kref *refcount) +void __release_mid (struct kref *refcount) {struct mid_q_entry *midEntry = container_of(refcount, struct mid_q_entry, refcount);
@@ -156,15 +156,6 @@ static void __release_mid(struct kref *rmempool_free (midEntry, cifs_mid_poolp); } -void release_mid (struct mid_q_entry *mid) -{ -struct TCP_Server_Info *server = mid->server; - -spin_lock (&server->mid_lock); -kref_put (&mid->refcount, __release_mid); -spin_unlock (&server->mid_lock); -} -void delete_mid (struct mid_q_entry *mid) {
Greg Kroah-Hartman
maintainerPATCH 273/372 cifs: reconnect helper should set reconnect for the right channel
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit c3326a61cdbf3ce1273d9198b6cbf90965d7e029 upstream.
We introduced a helper function to be used by non-cifsd threads to mark the connection for reconnect. For multichannel, when only a particular channel needs to be reconnected, this had a bug.
This change fixes that by marking that particular channel for reconnect.
--- fs/smb/client/connect.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/smb/client/connect.c +5 -4
@@ -205,13 +205,14 @@ cifs_signal_cifsd_for_reconnect(struct T/* If server is a channel, select the primary channel */ pserver =CIFS_SERVER_IS_CHAN (server) ? server->primary_server : server; -spin_lock (&pserver->srv_lock); +/* if we need to signal just this channel */ if (!all_channels) { - pserver->tcpStatus = CifsNeedReconnect; -spin_unlock (&pserver->srv_lock); +spin_lock (&server->srv_lock); +if (server->tcpStatus != CifsExiting) + server->tcpStatus = CifsNeedReconnect; +spin_unlock (&server->srv_lock);return ; } -spin_unlock (&pserver->srv_lock);spin_lock (&cifs_tcp_ses_lock);list_for_each_entry (ses, &pserver->smb_ses_list, smb_ses_list) {
Greg Kroah-Hartman
maintainerPATCH 274/372 cifs: force interface update before a fresh session setup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit d9a6d78096056a3cb5c5f07a730ab92f2f9ac4e6 upstream.
During a session reconnect, it is possible that the server moved to another physical server (happens in case of Azure files). So at this time, force a query of server interfaces again (in case of multichannel session), such that the secondary channels connect to the right IP addresses (possibly updated now).
--- fs/smb/client/connect.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/smb/client/connect.c +5 -1
@@ -4205,8 +4205,12 @@ cifs_setup_session(const unsigned int xi is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT (ses);spin_unlock (&ses->chan_lock); -if (!is_binding) +if (!is_binding) { ses->ses_status =SES_IN_SETUP ; + +/* force iface_list refresh */ + ses->iface_last_update =0 ; + }spin_unlock (&ses->ses_lock);/* update ses ip_addr only for primary chan */
Greg Kroah-Hartman
maintainerPATCH 275/372 cifs: do not reset chan_max if multichannel is not supported at mount
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit 6e5e64c9477d58e73cb1a0e83eacad1f8df247cf upstream.
If the mount command has specified multichannel as a mount option, but multichannel is found to be unsupported by the server at the time of mount, we set chan_max to 1. Which means that the user needs to remount the share if the server starts supporting multichannel.
This change removes this reset. What it means is that if the user specified multichannel or max_channels during mount, and at this time, multichannel is not supported, but the server starts supporting it at a later point, the client will be capable of scaling out the number of channels.
--- fs/smb/client/sess.c | 1 - 1 file changed, 1 deletion(-)
fs/smb/client/sess.c +0 -1
@@ -186,7 +186,6 @@ int cifs_try_adding_channels(struct cifs }if (!(server->capabilities &SMB2_GLOBAL_CAP_MULTI_CHANNEL )) { - ses->chan_max =1 ;spin_unlock (&ses->chan_lock);cifs_server_dbg (VFS ,"no multichannel support\n" );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 276/372 xfs: recovery should not clear di_flushiter unconditionally
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit 7930d9e103700cde15833638855b750715c12091 upstream.
Because on v3 inodes, di_flushiter doesn't exist. It overlaps with zero padding in the inode, except when NREXT64=1 configurations are in use and the zero padding is no longer padding but holds the 64 bit extent counter.
This manifests obviously on big endian platforms (e.g. s390) because the log dinode is in host order and the overlap is the LSBs of the extent count field. It is not noticed on little endian machines because the overlap is at the MSB end of the extent count field and we need to get more than 2^^48 extents in the inode before it manifests. i.e. the heat death of the universe will occur before we see the problem in little endian machines.
This is a zero-day issue for NREXT64=1 configuraitons on big endian machines. Fix it by only clearing di_flushiter on v2 inodes during recovery.
--- fs/xfs/xfs_inode_item_recover.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
fs/xfs/xfs_inode_item_recover.c +17 -15
@@ -369,24 +369,26 @@ xlog_recover_inode_commit_pass2(* superblock flag to determine whether we need to look at di_flushiter * to skip replay when the on disk inode is newer than the log one */ -if (!xfs_has_v3inodes (mp) && - ldip->di_flushiter <be16_to_cpu (dip->di_flushiter)) { -/* -* Deal with the wrap case, DI_MAX_FLUSH is less -* than smaller numbers -*/ -if (be16_to_cpu (dip->di_flushiter) ==DI_MAX_FLUSH && - ldip->di_flushiter < (DI_MAX_FLUSH >>1 )) { -/* do nothing */ - }else { -trace_xfs_log_recover_inode_skip (log, in_f); - error =0 ; - goto out_release; +if (!xfs_has_v3inodes (mp)) { +if (ldip->di_flushiter <be16_to_cpu (dip->di_flushiter)) { +/* +* Deal with the wrap case, DI_MAX_FLUSH is less +* than smaller numbers +*/ +if (be16_to_cpu (dip->di_flushiter) ==DI_MAX_FLUSH && + ldip->di_flushiter < (DI_MAX_FLUSH >>1 )) { +/* do nothing */ + }else { +trace_xfs_log_recover_inode_skip (log, in_f); + error =0 ; + goto out_release; + } } + +/* Take the opportunity to reset the flush iteration count */ + ldip->di_flushiter =0 ; } -/* Take the opportunity to reset the flush iteration count */ - ldip->di_flushiter =0 ;if (unlikely (S_ISREG (ldip->di_mode))) { if ((ldip->di_format != XFS_DINODE_FMT_EXTENTS) &&
Greg Kroah-Hartman
maintainerPATCH 277/372 btrfs: zoned: wait for data BG to be finished on direct IO allocation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naohiro Aota <[email protected]>
commit 776a838f1fa95670c1c1cf7109a898090b473fa3 upstream.
Running the fio command below on a ZNS device results in "Resource temporarily unavailable" error.
$ sudo fio --name=w --directory=/mnt --filesize=1GB --bs=16MB --numjobs=16 \
--rw=write --ioengine=libaio --iodepth=128 --direct=1 fio: io_u error on file /mnt/w.2.0: Resource temporarily unavailable: write offset=117440512, buflen=16777216
fio: io_u error on file /mnt/w.2.0: Resource temporarily unavailable: write offset=134217728, buflen=16777216
...
This happens because -EAGAIN error returned from btrfs_reserve_extent() called from btrfs_new_extent_direct() is spilling over to the userland.
btrfs_reserve_extent() returns -EAGAIN when there is no active zone available. Then, the caller should wait for some other on-going IO to finish a zone and retry the allocation.
This logic is already implemented for buffered write in cow_file_range(), but it is missing for the direct IO counterpart. Implement the same logic for it.
--- fs/btrfs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/btrfs/inode.c +7 -0
@@ -7166,8 +7166,15 @@ static struct extent_map *btrfs_new_exteint ret; alloc_hint =get_extent_allocation_hint (inode, start, len); +again: ret =btrfs_reserve_extent (root, len, len, fs_info->sectorsize,0 , alloc_hint, &ins,1 ,1 ); +if (ret == -EAGAIN ) { +ASSERT (btrfs_is_zoned (fs_info)); +wait_on_bit_io (&inode->root->fs_info->flags,BTRFS_FS_NEED_ZONE_FINISH , +TASK_UNINTERRUPTIBLE ); + goto again; + }if (ret)return ERR_PTR (ret);
Greg Kroah-Hartman
maintainerPATCH 278/372 ALSA: info: Fix potential deadlock at disconnection
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit c7a60651953359f98dbf24b43e1bf561e1573ed4 upstream.
As reported recently, ALSA core info helper may cause a deadlock at the forced device disconnection during the procfs operation.
The proc_remove() (that is called from the snd_card_disconnect() helper) has a synchronization of the pending procfs accesses via wait_for_completion(). Meanwhile, ALSA procfs helper takes the global mutex_lock(&info_mutex) at both the proc_open callback and snd_card_info_disconnect() helper. Since the proc_open can't finish due to the mutex lock, wait_for_completion() never returns, either, hence it deadlocks.
TASK#1 TASK#2 proc_reg_open() takes use_pde() snd_info_text_entry_open() snd_card_disconnect() snd_info_card_disconnect() takes mutex_lock(&info_mutex) proc_remove() wait_for_completion(unused_pde) ... waiting task#1 closes mutex_lock(&info_mutex) => DEADLOCK
This patch is a workaround for avoiding the deadlock scenario above.
The basic strategy is to move proc_remove() call outside the mutex lock. proc_remove() can work gracefully without extra locking, and it can delete the tree recursively alone. So, we call proc_remove() at snd_info_card_disconnection() at first, then delete the rest resources recursively within the info_mutex lock.
After the change, the function snd_info_disconnect() doesn't do disconnection by itself any longer, but it merely clears the procfs pointer. So rename the function to snd_info_clear_entries() for avoiding confusion.
The similar change is applied to snd_info_free_entry(), too. Since the proc_remove() is called only conditionally with the non-NULL entry->p, it's skipped after the snd_info_clear_entries() call.
--- sound/core/info.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
sound/core/info.c +13 -8
@@ -56,7 +56,7 @@ struct snd_info_private_data { };static int snd_info_version_init (void ); -static void snd_info_disconnect (struct snd_info_entry *entry); +static void snd_info_clear_entries (struct snd_info_entry *entry);/*
@@ -569,11 +569,16 @@ void snd_info_card_disconnect(struct snd {if (!card)return ; -mutex_lock (&info_mutex); +proc_remove (card->proc_root_link); - card->proc_root_link =NULL ;if (card->proc_root) -snd_info_disconnect (card->proc_root); +proc_remove (card->proc_root->p); + +mutex_lock (&info_mutex); +if (card->proc_root) +snd_info_clear_entries (card->proc_root); + card->proc_root_link =NULL ; + card->proc_root =NULL ;mutex_unlock (&info_mutex); }
@@ -745,15 +750,14 @@ struct snd_info_entry *snd_info_create_c }EXPORT_SYMBOL (snd_info_create_card_entry); -static void snd_info_disconnect (struct snd_info_entry *entry) +static void snd_info_clear_entries (struct snd_info_entry *entry) {struct snd_info_entry *p;if (!entry->p)return ;list_for_each_entry (p, &entry->children, list) -snd_info_disconnect (p); -proc_remove (entry->p); +snd_info_clear_entries (p); entry->p =NULL ; }
@@ -770,8 +774,9 @@ void snd_info_free_entry(struct snd_infoif (!entry)return ;if (entry->p) { +proc_remove (entry->p);mutex_lock (&info_mutex); -snd_info_disconnect (entry); +snd_info_clear_entries (entry);mutex_unlock (&info_mutex); }
Greg Kroah-Hartman
maintainerPATCH 279/372 ALSA: hda/realtek: Enable Mute LED on HP 255 G8
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eymen Yigit <[email protected]>
commit 8384c0baf223e1c3bc7b1c711d80a4c6106d210e upstream.
This HP Notebook uses ALC236 codec with COEF 0x07 idx 1 controlling the mute LED. Enable already existing quirk for this device.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9624,6 +9624,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8898 ,"HP EliteBook 845 G8 Notebook PC" ,ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x103c ,0x88d0 ,"HP Pavilion 15-eh1xxx (mainboard 88D0)" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8902 ,"HP OMEN 16" ,ALC285_FIXUP_HP_MUTE_LED ), +SND_PCI_QUIRK (0x103c ,0x890e ,"HP 255 G8 Notebook PC" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x8919 ,"HP Pavilion Aero Laptop 13-be0xxx" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x896d ,"HP ZBook Firefly 16 G9" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), SND_PCI_QUIRK(0x103c, 0x896e, "HP EliteBook x360 830 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
Greg Kroah-Hartman
maintainerPATCH 280/372 ALSA: hda/realtek - Add Dell ALC295 to pin fall back table
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit 4b21a669ca21ed8f24ef4530b2918be5730114de upstream.
Add ALC295 to pin fall back table.
Remove 5 pin quirks for Dell ALC295.
ALC295 was only support MIC2 for external MIC function. ALC295 assigned model "ALC269_FIXUP_DELL1_MIC_NO_PRESENCE" for pin fall back table.
It was assigned wrong model. So, let's remove it.
--- sound/pci/hda/patch_realtek.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
sound/pci/hda/patch_realtek.c +3 -16
@@ -10592,22 +10592,6 @@ static const struct snd_hda_pin_quirk al {0x12, 0x90a60130}, {0x17, 0x90170110}, {0x21, 0x03211020}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , - {0x14, 0x90170110}, - {0x21, 0x04211020}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , - {0x14, 0x90170110}, - {0x21, 0x04211030}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , -ALC295_STANDARD_PINS , - {0x17, 0x21014020}, - {0x18, 0x21a19030}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , -ALC295_STANDARD_PINS , - {0x17, 0x21014040}, - {0x18, 0x21a19050}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , -ALC295_STANDARD_PINS ),SND_HDA_PIN_QUIRK (0x10ec0298 ,0x1028 ,"Dell" ,ALC298_FIXUP_DELL1_MIC_NO_PRESENCE ,ALC298_STANDARD_PINS , {0x17, 0x90170110}),
@@ -10651,6 +10635,9 @@ static const struct snd_hda_pin_quirk alSND_HDA_PIN_QUIRK (0x10ec0289 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , {0x19, 0x40000000}, {0x1b, 0x40000000}), +SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , + {0x19, 0x40000000}, + {0x1b, 0x40000000}),SND_HDA_PIN_QUIRK (0x10ec0256 ,0x1028 ,"Dell" ,ALC255_FIXUP_DELL1_MIC_NO_PRESENCE , {0x19, 0x40000000}, {0x1a, 0x40000000}),
Greg Kroah-Hartman
maintainerPATCH 281/372 ALSA: hda/realtek - Enable internal speaker of ASUS K6500ZC
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandradeep Dey <[email protected]>
commit 713f040cd22285fcc506f40a0d259566e6758c3c upstream.
Apply the already existing quirk chain ALC294_FIXUP_ASUS_SPK to enable the internal speaker of ASUS K6500ZC.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9699,6 +9699,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1043 ,0x10a1 ,"ASUS UX391UA" ,ALC294_FIXUP_ASUS_SPK ),SND_PCI_QUIRK (0x1043 ,0x10c0 ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x10d0 ,"ASUS X540LA/X540LJ" ,ALC255_FIXUP_ASUS_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x1043 ,0x10d3 ,"ASUS K6500ZC" ,ALC294_FIXUP_ASUS_SPK ),SND_PCI_QUIRK (0x1043 ,0x115d ,"Asus 1015E" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x1043 ,0x11c0 ,"ASUS X556UR" ,ALC255_FIXUP_ASUS_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
Greg Kroah-Hartman
maintainerPATCH 282/372 ALSA: hda/realtek: Enable Mute LED on HP 255 G10
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matus Malych <[email protected]>
commit b944aa9d86d5f782bfe5e51336434c960304839c upstream.
HP 255 G10 has a mute LED that can be made to work using quirk ALC236_FIXUP_HP_MUTE_LED_COEFBIT2.
Enable already existing quirk - at correct line to keep order
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9660,6 +9660,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8abb ,"HP ZBook Firefly 14 G9" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8ad1 ,"HP EliteBook 840 14 inch G9 Notebook PC" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8ad2 ,"HP EliteBook 860 16 inch G9 Notebook PC" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8b2f ,"HP 255 15.6 inch G10 Notebook PC" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x8b42 ,"HP" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8b43 ,"HP" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), SND_PCI_QUIRK(0x103c, 0x8b44, "HP", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
Greg Kroah-Hartman
maintainerPATCH 283/372 ALSA: hda/realtek: Add quirks for HP Laptops
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Binding <[email protected]>
commit 5d639b60971f003d3a9b2b31f8ec73b0718b5d57 upstream.
These HP laptops use Realtek HDA codec combined with 2 or 4 CS35L41 Amplifiers using SPI with Internal Boost.
--- sound/pci/hda/patch_realtek.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/patch_realtek.c +3 -0
@@ -9694,6 +9694,9 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8c70 ,"HP EliteBook 835 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c71 ,"HP EliteBook 845 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c72 ,"HP EliteBook 865 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8ca4 ,"HP ZBook Fury" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8ca7 ,"HP ZBook Fury" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8cf5 ,"HP ZBook Studio 16" ,ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED ),SND_PCI_QUIRK (0x1043 ,0x103e ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x103f ,"ASUS TX300" ,ALC282_FIXUP_ASUS_TX300 ), SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Greg Kroah-Hartman
maintainerPATCH 284/372 pmdomain: bcm: bcm2835-power: check if the ASB register is equal to enable
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit 2e75396f1df61e1f1d26d0d703fc7292c4ae4371 ]
The commit c494a447c14e ("soc: bcm: bcm2835-power: Refactor ASB control") refactored the ASB control by using a general function to handle both the enable and disable. But this patch introduced a subtle regression:
we need to check if !!(readl(base + reg) & ASB_ACK) == enable, not just check if (readl(base + reg) & ASB_ACK) == true.
Currently, this is causing an invalid register state in V3D when unloading and loading the driver, because bcm2835_asb_disable() will return -ETIMEDOUT and bcm2835_asb_power_off() will fail to disable the ASB slave for V3D.
--- drivers/soc/bcm/bcm2835-power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/bcm/bcm2835-power.c +1 -1
@@ -175,7 +175,7 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable }writel (PM_PASSWORD | val, base + reg); -while (readl (base + reg) &ASB_ACK ) { +while (!!(readl (base + reg) &ASB_ACK ) == enable) {cpu_relax ();if (ktime_get_ns () - start >=1000 )return -ETIMEDOUT ;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 285/372 pmdomain: imx: Make imx pgc power domain also set the fwnode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengfei Li <[email protected]>
[ Upstream commit 374de39d38f97b0e58cfee88da590b2d056ccf7f ]
Currently, The imx pgc power domain doesn't set the fwnode pointer, which results in supply regulator device can't get consumer imx pgc power domain device from fwnode when creating a link.
This causes the driver core to instead try to create a link between the parent gpc device of imx pgc power domain device and supply regulator device. However, at this point, the gpc device has already been bound, and the link creation will fail. So adding the fwnode pointer to the imx pgc power domain device will fix this issue.
--- drivers/soc/imx/gpc.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/imx/gpc.c +1 -0
@@ -498,6 +498,7 @@ static int imx_gpc_probe(struct platform_device *pdev) pd_pdev->dev.parent = &pdev->dev; pd_pdev->dev.of_node = np; + pd_pdev->dev.fwnode =of_fwnode_handle (np); ret =platform_device_add (pd_pdev);if (ret) {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 286/372 cpufreq: stats: Fix buffer overflow detection in trans_stats()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
[ Upstream commit ea167a7fc2426f7685c3735e104921c1a20a6d3f ]
Commit 3c0897c180c6 ("cpufreq: Use scnprintf() for avoiding potential buffer overflow") switched from snprintf to the more secure scnprintf but never updated the exit condition for PAGE_SIZE.
As the commit say and as scnprintf document, what scnprintf returns what is actually written not counting the '\0' end char. This results in the case of len exceeding the size, len set to PAGE_SIZE - 1, as it can be written at max PAGE_SIZE - 1 (as '\0' is not counted)
Because of len is never set to PAGE_SIZE, the function never break early, never prints the warning and never return -EFBIG.
Fix this by changing the condition to PAGE_SIZE - 1 to correctly trigger the error.
--- drivers/cpufreq/cpufreq_stats.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/cpufreq/cpufreq_stats.c +7 -7
@@ -131,25 +131,25 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) len +=scnprintf (buf + len,PAGE_SIZE - len," From : To\n" ); len +=scnprintf (buf + len,PAGE_SIZE - len," : " );for (i =0 ; i < stats->state_num; i++) { -if (len >=PAGE_SIZE ) +if (len >=PAGE_SIZE -1 )break ; len +=scnprintf (buf + len,PAGE_SIZE - len,"%9u " , stats->freq_table[i]); } -if (len >=PAGE_SIZE ) -return PAGE_SIZE ; +if (len >=PAGE_SIZE -1 ) +return PAGE_SIZE -1 ; len +=scnprintf (buf + len,PAGE_SIZE - len,"\n" );for (i =0 ; i < stats->state_num; i++) { -if (len >=PAGE_SIZE ) +if (len >=PAGE_SIZE -1 )break ; len +=scnprintf (buf + len,PAGE_SIZE - len,"%9u: " , stats->freq_table[i]);for (j =0 ; j < stats->state_num; j++) { -if (len >=PAGE_SIZE ) +if (len >=PAGE_SIZE -1 )break ;if (pending)
@@ -159,12 +159,12 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) len +=scnprintf (buf + len,PAGE_SIZE - len,"%9u " , count); } -if (len >=PAGE_SIZE ) +if (len >=PAGE_SIZE -1 )break ; len +=scnprintf (buf + len,PAGE_SIZE - len,"\n" ); } -if (len >=PAGE_SIZE ) { +if (len >=PAGE_SIZE -1 ) {pr_warn_once ("cpufreq transition table exceeds PAGE_SIZE. Disabling\n" );return -EFBIG ; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 287/372 clk: visconti: remove unused visconti_pll_provider::regmap
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dario Binacchi <[email protected]>
[ Upstream commit 7e626a080bb2db47c27c29fea569ff18afec52ed ]
Field regmap of struct visconti_pll_provider is never used. Remove it.
Stable-dep-of: 5ad1e217a2b2 ("clk: visconti: Fix undefined behavior bug in struct visconti_pll_provider")
--- drivers/clk/visconti/pll.h | 1 - 1 file changed, 1 deletion(-)
drivers/clk/visconti/pll.h +0 -1
@@ -15,7 +15,6 @@struct visconti_pll_provider {void __iomem *reg_base; -struct regmap *regmap;struct clk_hw_onecell_data clk_data;struct device_node *node; };
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 288/372 clk: visconti: Fix undefined behavior bug in struct visconti_pll_provider
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
[ Upstream commit 5ad1e217a2b23aa046b241183bd9452d259d70d0 ]
struct clk_hw_onecell_data is a flexible structure, which means that it contains flexible-array member at the bottom, in this case array hws:
include/linux/clk-provider.h:
1380 struct clk_hw_onecell_data {
1381 unsigned int num;
1382 struct clk_hw *hws[] __counted_by(num);
1383 };
This could potentially lead to an overwrite of the objects following clk_data in struct visconti_pll_provider, in this case struct device_node *node;, at run-time:
drivers/clk/visconti/pll.h:
16 struct visconti_pll_provider {
17 void __iomem *reg_base; 18 struct clk_hw_onecell_data clk_data; 19 struct device_node *node;
20 };
Notice that a total of 56 bytes are allocated for flexible-array hws at line 328. See below:
include/dt-bindings/clock/toshiba,tmpv770x.h:
14 #define TMPV770X_NR_PLL 7
drivers/clk/visconti/pll-tmpv770x.c:
69 ctx = visconti_init_pll(np, reg_base, TMPV770X_NR_PLL);
drivers/clk/visconti/pll.c:
321 struct visconti_pll_provider * __init visconti_init_pll(struct device_node *np,
322 void __iomem *base,
323 unsigned long nr_plls)
324 {
325 struct visconti_pll_provider *ctx;
...
328 ctx = kzalloc(struct_size(ctx, clk_data.hws, nr_plls), GFP_KERNEL);
struct_size(ctx, clk_data.hws, nr_plls) above translates to sizeof(struct visconti_pll_provider) + sizeof(struct clk_hw *) * 7 == 24 + 8 * 7 == 24 + 56
^^^^ | allocated bytes for flex array `hws`
$ pahole -C visconti_pll_provider drivers/clk/visconti/pll.o
struct visconti_pll_provider {
void * reg_base; /* 0 8 */
struct clk_hw_onecell_data clk_data; /* 8 8 */
struct device_node * node; /* 16 8 *//* size: 24, cachelines: 1, members: 3 */ /* last cacheline: 24 bytes */ };
And then, after the allocation, some data is written into all members of struct visconti_pll_provider:
332 for (i = 0; i < nr_plls; ++i)
333 ctx->clk_data.hws[i] = ERR_PTR(-ENOENT);
334
335 ctx->node = np; 336 ctx->reg_base = base; 337 ctx->clk_data.num = nr_plls;
Fix all these by placing the declaration of object clk_data at the end of struct visconti_pll_provider. Also, add a comment to make it clear that this object must always be last in the structure, and prevent this bug from being introduced again in the future.
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting ready to enable it globally.
--- drivers/clk/visconti/pll.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/visconti/pll.h +3 -1
@@ -15,8 +15,10 @@struct visconti_pll_provider {void __iomem *reg_base; -struct clk_hw_onecell_data clk_data;struct device_node *node; + +/* Must be last */ +struct clk_hw_onecell_data clk_data; }; #define VISCONTI_PLL_RATE(_rate, _dacen, _dsmen, \
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 289/372 Bluetooth: btusb: Add Realtek RTL8852BE support ID 0x0cb8:0xc559
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artem Lukyanov <[email protected]>
[ Upstream commit 393b4916b7b5b94faf5c6a7c68df1c62d17e4f38 ]
Add the support ID(0x0cb8, 0xc559) to usb_device_id table for Realtek RTL8852BE.
The device info from /sys/kernel/debug/usb/devices as below.
T: Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cb8 ProdID=c559 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
Stable-dep-of: da06ff1f585e ("Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE")
--- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/btusb.c +4 -0
@@ -532,6 +532,10 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x13d3, 0x3592), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + /* Realtek 8852BE Bluetooth devices */ + { USB_DEVICE(0x0cb8, 0xc559), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, + /* Realtek Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01), .driver_info = BTUSB_REALTEK },
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 290/372 bluetooth: Add device 0bda:887b to device tables
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larry Finger <[email protected]>
[ Upstream commit 730a1d1a93a3e30c3723f87af97a8517334b2203 ]
This device is part of a Realtek RTW8852BE chip.
The device table entry is as follows:
T: Bus=03 Lev=01 Prnt=01 Port=12 Cnt=02 Dev#= 3 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0bda ProdID=887b Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
Stable-dep-of: da06ff1f585e ("Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE")
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -535,6 +535,8 @@ static const struct usb_device_id blacklist_table[] = {/* Realtek 8852BE Bluetooth devices */ { USB_DEVICE(0x0cb8, 0xc559), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH },/* Realtek Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01),
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 291/372 bluetooth: Add device 13d3:3571 to device tables
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larry Finger <[email protected]>
[ Upstream commit 069f534247bb6db4f8c2c2ea8e9155abf495c37e ]
This device is part of a Realtek RTW8852BE chip. The device table is as follows:
T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3571 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
Stable-dep-of: da06ff1f585e ("Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE")
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -537,6 +537,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH },/* Realtek Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01),
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 292/372 Bluetooth: btusb: Add RTW8852BE device 13d3:3570 to device tables
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masum Reza <[email protected]>
[ Upstream commit 02be109d3a405dbc4d53fb4b4473d7a113548088 ]
This device is used in TP-Link TX20E WiFi+Bluetooth adapter.
Relevant information in /sys/kernel/debug/usb/devices about the Bluetooth device is listed as the below.
T: Bus=01 Lev=01 Prnt=01 Port=08 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3570 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
Stable-dep-of: da06ff1f585e ("Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE")
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -537,6 +537,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3570), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH },
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 293/372 Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guan Wentao <[email protected]>
[ Upstream commit da06ff1f585ea784c79f80e7fab0e0c4ebb49c1c ]
Add PID/VID 0bda:b85b for Realtek RTL8852BE USB bluetooth part. The PID/VID was reported by the patch last year. [1] Some SBCs like rockpi 5B A8 module contains the device. And it`s founded in website. [2] [3]
Here is the device tables in /sys/kernel/debug/usb/devices .
T: Bus=07 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0bda ProdID=b85b Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -537,6 +537,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0bda, 0xb85b), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3570), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK |
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 294/372 drm/amd/display: enable dsc_clk even if dsc_pg disabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Ahmed <[email protected]>
[ Upstream commit 40255df370e94d44f0f0a924400d68db0ee31bec ]
[why]
need to enable dsc_clk regardless dsc_pg
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 8 ++++---- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +4 -4
@@ -1806,7 +1806,7 @@ static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *cif (dc->hwss.subvp_pipe_control_lock) dc->hwss.subvp_pipe_control_lock (dc, context, true, true,NULL , subvp_prev_use); -if (dc->debug.enable_double_buffered_dsc_pg_support) +if (dc->hwss.update_dsc_pg) dc->hwss.update_dsc_pg (dc, context, false);disable_dangling_plane (dc, context);
@@ -1905,7 +1905,7 @@ static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *c dc->hwss.optimize_bandwidth (dc, context); } -if (dc->debug.enable_double_buffered_dsc_pg_support) +if (dc->hwss.update_dsc_pg) dc->hwss.update_dsc_pg (dc, context, true);if (dc->ctx->dce_version >=DCE_VERSION_MAX )
@@ -2193,7 +2193,7 @@ void dc_post_update_surfaces_to_stream(struct dc *dc) dc->hwss.optimize_bandwidth (dc, context); -if (dc->debug.enable_double_buffered_dsc_pg_support) +if (dc->hwss.update_dsc_pg) dc->hwss.update_dsc_pg (dc, context, true); }
@@ -3453,7 +3453,7 @@ static void commit_planes_for_stream(struct dc *dc,if (get_seamless_boot_stream_count (context) ==0 ) dc->hwss.prepare_bandwidth (dc, context); -if (dc->debug.enable_double_buffered_dsc_pg_support) +if (dc->hwss.update_dsc_pg) dc->hwss.update_dsc_pg (dc, context, false);context_clock_trace (dc, context);
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c +3 -0
@@ -79,6 +79,9 @@ void dcn32_dsc_pg_control(if (hws->ctx->dc->debug.disable_dsc_power_gate)return ; +if (!hws->ctx->dc->debug.enable_double_buffered_dsc_pg_support) +return ; +REG_GET (DC_IP_REQUEST_CNTL ,IP_REQUEST_EN , &org_ip_request_cntl);if (org_ip_request_cntl ==0 )REG_SET (DC_IP_REQUEST_CNTL ,0 ,IP_REQUEST_EN ,1 );
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 295/372 cxl/region: Validate region mode vs decoder mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
[ Upstream commit 1b9b7a6fd618239db47a83da39dff9e725a5865a ]
In preparation for a new region mode, do not, for example, allow 'ram' decoders to be assigned to 'pmem' regions and vice versa.
Stable-dep-of: 0718588c7aaa ("cxl/region: Do not try to cleanup after cxl_region_setup_targets() fails")
--- drivers/cxl/core/region.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/cxl/core/region.c +6 -0
@@ -1191,6 +1191,12 @@ static int cxl_region_attach(struct cxl_region *cxlr,struct cxl_dport *dport;int i, rc = -ENXIO ; +if (cxled->mode != cxlr->mode) { +dev_dbg (&cxlr->dev,"%s region mode: %d mismatch: %d\n" , +dev_name (&cxled->cxld.dev), cxlr->mode, cxled->mode); +return -EINVAL ; + } +if (cxled->mode ==CXL_DECODER_DEAD ) {dev_dbg (&cxlr->dev,"%s dead\n" ,dev_name (&cxled->cxld.dev));return -ENODEV ;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 296/372 cxl/region: Cleanup target list on attach error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
[ Upstream commit 86987c766276acf1289700cd38bd6d5b5a167fea ]
Jonathan noticed that the target list setup is not unwound completely upon error. Undo all the setup in the 'err_decrement:' exit path.
Stable-dep-of: 0718588c7aaa ("cxl/region: Do not try to cleanup after cxl_region_setup_targets() fails")
--- drivers/cxl/core/region.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/cxl/core/region.c +2 -0
@@ -1317,6 +1317,8 @@ static int cxl_region_attach(struct cxl_region *cxlr, err_decrement: p->nr_targets--; + cxled->pos =-1 ; + p->targets[pos] =NULL ; err:for (iter = ep_port; !is_cxl_root (iter); iter =to_cxl_port (iter->dev.parent))
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 297/372 cxl/region: Move region-position validation to a helper
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
[ Upstream commit 9995576cef48dcbb0ba3de068292ed14f72fa0eb ]
In preparation for region autodiscovery, that needs all devices discovered before their relative position in the region can be determined, consolidate all position dependent validation in a helper.
Recall that in the on-demand region creation flow the end-user picks the position of a given endpoint decoder in a region. In the autodiscovery case the position of an endpoint decoder can only be determined after all other endpoint decoders that claim to decode the region's address range have been enumerated and attached. So, in the autodiscovery case endpoint decoders may be attached before their relative position is known. Once all decoders arrive, then positions can be determined and validated with cxl_region_validate_position() the same as user initiated on-demand creation.
Stable-dep-of: 0718588c7aaa ("cxl/region: Do not try to cleanup after cxl_region_setup_targets() fails")
--- drivers/cxl/core/region.c | 119 ++++++++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 43 deletions(-)
drivers/cxl/core/region.c +76 -43
@@ -1181,35 +1181,13 @@ static int cxl_region_setup_targets(struct cxl_region *cxlr)return 0 ; } -static int cxl_region_attach (struct cxl_region *cxlr, -struct cxl_endpoint_decoder *cxled,int pos) +static int cxl_region_validate_position (struct cxl_region *cxlr, +struct cxl_endpoint_decoder *cxled, +int pos) { -struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (cxlr->dev.parent);struct cxl_memdev *cxlmd =cxled_to_memdev (cxled); -struct cxl_port *ep_port, *root_port, *iter;struct cxl_region_params *p = &cxlr->params; -struct cxl_dport *dport; -int i, rc = -ENXIO ; - -if (cxled->mode != cxlr->mode) { -dev_dbg (&cxlr->dev,"%s region mode: %d mismatch: %d\n" , -dev_name (&cxled->cxld.dev), cxlr->mode, cxled->mode); -return -EINVAL ; - } - -if (cxled->mode ==CXL_DECODER_DEAD ) { -dev_dbg (&cxlr->dev,"%s dead\n" ,dev_name (&cxled->cxld.dev)); -return -ENODEV ; - } - -/* all full of members, or interleave config not established? */ -if (p->state >CXL_CONFIG_INTERLEAVE_ACTIVE ) { -dev_dbg (&cxlr->dev,"region already active\n" ); -return -EBUSY ; - }else if (p->state <CXL_CONFIG_INTERLEAVE_ACTIVE ) { -dev_dbg (&cxlr->dev,"interleave config missing\n" ); -return -ENXIO ; - } +int i;if (pos <0 || pos >= p->interleave_ways) { dev_dbg(&cxlr->dev, "position %d out of range %d\n", pos,
@@ -1248,6 +1226,71 @@ static int cxl_region_attach(struct cxl_region *cxlr, } } +return 0 ; +} + +static int cxl_region_attach_position (struct cxl_region *cxlr, +struct cxl_root_decoder *cxlrd, +struct cxl_endpoint_decoder *cxled, +const struct cxl_dport *dport,int pos) +{ +struct cxl_memdev *cxlmd =cxled_to_memdev (cxled); +struct cxl_port *iter; +int rc; + +if (cxlrd->calc_hb (cxlrd, pos) != dport) { +dev_dbg (&cxlr->dev,"%s:%s invalid target position for %s\n" , +dev_name (&cxlmd->dev),dev_name (&cxled->cxld.dev), +dev_name (&cxlrd->cxlsd.cxld.dev)); +return -ENXIO ; + } + +for (iter =cxled_to_port (cxled); !is_cxl_root (iter); + iter =to_cxl_port (iter->dev.parent)) { + rc =cxl_port_attach_region (iter, cxlr, cxled, pos); +if (rc) + goto err; + } + +return 0 ; + +err: +for (iter =cxled_to_port (cxled); !is_cxl_root (iter); + iter =to_cxl_port (iter->dev.parent)) +cxl_port_detach_region (iter, cxlr, cxled); +return rc; +} + +static int cxl_region_attach (struct cxl_region *cxlr, +struct cxl_endpoint_decoder *cxled,int pos) +{ +struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (cxlr->dev.parent); +struct cxl_memdev *cxlmd =cxled_to_memdev (cxled); +struct cxl_region_params *p = &cxlr->params; +struct cxl_port *ep_port, *root_port; +struct cxl_dport *dport; +int rc = -ENXIO ; + +if (cxled->mode != cxlr->mode) { +dev_dbg (&cxlr->dev,"%s region mode: %d mismatch: %d\n" , +dev_name (&cxled->cxld.dev), cxlr->mode, cxled->mode); +return -EINVAL ; + } + +if (cxled->mode ==CXL_DECODER_DEAD ) { +dev_dbg (&cxlr->dev,"%s dead\n" ,dev_name (&cxled->cxld.dev)); +return -ENODEV ; + } + +/* all full of members, or interleave config not established? */ +if (p->state >CXL_CONFIG_INTERLEAVE_ACTIVE ) { +dev_dbg (&cxlr->dev,"region already active\n" ); +return -EBUSY ; + }else if (p->state <CXL_CONFIG_INTERLEAVE_ACTIVE ) { +dev_dbg (&cxlr->dev,"interleave config missing\n" ); +return -ENXIO ; + } + ep_port =cxled_to_port (cxled); root_port =cxlrd_to_port (cxlrd); dport =cxl_find_dport_by_dev (root_port, ep_port->host_bridge);
@@ -1258,13 +1301,6 @@ static int cxl_region_attach(struct cxl_region *cxlr,return -ENXIO ; } -if (cxlrd->calc_hb (cxlrd, pos) != dport) { -dev_dbg (&cxlr->dev,"%s:%s invalid target position for %s\n" , -dev_name (&cxlmd->dev),dev_name (&cxled->cxld.dev), -dev_name (&cxlrd->cxlsd.cxld.dev)); -return -ENXIO ; - } -if (cxled->cxld.target_type != cxlr->type) { dev_dbg(&cxlr->dev, "%s:%s type mismatch: %d vs %d\n", dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev),
@@ -1288,12 +1324,13 @@ static int cxl_region_attach(struct cxl_region *cxlr,return -EINVAL ; } -for (iter = ep_port; !is_cxl_root (iter); - iter =to_cxl_port (iter->dev.parent)) { - rc =cxl_port_attach_region (iter, cxlr, cxled, pos); -if (rc) - goto err; - } + rc =cxl_region_validate_position (cxlr, cxled, pos); +if (rc) +return rc; + + rc =cxl_region_attach_position (cxlr, cxlrd, cxled, dport, pos); +if (rc) +return rc; p->targets[pos] = cxled; cxled->pos = pos;
@@ -1319,10 +1356,6 @@ static int cxl_region_attach(struct cxl_region *cxlr, p->nr_targets--; cxled->pos =-1 ; p->targets[pos] =NULL ; -err: -for (iter = ep_port; !is_cxl_root (iter); - iter =to_cxl_port (iter->dev.parent)) -cxl_port_detach_region (iter, cxlr, cxled);return rc; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 298/372 cxl/region: Do not try to cleanup after cxl_region_setup_targets() fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jim Harris <[email protected]>
[ Upstream commit 0718588c7aaa7a1510b4de972370535b61dddd0d ]
Commit 5e42bcbc3fef ("cxl/region: decrement ->nr_targets on error in cxl_region_attach()") tried to avoid 'eiw' initialization errors when ->nr_targets exceeded 16, by just decrementing ->nr_targets when cxl_region_setup_targets() failed.
Commit 86987c766276 ("cxl/region: Cleanup target list on attach error") extended that cleanup to also clear cxled->pos and p->targets[pos]. The initialization error was incidentally fixed separately by:
Commit 8d4285425714 ("cxl/region: Fix port setup uninitialized variable warnings") which was merged a few days after 5e42bcbc3fef.
But now the original cleanup when cxl_region_setup_targets() fails prevents endpoint and switch decoder resources from being reused:
1) the cleanup does not set the decoder's region to NULL, which results in future dpa_size_store() calls returning -EBUSY
2) the decoder is not properly freed, which results in future commit errors associated with the upstream switch
Now that the initialization errors were fixed separately, the proper cleanup for this case is to just return immediately. Then the resources associated with this target get cleanup up as normal when the failed region is deleted.
The ->nr_targets decrement in the error case also helped prevent a p->targets[] array overflow, so add a new check to prevent against that overflow.
Tested by trying to create an invalid region for a 2 switch * 2 endpoint topology, and then following up with creating a valid region.
--- drivers/cxl/core/region.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/cxl/core/region.c +7 -7
@@ -1291,6 +1291,12 @@ static int cxl_region_attach(struct cxl_region *cxlr,return -ENXIO ; } +if (p->nr_targets >= p->interleave_ways) { +dev_dbg (&cxlr->dev,"region already has %d endpoints\n" , + p->nr_targets); +return -EINVAL ; + } + ep_port =cxled_to_port (cxled); root_port =cxlrd_to_port (cxlrd); dport =cxl_find_dport_by_dev (root_port, ep_port->host_bridge);
@@ -1339,7 +1345,7 @@ static int cxl_region_attach(struct cxl_region *cxlr,if (p->nr_targets == p->interleave_ways) { rc =cxl_region_setup_targets (cxlr);if (rc) - goto err_decrement; +return rc; p->state =CXL_CONFIG_ACTIVE ; }
@@ -1351,12 +1357,6 @@ static int cxl_region_attach(struct cxl_region *cxlr, };return 0 ; - -err_decrement: - p->nr_targets--; - cxled->pos =-1 ; - p->targets[pos] =NULL ; -return rc; }static int cxl_region_detach (struct cxl_endpoint_decoder *cxled)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 299/372 i3c: master: svc: add NACK check after start byte sent
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Clark Wang <[email protected]>
[ Upstream commit 49b472ebc61de3d4aa7cc57539246bb39f6c5128 ]
Add NACK check after start byte is sent.
It is possible to detect early that a device is not on the bus and avoid invalid transmissions thereafter.
Stable-dep-of: 9aaeef113c55 ("i3c: master: svc: fix random hot join failure since timeout error")
--- drivers/i3c/master/svc-i3c-master.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/i3c/master/svc-i3c-master.c +6 -0
@@ -92,6 +92,7 @@#define SVC_I3C_MINTCLR 0x094#define SVC_I3C_MINTMASKED 0x098#define SVC_I3C_MERRWARN 0x09C +#define SVC_I3C_MERRWARN_NACK BIT(2)#define SVC_I3C_MDMACTRL 0x0A0#define SVC_I3C_MDATACTRL 0x0AC#define SVC_I3C_MDATACTRL_FLUSHTB BIT(0)
@@ -1028,6 +1029,11 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,if (ret) goto emit_stop; +if (readl (master->regs +SVC_I3C_MERRWARN ) &SVC_I3C_MERRWARN_NACK ) { + ret = -ENXIO ; + goto emit_stop; + } +if (rnw) ret =svc_i3c_master_read (master, in, xfer_len);else
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 300/372 i3c: master: svc: fix random hot join failure since timeout error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 9aaeef113c55248ecf3ab941c2e4460aaa8b8b9a ]
master side report:
silvaco-i3c-master 44330000.i3c-master: Error condition: MSTATUS 0x020090c7, MERRWARN 0x00100000
BIT 20: TIMEOUT error
The module has stalled too long in a frame. This happens when:
- The TX FIFO or RX FIFO is not handled and the bus is stuck in the
middle of a message,
- No STOP was issued and between messages,
- IBI manual is used and no decision was made.
The maximum stall period is 100 μs.
This can be considered as being just a warning as the system IRQ latency can easily be greater than 100us.
--- drivers/i3c/master/svc-i3c-master.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/i3c/master/svc-i3c-master.c +9 -0
@@ -93,6 +93,7 @@#define SVC_I3C_MINTMASKED 0x098#define SVC_I3C_MERRWARN 0x09C#define SVC_I3C_MERRWARN_NACK BIT(2) +#define SVC_I3C_MERRWARN_TIMEOUT BIT(20)#define SVC_I3C_MDMACTRL 0x0A0#define SVC_I3C_MDATACTRL 0x0AC#define SVC_I3C_MDATACTRL_FLUSHTB BIT(0)
@@ -220,6 +221,14 @@ static bool svc_i3c_master_error(struct svc_i3c_master *master)if (SVC_I3C_MSTATUS_ERRWARN (mstatus)) { merrwarn =readl (master->regs +SVC_I3C_MERRWARN );writel (merrwarn, master->regs +SVC_I3C_MERRWARN ); + +/* Ignore timeout error */ +if (merrwarn &SVC_I3C_MERRWARN_TIMEOUT ) { +dev_dbg (master->dev,"Warning condition: MSTATUS 0x%08x, MERRWARN 0x%08x\n" , + mstatus, merrwarn); +return false; + } +dev_err (master->dev,"Error condition: MSTATUS 0x%08x, MERRWARN 0x%08x\n" , mstatus, merrwarn);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 301/372 cxl: Unify debug messages when calling devm_cxl_add_port()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Richter <[email protected]>
[ Upstream commit f3cd264c4ec1ab9b8918f3b083cfc13c5e7c26b7 ]
CXL ports are added in a couple of code paths using devm_cxl_add_port(). Debug messages are individually generated, but are incomplete and inconsistent. Change this by moving its generation to devm_cxl_add_port(). This unifies the messages and reduces code duplication. Also, generate messages on failure. Use a __devm_cxl_add_port() wrapper to keep the readability of the error exits.
Stable-dep-of: 98a04c7aced2 ("cxl/region: Fix x1 root-decoder granularity calculations")
--- drivers/cxl/acpi.c | 2 -- drivers/cxl/core/port.c | 51 +++++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 14 deletions(-)
drivers/cxl/acpi.c +0 -2
@@ -219,7 +219,6 @@ static int add_host_bridge_uport(struct device *match, void *arg) port =devm_cxl_add_port (host, match, dport->component_reg_phys, dport);if (IS_ERR (port))return PTR_ERR (port); -dev_dbg (host,"%s: add: %s\n" ,dev_name (match),dev_name (&port->dev));return 0 ; }
@@ -465,7 +464,6 @@ static int cxl_acpi_probe(struct platform_device *pdev) root_port =devm_cxl_add_port (host, host,CXL_RESOURCE_NONE ,NULL );if (IS_ERR (root_port))return PTR_ERR (root_port); -dev_dbg (host,"add: %s\n" ,dev_name (&root_port->dev)); rc =bus_for_each_dev (adev->dev.bus,NULL , root_port, add_host_bridge_dport);
drivers/cxl/core/port.c +39 -12
69 lines not on this page · raw message
Signature · 1 line
2.42.0