5.15.181-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 137/373 Bluetooth: btrtl: Prevent potential NULL dereference
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 324dddea321078a6eeb535c2bff5257be74c9799 ]
The btrtl_initialize() function checks that rtl_load_file() either had an error or it loaded a zero length file. However, if it loaded a zero length file then the error code is not set correctly. It results in an error pointer vs NULL bug, followed by a NULL pointer dereference. This was detected by Smatch:
drivers/bluetooth/btrtl.c:592 btrtl_initialize() warn: passing zero to 'ERR_PTR'
--- drivers/bluetooth/btrtl.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btrtl.c +2 -0
@@ -677,6 +677,8 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,rtl_dev_err (hdev,"mandatory config file %s not found" , btrtl_dev->ic_info->cfg_name); ret = btrtl_dev->cfg_len; +if (!ret) + ret = -EINVAL ; goto err_free; } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 138/373 Bluetooth: l2cap: Check encryption key size on incoming connection
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frédéric Danis <[email protected]>
[ Upstream commit 522e9ed157e3c21b4dd623c79967f72c21e45b78 ]
This is required for passing GAP/SEC/SEM/BI-04-C PTS test case:
Security Mode 4 Level 4, Responder - Invalid Encryption Key Size
- 128 bit
This tests the security key with size from 1 to 15 bytes while the Security Mode 4 Level 4 requests 16 bytes key size.
Currently PTS fails with the following logs:
- expected:Connection Response:
Code: [3 (0x03)] Code
Identifier: (lt)WildCard: Exists(gt)
Length: [8 (0x0008)]
Destination CID: (lt)WildCard: Exists(gt)
Source CID: [64 (0x0040)]
Result: [3 (0x0003)] Connection refused - Security block
Status: (lt)WildCard: Exists(gt),
but received:Connection Response:
Code: [3 (0x03)] Code
Identifier: [1 (0x01)]
Length: [8 (0x0008)]
Destination CID: [64 (0x0040)]
Source CID: [64 (0x0040)]
Result: [0 (0x0000)] Connection Successful
Status: [0 (0x0000)] No further information availableAnd HCI logs:
< HCI Command: Read Encrypti.. (0x05|0x0008) plen 2
Handle: 14 Address: 00:1B:DC:F2:24:10 (Vencer Co., Ltd.)
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 7
Read Encryption Key Size (0x05|0x0008) ncmd 1
Status: Success (0x00)
Handle: 14 Address: 00:1B:DC:F2:24:10 (Vencer Co., Ltd.)
Key size: 7Quoted 1 line
ACL Data RX: Handle 14 flags
0x02dlen 12
L2CAP: Connection Request (0x02) ident 1 len 4
PSM: 4097 (0x1001)
Source CID: 64
< ACL Data TX: Handle 14 flags 0x00 dlen 16
L2CAP: Connection Response (0x03) ident 1 len 8
Destination CID: 64
Source CID: 64
Result: Connection successful (0x0000)
Status: No further information available (0x0000)--- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +2 -1
@@ -4162,7 +4162,8 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,/* Check if the ACL is secure enough (if not SDP) */ if (psm !=cpu_to_le16 (L2CAP_PSM_SDP ) && - !hci_conn_check_link_mode (conn->hcon)) { + (!hci_conn_check_link_mode (conn->hcon) || + !l2cap_check_enc_key_size (conn->hcon))) { conn->disc_reason =HCI_ERROR_AUTH_FAILURE ; result =L2CAP_CR_SEC_BLOCK ; goto response;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 139/373 Revert "wifi: mac80211: Update skbs control block key in ieee80211_tx_dequeue()"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 0937cb5f345c79d702b4d0d744e2a2529b551cb2 ]
This reverts commit a104042e2bf6528199adb6ca901efe7b60c2c27f.
Since the original bug seems to have been around for years, but a new issue was report with the fix, revert the fix for now. We have a couple of weeks to figure it out for this release, if needed.
--- net/mac80211/tx.c | 1 - 1 file changed, 1 deletion(-)
net/mac80211/tx.c +0 -1
@@ -3704,7 +3704,6 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,* The key can be removed while the packet was queued, so need to call * this here to get the current key. */ - info->control.hw_key =NULL ; r =ieee80211_tx_h_select_key (&tx);if (r !=TX_CONTINUE ) {ieee80211_free_txskb (&local->hw, skb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 140/373 igc: fix PTM cycle trigger logic
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christopher S M Hall <[email protected]>
[ Upstream commit 8e404ad95d2c10c261e2ef6992c7c12dde03df0e ]
Writing to clear the PTM status 'valid' bit while the PTM cycle is triggered results in unreliable PTM operation. To fix this, clear the PTM 'trigger' and status after each PTM transaction.
The issue can be reproduced with the following:
$ sudo phc2sys -R 1000 -O 0 -i tsn0 -m
Note: 1000 Hz (-R 1000) is unrealistically large, but provides a way to quickly reproduce the issue.
PHC2SYS exits with:
"ioctl PTP_OFFSET_PRECISE: Connection timed out" when the PTM transaction
fails
This patch also fixes a hang in igc_probe() when loading the igc driver in the kdump kernel on systems supporting PTM.
The igc driver running in the base kernel enables PTM trigger in igc_probe(). Therefore the driver is always in PTM trigger mode, except in brief periods when manually triggering a PTM cycle.
When a crash occurs, the NIC is reset while PTM trigger is enabled. Due to a hardware problem, the NIC is subsequently in a bad busmaster state and doesn't handle register reads/writes. When running igc_probe() in the kdump kernel, the first register access to a NIC register hangs driver probing and ultimately breaks kdump.
With this patch, igc has PTM trigger disabled most of the time, and the trigger is only enabled for very brief (10 - 100 us) periods when manually triggering a PTM cycle. Chances that a crash occurs during a PTM trigger are not 0, but extremely reduced.
--- drivers/net/ethernet/intel/igc/igc_defines.h | 1 + drivers/net/ethernet/intel/igc/igc_ptp.c | 70 ++++++++++++-------- 2 files changed, 42 insertions(+), 29 deletions(-)
drivers/net/ethernet/intel/igc/igc_defines.h +1 -0
@@ -577,6 +577,7 @@#define IGC_PTM_STAT_T4M1_OVFL BIT(3)/* T4 minus T1 overflow */ #define IGC_PTM_STAT_ADJUST_1ST BIT(4)/* 1588 timer adjusted during 1st PTM cycle */ #define IGC_PTM_STAT_ADJUST_CYC BIT(5)/* 1588 timer adjusted during non-1st PTM cycle */ +#define IGC_PTM_STAT_ALL GENMASK(5, 0)/* Used to clear all status */ /* PCIe PTM Cycle Control */ #define IGC_PTM_CYCLE_CTRL_CYC_TIME (msec) ((msec) & 0x3ff)/* PTM Cycle Time (msec) */
drivers/net/ethernet/intel/igc/igc_ptp.c +41 -29
115 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 141/373 igc: move ktime snapshot into PTM retry loop
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christopher S M Hall <[email protected]>
[ Upstream commit cd7f7328d691937102732f39f97ead35b15bf803 ]
Move ktime_get_snapshot() into the loop. If a retry does occur, a more recent snapshot will result in a more accurate cross-timestamp.
--- drivers/net/ethernet/intel/igc/igc_ptp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/igc/igc_ptp.c +9 -9
@@ -886,16 +886,16 @@ static int igc_phc_get_syncdevicetime(ktime_t *device,int err, count =100 ;ktime_t t1, t2_curr; -/* Get a snapshot of system clocks to use as historic value. */ -ktime_get_snapshot (&adapter->snapshot); - +/* Doing this in a loop because in the event of a +* badly timed (ha!) system clock adjustment, we may +* get PTM errors from the PCI root, but these errors +* are transitory. Repeating the process returns valid +* data eventually. +*/ do { - /* Doing this in a loop because in the event of a - * badly timed (ha!) system clock adjustment, we may - * get PTM errors from the PCI root, but these errors - * are transitory. Repeating the process returns valid - * data eventually. - */ + /* Get a snapshot of system clocks to use as historic value. */ + ktime_get_snapshot(&adapter->snapshot); + igc_ptm_trigger(hw); err = readx_poll_timeout(rd32, IGC_PTM_STAT, stat,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 142/373 igc: handle the IGC_PTP_ENABLED flag correctly
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christopher S M Hall <[email protected]>
[ Upstream commit 26a3910afd111f7c1a96dace6dc02f3225063896 ]
All functions in igc_ptp.c called from igc_main.c should check the IGC_PTP_ENABLED flag. Adding check for this flag to stop and reset functions.
--- drivers/net/ethernet/intel/igc/igc_ptp.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/intel/igc/igc_ptp.c +7 -0
@@ -1075,8 +1075,12 @@ void igc_ptp_suspend(struct igc_adapter *adapter)**/ void igc_ptp_stop (struct igc_adapter *adapter) { +if (!(adapter->ptp_flags &IGC_PTP_ENABLED )) +return ; +igc_ptp_suspend (adapter); + adapter->ptp_flags &= ~IGC_PTP_ENABLED ;if (adapter->ptp_clock) {ptp_clock_unregister (adapter->ptp_clock);netdev_info (adapter->netdev,"PHC removed\n" );
@@ -1097,6 +1101,9 @@ void igc_ptp_reset(struct igc_adapter *adapter)unsigned long flags;u32 timadj; +if (!(adapter->ptp_flags &IGC_PTP_ENABLED )) +return ; +/* reset the tstamp_config */ igc_ptp_set_timestamp_mode (adapter, &adapter->tstamp_config);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 143/373 igc: cleanup PTP module if probe fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christopher S M Hall <[email protected]>
[ Upstream commit 1f025759ba394dd53e434d2668cb0597886d9b69 ]
Make sure that the PTP module is cleaned up if the igc_probe() fails by calling igc_ptp_stop() on exit.
--- drivers/net/ethernet/intel/igc/igc_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/igc/igc_main.c +1 -0
@@ -6722,6 +6722,7 @@ static int igc_probe(struct pci_dev *pdev, err_register:igc_release_hw_control (adapter); +igc_ptp_stop (adapter); err_eeprom:if (!igc_check_reset_block (hw))igc_reset_phy (hw);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 144/373 net: mctp: Set SOCK_RCU_FREE
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Johnston <[email protected]>
[ Upstream commit 52024cd6ec71a6ca934d0cc12452bd8d49850679 ]
Bind lookup runs under RCU, so ensure that a socket doesn't go away in the middle of a lookup.
--- net/mctp/af_mctp.c | 3 +++ 1 file changed, 3 insertions(+)
net/mctp/af_mctp.c +3 -0
@@ -253,6 +253,9 @@ static int mctp_sk_hash(struct sock *sk) {struct net *net =sock_net (sk); +/* Bind lookup runs under RCU, remain live during that. */ +sock_set_flag (sk,SOCK_RCU_FREE ); +mutex_lock (&net->mctp.bind_lock);sk_add_node_rcu (sk, &net->mctp.binds);mutex_unlock (&net->mctp.bind_lock);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 145/373 net: openvswitch: fix nested key length validation in the set() action
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
[ Upstream commit 65d91192aa66f05710cfddf6a14b5a25ee554dba ]
It's not safe to access nla_len(ovs_key) if the data is smaller than the netlink header. Check that the attribute is OK first.
--- net/openvswitch/flow_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/openvswitch/flow_netlink.c +2 -1
@@ -2831,7 +2831,8 @@ static int validate_set(const struct nlattr *a,size_t key_len;/* There can be only one key in a action */ -if (nla_total_size (nla_len (ovs_key)) !=nla_len (a)) +if (!nla_ok (ovs_key,nla_len (a)) || +nla_total_size (nla_len (ovs_key)) !=nla_len (a))return -EINVAL ; key_len =nla_len (ovs_key);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 146/373 cxgb4: fix memory leak in cxgb4_init_ethtool_filters() error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
[ Upstream commit 00ffb3724ce743578163f5ade2884374554ca021 ]
In the for loop used to allocate the loc_array and bmap for each port, a memory leak is possible when the allocation for loc_array succeeds, but the allocation for bmap fails. This is because when the control flow goes to the label free_eth_finfo, only the allocations starting from (i-1)th iteration are freed.
Fix that by freeing the loc_array in the bmap allocation error path.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +1 -0
@@ -2262,6 +2262,7 @@ int cxgb4_init_ethtool_filters(struct adapter *adap) GFP_KERNEL);if (!eth_filter->port[i].bmap) { ret = -ENOMEM ; +kvfree (eth_filter->port[i].loc_array); goto free_eth_finfo; } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 147/373 net: b53: enable BPDU reception for management port
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Gorski <[email protected]>
[ Upstream commit 36355ddfe8955f226a88a543ed354b9f6b84cd70 ]
For STP to work, receiving BPDUs is essential, but the appropriate bit was never set. Without GC_RX_BPDU_EN, the switch chip will filter all BPDUs, even if an appropriate PVID VLAN was setup.
--- drivers/net/dsa/b53/b53_common.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/dsa/b53/b53_common.c +10 -0
@@ -724,6 +724,15 @@ static void b53_enable_mib(struct b53_device *dev)b53_write8 (dev,B53_MGMT_PAGE ,B53_GLOBAL_CONFIG , gc); } +static void b53_enable_stp (struct b53_device *dev) +{ +u8 gc; + +b53_read8 (dev,B53_MGMT_PAGE ,B53_GLOBAL_CONFIG , &gc); + gc |=GC_RX_BPDU_EN ; +b53_write8 (dev,B53_MGMT_PAGE ,B53_GLOBAL_CONFIG , gc); +} +static u16 b53_default_pvid (struct b53_device *dev) {if (is5325 (dev) ||is5365 (dev))
@@ -863,6 +872,7 @@ static int b53_switch_reset(struct b53_device *dev) }b53_enable_mib (dev); +b53_enable_stp (dev);return b53_flush_arl (dev,FAST_AGE_STATIC ); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 148/373 net: dsa: mv88e6xxx: avoid unregistering devlink regions which were never registered
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit c84f6ce918a9e6f4996597cbc62536bbf2247c96 ]
Russell King reports that a system with mv88e6xxx dereferences a NULL pointer when unbinding this driver:
https://lore.kernel.org/netdev/[email protected]/
The crash seems to be in devlink_region_destroy(), which is not NULL tolerant but is given a NULL devlink global region pointer.
At least on some chips, some devlink regions are conditionally registered since the blamed commit, see mv88e6xxx_setup_devlink_regions_global():
if (cond && !cond(chip)) continue;
These are MV88E6XXX_REGION_STU and MV88E6XXX_REGION_PVT. If the chip does not have an STU or PVT, it should crash like this.
To fix the issue, avoid unregistering those regions which are NULL, i.e. were skipped at mv88e6xxx_setup_devlink_regions_global() time.
--- drivers/net/dsa/mv88e6xxx/devlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/devlink.c +2 -1
@@ -653,7 +653,8 @@ void mv88e6xxx_teardown_devlink_regions_global(struct dsa_switch *ds)int i;for (i =0 ; i <ARRAY_SIZE (mv88e6xxx_regions); i++) -dsa_devlink_region_destroy (chip->regions[i]); +if (chip->regions[i]) +dsa_devlink_region_destroy (chip->regions[i]); }void mv88e6xxx_teardown_devlink_regions_port (struct dsa_switch *ds,int port)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 149/373 net: dsa: avoid refcount warnings when ds->ops->tag_8021q_vlan_del() fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit 514eff7b0aa1c5eb645ddbb8676ef3e2d88a8b99 ]
This is very similar to the problem and solution from commit 232deb3f9567 ("net: dsa: avoid refcount warnings when ->port_{fdb,mdb}_del returns error"), except for the dsa_port_do_tag_8021q_vlan_del() operation.
--- net/dsa/tag_8021q.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/dsa/tag_8021q.c +1 -1
@@ -196,7 +196,7 @@ static int dsa_switch_do_tag_8021q_vlan_del(struct dsa_switch *ds, int port, err = ds->ops->tag_8021q_vlan_del (ds, port, vid);if (err) { -refcount_inc (&v->refcount); +refcount_set (&v->refcount,1 );return err; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 150/373 riscv: Properly export reserved regions in /proc/iomem
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Björn Töpel <[email protected]>
[ Upstream commit e94eb7ea6f206e229791761a5fdf9389f8dbd183 ]
The /proc/iomem represents the kernel's memory map. Regions marked with "Reserved" tells the user that the range should not be tampered with. Kexec-tools, when using the older kexec_load syscall relies on the "Reserved" regions to build the memory segments, that will be the target of the new kexec'd kernel.
The RISC-V port tries to expose all reserved regions to userland, but some regions were not properly exposed: Regions that resided in both the "regular" and reserved memory block, e.g. the EFI Memory Map. A missing entry could result in reserved memory being overwritten.
It turns out, that arm64, and loongarch had a similar issue a while back:
commit d91680e687f4 ("arm64: Fix /proc/iomem for reserved but not memory regions") commit 50d7ba36b916 ("arm64: export memblock_reserve()d regions via /proc/iomem")
Similar to the other ports, resolve the issue by splitting the regions in an arch initcall, since we need a working allocator.
--- arch/riscv/kernel/setup.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
arch/riscv/kernel/setup.c +35 -1
@@ -84,6 +84,9 @@ static struct resource bss_res = { .name = "Kernel bss", };static struct resource elfcorehdr_res = { .name ="ELF Core hdr" , };#endif +static int num_standard_resources; +static struct resource *standard_resources; +static int __init add_resource (struct resource *parent,struct resource *res) {
@@ -157,7 +160,7 @@ static void __init init_resources(void)struct resource *res =NULL ;struct resource *mem_res =NULL ;size_t mem_res_sz =0 ; -int num_resources =0 , res_idx =0 ; +int num_resources =0 , res_idx =0 , non_resv_res =0 ;int ret =0 ;/* + 1 as memblock_alloc() might increase memblock.reserved.cnt */
@@ -221,6 +224,7 @@ static void __init init_resources(void)/* Add /memory regions to the resource tree */ for_each_mem_region (region) { res = &mem_res[res_idx--]; + non_resv_res++;if (unlikely (memblock_is_nomap (region))) { res->name ="Reserved" ;
@@ -238,6 +242,9 @@ static void __init init_resources(void) goto error; } + num_standard_resources = non_resv_res; + standard_resources = &mem_res[res_idx +1 ]; +/* Clean-up any unused pre-allocated resources */ if (res_idx >=0 )memblock_free (__pa (mem_res), (res_idx +1 ) *sizeof (*mem_res));
@@ -249,6 +256,33 @@ static void __init init_resources(void)memblock_free (__pa (mem_res), mem_res_sz); } +static int __init reserve_memblock_reserved_regions (void ) +{ +u64 i, j; + +for (i =0 ; i < num_standard_resources; i++) { +struct resource *mem = &standard_resources[i]; +phys_addr_t r_start, r_end, mem_size =resource_size (mem); + +if (!memblock_is_region_reserved (mem->start, mem_size)) +continue ; + +for_each_reserved_mem_range (j, &r_start, &r_end) { +resource_size_t start, end; + + start =max (PFN_PHYS (PFN_DOWN (r_start)), mem->start); + end =min (PFN_PHYS (PFN_UP (r_end)) -1 , mem->end); + +if (start > mem->end || end < mem->start) +continue ; + +reserve_region_with_split (mem, start, end,"Reserved" ); + } + } + +return 0 ; +} +arch_initcall (reserve_memblock_reserved_regions);static void __init parse_dtb (void ) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 151/373 riscv: KGDB: Do not inline arch_kgdb_breakpoint()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
[ Upstream commit 3af4bec9c1db3f003be4d5ae09b6a737e4be1612 ]
The arch_kgdb_breakpoint() function defines the kgdb_compiled_break symbol using inline assembly.
There's a potential issue where the compiler might inline arch_kgdb_breakpoint(), which would then define the kgdb_compiled_break symbol multiple times, leading to fail to link vmlinux.o.
This isn't merely a potential compilation problem. The intent here is to determine the global symbol address of kgdb_compiled_break, and if this function is inlined multiple times, it would logically be a grave error.
--- arch/riscv/include/asm/kgdb.h | 9 +-------- arch/riscv/kernel/kgdb.c | 8 ++++++++ 2 files changed, 9 insertions(+), 8 deletions(-)
arch/riscv/include/asm/kgdb.h +1 -8
@@ -19,16 +19,9 @@#ifndef __ASSEMBLY__ +void arch_kgdb_breakpoint (void );extern unsigned long kgdb_compiled_break; -static inline void arch_kgdb_breakpoint (void ) -{ - asm(".global kgdb_compiled_break\n" -".option norvc\n" -"kgdb_compiled_break: ebreak\n" -".option rvc\n" ); -} -#endif /* !__ASSEMBLY__ */ #define DBG_REG_ZERO "zero"
arch/riscv/kernel/kgdb.c +8 -0
@@ -273,6 +273,14 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) regs->epc = pc; } +noinline void arch_kgdb_breakpoint(void) +{ + asm(".global kgdb_compiled_break\n" +".option norvc\n" +"kgdb_compiled_break: ebreak\n" +".option rvc\n" ); +} +void kgdb_arch_handle_qxfer_pkt (char *remcom_in_buffer,char *remcom_out_buffer) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 152/373 riscv: KGDB: Remove ".option norvc/.option rvc" for kgdb_compiled_break
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
[ Upstream commit 550c2aa787d1b06efcb11de1877354502a1237f2 ]
[ Quoting Samuel Holland: ]
This is a separate issue, but using ".option rvc" here is a bug. It will unconditionally enable the C extension for the rest of the file, even if the kernel is being built with CONFIG_RISCV_ISA_C=n.
[ Quoting Palmer Dabbelt: ]
We're just looking at the address of kgdb_compiled_break, so it's fine if it ends up as a c.ebreak.
[ Quoting Alexandre Ghiti: ]
.option norvc is used to prevent the assembler from using compressed instructions, but it's generally used when we need to ensure the size of the instructions that are used, which is not the case here as noted by Palmer since we only care about the address. So yes it will work fine with C enabled :)
So let's just remove them all.
--- arch/riscv/kernel/kgdb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/riscv/kernel/kgdb.c +1 -3
@@ -276,9 +276,7 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) noinline void arch_kgdb_breakpoint(void) { asm(".global kgdb_compiled_break\n" -".option norvc\n" -"kgdb_compiled_break: ebreak\n" -".option rvc\n" ); +"kgdb_compiled_break: ebreak\n" ); } void kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 153/373 cpufreq/sched: Fix the usage of CPUFREQ_NEED_UPDATE_LIMITS
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit cfde542df7dd51d26cf667f4af497878ddffd85a ]
Commit 8e461a1cb43d ("cpufreq: schedutil: Fix superfluous updates caused by need_freq_update") modified sugov_should_update_freq() to set the need_freq_update flag only for drivers with CPUFREQ_NEED_UPDATE_LIMITS set, but that flag generally needs to be set when the policy limits change because the driver callback may need to be invoked for the new limits to take effect.
However, if the return value of cpufreq_driver_resolve_freq() after applying the new limits is still equal to the previously selected frequency, the driver callback needs to be invoked only in the case when CPUFREQ_NEED_UPDATE_LIMITS is set (which means that the driver specifically wants its callback to be invoked every time the policy limits change).
Update the code accordingly to avoid missing policy limits changes for drivers without CPUFREQ_NEED_UPDATE_LIMITS.
--- kernel/sched/cpufreq_schedutil.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
kernel/sched/cpufreq_schedutil.c +15 -3
@@ -91,7 +91,7 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)if (unlikely (sg_policy->limits_changed)) { sg_policy->limits_changed = false; - sg_policy->need_freq_update =cpufreq_driver_test_flags (CPUFREQ_NEED_UPDATE_LIMITS ); + sg_policy->need_freq_update = true;return true; }
@@ -103,10 +103,22 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)static bool sugov_update_next_freq (struct sugov_policy *sg_policy,u64 time,unsigned int next_freq) { -if (sg_policy->need_freq_update) +if (sg_policy->need_freq_update) { sg_policy->need_freq_update = false; -else if (sg_policy->next_freq == next_freq) +/* +* The policy limits have changed, but if the return value of +* cpufreq_driver_resolve_freq() after applying the new limits +* is still equal to the previously selected frequency, the +* driver callback need not be invoked unless the driver +* specifically wants that to happen on every update of the +* policy limits. +*/ +if (sg_policy->next_freq == next_freq && + !cpufreq_driver_test_flags (CPUFREQ_NEED_UPDATE_LIMITS )) +return false; + }else if (sg_policy->next_freq == next_freq) {return false; + } sg_policy->next_freq = next_freq; sg_policy->last_freq_update_time = time;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 154/373 writeback: fix false warning in inode_to_wb()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
commit 9e888998ea4d22257b07ce911576509486fa0667 upstream.
inode_to_wb() is used also for filesystems that don't support cgroup writeback. For these filesystems inode->i_wb is stable during the lifetime of the inode (it points to bdi->wb) and there's no need to hold locks protecting the inode->i_wb dereference. Improve the warning in inode_to_wb() to not trigger for these filesystems.
--- include/linux/backing-dev.h | 1 + 1 file changed, 1 insertion(+)
include/linux/backing-dev.h +1 -0
@@ -283,6 +283,7 @@ static inline struct bdi_writeback *inod {#ifdef CONFIG_LOCKDEP WARN_ON_ONCE (debug_locks && + (inode->i_sb->s_iflags &SB_I_CGROUPWB ) && (!lockdep_is_held (&inode->i_lock) && !lockdep_is_held (&inode->i_mapping->i_pages.xa_lock) && !lockdep_is_held (&inode->i_wb->list_lock)));
Greg Kroah-Hartman
maintainerPATCH 155/373 Revert "PCI: Avoid reset when disabled via sysfs"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
commit bc0b828ef6e561081ebc4c758d0c4d166bb9829c upstream.
This reverts commit 479380efe1625e251008d24b2810283db60d6fcd.
The reset_method attribute on a PCI device is only intended to manage the availability of function scoped resets for a device. It was never intended to restrict resets targeting the bus or slot.
In introducing a restriction that each device must support function level reset by testing pci_reset_supported(), we essentially create a catch-22, that a device must have a function scope reset in order to support bus/slot reset, when we use bus/slot reset to effect a reset of a device that does not support a function scoped reset, especially multi-function devices.
This breaks the majority of uses cases where vfio-pci uses bus/slot resets to manage multifunction devices that do not support function scoped resets.
--- drivers/pci/pci.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pci/pci.c +0 -4
@@ -5484,8 +5484,6 @@ static bool pci_bus_resetable(struct pcireturn false;list_for_each_entry (dev, &bus->devices, bus_list) { -if (!pci_reset_supported (dev)) -return false;if (dev->dev_flags &PCI_DEV_FLAGS_NO_BUS_RESET || (dev->subordinate && !pci_bus_resetable (dev->subordinate)))return false;
@@ -5562,8 +5560,6 @@ static bool pci_slot_resetable(struct pclist_for_each_entry (dev, &slot->bus->devices, bus_list) {if (!dev->slot || dev->slot != slot)continue ; -if (!pci_reset_supported (dev)) -return false;if (dev->dev_flags &PCI_DEV_FLAGS_NO_BUS_RESET || (dev->subordinate && !pci_bus_resetable (dev->subordinate)))return false;
Greg Kroah-Hartman
maintainerPATCH 156/373 ASoC: codecs:lpass-wsa-macro: Fix vi feedback rate
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit d7bff1415e85b889dc8908be6aedba8807ae5e37 upstream.
Currently the VI feedback rate is set to fixed 8K, fix this by getting the correct rate from params_rate.
Without this patch incorrect rate will be set on the VI feedback recording resulting in rate miss match and audio artifacts.
--- sound/soc/codecs/lpass-wsa-macro.c | 39 ++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-)
sound/soc/codecs/lpass-wsa-macro.c +36 -3
@@ -62,6 +62,10 @@#define CDC_WSA_TX_SPKR_PROT_CLK_DISABLE 0#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK GENMASK(3, 0)#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K 0 +#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_16K 1 +#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_24K 2 +#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_32K 3 +#define CDC_WSA_TX_SPKR_PROT_PCM_RATE_48K 4#define CDC_WSA_TX0_SPKR_PROT_PATH_CFG0 (0x0248)#define CDC_WSA_TX1_SPKR_PROT_PATH_CTL (0x0264)#define CDC_WSA_TX1_SPKR_PROT_PATH_CFG0 (0x0268)
@@ -344,6 +348,7 @@ struct wsa_macro {int ear_spkr_gain;int spkr_gain_offset;int spkr_mode; +u32 pcm_rate_vi;int is_softclip_on[WSA_MACRO_SOFTCLIP_MAX ];int softclip_clk_users[WSA_MACRO_SOFTCLIP_MAX ];struct regmap *regmap;
@@ -967,6 +972,7 @@ static int wsa_macro_hw_params(struct sn struct snd_soc_dai *dai) {struct snd_soc_component *component = dai->component; +struct wsa_macro *wsa =snd_soc_component_get_drvdata (component);int ret;switch (substream->stream) {
@@ -979,6 +985,11 @@ static int wsa_macro_hw_params(struct snreturn ret; }break ; +case SNDRV_PCM_STREAM_CAPTURE : +if (dai->id ==WSA_MACRO_AIF_VI ) + wsa->pcm_rate_vi =params_rate (params); + +break ;default :break ; }
@@ -1152,6 +1163,28 @@ static int wsa_macro_enable_vi_feedback(struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm);struct wsa_macro *wsa =snd_soc_component_get_drvdata (component);u32 tx_reg0, tx_reg1; +u32 rate_val; + +switch (wsa->pcm_rate_vi) { +case 8000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K ; +break ; +case 16000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_16K ; +break ; +case 24000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_24K ; +break ; +case 32000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_32K ; +break ; +case 48000 : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_48K ; +break ; +default : + rate_val =CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K ; +break ; + }if (test_bit (WSA_MACRO_TX0 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) { tx_reg0 =CDC_WSA_TX0_SPKR_PROT_PATH_CTL ;
@@ -1163,7 +1196,7 @@ static int wsa_macro_enable_vi_feedback(switch (event) {case SND_SOC_DAPM_POST_PMU : -/* Enable V&I sensing */ +/* Enable V&I sensing */ snd_soc_component_update_bits (component, tx_reg0,CDC_WSA_TX_SPKR_PROT_RESET_MASK ,CDC_WSA_TX_SPKR_PROT_RESET );
@@ -1172,10 +1205,10 @@ static int wsa_macro_enable_vi_feedback( CDC_WSA_TX_SPKR_PROT_RESET);snd_soc_component_update_bits (component, tx_reg0,CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , -CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K ); + rate_val);snd_soc_component_update_bits (component, tx_reg1,CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , -CDC_WSA_TX_SPKR_PROT_PCM_RATE_8K ); + rate_val);snd_soc_component_update_bits (component, tx_reg0,CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK ,CDC_WSA_TX_SPKR_PROT_CLK_ENABLE );
Greg Kroah-Hartman
maintainerPATCH 157/373 ASoC: codecs:lpass-wsa-macro: Fix logic of enabling vi channels
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 7648beb65600220996ebb2da207610b1ff9b735e upstream.
Existing code only configures one of WSA_MACRO_TX0 or WSA_MACRO_TX1 paths eventhough we enable both of them. Fix this bug by adding proper checks and rearranging some of the common code to able to allow setting both TX0 and TX1 paths
Without this patch only one channel gets enabled in VI path instead of 2 channels. End result would be 1 channel recording instead of 2.
--- sound/soc/codecs/lpass-wsa-macro.c | 108 +++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 45 deletions(-)
sound/soc/codecs/lpass-wsa-macro.c +63 -45
@@ -1146,6 +1146,67 @@ static void wsa_macro_mclk_enable(struct } } +static void wsa_macro_enable_disable_vi_sense (struct snd_soc_component *component,bool enable, +u32 tx_reg0,u32 tx_reg1,u32 val) +{ +if (enable) { +/* Enable V&I sensing */ +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_RESET ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_RESET ); +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , + val); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , + val); +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , +CDC_WSA_TX_SPKR_PROT_CLK_ENABLE ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , +CDC_WSA_TX_SPKR_PROT_CLK_ENABLE ); +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_NO_RESET ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_NO_RESET ); + }else { +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_RESET ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_RESET_MASK , +CDC_WSA_TX_SPKR_PROT_RESET ); +snd_soc_component_update_bits (component, tx_reg0, +CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , +CDC_WSA_TX_SPKR_PROT_CLK_DISABLE ); +snd_soc_component_update_bits (component, tx_reg1, +CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , +CDC_WSA_TX_SPKR_PROT_CLK_DISABLE ); + } +} + +static void wsa_macro_enable_disable_vi_feedback (struct snd_soc_component *component, +bool enable,u32 rate) +{ +struct wsa_macro *wsa =snd_soc_component_get_drvdata (component); + +if (test_bit (WSA_MACRO_TX0 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) +wsa_macro_enable_disable_vi_sense (component, enable, +CDC_WSA_TX0_SPKR_PROT_PATH_CTL , +CDC_WSA_TX1_SPKR_PROT_PATH_CTL , rate); + +if (test_bit (WSA_MACRO_TX1 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) +wsa_macro_enable_disable_vi_sense (component, enable, +CDC_WSA_TX2_SPKR_PROT_PATH_CTL , +CDC_WSA_TX3_SPKR_PROT_PATH_CTL , rate); +} +static int wsa_macro_mclk_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event) {
@@ -1162,7 +1223,6 @@ static int wsa_macro_enable_vi_feedback( {struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm);struct wsa_macro *wsa =snd_soc_component_get_drvdata (component); -u32 tx_reg0, tx_reg1;u32 rate_val;switch (wsa->pcm_rate_vi) {
@@ -1186,56 +1246,14 @@ static int wsa_macro_enable_vi_feedback(break ; } -if (test_bit (WSA_MACRO_TX0 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) { - tx_reg0 =CDC_WSA_TX0_SPKR_PROT_PATH_CTL ; - tx_reg1 =CDC_WSA_TX1_SPKR_PROT_PATH_CTL ; - }else if (test_bit (WSA_MACRO_TX1 , &wsa->active_ch_mask[WSA_MACRO_AIF_VI ])) { - tx_reg0 =CDC_WSA_TX2_SPKR_PROT_PATH_CTL ; - tx_reg1 =CDC_WSA_TX3_SPKR_PROT_PATH_CTL ; - } -switch (event) {case SND_SOC_DAPM_POST_PMU :/* Enable V&I sensing */ -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_RESET ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_RESET ); -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , - rate_val); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_PCM_RATE_MASK , - rate_val); -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , -CDC_WSA_TX_SPKR_PROT_CLK_ENABLE ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , -CDC_WSA_TX_SPKR_PROT_CLK_ENABLE ); -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_NO_RESET ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_NO_RESET ); +wsa_macro_enable_disable_vi_feedback (component, true, rate_val);break ;case SND_SOC_DAPM_POST_PMD :/* Disable V&I sensing */ -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_RESET ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_RESET_MASK , -CDC_WSA_TX_SPKR_PROT_RESET ); -snd_soc_component_update_bits (component, tx_reg0, -CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , -CDC_WSA_TX_SPKR_PROT_CLK_DISABLE ); -snd_soc_component_update_bits (component, tx_reg1, -CDC_WSA_TX_SPKR_PROT_CLK_EN_MASK , -CDC_WSA_TX_SPKR_PROT_CLK_DISABLE ); +wsa_macro_enable_disable_vi_feedback (component, false, rate_val);break ; }
Greg Kroah-Hartman
maintainerPATCH 158/373 asus-laptop: Fix an uninitialized variable
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 6c683c6887e4addcd6bd1ddce08cafccb0a21e32 upstream.
The value returned by acpi_evaluate_integer() is not checked, but the result is not always successful, so it is necessary to add a check of the returned value.
If the result remains negative during three iterations of the loop, then the uninitialized variable 'val' will be used in the clamp_val() macro, so it must be initialized with the current value of the 'curr' variable.
In this case, the algorithm should be less noisy.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/platform/x86/asus-laptop.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/platform/x86/asus-laptop.c +6 -3
@@ -427,11 +427,14 @@ static int asus_pega_lucid_set(struct asstatic int pega_acc_axis (struct asus_laptop *asus,int curr,char *method) { +unsigned long long val = (unsigned long long )curr; +acpi_status status;int i, delta; -unsigned long long val; -for (i =0 ; i <PEGA_ACC_RETRIES ; i++) { -acpi_evaluate_integer (asus->handle, method,NULL , &val); +for (i =0 ; i <PEGA_ACC_RETRIES ; i++) { + status =acpi_evaluate_integer (asus->handle, method,NULL , &val); +if (ACPI_FAILURE (status)) +continue ;/* The output is noisy. From reading the ASL * dissassembly, timeout errors are returned with 1's * in the high word, and the lack of locking around
Greg Kroah-Hartman
maintainerPATCH 159/373 nfs: move nfs_fhandle_hash to common include file
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit e59fb6749ed833deee5b3cfd7e89925296d41f49 ]
lockd needs to be able to hash filehandles for tracepoints. Move the nfs_fhandle_hash() helper to a common nfs include file.
Stable-dep-of: cd35b6cb4664 ("nfs: add missing selections of CONFIG_CRC32")
--- fs/nfs/internal.h | 15 --------------- include/linux/nfs.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-)
fs/nfs/internal.h +0 -15
@@ -769,27 +769,12 @@ u64 nfs_timespec_to_change_attr(const struct timespec64 *ts) }#ifdef CONFIG_CRC32 -/** -* nfs_fhandle_hash - calculate the crc32 hash for the filehandle -* @fh - pointer to filehandle -* -* returns a crc32 hash for the filehandle that is compatible with -* the one displayed by "wireshark". -*/ -static inline u32 nfs_fhandle_hash (const struct nfs_fh *fh) -{ -return ~crc32_le (0xFFFFFFFF , &fh->data[0 ], fh->size); -}static inline u32 nfs_stateid_hash (const nfs4_stateid *stateid) {return ~crc32_le (0xFFFFFFFF , &stateid->other[0 ],NFS4_STATEID_OTHER_SIZE ); }#else -static inline u32 nfs_fhandle_hash (const struct nfs_fh *fh) -{ -return 0 ; -}static inline u32 nfs_stateid_hash (nfs4_stateid *stateid) {return 0 ;
include/linux/nfs.h +20 -0
@@ -10,6 +10,7 @@#include <linux/sunrpc/msg_prot.h> #include <linux/string.h> +#include <linux/crc32.h> #include <uapi/linux/nfs.h> /*
@@ -44,4 +45,23 @@ enum nfs3_stable_how {/* used by direct.c to mark verf as invalid */ NFS_INVALID_STABLE_HOW =-1 }; + +#ifdef CONFIG_CRC32 +/** +* nfs_fhandle_hash - calculate the crc32 hash for the filehandle +* @fh - pointer to filehandle +* +* returns a crc32 hash for the filehandle that is compatible with +* the one displayed by "wireshark". +*/ +static inline u32 nfs_fhandle_hash (const struct nfs_fh *fh) +{ +return ~crc32_le (0xFFFFFFFF , &fh->data[0 ], fh->size); +} +#else /* CONFIG_CRC32 */ +static inline u32 nfs_fhandle_hash (const struct nfs_fh *fh) +{ +return 0 ; +} +#endif /* CONFIG_CRC32 */ #endif /* _LINUX_NFS_H */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 160/373 nfs: add missing selections of CONFIG_CRC32
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
[ Upstream commit cd35b6cb46649750b7dbd0df0e2d767415d8917b ]
nfs.ko, nfsd.ko, and lockd.ko all use crc32_le(), which is available only when CONFIG_CRC32 is enabled. But the only NFS kconfig option that selected CONFIG_CRC32 was CONFIG_NFS_DEBUG, which is client-specific and did not actually guard the use of crc32_le() even on the client.
The code worked around this bug by only actually calling crc32_le() when CONFIG_CRC32 is built-in, instead hard-coding '0' in other cases. This avoided randconfig build errors, and in real kernels the fallback code was unlikely to be reached since CONFIG_CRC32 is 'default y'. But, this really needs to just be done properly, especially now that I'm planning to update CONFIG_CRC32 to not be 'default y'.
Therefore, make CONFIG_NFS_FS, CONFIG_NFSD, and CONFIG_LOCKD select CONFIG_CRC32. Then remove the fallback code that becomes unnecessary, as well as the selection of CONFIG_CRC32 from CONFIG_NFS_DEBUG.
--- fs/Kconfig | 1 + fs/nfs/Kconfig | 2 +- fs/nfs/internal.h | 7 ------- fs/nfs/nfs4session.h | 4 ---- fs/nfsd/Kconfig | 1 + fs/nfsd/nfsfh.h | 7 ------- include/linux/nfs.h | 7 ------- 7 files changed, 3 insertions(+), 26 deletions(-)
fs/Kconfig +1 -0
@@ -340,6 +340,7 @@ config GRACE_PERIOD config LOCKD tristate depends on FILE_LOCKING + select CRC32 select GRACE_PERIOD config LOCKD_V4
fs/nfs/Kconfig +1 -1
@@ -2,6 +2,7 @@ config NFS_FS tristate "NFS client support" depends on INET && FILE_LOCKING && MULTIUSER + select CRC32 select LOCKD select SUNRPC select NFS_ACL_SUPPORT if NFS_V3_ACL
@@ -194,7 +195,6 @@ config NFS_USE_KERNEL_DNS config NFS_DEBUG bool depends on NFS_FS && SUNRPC_DEBUG - select CRC32 default y config NFS_DISABLE_UDP_SUPPORT
fs/nfs/internal.h +0 -7
@@ -768,18 +768,11 @@ u64 nfs_timespec_to_change_attr(const struct timespec64 *ts)return ((u64 )ts->tv_sec <<30 ) + ts->tv_nsec; } -#ifdef CONFIG_CRC32 static inline u32 nfs_stateid_hash (const nfs4_stateid *stateid) {return ~crc32_le (0xFFFFFFFF , &stateid->other[0 ],NFS4_STATEID_OTHER_SIZE ); } -#else -static inline u32 nfs_stateid_hash (nfs4_stateid *stateid) -{ -return 0 ; -} -#endif static inline bool nfs_error_is_fatal (int err) {
fs/nfs/nfs4session.h +0 -4
@@ -147,16 +147,12 @@ static inline void nfs4_copy_sessionid(struct nfs4_sessionid *dst, memcpy(dst->data, src->data, NFS4_MAX_SESSIONID_LEN); } -#ifdef CONFIG_CRC32 /* * nfs_session_id_hash - calculate the crc32 hash for the session id * @session - pointer to session */ #define nfs_session_id_hash (sess_id) \ (~crc32_le(0xFFFFFFFF, &(sess_id)->data[0], sizeof((sess_id)->data))) -#else -#define nfs_session_id_hash (session) (0) -#endif #else /* defined(CONFIG_NFS_V4_1) */ static inline int nfs4_init_session (struct nfs_client *clp)
fs/nfsd/Kconfig +1 -0
@@ -4,6 +4,7 @@ config NFSD depends on INET depends on FILE_LOCKING depends on FSNOTIFY + select CRC32 select LOCKD select SUNRPC select EXPORTFS
fs/nfsd/nfsfh.h +0 -7
@@ -263,7 +263,6 @@ static inline bool fh_fsid_match(const struct knfsd_fh *fh1,return true; } -#ifdef CONFIG_CRC32 /** * knfsd_fh_hash - calculate the crc32 hash for the filehandle * @fh - pointer to filehandle
@@ -275,12 +274,6 @@ static inline u32 knfsd_fh_hash(const struct knfsd_fh *fh) {return ~crc32_le (0xFFFFFFFF , fh->fh_raw, fh->fh_size); } -#else -static inline u32 knfsd_fh_hash (const struct knfsd_fh *fh) -{ -return 0 ; -} -#endif /** * fh_clear_pre_post_attrs - Reset pre/post attributes
include/linux/nfs.h +0 -7
@@ -46,7 +46,6 @@ enum nfs3_stable_how { NFS_INVALID_STABLE_HOW = -1 }; -#ifdef CONFIG_CRC32 /** * nfs_fhandle_hash - calculate the crc32 hash for the filehandle * @fh - pointer to filehandle
@@ -58,10 +57,4 @@ static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh) {return ~crc32_le (0xFFFFFFFF , &fh->data[0 ], fh->size); } -#else /* CONFIG_CRC32 */ -static inline u32 nfs_fhandle_hash (const struct nfs_fh *fh) -{ -return 0 ; -} -#endif /* CONFIG_CRC32 */ #endif /* _LINUX_NFS_H */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 161/373 nfsd: decrease sc_count directly if fail to queue dl_recall
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Lingfeng <[email protected]>
[ Upstream commit a1d14d931bf700c1025db8c46d6731aa5cf440f9 ]
A deadlock warning occurred when invoking nfs4_put_stid following a failed dl_recall queue operation:
T1 T2
nfs4_laundromat
nfs4_get_client_reaplist
nfs4_anylock_blockers__break_lease
spin_lock // ctx->flc_lock
spin_lock // clp->cl_lock
nfs4_lockowner_has_blockers
locks_owner_has_blockers
spin_lock // flctx->flc_lock
nfsd_break_deleg_cb
nfsd_break_one_deleg
nfs4_put_stid
refcount_dec_and_lock
spin_lock // clp->cl_lockWhen a file is opened, an nfs4_delegation is allocated with sc_count initialized to 1, and the file_lease holds a reference to the delegation. The file_lease is then associated with the file through kernel_setlease.
The disassociation is performed in nfsd4_delegreturn via the following call chain:nfsd4_delegreturn --> destroy_delegation --> destroy_unhashed_deleg --> nfs4_unlock_deleg_lease --> kernel_setlease --> generic_delete_lease The corresponding sc_count reference will be released after this disassociation.
Since nfsd_break_one_deleg executes while holding the flc_lock, the disassociation process becomes blocked when attempting to acquire flc_lock in generic_delete_lease. This means:
1) sc_count in nfsd_break_one_deleg will not be decremented to 0;
2) The nfs4_put_stid called by nfsd_break_one_deleg will not attempt to acquire cl_lock;
3) Consequently, no deadlock condition is created.
Given that sc_count in nfsd_break_one_deleg remains non-zero, we can safely perform refcount_dec on sc_count directly. This approach effectively avoids triggering deadlock warnings.
--- fs/nfsd/nfs4state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -1
@@ -4944,7 +4944,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp) queued =nfsd4_run_cb (&dp->dl_recall);WARN_ON_ONCE (!queued);if (!queued) -nfs4_put_stid (&dp->dl_stid); +refcount_dec (&dp->dl_stid.sc_count); }/* Called from break_lease() with flc_lock held. */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 162/373 btrfs: correctly escape subvol in btrfs_show_options()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Kimmel <[email protected]>
commit dc08c58696f8555e4a802f1f23c894a330d80ab7 upstream.
Currently, displaying the btrfs subvol mount option doesn't escape ','. This makes parsing /proc/self/mounts and /proc/self/mountinfo ambiguous for subvolume names that contain commas. The text after the comma could be mistaken for another option (think "subvol=foo,ro", where ro is actually part of the subvolumes name).
Replace the manual escape characters list with a call to seq_show_option(). Thanks to Calvin Walton for suggesting this approach.
--- fs/btrfs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/super.c +1 -2
@@ -1559,8 +1559,7 @@ static int btrfs_show_options(struct seq subvol_name =btrfs_get_subvol_name_from_objectid (info,BTRFS_I (d_inode (dentry))->root->root_key.objectid);if (!IS_ERR (subvol_name)) { -seq_puts (seq,",subvol=" ); -seq_escape (seq, subvol_name," \t\n\\" ); +seq_show_option (seq,"subvol" , subvol_name);kfree (subvol_name); }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 163/373 crypto: caam/qi - Fix drv_ctx refcount bug
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit b7b39df7e710b0068356e4c696af07aa10e2cd3d upstream.
Ensure refcount is raised before request is enqueued since it could be dequeued before the call returns.
--- drivers/crypto/caam/qi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/caam/qi.c +3 -3
@@ -115,12 +115,12 @@ int caam_qi_enqueue(struct device *qidevqm_fd_addr_set64 (&fd, addr); do { + refcount_inc(&req->drv_ctx->refcnt); ret = qman_enqueue(req->drv_ctx->req_fq, &fd); - if (likely(!ret)) { - refcount_inc(&req->drv_ctx->refcnt); + if (likely(!ret)) return 0; - } + refcount_dec(&req->drv_ctx->refcnt); if (ret != -EBUSY) break; num_retries++;
Greg Kroah-Hartman
maintainerPATCH 164/373 hfs/hfsplus: fix slab-out-of-bounds in hfs_bnode_read_key
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasiliy Kovalev <[email protected]>
commit bb5e07cb927724e0b47be371fa081141cfb14414 upstream.
Syzbot reported an issue in hfs subsystem:
BUG: KASAN: slab-out-of-bounds in memcpy_from_page include/linux/highmem.h:423 [inline] BUG: KASAN: slab-out-of-bounds in hfs_bnode_read fs/hfs/bnode.c:35 [inline] BUG: KASAN: slab-out-of-bounds in hfs_bnode_read_key+0x314/0x450 fs/hfs/bnode.c:70 Write of size 94 at addr ffff8880123cd100 by task syz-executor237/5102 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189 __asan_memcpy+0x40/0x70 mm/kasan/shadow.c:106 memcpy_from_page include/linux/highmem.h:423 [inline] hfs_bnode_read fs/hfs/bnode.c:35 [inline] hfs_bnode_read_key+0x314/0x450 fs/hfs/bnode.c:70 hfs_brec_insert+0x7f3/0xbd0 fs/hfs/brec.c:159 hfs_cat_create+0x41d/0xa50 fs/hfs/catalog.c:118 hfs_mkdir+0x6c/0xe0 fs/hfs/dir.c:232 vfs_mkdir+0x2f9/0x4f0 fs/namei.c:4257 do_mkdirat+0x264/0x3a0 fs/namei.c:4280 __do_sys_mkdir fs/namei.c:4300 [inline] __se_sys_mkdir fs/namei.c:4298 [inline] __x64_sys_mkdir+0x6c/0x80 fs/namei.c:4298 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fbdd6057a99
Add a check for key length in hfs_bnode_read_key to prevent out-of-bounds memory access. If the key length is invalid, the key buffer is cleared, improving stability and reliability.
--- fs/hfs/bnode.c | 6 ++++++ fs/hfsplus/bnode.c | 6 ++++++ 2 files changed, 12 insertions(+)
fs/hfs/bnode.c +6 -0
@@ -70,6 +70,12 @@ void hfs_bnode_read_key(struct hfs_bnodeelse key_len = tree->max_key_len +1 ; +if (key_len >sizeof (hfs_btree_key) || key_len <1 ) { +memset (key,0 ,sizeof (hfs_btree_key)); +pr_err ("hfs: Invalid key length: %d\n" , key_len); +return ; + } +hfs_bnode_read (node, key, off, key_len); }
fs/hfsplus/bnode.c +6 -0
@@ -69,6 +69,12 @@ void hfs_bnode_read_key(struct hfs_bnodeelse key_len = tree->max_key_len +2 ; +if (key_len >sizeof (hfsplus_btree_key) || key_len <1 ) { +memset (key,0 ,sizeof (hfsplus_btree_key)); +pr_err ("hfsplus: Invalid key length: %d\n" , key_len); +return ; + } +hfs_bnode_read (node, key, off, key_len); }
Greg Kroah-Hartman
maintainerPATCH 165/373 i2c: cros-ec-tunnel: defer probe if parent EC is not present
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
commit 424eafe65647a8d6c690284536e711977153195a upstream.
When i2c-cros-ec-tunnel and the EC driver are built-in, the EC parent device will not be found, leading to NULL pointer dereference.
That can also be reproduced by unbinding the controller driver and then loading i2c-cros-ec-tunnel module (or binding the device).
[ 271.991245] BUG: kernel NULL pointer dereference, address: 0000000000000058 [ 271.998215] #PF: supervisor read access in kernel mode [ 272.003351] #PF: error_code(0x0000) - not-present page [ 272.008485] PGD 0 P4D 0 [ 272.011022] Oops: Oops: 0000 [#1] SMP NOPTI [ 272.015207] CPU: 0 UID: 0 PID: 3859 Comm: insmod Tainted: G S 6.15.0-rc1-00004-g44722359ed83 #30 PREEMPT(full) 3c7fb39a552e7d949de2ad921a7d6588d3a4fdc5 [ 272.030312] Tainted: [S]=CPU_OUT_OF_SPEC [ 272.034233] Hardware name: HP Berknip/Berknip, BIOS Google_Berknip.13434.356.0 05/17/2021 [ 272.042400] RIP: 0010:ec_i2c_probe+0x2b/0x1c0 [i2c_cros_ec_tunnel] [ 272.048577] Code: 1f 44 00 00 41 57 41 56 41 55 41 54 53 48 83 ec 10 65 48 8b 05 06 a0 6c e7 48 89 44 24 08 4c 8d 7f 10 48 8b 47 50 4c 8b 60 78 <49> 83 7c 24 58 00 0f 84 2f 01 00 00 48 89 fb be 30 06 00 00 4c 9 [ 272.067317] RSP: 0018:ffffa32082a03940 EFLAGS: 00010282 [ 272.072541] RAX: ffff969580b6a810 RBX: ffff969580b68c10 RCX: 0000000000000000 [ 272.079672] RDX: 0000000000000000 RSI: 0000000000000282 RDI: ffff969580b68c00 [ 272.086804] RBP: 00000000fffffdfb R08: 0000000000000000 R09: 0000000000000000 [ 272.093936] R10: 0000000000000000 R11: ffffffffc0600000 R12: 0000000000000000 [ 272.101067] R13: ffffffffa666fbb8 R14: ffffffffc05b5528 R15: ffff969580b68c10 [ 272.108198] FS: 00007b930906fc40(0000) GS:ffff969603149000(0000) knlGS:0000000000000000 [ 272.116282] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 272.122024] CR2: 0000000000000058 CR3: 000000012631c000 CR4: 00000000003506f0 [ 272.129155] Call Trace: [ 272.131606] <TASK> [ 272.133709] ? acpi_dev_pm_attach+0xdd/0x110 [ 272.137985] platform_probe+0x69/0xa0 [ 272.141652] really_probe+0x152/0x310 [ 272.145318] __driver_probe_device+0x77/0x110 [ 272.149678] driver_probe_device+0x1e/0x190 [ 272.153864] __driver_attach+0x10b/0x1e0 [ 272.157790] ? driver_attach+0x20/0x20 [ 272.161542] bus_for_each_dev+0x107/0x150 [ 272.165553] bus_add_driver+0x15d/0x270 [ 272.169392] driver_register+0x65/0x110 [ 272.173232] ? cleanup_module+0xa80/0xa80 [i2c_cros_ec_tunnel 3a00532f3f4af4a9eade753f86b0f8dd4e4e5698] [ 272.182617] do_one_initcall+0x110/0x350 [ 272.186543] ? security_kernfs_init_security+0x49/0xd0 [ 272.191682] ? __kernfs_new_node+0x1b9/0x240 [ 272.195954] ? security_kernfs_init_security+0x49/0xd0 [ 272.201093] ? __kernfs_new_node+0x1b9/0x240 [ 272.205365] ? kernfs_link_sibling+0x105/0x130 [ 272.209810] ? kernfs_next_descendant_post+0x1c/0xa0 [ 272.214773] ? kernfs_activate+0x57/0x70 [ 272.218699] ? kernfs_add_one+0x118/0x160 [ 272.222710] ? __kernfs_create_file+0x71/0xa0 [ 272.227069] ? sysfs_add_bin_file_mode_ns+0xd6/0x110 [ 272.232033] ? internal_create_group+0x453/0x4a0 [ 272.236651] ? __vunmap_range_noflush+0x214/0x2d0 [ 272.241355] ? __free_frozen_pages+0x1dc/0x420 [ 272.245799] ? free_vmap_area_noflush+0x10a/0x1c0 [ 272.250505] ? load_module+0x1509/0x16f0 [ 272.254431] do_init_module+0x60/0x230 [ 272.258181] __se_sys_finit_module+0x27a/0x370 [ 272.262627] do_syscall_64+0x6a/0xf0 [ 272.266206] ? do_syscall_64+0x76/0xf0 [ 272.269956] ? irqentry_exit_to_user_mode+0x79/0x90 [ 272.274836] entry_SYSCALL_64_after_hwframe+0x55/0x5d [ 272.279887] RIP: 0033:0x7b9309168d39 [ 272.283466] Code: 5b 41 5c 5d c3 66 2e 0f 1f 84 00 00 00 00 00 66 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 8b 0d af 40 0c 00 f7 d8 64 89 01 8 [ 272.302210] RSP: 002b:00007fff50f1a288 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 272.309774] RAX: ffffffffffffffda RBX: 000058bf9b50f6d0 RCX: 00007b9309168d39 [ 272.316905] RDX: 0000000000000000 RSI: 000058bf6c103a77 RDI: 0000000000000003 [ 272.324036] RBP: 00007fff50f1a2e0 R08: 00007fff50f19218 R09: 0000000021ec4150 [ 272.331166] R10: 000058bf9b50f7f0 R11: 0000000000000246 R12: 0000000000000000 [ 272.338296] R13: 00000000fffffffe R14: 0000000000000000 R15: 000058bf6c103a77 [ 272.345428] </TASK> [ 272.347617] Modules linked in: i2c_cros_ec_tunnel(+) [ 272.364585] gsmi: Log Shutdown Reason 0x03
Returning -EPROBE_DEFER will allow the device to be bound once the controller is bound, in the case of built-in drivers.
--- drivers/i2c/busses/i2c-cros-ec-tunnel.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/i2c/busses/i2c-cros-ec-tunnel.c +3 -0
@@ -247,6 +247,9 @@ static int ec_i2c_probe(struct platform_u32 remote_bus;int err; +if (!ec) +return dev_err_probe (dev, -EPROBE_DEFER ,"couldn't find parent EC device\n" ); +if (!ec->cmd_xfer) {dev_err (dev,"Missing sendrecv\n" );return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 166/373 isofs: Prevent the use of too small fid
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
commit 0405d4b63d082861f4eaff9d39c78ee9dc34f845 upstream.
syzbot reported a slab-out-of-bounds Read in isofs_fh_to_parent. [1]
The handle_bytes value passed in by the reproducing program is equal to 12. In handle_to_path(), only 12 bytes of memory are allocated for the structure file_handle->f_handle member, which causes an out-of-bounds access when accessing the member parent_block of the structure isofs_fid in isofs, because accessing parent_block requires at least 16 bytes of f_handle. Here, fh_len is used to indirectly confirm that the value of handle_bytes is greater than 3 before accessing parent_block.
[1]
BUG: KASAN: slab-out-of-bounds in isofs_fh_to_parent+0x1b8/0x210 fs/isofs/export.c:183 Read of size 4 at addr ffff0000cc030d94 by task syz-executor215/6466 CPU: 1 UID: 0 PID: 6466 Comm: syz-executor215 Not tainted 6.14.0-rc7-syzkaller-ga2392f333575 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 Call trace: show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:466 (C) __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0x198/0x550 mm/kasan/report.c:521 kasan_report+0xd8/0x138 mm/kasan/report.c:634 __asan_report_load4_noabort+0x20/0x2c mm/kasan/report_generic.c:380 isofs_fh_to_parent+0x1b8/0x210 fs/isofs/export.c:183 exportfs_decode_fh_raw+0x2dc/0x608 fs/exportfs/expfs.c:523 do_handle_to_path+0xa0/0x198 fs/fhandle.c:257 handle_to_path fs/fhandle.c:385 [inline] do_handle_open+0x8cc/0xb8c fs/fhandle.c:403 __do_sys_open_by_handle_at fs/fhandle.c:443 [inline] __se_sys_open_by_handle_at fs/fhandle.c:434 [inline] __arm64_sys_open_by_handle_at+0x80/0x94 fs/fhandle.c:434 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:49 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:744 el0t_64_sync_handler+0x84/0x108 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:600 Allocated by task 6466: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_alloc_info+0x40/0x50 mm/kasan/generic.c:562 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:394 kasan_kmalloc include/linux/kasan.h:260 [inline] __do_kmalloc_node mm/slub.c:4294 [inline] __kmalloc_noprof+0x32c/0x54c mm/slub.c:4306 kmalloc_noprof include/linux/slab.h:905 [inline] handle_to_path fs/fhandle.c:357 [inline] do_handle_open+0x5a4/0xb8c fs/fhandle.c:403 __do_sys_open_by_handle_at fs/fhandle.c:443 [inline] __se_sys_open_by_handle_at fs/fhandle.c:434 [inline] __arm64_sys_open_by_handle_at+0x80/0x94 fs/fhandle.c:434 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:49 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:132 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:151 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:744 el0t_64_sync_handler+0x84/0x108 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:600
--- fs/isofs/export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/isofs/export.c +1 -1
@@ -180,7 +180,7 @@ static struct dentry *isofs_fh_to_parentreturn NULL ;return isofs_export_iget (sb, - fh_len >2 ? ifid->parent_block :0 , + fh_len >3 ? ifid->parent_block :0 , ifid->parent_offset, fh_len >4 ? ifid->parent_generation :0 ); }
Greg Kroah-Hartman
maintainerPATCH 167/373 loop: properly send KOBJ_CHANGED uevent for disk device
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit e7bc0010ceb403d025100698586c8e760921d471 upstream.
The original commit message and the wording "uncork" in the code comment indicate that it is expected that the suppressed event instances are automatically sent after unsuppressing.
This is not the case, instead they are discarded.
In effect this means that no "changed" events are emitted on the device itself by default.
While each discovered partition does trigger a changed event on the device, devices without partitions don't have any event emitted.
This makes udev miss the device creation and prompted workarounds in userspace. See the linked util-linux/losetup bug.
Explicitly emit the events and drop the confusingly worded comments.
--- drivers/block/loop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/loop.c +2 -2
@@ -797,8 +797,8 @@ static int loop_change_fd(struct loop_de error =0 ; done: -/* enable and uncork uevent now that we are done */ dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 ); +kobject_uevent (&disk_to_dev (lo->lo_disk)->kobj,KOBJ_CHANGE );return error; out_err:
@@ -1316,8 +1316,8 @@ static int loop_configure(struct loop_deif (partscan) lo->lo_disk->flags &= ~GENHD_FL_NO_PART ; -/* enable and uncork uevent now that we are done */ dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 ); +kobject_uevent (&disk_to_dev (lo->lo_disk)->kobj,KOBJ_CHANGE );loop_global_unlock (lo, is_loop);if (partscan)
Greg Kroah-Hartman
maintainerPATCH 168/373 loop: LOOP_SET_FD: send uevents for partitions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit 0dba7a05b9e47d8b546399117b0ddf2426dc6042 upstream.
Remove the suppression of the uevents before scanning for partitions. The partitions inherit their suppression settings from their parent device, which lead to the uevents being dropped.
This is similar to the same changes for LOOP_CONFIGURE done in commit bb430b694226 ("loop: LOOP_CONFIGURE: send uevents for partitions").
--- drivers/block/loop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/loop.c +2 -1
@@ -792,12 +792,12 @@ static int loop_change_fd(struct loop_de* dependency. */ fput (old_file); +dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 );if (partscan)loop_reread_partitions (lo); error =0 ; done: -dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 );kobject_uevent (&disk_to_dev (lo->lo_disk)->kobj,KOBJ_CHANGE );return error;
@@ -805,6 +805,7 @@ out_err:loop_global_unlock (lo, is_loop); out_putf:fput (file); +dev_set_uevent_suppress (disk_to_dev (lo->lo_disk),0 ); goto done; }
Greg Kroah-Hartman
maintainerPATCH 169/373 mm/gup: fix wrongly calculated returned value in fault_in_safe_writeable()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baoquan He <[email protected]>
commit 8c03ebd7cdc06bd0d2fecb4d1a609ef1dbb7d0aa upstream.
Not like fault_in_readable() or fault_in_writeable(), in fault_in_safe_writeable() local variable 'start' is increased page by page to loop till the whole address range is handled. However, it mistakenly calculates the size of the handled range with 'uaddr - start'.
Fix it here.
Andreas said:
: In gfs2, fault_in_iov_iter_writeable() is used in
: gfs2_file_direct_read() and gfs2_file_read_iter(), so this potentially : affects buffered as well as direct reads. This bug could cause those : gfs2 functions to spin in a loop.
--- mm/gup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/gup.c +2 -2
@@ -1768,8 +1768,8 @@ size_t fault_in_safe_writeable(const cha }while (start != end);mmap_read_unlock (mm); -if (size > (unsigned long )uaddr - start) -return size - ((unsigned long )uaddr - start); +if (size > start - (unsigned long )uaddr) +return size - (start - (unsigned long )uaddr);return 0 ; }EXPORT_SYMBOL (fault_in_safe_writeable);
Greg Kroah-Hartman
maintainerPATCH 170/373 riscv: Avoid fortify warning in syscall_get_arguments()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit adf53771a3123df99ca26e38818760fbcf5c05d0 upstream.
When building with CONFIG_FORTIFY_SOURCE=y and W=1, there is a warning because of the memcpy() in syscall_get_arguments():
In file included from include/linux/string.h:392,
from include/linux/bitmap.h:13,
from include/linux/cpumask.h:12,
from arch/riscv/include/asm/processor.h:55,
from include/linux/sched.h:13,
from kernel/ptrace.c:13:
In function 'fortify_memcpy_chk',
inlined from 'syscall_get_arguments.isra' at arch/riscv/include/asm/syscall.h:66:2:
include/linux/fortify-string.h:580:25: error: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
580 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
The fortified memcpy() routine enforces that the source is not overread and the destination is not overwritten if the size of either field and the size of the copy are known at compile time. The memcpy() in syscall_get_arguments() intentionally overreads from a1 to a5 in 'struct pt_regs' but this is bigger than the size of a1.
Normally, this could be solved by wrapping a1 through a5 with struct_group() but there was already a struct_group() applied to these members in commit bba547810c66 ("riscv: tracing: Fix __write_overflow_field in ftrace_partial_regs()").
Just avoid memcpy() altogether and write the copying of args from regs manually, which clears up the warning at the expense of three extra lines of code.
--- arch/riscv/include/asm/syscall.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/riscv/include/asm/syscall.h +5 -2
@@ -60,8 +60,11 @@ static inline void syscall_get_arguments unsigned long *args) { args[0 ] = regs->orig_a0; - args++; -memcpy (args, ®s->a1,5 *sizeof (args[0 ])); + args[1 ] = regs->a1; + args[2 ] = regs->a2; + args[3 ] = regs->a3; + args[4 ] = regs->a4; + args[5 ] = regs->a5; } static inline void syscall_set_arguments(struct task_struct *task,
Greg Kroah-Hartman
maintainerPATCH 171/373 tracing: Fix filter string testing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit a8c5b0ed89a3f2c81c6ae0b041394e6eea0e7024 upstream.
The filter string testing uses strncpy_from_kernel/user_nofault() to retrieve the string to test the filter against. The if() statement was incorrect as it considered 0 as a fault, when it is only negative that it faulted.
Running the following commands:
# cd /sys/kernel/tracing # echo "filename.ustring ~ \"/proc*\"" > events/syscalls/sys_enter_openat/filter # echo 1 > events/syscalls/sys_enter_openat/enable # ls /proc/$$/maps # cat trace
Would produce nothing, but with the fix it will produce something like:
ls-1192 [007] ..... 8169.828333: sys_openat(dfd: ffffffffffffff9c, filename: 7efc18359904, flags: 80000, mode: 0)
--- kernel/trace/trace_events_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_events_filter.c +2 -2
@@ -676,7 +676,7 @@ static __always_inline char *test_string kstr = ubuf->buffer;/* For safety, do not trust the string pointer */ -if (!strncpy_from_kernel_nofault (kstr, str,USTRING_BUF_SIZE )) +if (strncpy_from_kernel_nofault (kstr, str,USTRING_BUF_SIZE ) <0 )return NULL ;return kstr; }
@@ -695,7 +695,7 @@ static __always_inline char *test_ustrin/* user space address? */ ustr = (char __user *)str; -if (!strncpy_from_user_nofault (kstr, ustr,USTRING_BUF_SIZE )) +if (strncpy_from_user_nofault (kstr, ustr,USTRING_BUF_SIZE ) <0 )return NULL ;return kstr;
Greg Kroah-Hartman
maintainerPATCH 172/373 virtiofs: add filesystem context source name check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiangsheng Hou <[email protected]>
commit a94fd938df2b1628da66b498aa0eeb89593bc7a2 upstream.
In certain scenarios, for example, during fuzz testing, the source name may be NULL, which could lead to a kernel panic. Therefore, an extra check for the source name should be added.
--- fs/fuse/virtio_fs.c | 3 +++ 1 file changed, 3 insertions(+)
fs/fuse/virtio_fs.c +3 -0
@@ -1431,6 +1431,9 @@ static int virtio_fs_get_tree(struct fs_unsigned int virtqueue_size;int err = -EIO ; +if (!fsc->source) +return invalf (fsc,"No source specified" ); +/* This gets a reference on virtio_fs object. This ptr gets installed * in fc->iq->priv. Once fuse_conn is going away, it calls ->put() * to drop the reference to this object.
Greg Kroah-Hartman
maintainerPATCH 173/373 perf/x86/intel: Allow to update user space GPRs from PEBS records
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dapeng Mi <[email protected]>
commit 71dcc11c2cd9e434c34a63154ecadca21c135ddd upstream.
Currently when a user samples user space GPRs (--user-regs option) with PEBS, the user space GPRs actually always come from software PMI instead of from PEBS hardware. This leads to the sampled GPRs to possibly be inaccurate for single PEBS record case because of the skid between counter overflow and GPRs sampling on PMI.
For the large PEBS case, it is even worse. If user sets the exclude_kernel attribute, large PEBS would be used to sample user space GPRs, but since PEBS GPRs group is not really enabled, it leads to all samples in the large PEBS record to share the same piece of user space GPRs, like this reproducer shows:
$ perf record -e branches:pu --user-regs=ip,ax -c 100000 ./foo $ perf report -D | grep "AX"
.... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead .... AX 0x000000003a0d4ead
So enable GPRs group for user space GPRs sampling and prioritize reading GPRs from PEBS. If the PEBS sampled GPRs is not user space GPRs (single PEBS record case), perf_sample_regs_user() modifies them to user space GPRs.
[ mingo: Clarified the changelog. ]
--- arch/x86/events/intel/ds.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/x86/events/intel/ds.c +5 -3
@@ -1101,8 +1101,10 @@ static u64 pebs_update_adaptive_cfg(stru* + precise_ip < 2 for the non event IP * + For RTM TSX weight we need GPRs for the abort code. */ - gprs = (sample_type &PERF_SAMPLE_REGS_INTR ) && - (attr->sample_regs_intr &PEBS_GP_REGS ); + gprs = ((sample_type &PERF_SAMPLE_REGS_INTR ) && + (attr->sample_regs_intr &PEBS_GP_REGS )) || + ((sample_type &PERF_SAMPLE_REGS_USER ) && + (attr->sample_regs_user &PEBS_GP_REGS )); tsx_weight = (sample_type & PERF_SAMPLE_WEIGHT_TYPE) && ((attr->config & INTEL_ARCH_EVENT_MASK) ==
@@ -1701,7 +1703,7 @@ static void setup_pebs_adaptive_sample_d regs->flags &= ~PERF_EFLAGS_EXACT ; } -if (sample_type &PERF_SAMPLE_REGS_INTR ) +if (sample_type & (PERF_SAMPLE_REGS_INTR |PERF_SAMPLE_REGS_USER ))adaptive_pebs_save_regs (regs, gprs); }
Greg Kroah-Hartman
maintainerPATCH 174/373 perf/x86/intel/uncore: Fix the scale of IIO free running counters on SNR
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 96a720db59ab330c8562b2437153faa45dac705f upstream.
There was a mistake in the SNR uncore spec. The counter increments for every 32 bytes of data sent from the IO agent to the SOC, not 4 bytes which was documented in the spec.
The event list has been updated:
"EventName": "UNC_IIO_BANDWIDTH_IN.PART0_FREERUN", "BriefDescription": "Free running counter that increments for every 32
bytes of data sent from the IO agent to the SOC",
Update the scale of the IIO bandwidth in free running counters as well.
--- arch/x86/events/intel/uncore_snbep.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/x86/events/intel/uncore_snbep.c +8 -8
@@ -4656,28 +4656,28 @@ static struct uncore_event_desc snr_uncoINTEL_UNCORE_EVENT_DESC (ioclk,"event=0xff,umask=0x10" ),/* Free-Running IIO BANDWIDTH IN Counters */ INTEL_UNCORE_EVENT_DESC (bw_in_port0,"event=0xff,umask=0x20" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port0.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port0.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port1,"event=0xff,umask=0x21" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port1.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port1.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port2,"event=0xff,umask=0x22" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port2.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port2.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port3,"event=0xff,umask=0x23" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port3.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port3.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port4,"event=0xff,umask=0x24" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port4.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port4.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port5,"event=0xff,umask=0x25" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port5.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port5.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port6,"event=0xff,umask=0x26" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port6.scale,"3.0517578125e-5" ),INTEL_UNCORE_EVENT_DESC (bw_in_port6.unit,"MiB" ),INTEL_UNCORE_EVENT_DESC (bw_in_port7,"event=0xff,umask=0x27" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.scale,"3.814697266e-6" ), +INTEL_UNCORE_EVENT_DESC (bw_in_port7.scale,"3.0517578125e-5" ), INTEL_UNCORE_EVENT_DESC(bw_in_port7.unit, "MiB"), { /* end: all zeroes */ }, };
Greg Kroah-Hartman
maintainerPATCH 175/373 perf/x86/intel/uncore: Fix the scale of IIO free running counters on ICX
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 32c7f1150225694d95a51110a93be25db03bb5db upstream.
There was a mistake in the ICX uncore spec too. The counter increments for every 32 bytes rather than 4 bytes.
The same as SNR, there are 1 ioclk and 8 IIO bandwidth in free running counters. Reuse the snr_uncore_iio_freerunning_events().
--- arch/x86/events/intel/uncore_snbep.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-)
arch/x86/events/intel/uncore_snbep.c +1 -32
@@ -5250,37 +5250,6 @@ static struct freerunning_counters icx_i [ICX_IIO_MSR_BW_IN] = { 0xaa0, 0x1, 0x10, 8, 48, icx_iio_bw_freerunning_box_offsets }, }; -static struct uncore_event_desc icx_uncore_iio_freerunning_events[] = { -/* Free-Running IIO CLOCKS Counter */ -INTEL_UNCORE_EVENT_DESC (ioclk,"event=0xff,umask=0x10" ), -/* Free-Running IIO BANDWIDTH IN Counters */ -INTEL_UNCORE_EVENT_DESC (bw_in_port0,"event=0xff,umask=0x20" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1,"event=0xff,umask=0x21" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2,"event=0xff,umask=0x22" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3,"event=0xff,umask=0x23" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4,"event=0xff,umask=0x24" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5,"event=0xff,umask=0x25" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6,"event=0xff,umask=0x26" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7,"event=0xff,umask=0x27" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.unit,"MiB" ), - {/* end: all zeroes */ }, -}; -static struct intel_uncore_type icx_uncore_iio_free_running = { .name ="iio_free_running" , .num_counters =9 ,
@@ -5288,7 +5257,7 @@ static struct intel_uncore_type icx_unco .num_freerunning_types = ICX_IIO_FREERUNNING_TYPE_MAX, .freerunning = icx_iio_freerunning, .ops = &skx_uncore_iio_freerunning_ops, - .event_descs = icx_uncore_iio_freerunning_events, + .event_descs = snr_uncore_iio_freerunning_events, .format_group = &skx_uncore_iio_freerunning_format_group, };
Greg Kroah-Hartman
maintainerPATCH 176/373 perf/x86/intel/uncore: Fix the scale of IIO free running counters on SPR
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 506f981ab40f0b03a11a640cfd77f48b09aff330 upstream.
The scale of IIO bandwidth in free running counters is inherited from the ICX. The counter increments for every 32 bytes rather than 4 bytes.
The IIO bandwidth out free running counters don't increment with a consistent size. The increment depends on the requested size. It's impossible to find a fixed increment. Remove it from the event_descs.
--- arch/x86/events/intel/uncore_snbep.c | 58 ----------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-)
arch/x86/events/intel/uncore_snbep.c +1 -57
@@ -5826,69 +5826,13 @@ static struct freerunning_counters spr_i [SPR_IIO_MSR_BW_OUT] = { 0x3808, 0x1, 0x10, 8, 48 }, }; -static struct uncore_event_desc spr_uncore_iio_freerunning_events[] = { -/* Free-Running IIO CLOCKS Counter */ -INTEL_UNCORE_EVENT_DESC (ioclk,"event=0xff,umask=0x10" ), -/* Free-Running IIO BANDWIDTH IN Counters */ -INTEL_UNCORE_EVENT_DESC (bw_in_port0,"event=0xff,umask=0x20" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port0.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1,"event=0xff,umask=0x21" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port1.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2,"event=0xff,umask=0x22" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port2.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3,"event=0xff,umask=0x23" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port3.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4,"event=0xff,umask=0x24" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port4.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5,"event=0xff,umask=0x25" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port5.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6,"event=0xff,umask=0x26" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port6.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7,"event=0xff,umask=0x27" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_in_port7.unit,"MiB" ), -/* Free-Running IIO BANDWIDTH OUT Counters */ -INTEL_UNCORE_EVENT_DESC (bw_out_port0,"event=0xff,umask=0x30" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port0.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port0.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port1,"event=0xff,umask=0x31" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port1.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port1.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port2,"event=0xff,umask=0x32" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port2.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port2.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port3,"event=0xff,umask=0x33" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port3.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port3.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port4,"event=0xff,umask=0x34" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port4.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port4.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port5,"event=0xff,umask=0x35" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port5.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port5.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port6,"event=0xff,umask=0x36" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port6.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port6.unit,"MiB" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port7,"event=0xff,umask=0x37" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port7.scale,"3.814697266e-6" ), -INTEL_UNCORE_EVENT_DESC (bw_out_port7.unit,"MiB" ), - {/* end: all zeroes */ }, -}; -static struct intel_uncore_type spr_uncore_iio_free_running = { .name ="iio_free_running" , .num_counters =17 , .num_freerunning_types =SPR_IIO_FREERUNNING_TYPE_MAX , .freerunning = spr_iio_freerunning, .ops = &skx_uncore_iio_freerunning_ops, - .event_descs = spr_uncore_iio_freerunning_events, + .event_descs = snr_uncore_iio_freerunning_events, .format_group = &skx_uncore_iio_freerunning_format_group, };
Greg Kroah-Hartman
maintainerPATCH 177/373 drm/repaper: fix integer overflows in repeat functions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
commit 4d098000ac193f359e6b8ca4801dbdbd6a27b41f upstream.
There are conditions, albeit somewhat unlikely, under which right hand expressions, calculating the end of time period in functions like repaper_frame_fixed_repeat(), may overflow.
For instance, if 'factor10x' in repaper_get_temperature() is high enough (170), as is 'epd->stage_time' in repaper_probe(), then the resulting value of 'end' will not fit in unsigned int expression.
Mitigate this by casting 'epd->factored_stage_time' to wider type before any multiplication is done.
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- drivers/gpu/drm/tiny/repaper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tiny/repaper.c +2 -2
@@ -454,7 +454,7 @@ static void repaper_frame_fixed_repeat(s enum repaper_stage stage) {u64 start =local_clock (); -u64 end = start + (epd->factored_stage_time *1000 *1000 ); +u64 end = start + ((u64 )epd->factored_stage_time *1000 *1000 ); do { repaper_frame_fixed(epd, fixed_value, stage);
@@ -465,7 +465,7 @@ static void repaper_frame_data_repeat(st const u8 *mask, enum repaper_stage stage) { u64 start = local_clock(); -u64 end = start + (epd->factored_stage_time *1000 *1000 ); +u64 end = start + ((u64 )epd->factored_stage_time *1000 *1000 ); do { repaper_frame_data(epd, image, mask, stage);
Greg Kroah-Hartman
maintainerPATCH 178/373 drm/amd/pm: Prevent division by zero
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 7d641c2b83275d3b0424127b2e0d2d0f7dd82aef upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +3 -0
@@ -1278,6 +1278,9 @@ static int arcturus_set_fan_speed_rpm(stuint32_t crystal_clock_freq =2500 ;uint32_t tach_period; +if (!speed || speed >UINT_MAX /8 ) +return -EINVAL ; + tach_period =60 * crystal_clock_freq *10000 / (8 * speed); WREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT, REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT),
Greg Kroah-Hartman
maintainerPATCH 179/373 drm/amd/pm/powerplay: Prevent division by zero
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 4b8c3c0d17c07f301011e2908fecd2ebdcfe3d1c upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c +2 -2
@@ -307,10 +307,10 @@ int vega10_fan_ctrl_set_fan_speed_rpm(stint result =0 ;if (hwmgr->thermal_controller.fanInfo.bNoFan || - speed ==0 || + (!speed || speed >UINT_MAX /8 ) || (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) -return -1 ; +return -EINVAL ;if (PP_CAP (PHM_PlatformCaps_MicrocodeFanControl)) result =vega10_fan_ctrl_stop_smc_fan_control (hwmgr);
Greg Kroah-Hartman
maintainerPATCH 180/373 drm/amd/pm/powerplay/hwmgr/smu7_thermal: Prevent division by zero
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 7c246a05df51c52fe0852ce56ba10c41e6ed1f39 upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c +2 -2
@@ -267,10 +267,10 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struif (hwmgr->thermal_controller.fanInfo.bNoFan || (hwmgr->thermal_controller.fanInfo. ucTachometerPulsesPerRevolution ==0 ) || - speed ==0 || + (!speed || speed >UINT_MAX /8 ) || (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) -return 0 ; +return -EINVAL ;if (PP_CAP (PHM_PlatformCaps_MicrocodeFanControl))smu7_fan_ctrl_stop_smc_fan_control (hwmgr);
Greg Kroah-Hartman
maintainerPATCH 181/373 drm/amd/pm/swsmu/smu13/smu_v13_0: Prevent division by zero
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit f23e9116ebb71b63fe9cec0dcac792aa9af30b0c upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1 -1
@@ -1154,7 +1154,7 @@ int smu_v13_0_set_fan_speed_rpm(struct sint ret;uint32_t tach_period, crystal_clock_freq; -if (!speed) +if (!speed || speed >UINT_MAX /8 )return -EINVAL ; ret =smu_v13_0_auto_fan_control (smu,0 );
Greg Kroah-Hartman
maintainerPATCH 182/373 drm/amd/pm/powerplay/hwmgr/vega20_thermal: Prevent division by zero
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 4e3d9508c056d7e0a56b58d5c81253e2a0d22b6c upstream.
The user can set any speed value.
If speed is greater than UINT_MAX/8, division by zero is possible.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c +1 -1
@@ -191,7 +191,7 @@ int vega20_fan_ctrl_set_fan_speed_rpm(stuint32_t tach_period, crystal_clock_freq;int result =0 ; -if (!speed) +if (!speed || speed >UINT_MAX /8 )return -EINVAL ;if (PP_CAP (PHM_PlatformCaps_MicrocodeFanControl)) {
Greg Kroah-Hartman
maintainerPATCH 183/373 drm/amdgpu/dma_buf: fix page_link check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
commit c0dd8a9253fadfb8e5357217d085f1989da4ef0a upstream.
The page_link lower bits of the first sg could contain something like SG_END, if we are mapping a single VRAM page or contiguous blob which fits into one sg entry. Rather pull out the struct page, and use that in our check to know if we mapped struct pages vs VRAM.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +1 -1
@@ -225,7 +225,7 @@ static void amdgpu_dma_buf_unmap(struct struct sg_table *sgt, enum dma_data_direction dir) { -if (sgt->sgl->page_link) { + if (sg_page(sgt->sgl)) {dma_unmap_sgtable (attach->dev, sgt, dir,0 );sg_free_table (sgt);kfree (sgt);
Greg Kroah-Hartman
maintainerPATCH 184/373 drm/nouveau: prime: fix ttm_bo_delayed_delete oops
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Bainbridge <[email protected]>
commit 8ec0fbb28d049273bfd4f1e7a5ae4c74884beed3 upstream.
Fix an oops in ttm_bo_delayed_delete which results from dererencing a dangling pointer:
Oops: general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6b7b: 0000 [#1] PREEMPT SMP CPU: 4 UID: 0 PID: 1082 Comm: kworker/u65:2 Not tainted 6.14.0-rc4-00267-g505460b44513-dirty #216 Hardware name: LENOVO 82N6/LNVNB161216, BIOS GKCN65WW 01/16/2024 Workqueue: ttm ttm_bo_delayed_delete [ttm] RIP: 0010:dma_resv_iter_first_unlocked+0x55/0x290 Code: 31 f6 48 c7 c7 00 2b fa aa e8 97 bd 52 ff e8 a2 c1 53 00 5a 85 c0 74 48 e9 88 01 00 00 4c 89 63 20 4d 85 e4 0f 84 30 01 00 00 <41> 8b 44 24 10 c6 43 2c 01 48 89 df 89 43 28 e8 97 fd ff ff 4c 8b RSP: 0018:ffffbf9383473d60 EFLAGS: 00010202 RAX: 0000000000000001 RBX: ffffbf9383473d88 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffbf9383473d78 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 6b6b6b6b6b6b6b6b R13: ffffa003bbf78580 R14: ffffa003a6728040 R15: 00000000000383cc FS: 0000000000000000(0000) GS:ffffa00991c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000758348024dd0 CR3: 000000012c259000 CR4: 0000000000f50ef0 PKRU: 55555554 Call Trace: <TASK> ? __die_body.cold+0x19/0x26 ? die_addr+0x3d/0x70 ? exc_general_protection+0x159/0x460 ? asm_exc_general_protection+0x27/0x30 ? dma_resv_iter_first_unlocked+0x55/0x290 dma_resv_wait_timeout+0x56/0x100 ttm_bo_delayed_delete+0x69/0xb0 [ttm] process_one_work+0x217/0x5c0 worker_thread+0x1c8/0x3d0 ? apply_wqattrs_cleanup.part.0+0xc0/0xc0 kthread+0x10b/0x240 ? kthreads_online_cpu+0x140/0x140 ret_from_fork+0x40/0x70 ? kthreads_online_cpu+0x140/0x140 ret_from_fork_asm+0x11/0x20 </TASK>
The cause of this is:
- drm_prime_gem_destroy calls dma_buf_put(dma_buf) which releases the reference to the shared dma_buf. The reference count is 0, so the dma_buf is destroyed, which in turn decrements the corresponding amdgpu_bo reference count to 0, and the amdgpu_bo is destroyed - calling drm_gem_object_release then dma_resv_fini (which destroys the reservation object), then finally freeing the amdgpu_bo.
- nouveau_bo obj->bo.base.resv is now a dangling pointer to the memory formerly allocated to the amdgpu_bo.
- nouveau_gem_object_del calls ttm_bo_put(&nvbo->bo) which calls ttm_bo_release, which schedules ttm_bo_delayed_delete.
- ttm_bo_delayed_delete runs and dereferences the dangling resv pointer, resulting in a general protection fault.
Fix this by moving the drm_prime_gem_destroy call from nouveau_gem_object_del to nouveau_bo_del_ttm. This ensures that it will be run after ttm_bo_delayed_delete.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 3 +++ drivers/gpu/drm/nouveau/nouveau_gem.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +3 -0
@@ -143,6 +143,9 @@ nouveau_bo_del_ttm(struct ttm_buffer_objnouveau_bo_del_io_reserve_lru (bo);nv10_bo_put_tile_region (dev, nvbo->tile,NULL ); +if (bo->base.import_attach) +drm_prime_gem_destroy (&bo->base, bo->sg); +/* * If nouveau_bo_new() allocated this buffer, the GEM object was never * initialized, so don't attempt to release it.
drivers/gpu/drm/nouveau/nouveau_gem.c +0 -3
@@ -87,9 +87,6 @@ nouveau_gem_object_del(struct drm_gem_obreturn ; } -if (gem->import_attach) -drm_prime_gem_destroy (gem, nvbo->bo.sg); -ttm_bo_put (&nvbo->bo);pm_runtime_mark_last_busy (dev);
Greg Kroah-Hartman
maintainerPATCH 185/373 drm/sti: remove duplicate object names
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rolf Eike Beer <[email protected]>
commit 7fb6afa9125fc111478615e24231943c4f76cc2e upstream.
When merging 2 drivers common object files were not deduplicated.
--- drivers/gpu/drm/sti/Makefile | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/sti/Makefile +0 -2
@@ -7,8 +7,6 @@ sti-drm-y := \ sti_compositor.o \ sti_crtc.o \ sti_plane.o \ - sti_crtc.o \ - sti_plane.o \ sti_hdmi.o \ sti_hdmi_tx3g4c28phy.o \ sti_dvo.o \
Greg Kroah-Hartman
maintainerPATCH 186/373 KVM: arm64: Get rid of host SVE tracking/saving
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
From: Marc Zyngier <[email protected]>
[ Upstream commit 8383741ab2e773a992f1f0f8acdca5e7a4687c49 ]
The SVE host tracking in KVM is pretty involved. It relies on a set of flags tracking the ownership of the SVE register, as well as that of the EL0 access.
It is also pretty scary: __hyp_sve_save_host() computes a thread_struct pointer and obtains a sve_state which gets directly accessed without further ado, even on nVHE. How can this even work?
The answer to that is that it doesn't, and that this is mostly dead code. Closer examination shows that on executing a syscall, userspace loses its SVE state entirely. This is part of the ABI. Another thing to notice is that although the kernel provides helpers such as kernel_neon_begin()/end(), they only deal with the FP/NEON state, and not SVE.
Given that you can only execute a guest as the result of a syscall, and that the kernel cannot use SVE by itself, it becomes pretty obvious that there is never any host SVE state to save, and that this code is only there to increase confusion.
Get rid of the TIF_SVE tracking and host save infrastructure altogether.
--- arch/arm64/include/asm/kvm_host.h | 1 - arch/arm64/kvm/fpsimd.c | 20 +++++--------------- arch/arm64/kvm/hyp/include/hyp/switch.h | 27 +++------------------------ 3 files changed, 8 insertions(+), 40 deletions(-)
arch/arm64/include/asm/kvm_host.h +0 -1
@@ -410,7 +410,6 @@ struct kvm_vcpu_arch {#define KVM_ARM64_DEBUG_DIRTY (1 << 0)#define KVM_ARM64_FP_ENABLED (1 << 1)/* guest FP regs loaded */ #define KVM_ARM64_FP_HOST (1 << 2)/* host FP regs loaded */ -#define KVM_ARM64_HOST_SVE_IN_USE (1 << 3)/* backup for host TIF_SVE */ #define KVM_ARM64_HOST_SVE_ENABLED (1 << 4)/* SVE enabled for EL0 */ #define KVM_ARM64_GUEST_HAS_SVE (1 << 5)/* SVE exposed to guest */ #define KVM_ARM64_VCPU_SVE_FINALIZED (1 << 6)/* SVE config completed */
arch/arm64/kvm/fpsimd.c +5 -15
@@ -66,22 +66,15 @@ error:* * Here, we just set the correct metadata to indicate that the FPSIMD * state in the cpu regs (if any) belongs to current on the host. -* -* TIF_SVE is backed up here, since it may get clobbered with guest state. -* This flag is restored by kvm_arch_vcpu_put_fp(vcpu). */ void kvm_arch_vcpu_load_fp (struct kvm_vcpu *vcpu) {BUG_ON (!current->mm); +BUG_ON (test_thread_flag (TIF_SVE )); - vcpu->arch.flags &= ~(KVM_ARM64_FP_ENABLED | -KVM_ARM64_HOST_SVE_IN_USE | -KVM_ARM64_HOST_SVE_ENABLED ); + vcpu->arch.flags &= ~KVM_ARM64_FP_ENABLED ; vcpu->arch.flags |=KVM_ARM64_FP_HOST ; -if (test_thread_flag (TIF_SVE )) - vcpu->arch.flags |=KVM_ARM64_HOST_SVE_IN_USE ; -if (read_sysreg (cpacr_el1) &CPACR_EL1_ZEN_EL0EN ) vcpu->arch.flags |=KVM_ARM64_HOST_SVE_ENABLED ; }
@@ -115,13 +108,11 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvmvoid kvm_arch_vcpu_put_fp (struct kvm_vcpu *vcpu) {unsigned long flags; -bool host_has_sve =system_supports_sve (); -bool guest_has_sve =vcpu_has_sve (vcpu);local_irq_save (flags);if (vcpu->arch.flags &KVM_ARM64_FP_ENABLED ) { -if (guest_has_sve) { +if (vcpu_has_sve (vcpu)) {__vcpu_sys_reg (vcpu,ZCR_EL1 ) =read_sysreg_el1 (SYS_ZCR );/* Restore the VL that was saved when bound to the CPU */
@@ -131,7 +122,7 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcp }fpsimd_save_and_flush_cpu_state (); - }else if (has_vhe () && host_has_sve) { + }else if (has_vhe () &&system_supports_sve ()) {/* * The FPSIMD/SVE state in the CPU has not been touched, and we * have SVE (and VHE): CPACR_EL1 (alias CPTR_EL2) has been
@@ -145,8 +136,7 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpsysreg_clear_set (CPACR_EL1 ,CPACR_EL1_ZEN_EL0EN ,0 ); } -update_thread_flag (TIF_SVE , - vcpu->arch.flags &KVM_ARM64_HOST_SVE_IN_USE ); +update_thread_flag (TIF_SVE ,0 );local_irq_restore (flags); }
arch/arm64/kvm/hyp/include/hyp/switch.h +3 -24
@@ -207,16 +207,6 @@ static inline bool __populate_fault_inforeturn __get_fault_info (esr, &vcpu->arch.fault); } -static inline void __hyp_sve_save_host (struct kvm_vcpu *vcpu) -{ -struct thread_struct *thread; - - thread = container_of(vcpu->arch.host_fpsimd_state, struct thread_struct, - uw.fpsimd_state); - -__sve_save_state (sve_pffr (thread), &vcpu->arch.host_fpsimd_state->fpsr); -} -static inline void __hyp_sve_restore_guest (struct kvm_vcpu *vcpu) {sve_cond_update_zcr_vq (vcpu_sve_max_vq (vcpu) -1 ,SYS_ZCR_EL2 );
@@ -228,21 +218,14 @@ static inline void __hyp_sve_restore_gue/* Check for an FPSIMD/SVE trap and handle as appropriate */ static inline bool __hyp_handle_fpsimd (struct kvm_vcpu *vcpu) { -bool sve_guest, sve_host; +bool sve_guest;u8 esr_ec;u64 reg;if (!system_supports_fpsimd ())return false; -if (system_supports_sve ()) { - sve_guest =vcpu_has_sve (vcpu); - sve_host = vcpu->arch.flags &KVM_ARM64_HOST_SVE_IN_USE ; - }else { - sve_guest = false; - sve_host = false; - } - + sve_guest =vcpu_has_sve (vcpu); esr_ec =kvm_vcpu_trap_get_class (vcpu);if (esr_ec != ESR_ELx_EC_FP_ASIMD && esr_ec != ESR_ELx_EC_SVE)
@@ -269,11 +252,7 @@ static inline bool __hyp_handle_fpsimd(sisb ();if (vcpu->arch.flags &KVM_ARM64_FP_HOST ) { -if (sve_host) -__hyp_sve_save_host (vcpu); -else -__fpsimd_save_state (vcpu->arch.host_fpsimd_state); - +__fpsimd_save_state (vcpu->arch.host_fpsimd_state); vcpu->arch.flags &= ~KVM_ARM64_FP_HOST ; }
Greg Kroah-Hartman
maintainerPATCH 187/373 KVM: arm64: Always start with clearing SVE flag on load
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit d52d165d67c5aa26c8c89909003c94a66492d23d ]
On each vcpu load, we set the KVM_ARM64_HOST_SVE_ENABLED flag if SVE is enabled for EL0 on the host. This is used to restore the correct state on vpcu put.
However, it appears that nothing ever clears this flag. Once set, it will stick until the vcpu is destroyed, which has the potential to spuriously enable SVE for userspace.
We probably never saw the issue because no VMM uses SVE, but that's still pretty bad. Unconditionally clearing the flag on vcpu load addresses the issue.
--- arch/arm64/kvm/fpsimd.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kvm/fpsimd.c +1 -0
@@ -75,6 +75,7 @@ void kvm_arch_vcpu_load_fp(struct kvm_vc vcpu->arch.flags &= ~KVM_ARM64_FP_ENABLED ; vcpu->arch.flags |=KVM_ARM64_FP_HOST ; + vcpu->arch.flags &= ~KVM_ARM64_HOST_SVE_ENABLED ;if (read_sysreg (cpacr_el1) &CPACR_EL1_ZEN_EL0EN ) vcpu->arch.flags |=KVM_ARM64_HOST_SVE_ENABLED ; }
Greg Kroah-Hartman
maintainerPATCH 188/373 KVM: arm64: Discard any SVE state when entering KVM guests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit 93ae6b01bafee8fa385aa25ee7ebdb40057f6abe ]
Since 8383741ab2e773a99 (KVM: arm64: Get rid of host SVE tracking/saving) KVM has not tracked the host SVE state, relying on the fact that we currently disable SVE whenever we perform a syscall. This may not be true in future since performance optimisation may result in us keeping SVE enabled in order to avoid needing to take access traps to reenable it. Handle this by clearing TIF_SVE and converting the stored task state to FPSIMD format when preparing to run the guest. This is done with a new call fpsimd_kvm_prepare() to keep the direct state manipulation functions internal to fpsimd.c.
--- arch/arm64/include/asm/fpsimd.h | 1 + arch/arm64/kernel/fpsimd.c | 23 +++++++++++++++++++++++ arch/arm64/kvm/fpsimd.c | 4 +++- 3 files changed, 27 insertions(+), 1 deletion(-)
arch/arm64/include/asm/fpsimd.h +1 -0
@@ -44,6 +44,7 @@ extern void fpsimd_signal_preserve_curreextern void fpsimd_preserve_current_state (void );extern void fpsimd_restore_current_state (void );extern void fpsimd_update_current_state (struct user_fpsimd_state const *state); +extern void fpsimd_kvm_prepare (void );extern void fpsimd_bind_state_to_cpu (struct user_fpsimd_state *state,void *sve_state,unsigned int sve_vl);
arch/arm64/kernel/fpsimd.c +23 -0
@@ -1109,6 +1109,29 @@ void fpsimd_signal_preserve_current_stat }/* +* Called by KVM when entering the guest. +*/ +void fpsimd_kvm_prepare (void ) +{ +if (!system_supports_sve ()) +return ; + +/* +* KVM does not save host SVE state since we can only enter +* the guest from a syscall so the ABI means that only the +* non-saved SVE state needs to be saved. If we have left +* SVE enabled for performance reasons then update the task +* state to be FPSIMD only. +*/ +get_cpu_fpsimd_context (); + +if (test_and_clear_thread_flag (TIF_SVE )) +sve_to_fpsimd (current); + +put_cpu_fpsimd_context (); +} + +/* * Associate current's FPSIMD context with this cpu * The caller must have ownership of the cpu FPSIMD context before calling * this function.
arch/arm64/kvm/fpsimd.c +3 -1
@@ -70,12 +70,14 @@ error:void kvm_arch_vcpu_load_fp (struct kvm_vcpu *vcpu) {BUG_ON (!current->mm); -BUG_ON (test_thread_flag (TIF_SVE )); vcpu->arch.flags &= ~KVM_ARM64_FP_ENABLED ; vcpu->arch.flags |=KVM_ARM64_FP_HOST ; +fpsimd_kvm_prepare (); + vcpu->arch.flags &= ~KVM_ARM64_HOST_SVE_ENABLED ; +if (read_sysreg (cpacr_el1) &CPACR_EL1_ZEN_EL0EN ) vcpu->arch.flags |=KVM_ARM64_HOST_SVE_ENABLED ; }
Greg Kroah-Hartman
maintainerPATCH 189/373 arm64/fpsimd: Track the saved FPSIMD state type separately to TIF_SVE
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit baa8515281b30861cff3da7db70662d2a25c6440 ]
When we save the state for the floating point registers this can be done in the form visible through either the FPSIMD V registers or the SVE Z and P registers. At present we track which format is currently used based on TIF_SVE and the SME streaming mode state but particularly in the SVE case this limits our options for optimising things, especially around syscalls. Introduce a new enum which we place together with saved floating point state in both thread_struct and the KVM guest state which explicitly states which format is active and keep it up to date when we change it.
At present we do not use this state except to verify that it has the expected value when loading the state, future patches will introduce functional changes.
--- arch/arm64/include/asm/fpsimd.h | 3 + arch/arm64/include/asm/kvm_host.h | 12 +++++++ arch/arm64/include/asm/processor.h | 6 +++ arch/arm64/kernel/fpsimd.c | 58 +++++++++++++++++++++++++++---------- arch/arm64/kernel/process.c | 3 + arch/arm64/kernel/ptrace.c | 3 + arch/arm64/kernel/signal.c | 3 + arch/arm64/kvm/fpsimd.c | 3 + 8 files changed, 74 insertions(+), 17 deletions(-)
arch/arm64/include/asm/fpsimd.h +2 -1
@@ -47,7 +47,8 @@ extern void fpsimd_update_current_state(extern void fpsimd_kvm_prepare (void );extern void fpsimd_bind_state_to_cpu (struct user_fpsimd_state *state, -void *sve_state,unsigned int sve_vl); +void *sve_state,unsigned int sve_vl, +enum fp_type *type);extern void fpsimd_flush_task_state (struct task_struct *target);extern void fpsimd_save_and_flush_cpu_state (void );
arch/arm64/include/asm/kvm_host.h +12 -0
@@ -280,7 +280,19 @@ struct vcpu_reset_state {struct kvm_vcpu_arch {struct kvm_cpu_context ctxt; + +/* +* Guest floating point state +* +* The architecture has two main floating point extensions, +* the original FPSIMD and SVE. These have overlapping +* register views, with the FPSIMD V registers occupying the +* low 128 bits of the SVE Z registers. When the core +* floating point code saves the register state of a task it +* records which view it saved in fp_type. +*/ void *sve_state; +enum fp_type fp_type;unsigned int sve_max_vl;/* Stage 2 paging state used by the hardware on next switch */
arch/arm64/include/asm/processor.h +6 -0
@@ -115,6 +115,11 @@ struct debug_info {#endif }; +enum fp_type { +FP_STATE_FPSIMD , +FP_STATE_SVE , +}; +struct cpu_context {unsigned long x19;unsigned long x20;
@@ -145,6 +150,7 @@ struct thread_struct {struct user_fpsimd_state fpsimd_state; } uw; +enum fp_type fp_type;/* registers FPSIMD or SVE? */ unsigned int fpsimd_cpu;void *sve_state;/* SVE registers, if any */ unsigned int sve_vl;/* SVE vector length */
arch/arm64/kernel/fpsimd.c +43 -15
137 lines not on this page · raw message
arch/arm64/kernel/process.c +3 -0
@@ -307,6 +307,9 @@ int arch_dup_task_struct(struct task_str dst->thread.sve_state =NULL ;clear_tsk_thread_flag (dst,TIF_SVE ); + + dst->thread.fp_type =FP_STATE_FPSIMD ; +/* clear any pending asynchronous tag fault raised by the parent */ clear_tsk_thread_flag (dst,TIF_MTE_ASYNC_FAULT );
arch/arm64/kernel/ptrace.c +3 -0
@@ -829,6 +829,7 @@ static int sve_set(struct task_struct *t ret =__fpr_set (target, regset, pos, count, kbuf, ubuf,SVE_PT_FPSIMD_OFFSET );clear_tsk_thread_flag (target,TIF_SVE ); + target->thread.fp_type =FP_STATE_FPSIMD ; goto out; }
@@ -848,6 +849,7 @@ static int sve_set(struct task_struct *tif (!target->thread.sve_state) { ret = -ENOMEM ;clear_tsk_thread_flag (target,TIF_SVE ); + target->thread.fp_type =FP_STATE_FPSIMD ; goto out; }
@@ -858,6 +860,7 @@ static int sve_set(struct task_struct *t*/ fpsimd_sync_to_sve (target);set_tsk_thread_flag (target,TIF_SVE ); + target->thread.fp_type =FP_STATE_SVE ;BUILD_BUG_ON (SVE_PT_SVE_OFFSET !=sizeof (header)); start =SVE_PT_SVE_OFFSET ;
arch/arm64/kernel/signal.c +3 -0
@@ -207,6 +207,7 @@ static int restore_fpsimd_context(struct__get_user_error (fpsimd.fpcr, &ctx->fpcr, err);clear_thread_flag (TIF_SVE ); + current->thread.fp_type =FP_STATE_FPSIMD ;/* load the hardware registers from the fpsimd_state structure */ if (!err)
@@ -271,6 +272,7 @@ static int restore_sve_fpsimd_context(stif (sve.head.size <=sizeof (*user->sve)) {clear_thread_flag (TIF_SVE ); + current->thread.fp_type =FP_STATE_FPSIMD ; goto fpsimd_only; }
@@ -303,6 +305,7 @@ static int restore_sve_fpsimd_context(streturn -EFAULT ;set_thread_flag (TIF_SVE ); + current->thread.fp_type =FP_STATE_SVE ; fpsimd_only:/* copy the FP and status/control registers */
arch/arm64/kvm/fpsimd.c +2 -1
@@ -95,7 +95,8 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvmif (vcpu->arch.flags &KVM_ARM64_FP_ENABLED ) {fpsimd_bind_state_to_cpu (&vcpu->arch.ctxt.fp_regs, vcpu->arch.sve_state, - vcpu->arch.sve_max_vl); + vcpu->arch.sve_max_vl, + &vcpu->arch.fp_type);clear_thread_flag (TIF_FOREIGN_FPSTATE );update_thread_flag (TIF_SVE ,vcpu_has_sve (vcpu));
Greg Kroah-Hartman
maintainerPATCH 190/373 arm64/fpsimd: Have KVM explicitly say which FP registers to save
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit deeb8f9a80fdae5a62525656d65c7070c28bd3a4 ]
In order to avoid needlessly saving and restoring the guest registers KVM relies on the host FPSMID code to save the guest registers when we context switch away from the guest. This is done by binding the KVM guest state to the CPU on top of the task state that was originally there, then carefully managing the TIF_SVE flag for the task to cause the host to save the full SVE state when needed regardless of the needs of the host task. This works well enough but isn't terribly direct about what is going on and makes it much more complicated to try to optimise what we're doing with the SVE register state.
Let's instead have KVM pass in the register state it wants saving when it binds to the CPU. We introduce a new FP_STATE_CURRENT for use during normal task binding to indicate that we should base our decisions on the current task. This should not be used when actually saving. Ideally we might want to use a separate enum for the type to save but this enum and the enum values would then need to be named which has problems with clarity and ambiguity.
In order to ease any future debugging that might be required this patch does not actually update any of the decision making about what to save, it merely starts tracking the new information and warns if the requested state is not what we would otherwise have decided to save.
--- arch/arm64/include/asm/fpsimd.h | 2 arch/arm64/include/asm/processor.h | 1 arch/arm64/kernel/fpsimd.c | 79 ++++++++++++++++++++++++++----------- arch/arm64/kvm/fpsimd.c | 13 +++++- 4 files changed, 70 insertions(+), 25 deletions(-)
arch/arm64/include/asm/fpsimd.h +1 -1
@@ -48,7 +48,7 @@ extern void fpsimd_kvm_prepare(void);extern void fpsimd_bind_state_to_cpu (struct user_fpsimd_state *state,void *sve_state,unsigned int sve_vl, -enum fp_type *type); +enum fp_type *type,enum fp_type to_save);extern void fpsimd_flush_task_state (struct task_struct *target);extern void fpsimd_save_and_flush_cpu_state (void );
arch/arm64/include/asm/processor.h +1 -0
@@ -116,6 +116,7 @@ struct debug_info { };enum fp_type { +FP_STATE_CURRENT ,/* Save based on current task state. */ FP_STATE_FPSIMD ,FP_STATE_SVE , };
arch/arm64/kernel/fpsimd.c +56 -23
133 lines not on this page · raw message
arch/arm64/kvm/fpsimd.c +12 -1
@@ -90,13 +90,24 @@ void kvm_arch_vcpu_load_fp(struct kvm_vc*/ void kvm_arch_vcpu_ctxsync_fp (struct kvm_vcpu *vcpu) { +enum fp_type fp_type; +WARN_ON_ONCE (!irqs_disabled ());if (vcpu->arch.flags &KVM_ARM64_FP_ENABLED ) { +if (vcpu_has_sve (vcpu)) + fp_type =FP_STATE_SVE ; +else + fp_type =FP_STATE_FPSIMD ; + +/* +* Currently we do not support SME guests so SVCR is +* always 0 and we just need a variable to point to. +*/ fpsimd_bind_state_to_cpu (&vcpu->arch.ctxt.fp_regs, vcpu->arch.sve_state, vcpu->arch.sve_max_vl, - &vcpu->arch.fp_type); + &vcpu->arch.fp_type, fp_type);clear_thread_flag (TIF_FOREIGN_FPSTATE );update_thread_flag (TIF_SVE ,vcpu_has_sve (vcpu));
Greg Kroah-Hartman
maintainerPATCH 191/373 arm64/fpsimd: Stop using TIF_SVE to manage register saving in KVM
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit 62021cc36add7b2c015b837f7893f2fb4b8c2586 ]
Now that we are explicitly telling the host FP code which register state it needs to save we can remove the manipulation of TIF_SVE from the KVM code, simplifying it and allowing us to optimise our handling of normal tasks. Remove the manipulation of TIF_SVE from KVM and instead rely on to_save to ensure we save the correct data for it.
There should be no functional or performance impact from this change.
--- arch/arm64/kernel/fpsimd.c | 40 ++++++++++++++++------------------------ arch/arm64/kvm/fpsimd.c | 3 --- 2 files changed, 16 insertions(+), 27 deletions(-)
arch/arm64/kernel/fpsimd.c +16 -24
@@ -318,7 +318,13 @@ static void task_fpsimd_load(void)/* * Ensure FPSIMD/SVE storage in memory for the loaded context is up to -* date with respect to the CPU registers. +* date with respect to the CPU registers. Note carefully that the +* current context is the context last bound to the CPU stored in +* last, if KVM is involved this may be the guest VM context rather +* than the host thread for the VM pointed to by current. This means +* that we must always reference the state storage via last rather +* than via current, if we are saving KVM state then it will have +* ensured that the type of registers to save is set in last->to_save. */ static void fpsimd_save (void ) {
@@ -334,9 +340,15 @@ static void fpsimd_save(void)if (test_thread_flag (TIF_FOREIGN_FPSTATE ))return ; -if (IS_ENABLED (CONFIG_ARM64_SVE ) && -test_thread_flag (TIF_SVE )) { -if (WARN_ON (sve_get_vl () != last->sve_vl)) { +if ((last->to_save ==FP_STATE_CURRENT &&test_thread_flag (TIF_SVE )) || + last->to_save ==FP_STATE_SVE ) { + save_sve_regs = true; + vl = last->sve_vl; + } + +if (IS_ENABLED (CONFIG_ARM64_SVE ) && save_sve_regs) { +/* Get the configured VL from RDVL, will account for SM */ +if (WARN_ON (sve_get_vl () != vl)) {/* * Can't save the user regs, so current would * re-enter user with corrupt state.
@@ -347,26 +359,6 @@ static void fpsimd_save(void) } } -if (test_thread_flag (TIF_SVE )) { - save_sve_regs = true; - vl = last->sve_vl; - } - -/* -* Validate that an explicitly specified state to save is -* consistent with the task state. -*/ -switch (last->to_save) { -case FP_STATE_CURRENT : -break ; -case FP_STATE_FPSIMD : -WARN_ON_ONCE (save_sve_regs); -break ; -case FP_STATE_SVE : -WARN_ON_ONCE (!save_sve_regs); -break ; - } -if (IS_ENABLED (CONFIG_ARM64_SVE ) && save_sve_regs) { sve_save_state((char *)last->sve_state + sve_ffr_offset(last->sve_vl),
arch/arm64/kvm/fpsimd.c +0 -3
@@ -110,7 +110,6 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvm &vcpu->arch.fp_type, fp_type);clear_thread_flag (TIF_FOREIGN_FPSTATE ); -update_thread_flag (TIF_SVE ,vcpu_has_sve (vcpu)); } }
@@ -151,7 +150,5 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpsysreg_clear_set (CPACR_EL1 ,CPACR_EL1_ZEN_EL0EN ,0 ); } -update_thread_flag (TIF_SVE ,0 ); -local_irq_restore (flags); }
Greg Kroah-Hartman
maintainerPATCH 192/373 KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
[ Upstream commit fbc7e61195e23f744814e78524b73b59faa54ab4 ]
There are several problems with the way hyp code lazily saves the host's FPSIMD/SVE state, including:
* Host SVE being discarded unexpectedly due to inconsistent configuration of TIF_SVE and CPACR_ELx.ZEN. This has been seen to result in QEMU crashes where SVE is used by memmove(), as reported by Eric Auger:
https://issues.redhat.com/browse/RHEL-68997
* Host SVE state is discarded *after* modification by ptrace, which was an unintentional ptrace ABI change introduced with lazy discarding of SVE state.
* The host FPMR value can be discarded when running a non-protected VM, where FPMR support is not exposed to a VM, and that VM uses FPSIMD/SVE. In these cases the hyp code does not save the host's FPMR before unbinding the host's FPSIMD/SVE/SME state, leaving a stale value in memory.
Avoid these by eagerly saving and "flushing" the host's FPSIMD/SVE/SME state when loading a vCPU such that KVM does not need to save any of the host's FPSIMD/SVE/SME state. For clarity, fpsimd_kvm_prepare() is removed and the necessary call to fpsimd_save_and_flush_cpu_state() is placed in kvm_arch_vcpu_load_fp(). As 'fpsimd_state' and 'fpmr_ptr' should not be used, they are set to NULL; all uses of these will be removed in subsequent patches.
Historical problems go back at least as far as v5.17, e.g. erroneous assumptions about TIF_SVE being clear in commit:
8383741ab2e773a9 ("KVM: arm64: Get rid of host SVE tracking/saving")
... and so this eager save+flush probably needs to be backported to ALL stable trees.
--- arch/arm64/kernel/fpsimd.c | 25 ------------------------- arch/arm64/kvm/fpsimd.c | 13 ++++++++++--- 2 files changed, 10 insertions(+), 28 deletions(-)
arch/arm64/kernel/fpsimd.c +0 -25
@@ -1155,31 +1155,6 @@ void fpsimd_signal_preserve_current_stat }/* -* Called by KVM when entering the guest. -*/ -void fpsimd_kvm_prepare (void ) -{ -if (!system_supports_sve ()) -return ; - -/* -* KVM does not save host SVE state since we can only enter -* the guest from a syscall so the ABI means that only the -* non-saved SVE state needs to be saved. If we have left -* SVE enabled for performance reasons then update the task -* state to be FPSIMD only. -*/ -get_cpu_fpsimd_context (); - -if (test_and_clear_thread_flag (TIF_SVE )) { -sve_to_fpsimd (current); - current->thread.fp_type =FP_STATE_FPSIMD ; - } - -put_cpu_fpsimd_context (); -} - -/* * Associate current's FPSIMD context with this cpu * The caller must have ownership of the cpu FPSIMD context before calling * this function.
arch/arm64/kvm/fpsimd.c +10 -3
@@ -74,9 +74,16 @@ void kvm_arch_vcpu_load_fp(struct kvm_vc vcpu->arch.flags &= ~KVM_ARM64_FP_ENABLED ; vcpu->arch.flags |=KVM_ARM64_FP_HOST ; -fpsimd_kvm_prepare (); - - vcpu->arch.flags &= ~KVM_ARM64_HOST_SVE_ENABLED ; +/* +* Ensure that any host FPSIMD/SVE/SME state is saved and unbound such +* that the host kernel is responsible for restoring this state upon +* return to userspace, and the hyp code doesn't need to save anything. +* +* When the host may use SME, fpsimd_save_and_flush_cpu_state() ensures +* that PSTATE.{SM,ZA} == {0,0}. +*/ +fpsimd_save_and_flush_cpu_state (); + vcpu->arch.flags &= ~KVM_ARM64_FP_HOST ;if (read_sysreg (cpacr_el1) &CPACR_EL1_ZEN_EL0EN ) vcpu->arch.flags |=KVM_ARM64_HOST_SVE_ENABLED ;
Greg Kroah-Hartman
maintainerPATCH 193/373 KVM: arm64: Remove host FPSIMD saving for non-protected KVM
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
[ Upstream commit 8eca7f6d5100b6997df4f532090bc3f7e0203bef ]
Now that the host eagerly saves its own FPSIMD/SVE/SME state, non-protected KVM never needs to save the host FPSIMD/SVE/SME state, and the code to do this is never used. Protected KVM still needs to save/restore the host FPSIMD/SVE state to avoid leaking guest state to the host (and to avoid revealing to the host whether the guest used FPSIMD/SVE/SME), and that code needs to be retained.
Remove the unused code and data structures.
To avoid the need for a stub copy of kvm_hyp_save_fpsimd_host() in the VHE hyp code, the nVHE/hVHE version is moved into the shared switch header, where it is only invoked when KVM is in protected mode.
--- arch/arm64/include/asm/kvm_host.h | 1 - arch/arm64/kvm/fpsimd.c | 1 - arch/arm64/kvm/hyp/include/hyp/switch.h | 6 +----- 3 files changed, 1 insertion(+), 7 deletions(-)
arch/arm64/include/asm/kvm_host.h +0 -1
@@ -333,7 +333,6 @@ struct kvm_vcpu_arch {struct kvm_guest_debug_arch external_debug_state;struct thread_info *host_thread_info;/* hyp VA */ -struct user_fpsimd_state *host_fpsimd_state;/* hyp VA */ struct {/* {Break,watch}point registers */
arch/arm64/kvm/fpsimd.c +0 -1
@@ -55,7 +55,6 @@ int kvm_arch_vcpu_run_map_fp(struct kvm_ } vcpu->arch.host_thread_info =kern_hyp_va (ti); - vcpu->arch.host_fpsimd_state =kern_hyp_va (fpsimd); error:return ret; }
arch/arm64/kvm/hyp/include/hyp/switch.h +1 -5
@@ -251,11 +251,7 @@ static inline bool __hyp_handle_fpsimd(s }isb (); -if (vcpu->arch.flags &KVM_ARM64_FP_HOST ) { -__fpsimd_save_state (vcpu->arch.host_fpsimd_state); - vcpu->arch.flags &= ~KVM_ARM64_FP_HOST ; - } - +/* Restore the guest state */ if (sve_guest)__hyp_sve_restore_guest (vcpu);else
Greg Kroah-Hartman
maintainerPATCH 194/373 KVM: arm64: Remove VHE host restore of CPACR_EL1.ZEN
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
[ Upstream commit 459f059be702056d91537b99a129994aa6ccdd35 ]
When KVM is in VHE mode, the host kernel tries to save and restore the configuration of CPACR_EL1.ZEN (i.e. CPTR_EL2.ZEN when HCR_EL2.E2H=1) across kvm_arch_vcpu_load_fp() and kvm_arch_vcpu_put_fp(), since the configuration may be clobbered by hyp when running a vCPU. This logic is currently redundant.
The VHE hyp code unconditionally configures CPTR_EL2.ZEN to 0b01 when returning to the host, permitting host kernel usage of SVE.
Now that the host eagerly saves and unbinds its own FPSIMD/SVE/SME state, there's no need to save/restore the state of the EL0 SVE trap. The kernel can safely save/restore state without trapping, as described above, and will restore userspace state (including trap controls) before returning to userspace.
Remove the redundant logic.
--- arch/arm64/include/asm/kvm_host.h | 1 - arch/arm64/kvm/fpsimd.c | 15 --------------- 2 files changed, 16 deletions(-)
arch/arm64/include/asm/kvm_host.h +0 -1
@@ -421,7 +421,6 @@ struct kvm_vcpu_arch {#define KVM_ARM64_DEBUG_DIRTY (1 << 0)#define KVM_ARM64_FP_ENABLED (1 << 1)/* guest FP regs loaded */ #define KVM_ARM64_FP_HOST (1 << 2)/* host FP regs loaded */ -#define KVM_ARM64_HOST_SVE_ENABLED (1 << 4)/* SVE enabled for EL0 */ #define KVM_ARM64_GUEST_HAS_SVE (1 << 5)/* SVE exposed to guest */ #define KVM_ARM64_VCPU_SVE_FINALIZED (1 << 6)/* SVE config completed */ #define KVM_ARM64_GUEST_HAS_PTRAUTH (1 << 7)/* PTRAUTH exposed to guest */
arch/arm64/kvm/fpsimd.c +0 -15
@@ -83,9 +83,6 @@ void kvm_arch_vcpu_load_fp(struct kvm_vc*/ fpsimd_save_and_flush_cpu_state (); vcpu->arch.flags &= ~KVM_ARM64_FP_HOST ; - -if (read_sysreg (cpacr_el1) &CPACR_EL1_ZEN_EL0EN ) - vcpu->arch.flags |=KVM_ARM64_HOST_SVE_ENABLED ; }/*
@@ -142,18 +139,6 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcp }fpsimd_save_and_flush_cpu_state (); - }else if (has_vhe () &&system_supports_sve ()) { -/* -* The FPSIMD/SVE state in the CPU has not been touched, and we -* have SVE (and VHE): CPACR_EL1 (alias CPTR_EL2) has been -* reset to CPACR_EL1_DEFAULT by the Hyp code, disabling SVE -* for EL0. To avoid spurious traps, restore the trap state -* seen by kvm_arch_vcpu_load_fp(): -*/ -if (vcpu->arch.flags &KVM_ARM64_HOST_SVE_ENABLED ) -sysreg_clear_set (CPACR_EL1 ,0 ,CPACR_EL1_ZEN_EL0EN ); -else -sysreg_clear_set (CPACR_EL1 ,CPACR_EL1_ZEN_EL0EN ,0 ); }local_irq_restore (flags);
Greg Kroah-Hartman
maintainerPATCH 195/373 KVM: arm64: Calculate cptr_el2 traps on activating traps
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 2fd5b4b0e7b440602455b79977bfa64dea101e6c ]
Similar to VHE, calculate the value of cptr_el2 from scratch on activate traps. This removes the need to store cptr_el2 in every vcpu structure. Moreover, some traps, such as whether the guest owns the fp registers, need to be set on every vcpu run.
--- arch/arm64/include/asm/kvm_host.h | 1 - arch/arm64/kvm/arm.c | 1 - arch/arm64/kvm/hyp/nvhe/switch.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 26 insertions(+), 11 deletions(-)
arch/arm64/include/asm/kvm_host.h +0 -1
@@ -301,7 +301,6 @@ struct kvm_vcpu_arch {/* Values of trap registers for the guest. */ u64 hcr_el2;u64 mdcr_el2; -u64 cptr_el2;/* Values of trap registers for the host before guest entry. */ u64 mdcr_el2_host;
arch/arm64/kvm/arm.c +0 -1
@@ -1138,7 +1138,6 @@ static int kvm_arch_vcpu_ioctl_vcpu_init }vcpu_reset_hcr (vcpu); - vcpu->arch.cptr_el2 =CPTR_EL2_DEFAULT ;/* * Handle the "start in power-off" case.
arch/arm64/kvm/hyp/nvhe/switch.c +26 -9
@@ -34,21 +34,38 @@ DEFINE_PER_CPU(struct kvm_host_data, kvm DEFINE_PER_CPU(struct kvm_cpu_context, kvm_hyp_ctxt); DEFINE_PER_CPU(unsigned long, kvm_hyp_vector); -static void __activate_traps (struct kvm_vcpu *vcpu) +static bool guest_owns_fp_regs (struct kvm_vcpu *vcpu) { -u64 val; +return vcpu->arch.flags &KVM_ARM64_FP_ENABLED ; +} -___activate_traps (vcpu); -__activate_traps_common (vcpu); +static void __activate_cptr_traps (struct kvm_vcpu *vcpu) +{ +u64 val =CPTR_EL2_TAM ;/* Same bit irrespective of E2H */ - val = vcpu->arch.cptr_el2; - val |=CPTR_EL2_TTA |CPTR_EL2_TAM ; -if (!update_fp_enabled (vcpu)) { - val |=CPTR_EL2_TFP |CPTR_EL2_TZ ; -__activate_traps_fpsimd32 (vcpu); +/* !hVHE case upstream */ +if (1 ) { + val |=CPTR_EL2_TTA |CPTR_NVHE_EL2_RES1 ; + +if (!vcpu_has_sve (vcpu) || !guest_owns_fp_regs (vcpu)) + val |=CPTR_EL2_TZ ; + +if (!guest_owns_fp_regs (vcpu)) + val |=CPTR_EL2_TFP ; } +if (!guest_owns_fp_regs (vcpu)) +__activate_traps_fpsimd32 (vcpu); +write_sysreg (val, cptr_el2); +} + +static void __activate_traps (struct kvm_vcpu *vcpu) +{ +___activate_traps (vcpu); +__activate_traps_common (vcpu); +__activate_cptr_traps (vcpu); +write_sysreg (__this_cpu_read (kvm_hyp_vector), vbar_el2);if (cpus_have_final_cap (ARM64_WORKAROUND_SPECULATIVE_AT )) {
Greg Kroah-Hartman
maintainerPATCH 196/373 KVM: arm64: Eagerly switch ZCR_EL{1,2}
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
[ Upstream commit 59419f10045bc955d2229819c7cf7a8b0b9c5b59 ]
In non-protected KVM modes, while the guest FPSIMD/SVE/SME state is live on the CPU, the host's active SVE VL may differ from the guest's maximum SVE VL:
* For VHE hosts, when a VM uses NV, ZCR_EL2 contains a value constrained by the guest hypervisor, which may be less than or equal to that guest's maximum VL.
Note: in this case the value of ZCR_EL1 is immaterial due to E2H.
* For nVHE/hVHE hosts, ZCR_EL1 contains a value written by the guest, which may be less than or greater than the guest's maximum VL.
Note: in this case hyp code traps host SVE usage and lazily restores ZCR_EL2 to the host's maximum VL, which may be greater than the guest's maximum VL.
This can be the case between exiting a guest and kvm_arch_vcpu_put_fp(). If a softirq is taken during this period and the softirq handler tries to use kernel-mode NEON, then the kernel will fail to save the guest's FPSIMD/SVE state, and will pend a SIGKILL for the current thread.
This happens because kvm_arch_vcpu_ctxsync_fp() binds the guest's live FPSIMD/SVE state with the guest's maximum SVE VL, and fpsimd_save_user_state() verifies that the live SVE VL is as expected before attempting to save the register state:
| if (WARN_ON(sve_get_vl() != vl)) {
| force_signal_inject(SIGKILL, SI_KERNEL, 0, 0);
| return;
| }Fix this and make this a bit easier to reason about by always eagerly switching ZCR_EL{1,2} at hyp during guest<->host transitions. With this happening, there's no need to trap host SVE usage, and the nVHE/nVHE __deactivate_cptr_traps() logic can be simplified to enable host access to all present FPSIMD/SVE/SME features.
In protected nVHE/hVHE modes, the host's state is always saved/restored by hyp, and the guest's state is saved prior to exit to the host, so from the host's PoV the guest never has live FPSIMD/SVE/SME state, and the host's ZCR_EL1 is never clobbered by hyp.
[ v6.6 lacks pKVM saving of host SVE state, pull in discovery of maximum
host VL separately -- broonie ]
--- arch/arm64/include/asm/kvm_host.h | 1 arch/arm64/include/asm/kvm_hyp.h | 7 ++++ arch/arm64/kvm/fpsimd.c | 19 +++++------ arch/arm64/kvm/hyp/entry.S | 5 ++ arch/arm64/kvm/hyp/include/hyp/switch.h | 55 ++++++++++++++++++++++++++++++++ arch/arm64/kvm/hyp/nvhe/hyp-main.c | 9 ++--- arch/arm64/kvm/hyp/nvhe/switch.c | 31 +++++++++--------- arch/arm64/kvm/hyp/vhe/switch.c | 4 ++ arch/arm64/kvm/reset.c | 3 + 9 files changed, 106 insertions(+), 28 deletions(-)
arch/arm64/include/asm/kvm_host.h +1 -0
@@ -64,6 +64,7 @@ enum kvm_mode kvm_get_mode(void);DECLARE_STATIC_KEY_FALSE (userspace_irqchip_in_use);extern unsigned int kvm_sve_max_vl; +extern unsigned int kvm_host_sve_max_vl;int kvm_arm_init_sve (void ); u32 __attribute_const__ kvm_target_cpu(void);
arch/arm64/include/asm/kvm_hyp.h +7 -0
@@ -117,5 +117,12 @@ void __noreturn __host_enter(struct kvm_extern u64 kvm_nvhe_sym (id_aa64mmfr0_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64mmfr1_el1_sys_val ); +extern unsigned int kvm_nvhe_sym (kvm_host_sve_max_vl ); + +static inline bool guest_owns_fp_regs (struct kvm_vcpu *vcpu) +{ +return vcpu->arch.flags &KVM_ARM64_FP_ENABLED ; +} +#endif /* __ARM64_KVM_HYP_H__ */
arch/arm64/kvm/fpsimd.c +10 -9
@@ -129,15 +129,16 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcplocal_irq_save (flags);if (vcpu->arch.flags &KVM_ARM64_FP_ENABLED ) { -if (vcpu_has_sve (vcpu)) { -__vcpu_sys_reg (vcpu,ZCR_EL1 ) =read_sysreg_el1 (SYS_ZCR ); - -/* Restore the VL that was saved when bound to the CPU */ -if (!has_vhe ()) -sve_cond_update_zcr_vq (vcpu_sve_max_vq (vcpu) -1 , -SYS_ZCR_EL1 ); - } - +/* +* Flush (save and invalidate) the fpsimd/sve state so that if +* the host tries to use fpsimd/sve, it's not using stale data +* from the guest. +* +* Flushing the state sets the TIF_FOREIGN_FPSTATE bit for the +* context unconditionally, in both nVHE and VHE. This allows +* the kernel to restore the fpsimd/sve state, including ZCR_EL1 +* when needed. +*/ fpsimd_save_and_flush_cpu_state (); }
arch/arm64/kvm/hyp/entry.S +5 -0
@@ -44,6 +44,11 @@ alternative_if ARM64_HAS_RAS_EXTN alternative_else_nop_endif mrs x1, isr_el1 cbz x1, 1f + + // Ensure that __guest_enter() always provides a context + // synchronization event so that callers don't need ISBs for anything + // that would usually be synchonized by the ERET. + isb mov x0, #ARM_EXCEPTION_IRQ ret
arch/arm64/kvm/hyp/include/hyp/switch.h +55 -0
61 lines not on this page · raw message
arch/arm64/kvm/hyp/nvhe/hyp-main.c +4 -5
@@ -19,13 +19,17 @@ DEFINE_PER_CPU(struct kvm_nvhe_init_params, kvm_init_params); +unsigned int kvm_host_sve_max_vl; +void __kvm_hyp_host_forward_smc (struct kvm_cpu_context *host_ctxt);static void handle___kvm_vcpu_run (struct kvm_cpu_context *host_ctxt) { DECLARE_REG(struct kvm_vcpu *, vcpu, host_ctxt, 1); +fpsimd_lazy_switch_to_guest (kern_hyp_va (vcpu));cpu_reg (host_ctxt,1 ) =__kvm_vcpu_run (kern_hyp_va (vcpu)); +fpsimd_lazy_switch_to_host (kern_hyp_va (vcpu)); }static void handle___kvm_adjust_pc (struct kvm_cpu_context *host_ctxt)
@@ -237,11 +241,6 @@ void handle_trap(struct kvm_cpu_contextcase ESR_ELx_EC_SMC64:handle_host_smc (host_ctxt);break ; -case ESR_ELx_EC_SVE: -sysreg_clear_set (cptr_el2,CPTR_EL2_TZ ,0 ); -isb (); -sve_cond_update_zcr_vq (ZCR_ELx_LEN_MASK,SYS_ZCR_EL2 ); -break ;case ESR_ELx_EC_IABT_LOW:case ESR_ELx_EC_DABT_LOW:handle_host_mem_abort (host_ctxt);
arch/arm64/kvm/hyp/nvhe/switch.c +17 -14
@@ -34,15 +34,13 @@ DEFINE_PER_CPU(struct kvm_host_data, kvm DEFINE_PER_CPU(struct kvm_cpu_context, kvm_hyp_ctxt); DEFINE_PER_CPU(unsigned long, kvm_hyp_vector); -static bool guest_owns_fp_regs (struct kvm_vcpu *vcpu) -{ -return vcpu->arch.flags &KVM_ARM64_FP_ENABLED ; -} -static void __activate_cptr_traps (struct kvm_vcpu *vcpu) {u64 val =CPTR_EL2_TAM ;/* Same bit irrespective of E2H */ +if (!guest_owns_fp_regs (vcpu)) +__activate_traps_fpsimd32 (vcpu); +/* !hVHE case upstream */ if (1 ) { val |=CPTR_EL2_TTA |CPTR_NVHE_EL2_RES1 ;
@@ -52,12 +50,22 @@ static void __activate_cptr_traps(structif (!guest_owns_fp_regs (vcpu)) val |=CPTR_EL2_TFP ; + +write_sysreg (val, cptr_el2); } +} -if (!guest_owns_fp_regs (vcpu)) -__activate_traps_fpsimd32 (vcpu); +static void __deactivate_cptr_traps (struct kvm_vcpu *vcpu) +{ +/* !hVHE case upstream */ +if (1 ) { +u64 val =CPTR_NVHE_EL2_RES1 ; -write_sysreg (val, cptr_el2); +if (!cpus_have_final_cap (ARM64_SVE )) + val |=CPTR_EL2_TZ ; + +write_sysreg (val, cptr_el2); + } }static void __activate_traps (struct kvm_vcpu *vcpu)
@@ -86,7 +94,6 @@ static void __activate_traps(struct kvm_static void __deactivate_traps (struct kvm_vcpu *vcpu) {extern char __kvm_hyp_host_vector[]; -u64 cptr;___deactivate_traps (vcpu);
@@ -111,11 +118,7 @@ static void __deactivate_traps(struct kvwrite_sysreg (this_cpu_ptr (&kvm_init_params)->hcr_el2, hcr_el2); - cptr =CPTR_EL2_DEFAULT ; -if (vcpu_has_sve (vcpu) && (vcpu->arch.flags &KVM_ARM64_FP_ENABLED )) - cptr |=CPTR_EL2_TZ ; - -write_sysreg (cptr, cptr_el2); +__deactivate_cptr_traps (vcpu);write_sysreg (__kvm_hyp_host_vector, vbar_el2); }
arch/arm64/kvm/hyp/vhe/switch.c +4 -0
@@ -114,6 +114,8 @@ static int __kvm_vcpu_run_vhe(struct kvmsysreg_save_host_state_vhe (host_ctxt); +fpsimd_lazy_switch_to_guest (vcpu); +/* * ARM erratum 1165522 requires us to configure both stage 1 and * stage 2 translation for the guest context before we clear
@@ -144,6 +146,8 @@ static int __kvm_vcpu_run_vhe(struct kvm__deactivate_traps (vcpu); +fpsimd_lazy_switch_to_host (vcpu); +sysreg_restore_host_state_vhe (host_ctxt);if (vcpu->arch.flags &KVM_ARM64_FP_ENABLED )
arch/arm64/kvm/reset.c +3 -0
@@ -42,11 +42,14 @@ static u32 kvm_ipa_limit; PSR_AA32_I_BIT | PSR_AA32_F_BIT)unsigned int kvm_sve_max_vl; +unsigned int kvm_host_sve_max_vl;int kvm_arm_init_sve (void ) {if (system_supports_sve ()) { kvm_sve_max_vl = sve_max_virtualisable_vl; + kvm_host_sve_max_vl = sve_max_vl; +kvm_nvhe_sym (kvm_host_sve_max_vl) = kvm_host_sve_max_vl;/* * The get_sve_reg()/set_sve_reg() ioctl interface will need
Greg Kroah-Hartman
maintainerPATCH 197/373 cpufreq: Reference count policy in cpufreq_update_limits()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit 9e4e249018d208678888bdf22f6b652728106528 upstream.
Since acpi_processor_notify() can be called before registering a cpufreq driver or even in cases when a cpufreq driver is not registered at all, cpufreq_update_limits() needs to check if a cpufreq driver is present and prevent it from being unregistered.
For this purpose, make it call cpufreq_cpu_get() to obtain a cpufreq policy pointer for the given CPU and reference count the corresponding policy object, if present.
--- drivers/cpufreq/cpufreq.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/cpufreq/cpufreq.c +8 -0
@@ -2654,10 +2654,18 @@ EXPORT_SYMBOL(cpufreq_update_policy);*/ void cpufreq_update_limits (unsigned int cpu) { +struct cpufreq_policy *policy; + + policy =cpufreq_cpu_get (cpu); +if (!policy) +return ; +if (cpufreq_driver->update_limits) cpufreq_driver->update_limits (cpu);else cpufreq_update_policy (cpu); + +cpufreq_cpu_put (policy); }EXPORT_SYMBOL_GPL (cpufreq_update_limits);
Greg Kroah-Hartman
maintainerPATCH 198/373 kbuild: Add -fno-builtin-wcslen
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 84ffc79bfbf70c779e60218563f2f3ad45288671 upstream.
A recent optimization change in LLVM [1] aims to transform certain loop idioms into calls to strlen() or wcslen(). This change transforms the first while loop in UniStrcat() into a call to wcslen(), breaking the build when UniStrcat() gets inlined into alloc_path_with_tree_prefix():
ld.lld: error: undefined symbol: wcslen
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
referenced by nls_ucs2_utils.h:54 (
fs/smb/client/../../nls/nls_ucs2_utils.h:54)
vmlinux.o:(alloc_path_with_tree_prefix)
referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
vmlinux.o:(alloc_path_with_tree_prefix)
Disable this optimization with '-fno-builtin-wcslen', which prevents the compiler from assuming that wcslen() is available in the kernel's C library.
[ More to the point - it's not that we couldn't implement wcslen(), it's
that this isn't an optimization at all in the context of the kernel.
Replacing a simple inlined loop with a function call to the same loop is just stupid and pointless if you don't have long strings and fancy libraries with vectorization support etc.
For the regular 'strlen()' cases, we want the compiler to do this in order to handle the trivial case of constant strings. And we do have optimized versions of 'strlen()' on some architectures. But for
wcslen? Just no. - Linus ]
--- Makefile | 3 +++ 1 file changed, 3 insertions(+)
Makefile +3 -0
@@ -1066,6 +1066,9 @@ KBUILD_CFLAGS += $(call cc-option,-Wer # Require designated initializers for all marked structures KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) +# Ensure compilers do not transform certain loops into calls to wcslen() +KBUILD_CFLAGS += -fno-builtin-wcslen + # change __FILE__ to the relative path from the srctree KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
Greg Kroah-Hartman
maintainerPATCH 199/373 mptcp: sockopt: fix getting IPV6_V6ONLY
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 8c39633759885b6ff85f6d96cf445560e74df5e8 upstream.
When adding a socket option support in MPTCP, both the get and set parts are supposed to be implemented.
IPV6_V6ONLY support for the setsockopt part has been added a while ago, but it looks like the get part got forgotten. It should have been present as a way to verify a setting has been set as expected, and not to act differently from TCP or any other socket types.
Not supporting this getsockopt(IPV6_V6ONLY) blocks some apps which want to check the default value, before doing extra actions. On Linux, the default value is 0, but this can be changed with the net.ipv6.bindv6only sysctl knob. On Windows, it is set to 1 by default. So supporting the get part, like for all other socket options, is important.
Everything was in place to expose it, just the last step was missing. Only new code is added to cover this specific getsockopt(), that seems safe.
[ Conflicts in sockopt.c in the context, because commit 3b1e21eb60e8
("mptcp: getsockopt: add support for IP_TOS") is not in this release. The conflicts are in the context, the new helper can be added without issue. It depends on mptcp_put_int_option() which has been added via another backport, see commit 874aae15fbef ("mptcp: fix full TCP keep-alive support"). ]
--- net/mptcp/sockopt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/mptcp/sockopt.c +16 -0
@@ -793,6 +793,20 @@ static int mptcp_getsockopt_sol_tcp(strureturn -EOPNOTSUPP ; } +static int mptcp_getsockopt_v6 (struct mptcp_sock *msk,int optname, +char __user *optval,int __user *optlen) +{ +struct sock *sk = (void *)msk; + +switch (optname) { +case IPV6_V6ONLY : +return mptcp_put_int_option (msk, optval, optlen, + sk->sk_ipv6only); + } + +return -EOPNOTSUPP ; +} +int mptcp_getsockopt (struct sock *sk,int level,int optname,char __user *optval,int __user *option) {
@@ -813,6 +827,8 @@ int mptcp_getsockopt(struct sock *sk, inif (ssk)return tcp_getsockopt (ssk, level, optname, optval, option); +if (level ==SOL_IPV6 ) +return mptcp_getsockopt_v6 (msk, optname, optval, option);if (level ==SOL_TCP )return mptcp_getsockopt_sol_tcp (msk, optname, optval, option);return -EOPNOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 200/373 misc: pci_endpoint_test: Avoid issue of interrupts remaining after request_irq error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
commit f6cb7828c8e17520d4f5afb416515d3fae1af9a9 upstream.
After devm_request_irq() fails with error in pci_endpoint_test_request_irq(), the pci_endpoint_test_free_irq_vectors() is called assuming that all IRQs have been released.
However, some requested IRQs remain unreleased, so there are still /proc/irq/* entries remaining, and this results in WARN() with the following message:
remove_proc_entry: removing non-empty directory 'irq/30', leaking at least 'pci-endpoint-test.0'
WARNING: CPU: 0 PID: 202 at fs/proc/generic.c:719 remove_proc_entry +0x190/0x19c
To solve this issue, set the number of remaining IRQs to test->num_irqs, and release IRQs in advance by calling pci_endpoint_test_release_irq().
--- drivers/misc/pci_endpoint_test.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/pci_endpoint_test.c +3 -0
@@ -262,6 +262,9 @@ fail:break ; } + test->num_irqs = i; +pci_endpoint_test_release_irq (test); +return false; }
Greg Kroah-Hartman
maintainerPATCH 201/373 misc: pci_endpoint_test: Fix displaying irq_type after request_irq error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
commit 919d14603dab6a9cf03ebbeb2cfa556df48737c8 upstream.
There are two variables that indicate the interrupt type to be used in the next test execution, global "irq_type" and "test->irq_type".
The former is referenced from pci_endpoint_test_get_irq() to preserve the current type for ioctl(PCITEST_GET_IRQTYPE).
In the pci_endpoint_test_request_irq(), since this global variable is referenced when an error occurs, the unintended error message is displayed.
For example, after running "pcitest -i 2", the following message shows "MSI 3" even if the current IRQ type becomes "MSI-X":
pci-endpoint-test 0000:01:00.0: Failed to request IRQ 30 for MSI 3
SET IRQ TYPE TO MSI-X: NOT OKAY
Fix this issue by using "test->irq_type" instead of global "irq_type".
--- drivers/misc/pci_endpoint_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/pci_endpoint_test.c +1 -1
@@ -245,7 +245,7 @@ static bool pci_endpoint_test_request_irreturn true; fail: -switch (irq_type) { +switch (test->irq_type) {case IRQ_TYPE_LEGACY :dev_err (dev,"Failed to request IRQ %d for Legacy\n" ,pci_irq_vector (pdev, i));
Greg Kroah-Hartman
maintainerPATCH 202/373 misc: pci_endpoint_test: Fix irq_type to convey the correct type
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
commit baaef0a274cfb75f9b50eab3ef93205e604f662c upstream.
There are two variables that indicate the interrupt type to be used in the next test execution, "irq_type" as global and "test->irq_type".
The global is referenced from pci_endpoint_test_get_irq() to preserve the current type for ioctl(PCITEST_GET_IRQTYPE).
The type set in this function isn't reflected in the global "irq_type", so ioctl(PCITEST_GET_IRQTYPE) returns the previous type.
As a result, the wrong type is displayed in old version of "pcitest" as follows:
- Result of running "pcitest -i 0"
SET IRQ TYPE TO LEGACY: OKAY
- Result of running "pcitest -I"
GET IRQ TYPE: MSI
Whereas running the new version of "pcitest" in kselftest results in an error as follows:
# RUN pci_ep_basic.LEGACY_IRQ_TEST ...
# pci_endpoint_test.c:104:LEGACY_IRQ_TEST:Expected 0 (0) == ret (1) # pci_endpoint_test.c:104:LEGACY_IRQ_TEST:Can't get Legacy IRQ type
Fix this issue by propagating the current type to the global "irq_type".
--- drivers/misc/pci_endpoint_test.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/pci_endpoint_test.c +1 -0
@@ -717,6 +717,7 @@ static bool pci_endpoint_test_set_irq(stif (!pci_endpoint_test_request_irq (test)) goto err; + irq_type = test->irq_type;return true; err:
Greg Kroah-Hartman
maintainerPATCH 203/373 ipv6: release nexthop on device removal
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit eb02688c5c45c3e7af7e71f036a7144f5639cbfe ]
The CI is hitting some aperiodic hangup at device removal time in the pmtu.sh self-test:
unregister_netdevice: waiting for veth_A-R1 to become free. Usage count = 6ref_tracker: veth_A-R1@ffff888013df15d8 has 1/5 users at
dst_init+0x84/0x4a0 dst_alloc+0x97/0x150 ip6_dst_alloc+0x23/0x90 ip6_rt_pcpu_alloc+0x1e6/0x520 ip6_pol_route+0x56f/0x840 fib6_rule_lookup+0x334/0x630 ip6_route_output_flags+0x259/0x480 ip6_dst_lookup_tail.constprop.0+0x5c2/0x940 ip6_dst_lookup_flow+0x88/0x190 udp_tunnel6_dst_lookup+0x2a7/0x4c0 vxlan_xmit_one+0xbde/0x4a50 [vxlan] vxlan_xmit+0x9ad/0xf20 [vxlan] dev_hard_start_xmit+0x10e/0x360 __dev_queue_xmit+0xf95/0x18c0 arp_solicit+0x4a2/0xe00 neigh_probe+0xaa/0xf0
While the first suspect is the dst_cache, explicitly tracking the dst owing the last device reference via probes proved such dst is held by the nexthop in the originating fib6_info.
Similar to commit f5b51fe804ec ("ipv6: route: purge exception on removal"), we need to explicitly release the originating fib info when disconnecting a to-be-removed device from a live ipv6 dst: move the fib6_info cleanup into ip6_dst_ifdown().
Tested running:
./pmtu.sh cleanup_ipv6_exception
in a tight loop for more than 400 iterations with no spat, running an unpatched kernel I observed a splat every ~10 iterations.
[Harshit: Resolved conflict due to missing commit: e5f80fcf869a ("ipv6:
give an IPv6 dev to blackhole_netdev") and commit: b4cb4a1391dc ("net:
use unrcu_pointer() helper") in linux-5.15.y]
--- net/ipv6/route.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv6/route.c +3 -3
@@ -377,6 +377,7 @@ static void ip6_dst_ifdown(struct dst_enstruct inet6_dev *idev = rt->rt6i_idev;struct net_device *loopback_dev =dev_net (dev)->loopback_dev; +struct fib6_info *from;if (idev && idev->dev != loopback_dev) {struct inet6_dev *loopback_idev =in6_dev_get (loopback_dev);
@@ -385,6 +386,8 @@ static void ip6_dst_ifdown(struct dst_enin6_dev_put (idev); } } + from =xchg ((__force struct fib6_info **)&rt->from,NULL ); +fib6_info_release (from); }static bool __rt6_check_expired (const struct rt6_info *rt)
@@ -1443,7 +1446,6 @@ static DEFINE_SPINLOCK(rt6_exception_locstatic void rt6_remove_exception (struct rt6_exception_bucket *bucket,struct rt6_exception *rt6_ex) { -struct fib6_info *from;struct net *net;if (!bucket || !rt6_ex)
@@ -1455,8 +1457,6 @@ static void rt6_remove_exception(struct/* purge completely the exception to allow releasing the held resources: * some [sk] cache may keep the dst around for unlimited time */ - from =xchg ((__force struct fib6_info **)&rt6_ex->rt6i->from,NULL ); -fib6_info_release (from);dst_dev_put (&rt6_ex->rt6i->dst);hlist_del_rcu (&rt6_ex->hlist);
Greg Kroah-Hartman
maintainerPATCH 204/373 net: fix crash when config small gso_max_size/gso_ipv4_max_size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Liang <[email protected]>
[ Upstream commit 9ab5cf19fb0e4680f95e506d6c544259bf1111c4 ]
Config a small gso_max_size/gso_ipv4_max_size will lead to an underflow in sk_dst_gso_max_size(), which may trigger a BUG_ON crash, because sk->sk_gso_max_size would be much bigger than device limits.
Call Trace:
tcp_write_xmit
tso_segs = tcp_init_tso_segs(skb, mss_now);
tcp_set_skb_tso_segs
tcp_skb_pcount_set
// skb->len = 524288, mss_now = 8
// u16 tso_segs = 524288/8 = 65535 -> 0
tso_segs = DIV_ROUND_UP(skb->len, mss_now)
BUG_ON(!tso_segs)Add check for the minimum value of gso_max_size and gso_ipv4_max_size.
--- net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/rtnetlink.c +1 -1
@@ -1899,7 +1899,7 @@ static const struct nla_policy ifla_poli [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 }, [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, [IFLA_GSO_MAX_SEGS] = { .type = NLA_U32 }, - [IFLA_GSO_MAX_SIZE] = { .type = NLA_U32 }, + [IFLA_GSO_MAX_SIZE] = NLA_POLICY_MIN(NLA_U32, MAX_TCP_HEADER + 1), [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN }, [IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */ [IFLA_PHYS_SWITCH_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
Greg Kroah-Hartman
maintainerPATCH 205/373 filemap: Fix bounds checking in filemap_read()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
[ Upstream commit ace149e0830c380ddfce7e466fe860ca502fe4ee ]
If the caller supplies an iocb->ki_pos value that is close to the filesystem upper limit, and an iterator with a count that causes us to overflow that limit, then filemap_read() enters an infinite loop.
This behaviour was discovered when testing xfstests generic/525 with the "localio" optimisation for loopback NFS mounts.
[Harshit: Minor conflict resolved due to missing commit: 25d6a23e8d28 ("filemap: Convert filemap_get_read_batch() to use a folio_batch") in 5.15.y]
--- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +1 -1
@@ -2617,7 +2617,7 @@ ssize_t filemap_read(struct kiocb *iocb,if (unlikely (!iov_iter_count (iter)))return 0 ; -iov_iter_truncate (iter, inode->i_sb->s_maxbytes); +iov_iter_truncate (iter, inode->i_sb->s_maxbytes - iocb->ki_pos);pagevec_init (&pvec); do {
Greg Kroah-Hartman
maintainerPATCH 206/373 phonet/pep: fix racy skb_queue_empty() use
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rémi Denis-Courmont <[email protected]>
[ Upstream commit 7d2a894d7f487dcb894df023e9d3014cf5b93fe5 ]
The receive queues are protected by their respective spin-lock, not the socket lock. This could lead to skb_peek() unexpectedly returning NULL or a pointer to an already dequeued socket buffer.
--- net/phonet/pep.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
net/phonet/pep.c +32 -9
@@ -916,6 +916,37 @@ static int pep_sock_enable(struct sock *return 0 ; } +static unsigned int pep_first_packet_length (struct sock *sk) +{ +struct pep_sock *pn =pep_sk (sk); +struct sk_buff_head *q; +struct sk_buff *skb; +unsigned int len =0 ; +bool found = false; + +if (sock_flag (sk,SOCK_URGINLINE )) { + q = &pn->ctrlreq_queue; +spin_lock_bh (&q->lock); + skb =skb_peek (q); +if (skb) { + len = skb->len; + found = true; + } +spin_unlock_bh (&q->lock); + } + +if (likely (!found)) { + q = &sk->sk_receive_queue; +spin_lock_bh (&q->lock); + skb =skb_peek (q); +if (skb) + len = skb->len; +spin_unlock_bh (&q->lock); + } + +return len; +} +static int pep_ioctl (struct sock *sk,int cmd,unsigned long arg) {struct pep_sock *pn =pep_sk (sk);
@@ -929,15 +960,7 @@ static int pep_ioctl(struct sock *sk, inbreak ; } -lock_sock (sk); -if (sock_flag (sk,SOCK_URGINLINE ) && - !skb_queue_empty (&pn->ctrlreq_queue)) - answ =skb_peek (&pn->ctrlreq_queue)->len; -else if (!skb_queue_empty (&sk->sk_receive_queue)) - answ =skb_peek (&sk->sk_receive_queue)->len; -else - answ =0 ; -release_sock (sk); + answ =pep_first_packet_length (sk); ret =put_user (answ, (int __user *)arg);break ;
Greg Kroah-Hartman
maintainerPATCH 207/373 bnxt_re: avoid shift undefined behavior in bnxt_qplib_alloc_init_hwq
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Schmidt <[email protected]>
commit 78cfd17142ef70599d6409cbd709d94b3da58659 upstream.
Undefined behavior is triggered when bnxt_qplib_alloc_init_hwq is called with hwq_attr->aux_depth != 0 and hwq_attr->aux_stride == 0. In that case, "roundup_pow_of_two(hwq_attr->aux_stride)" gets called. roundup_pow_of_two is documented as undefined for 0.
Fix it in the one caller that had this combination.
The undefined behavior was detected by UBSAN:
UBSAN: shift-out-of-bounds in ./include/linux/log2.h:57:13 shift exponent 64 is too large for 64-bit type 'long unsigned int' CPU: 24 PID: 1075 Comm: (udev-worker) Not tainted 6.9.0-rc6+ #4 Hardware name: Abacus electric, s.r.o. - [email protected] Super Server/H12SSW-iN, BIOS 2.7 10/25/2023 Call Trace: <TASK> dump_stack_lvl+0x5d/0x80 ubsan_epilogue+0x5/0x30 __ubsan_handle_shift_out_of_bounds.cold+0x61/0xec __roundup_pow_of_two+0x25/0x35 [bnxt_re] bnxt_qplib_alloc_init_hwq+0xa1/0x470 [bnxt_re] bnxt_qplib_create_qp+0x19e/0x840 [bnxt_re] bnxt_re_create_qp+0x9b1/0xcd0 [bnxt_re] ? srso_alias_return_thunk+0x5/0xfbef5 ? srso_alias_return_thunk+0x5/0xfbef5 ? __kmalloc+0x1b6/0x4f0 ? create_qp.part.0+0x128/0x1c0 [ib_core] ? __pfx_bnxt_re_create_qp+0x10/0x10 [bnxt_re] create_qp.part.0+0x128/0x1c0 [ib_core] ib_create_qp_kernel+0x50/0xd0 [ib_core] create_mad_qp+0x8e/0xe0 [ib_core] ? __pfx_qp_event_handler+0x10/0x10 [ib_core] ib_mad_init_device+0x2be/0x680 [ib_core] add_client_context+0x10d/0x1a0 [ib_core] enable_device_and_get+0xe0/0x1d0 [ib_core] ib_register_device+0x53c/0x630 [ib_core] ? srso_alias_return_thunk+0x5/0xfbef5 bnxt_re_probe+0xbd8/0xe50 [bnxt_re] ? __pfx_bnxt_re_probe+0x10/0x10 [bnxt_re] auxiliary_bus_probe+0x49/0x80 ? driver_sysfs_add+0x57/0xc0 really_probe+0xde/0x340 ? pm_runtime_barrier+0x54/0x90 ? __pfx___driver_attach+0x10/0x10 __driver_probe_device+0x78/0x110 driver_probe_device+0x1f/0xa0 __driver_attach+0xba/0x1c0 bus_for_each_dev+0x8f/0xe0 bus_add_driver+0x146/0x220 driver_register+0x72/0xd0 __auxiliary_driver_register+0x6e/0xd0 ? __pfx_bnxt_re_mod_init+0x10/0x10 [bnxt_re] bnxt_re_mod_init+0x3e/0xff0 [bnxt_re] ? __pfx_bnxt_re_mod_init+0x10/0x10 [bnxt_re] do_one_initcall+0x5b/0x310 do_init_module+0x90/0x250 init_module_from_file+0x86/0xc0 idempotent_init_module+0x121/0x2b0 __x64_sys_finit_module+0x5e/0xb0 do_syscall_64+0x82/0x160 ? srso_alias_return_thunk+0x5/0xfbef5 ? syscall_exit_to_user_mode_prepare+0x149/0x170 ? srso_alias_return_thunk+0x5/0xfbef5 ? syscall_exit_to_user_mode+0x75/0x230 ? srso_alias_return_thunk+0x5/0xfbef5 ? do_syscall_64+0x8e/0x160 ? srso_alias_return_thunk+0x5/0xfbef5 ? __count_memcg_events+0x69/0x100 ? srso_alias_return_thunk+0x5/0xfbef5 ? count_memcg_events.constprop.0+0x1a/0x30 ? srso_alias_return_thunk+0x5/0xfbef5 ? handle_mm_fault+0x1f0/0x300 ? srso_alias_return_thunk+0x5/0xfbef5 ? do_user_addr_fault+0x34e/0x640 ? srso_alias_return_thunk+0x5/0xfbef5 ? srso_alias_return_thunk+0x5/0xfbef5 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7f4e5132821d Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 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 8b 0d e3 db 0c 00 f7 d8 64 89 01 48 RSP: 002b:00007ffca9c906a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 0000563ec8a8f130 RCX: 00007f4e5132821d RDX: 0000000000000000 RSI: 00007f4e518fa07d RDI: 000000000000003b RBP: 00007ffca9c90760 R08: 00007f4e513f6b20 R09: 00007ffca9c906f0 R10: 0000563ec8a8faa0 R11: 0000000000000246 R12: 00007f4e518fa07d R13: 0000000000020000 R14: 0000563ec8409e90 R15: 0000563ec8a8fa60 </TASK> ---[ end trace ]---
[Harshit: backport to 5.15.y, this is a clean cherrypick from 6.1.y commit ]
--- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/qplib_fp.c +2 -1
@@ -1013,7 +1013,8 @@ int bnxt_qplib_create_qp(struct bnxt_qpl hwq_attr.stride =sizeof (struct sq_sge ); hwq_attr.depth =bnxt_qplib_get_depth (sq); hwq_attr.aux_stride = psn_sz; - hwq_attr.aux_depth =bnxt_qplib_set_sq_size (sq, qp->wqe_mode); + hwq_attr.aux_depth = psn_sz ?bnxt_qplib_set_sq_size (sq, qp->wqe_mode) + :0 ; hwq_attr.type =HWQ_TYPE_QUEUE ; rc =bnxt_qplib_alloc_init_hwq (&sq->hwq, &hwq_attr);if (rc)
Greg Kroah-Hartman
maintainerPATCH 208/373 net: mana: Fix error handling in mana_create_txq/rxqs NAPI cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Souradeep Chakrabarti <[email protected]>
[ Upstream commit b6ecc662037694488bfff7c9fd21c405df8411f2 ]
Currently napi_disable() gets called during rxq and txq cleanup, even before napi is enabled and hrtimer is initialized. It causes kernel panic.
? page_fault_oops+0x136/0x2b0 ? page_counter_cancel+0x2e/0x80 ? do_user_addr_fault+0x2f2/0x640 ? refill_obj_stock+0xc4/0x110 ? exc_page_fault+0x71/0x160 ? asm_exc_page_fault+0x27/0x30 ? __mmdrop+0x10/0x180 ? __mmdrop+0xec/0x180 ? hrtimer_active+0xd/0x50 hrtimer_try_to_cancel+0x2c/0xf0 hrtimer_cancel+0x15/0x30 napi_disable+0x65/0x90 mana_destroy_rxq+0x4c/0x2f0 mana_create_rxq.isra.0+0x56c/0x6d0 ? mana_uncfg_vport+0x50/0x50 mana_alloc_queues+0x21b/0x320 ? skb_dequeue+0x5f/0x80
[Harshit: conflicts resolved due to missing commit: ed5356b53f07 ("net:
mana: Add XDP support") and commit: d356abb95b98 ("net: mana: Add counter for XDP_TX") in 5.15.y]
--- drivers/net/ethernet/microsoft/mana/mana.h | 2 ++ drivers/net/ethernet/microsoft/mana/mana_en.c | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/net/ethernet/microsoft/mana/mana.h +2 -0
@@ -76,6 +76,8 @@ struct mana_txq {atomic_t pending_sends; +bool napi_initialized; +struct mana_stats stats; };
drivers/net/ethernet/microsoft/mana/mana_en.c +13 -8
@@ -1154,10 +1154,12 @@ static void mana_destroy_txq(struct manafor (i =0 ; i < apc->num_queues; i++) { napi = &apc->tx_qp[i].tx_cq.napi; -napi_synchronize (napi); -napi_disable (napi); -netif_napi_del (napi); - +if (apc->tx_qp[i].txq.napi_initialized) { +napi_synchronize (napi); +napi_disable (napi); +netif_napi_del (napi); + apc->tx_qp[i].txq.napi_initialized = false; + }mana_destroy_wq_obj (apc,GDMA_SQ , apc->tx_qp[i].tx_object);mana_deinit_cq (apc, &apc->tx_qp[i].tx_cq);
@@ -1213,6 +1215,7 @@ static int mana_create_txq(struct mana_p txq->ndev = net; txq->net_txq =netdev_get_tx_queue (net, i); txq->vp_offset = apc->tx_vp_offset; + txq->napi_initialized = false;skb_queue_head_init (&txq->pending_skbs);memset (&spec,0 ,sizeof (spec));
@@ -1277,6 +1280,7 @@ static int mana_create_txq(struct mana_pnetif_tx_napi_add (net, &cq->napi, mana_poll,NAPI_POLL_WEIGHT );napi_enable (&cq->napi); + txq->napi_initialized = true;mana_gd_ring_cq (cq->gdma_cq,SET_ARM_BIT ); }
@@ -1288,7 +1292,7 @@ out: }static void mana_destroy_rxq (struct mana_port_context *apc, -struct mana_rxq *rxq,bool validate_state) +struct mana_rxq *rxq,bool napi_initialized) {struct gdma_context *gc = apc->ac->gdma_dev->gdma_context;
@@ -1302,12 +1306,13 @@ static void mana_destroy_rxq(struct mana napi = &rxq->rx_cq.napi; -if (validate_state) +if (napi_initialized) {napi_synchronize (napi); -napi_disable (napi); -netif_napi_del (napi); +napi_disable (napi); +netif_napi_del (napi); + }mana_destroy_wq_obj (apc,GDMA_RQ , rxq->rxobj);mana_deinit_cq (apc, &rxq->rx_cq);
Greg Kroah-Hartman
maintainerPATCH 209/373 x86/pvh: Call C code via the kernel virtual mapping
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit e8fbc0d9cab6c1ee6403f42c0991b0c1d5dbc092 upstream.
Calling C code via a different mapping than it was linked at is problematic, because the compiler assumes that RIP-relative and absolute symbol references are interchangeable. GCC in particular may use RIP-relative per-CPU variable references even when not using -fpic.
So call xen_prepare_pvh() via its kernel virtual mapping on x86_64, so that those RIP-relative references produce the correct values. This matches the pre-existing behavior for i386, which also invokes xen_prepare_pvh() via the kernel virtual mapping before invoking startup_32 with paging disabled again.
Message-ID: <[email protected]>
--- arch/x86/platform/pvh/head.S | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/platform/pvh/head.S +6 -1
@@ -99,7 +99,12 @@ SYM_CODE_START_LOCAL(pvh_start_xen) xor %edx, %edx wrmsr - call xen_prepare_pvh + /* Call xen_prepare_pvh() via the kernel virtual mapping */ + leaq xen_prepare_pvh(%rip), %rax + subq phys_base(%rip), %rax + addq $__START_KERNEL_map, %rax + ANNOTATE_RETPOLINE_SAFE + call *%rax /* startup_64 expects boot_params in %rsi. */ mov $_pa(pvh_bootparams), %rsi
Greg Kroah-Hartman
maintainerPATCH 210/373 powerpc/rtas: Prevent Spectre v1 gadget construction in sys_rtas()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Lynch <[email protected]>
commit 0974d03eb479384466d828d65637814bee6b26d7 upstream.
Smatch warns:
arch/powerpc/kernel/rtas.c:1932 __do_sys_rtas() warn: potential spectre issue 'args.args' [r] (local cap)
The 'nargs' and 'nret' locals come directly from a user-supplied buffer and are used as indexes into a small stack-based array and as inputs to copy_to_user() after they are subject to bounds checks.
Use array_index_nospec() after the bounds checks to clamp these values for speculative execution.
--- arch/powerpc/kernel/rtas.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/kernel/rtas.c +4 -0
@@ -16,6 +16,7 @@#include <linux/capability.h> #include <linux/delay.h> #include <linux/cpu.h> +#include <linux/nospec.h> #include <linux/sched.h> #include <linux/smp.h> #include <linux/completion.h>
@@ -1076,6 +1077,9 @@ SYSCALL_DEFINE1(rtas, struct rtas_args _ || nargs + nret > ARRAY_SIZE(args.args))return -EINVAL ; + nargs =array_index_nospec (nargs,ARRAY_SIZE (args.args)); + nret =array_index_nospec (nret,ARRAY_SIZE (args.args) - nargs); +/* Copy in args. */ if (copy_from_user (args.args, uargs->args, nargs *sizeof (rtas_arg_t)) !=0 )
Greg Kroah-Hartman
maintainerPATCH 211/373 phy: tegra: xusb: Fix return value of tegra_xusb_find_port_node function
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaoqian Lin <[email protected]>
commit 045a31b95509c8f25f5f04ec5e0dec5cd09f2c5f upstream.
callers of tegra_xusb_find_port_node() function only do NULL checking for the return value. return NULL instead of ERR_PTR(-ENOMEM) to keep consistent.
--- drivers/phy/tegra/xusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/tegra/xusb.c +1 -1
@@ -455,7 +455,7 @@ tegra_xusb_find_port_node(struct tegra_x name =kasprintf (GFP_KERNEL ,"%s-%u" , type, index);if (!name) {of_node_put (ports); -return ERR_PTR (-ENOMEM ); +return NULL ; } np =of_get_child_by_name (ports, name);kfree (name);
Greg Kroah-Hartman
maintainerPATCH 212/373 wifi: ath10k: avoid NULL pointer error during sdio remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kang Yang <[email protected]>
commit 95c38953cb1ecf40399a676a1f85dfe2b5780a9a upstream.
When running 'rmmod ath10k', ath10k_sdio_remove() will free sdio workqueue by destroy_workqueue(). But if CONFIG_INIT_ON_FREE_DEFAULT_ON is set to yes, kernel panic will happen:
Call trace: destroy_workqueue+0x1c/0x258 ath10k_sdio_remove+0x84/0x94 sdio_bus_remove+0x50/0x16c device_release_driver_internal+0x188/0x25c device_driver_detach+0x20/0x2c
This is because during 'rmmod ath10k', ath10k_sdio_remove() will call ath10k_core_destroy() before destroy_workqueue(). wiphy_dev_release() will finally be called in ath10k_core_destroy(). This function will free struct cfg80211_registered_device *rdev and all its members, including wiphy, dev and the pointer of sdio workqueue. Then the pointer of sdio workqueue will be set to NULL due to CONFIG_INIT_ON_FREE_DEFAULT_ON.
After device release, destroy_workqueue() will use NULL pointer then the kernel panic happen.
Call trace:
ath10k_sdio_remove
->ath10k_core_unregister
……
->ath10k_core_stop
->ath10k_hif_stop
->ath10k_sdio_irq_disable
->ath10k_hif_power_down
->del_timer_sync(&ar_sdio->sleep_timer)
->ath10k_core_destroy
->ath10k_mac_destroy
->ieee80211_free_hw
->wiphy_free
……
->wiphy_dev_release->destroy_workqueue
Need to call destroy_workqueue() before ath10k_core_destroy(), free the work queue buffer first and then free pointer of work queue by ath10k_core_destroy(). This order matches the error path order in ath10k_sdio_probe().
No work will be queued on sdio workqueue between it is destroyed and ath10k_core_destroy() is called. Based on the call_stack above, the reason is:
Only ath10k_sdio_sleep_timer_handler(), ath10k_sdio_hif_tx_sg() and ath10k_sdio_irq_disable() will queue work on sdio workqueue. Sleep timer will be deleted before ath10k_core_destroy() in ath10k_hif_power_down().ath10k_sdio_irq_disable() only be called in ath10k_hif_stop(). ath10k_core_unregister() will call ath10k_hif_power_down() to stop hif bus, so ath10k_sdio_hif_tx_sg() won't be called anymore.
Tested-on: QCA6174 hw3.2 SDIO WLAN.RMH.4.4.1-00189
--- drivers/net/wireless/ath/ath10k/sdio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/sdio.c +3 -2
@@ -3,6 +3,7 @@* Copyright (c) 2004-2011 Atheros Communications Inc. * Copyright (c) 2011-2012,2017 Qualcomm Atheros, Inc. * Copyright (c) 2016-2017 Erik Stromdahl <[email protected]> +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/module.h>
@@ -2648,9 +2649,9 @@ static void ath10k_sdio_remove(struct sdnetif_napi_del (&ar->napi); -ath10k_core_destroy (ar); -destroy_workqueue (ar_sdio->workqueue); + +ath10k_core_destroy (ar); }static const struct sdio_device_id ath10k_sdio_devices[] = {
Greg Kroah-Hartman
maintainerPATCH 213/373 drm/amd/display: Stop amdgpu_dm initialize when link nums greater than max_links
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hersen Wu <[email protected]>
commit cf8b16857db702ceb8d52f9219a4613363e2b1cf upstream.
[Why]
Coverity report OVERRUN warning. There are only max_links elements within dc->links. link count could up to AMDGPU_DM_MAX_DISPLAY_INDEX 31.
[How]
Make sure link count less than max_links.
[Minor conflict resolved due to code context change. And the macro MAX_LINKS
is introduced by Commit 60df5628144b ("drm/amd/display: handle invalid connector indices") after 6.10. So here we still use the original array length MAX_PIPES * 2]
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -7
@@ -4321,17 +4321,17 @@ static int amdgpu_dm_initialize_drm_devi }#endif +if (link_cnt > (MAX_PIPES *2 )) { +DRM_ERROR ( +"KMS: Cannot support more than %d display indexes\n" , +MAX_PIPES *2 ); + goto fail; + } +/* loops over all connectors on the board */ for (i =0 ; i < link_cnt; i++) {struct dc_link *link =NULL ; -if (i >AMDGPU_DM_MAX_DISPLAY_INDEX ) { -DRM_ERROR ( -"KMS: Cannot support more than %d display indexes\n" , -AMDGPU_DM_MAX_DISPLAY_INDEX ); -continue ; - } - aconnector =kzalloc (sizeof (*aconnector),GFP_KERNEL );if (!aconnector) goto fail;
Greg Kroah-Hartman
maintainerPATCH 214/373 drm/amd/display: Fix out-of-bounds access in dcn21_link_encoder_create
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
commit 63de35a8fcfca59ae8750d469a7eb220c7557baf upstream.
An issue was identified in the dcn21_link_encoder_create function where an out-of-bounds access could occur when the hpd_source index was used to reference the link_enc_hpd_regs array. This array has a fixed size and the index was not being checked against the array's bounds before accessing it.
This fix adds a conditional check to ensure that the hpd_source index is within the valid range of the link_enc_hpd_regs array. If the index is out of bounds, the function now returns NULL to prevent undefined behavior.
References:
[ 65.920507] ------------[ cut here ]------------ [ 65.920510] UBSAN: array-index-out-of-bounds in drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn21/dcn21_resource.c:1312:29 [ 65.920519] index 7 is out of range for type 'dcn10_link_enc_hpd_registers [5]' [ 65.920523] CPU: 3 PID: 1178 Comm: modprobe Tainted: G OE 6.8.0-cleanershaderfeatureresetasdntipmi200nv2132 #13 [ 65.920525] Hardware name: AMD Majolica-RN/Majolica-RN, BIOS WMJ0429N_Weekly_20_04_2 04/29/2020 [ 65.920527] Call Trace: [ 65.920529] <TASK> [ 65.920532] dump_stack_lvl+0x48/0x70 [ 65.920541] dump_stack+0x10/0x20 [ 65.920543] __ubsan_handle_out_of_bounds+0xa2/0xe0 [ 65.920549] dcn21_link_encoder_create+0xd9/0x140 [amdgpu] [ 65.921009] link_create+0x6d3/0xed0 [amdgpu] [ 65.921355] create_links+0x18a/0x4e0 [amdgpu] [ 65.921679] dc_create+0x360/0x720 [amdgpu] [ 65.921999] ? dmi_matches+0xa0/0x220 [ 65.922004] amdgpu_dm_init+0x2b6/0x2c90 [amdgpu] [ 65.922342] ? console_unlock+0x77/0x120 [ 65.922348] ? dev_printk_emit+0x86/0xb0 [ 65.922354] dm_hw_init+0x15/0x40 [amdgpu] [ 65.922686] amdgpu_device_init+0x26a8/0x33a0 [amdgpu] [ 65.922921] amdgpu_driver_load_kms+0x1b/0xa0 [amdgpu] [ 65.923087] amdgpu_pci_probe+0x1b7/0x630 [amdgpu] [ 65.923087] local_pci_probe+0x4b/0xb0 [ 65.923087] pci_device_probe+0xc8/0x280 [ 65.923087] really_probe+0x187/0x300 [ 65.923087] __driver_probe_device+0x85/0x130 [ 65.923087] driver_probe_device+0x24/0x110 [ 65.923087] __driver_attach+0xac/0x1d0 [ 65.923087] ? __pfx___driver_attach+0x10/0x10 [ 65.923087] bus_for_each_dev+0x7d/0xd0 [ 65.923087] driver_attach+0x1e/0x30 [ 65.923087] bus_add_driver+0xf2/0x200 [ 65.923087] driver_register+0x64/0x130 [ 65.923087] ? __pfx_amdgpu_init+0x10/0x10 [amdgpu] [ 65.923087] __pci_register_driver+0x61/0x70 [ 65.923087] amdgpu_init+0x7d/0xff0 [amdgpu] [ 65.923087] do_one_initcall+0x49/0x310 [ 65.923087] ? kmalloc_trace+0x136/0x360 [ 65.923087] do_init_module+0x6a/0x270 [ 65.923087] load_module+0x1fce/0x23a0 [ 65.923087] init_module_from_file+0x9c/0xe0 [ 65.923087] ? init_module_from_file+0x9c/0xe0 [ 65.923087] idempotent_init_module+0x179/0x230 [ 65.923087] __x64_sys_finit_module+0x5d/0xa0 [ 65.923087] do_syscall_64+0x76/0x120 [ 65.923087] entry_SYSCALL_64_after_hwframe+0x6e/0x76 [ 65.923087] RIP: 0033:0x7f2d80f1e88d [ 65.923087] Code: 5b 41 5c c3 66 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 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 8b 0d 73 b5 0f 00 f7 d8 64 89 01 48 [ 65.923087] RSP: 002b:00007ffc7bc1aa78 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 65.923087] RAX: ffffffffffffffda RBX: 0000564c9c1db130 RCX: 00007f2d80f1e88d [ 65.923087] RDX: 0000000000000000 RSI: 0000564c9c1e5480 RDI: 000000000000000f [ 65.923087] RBP: 0000000000040000 R08: 0000000000000000 R09: 0000000000000002 [ 65.923087] R10: 000000000000000f R11: 0000000000000246 R12: 0000564c9c1e5480 [ 65.923087] R13: 0000564c9c1db260 R14: 0000000000000000 R15: 0000564c9c1e54b0 [ 65.923087] </TASK> [ 65.923927] ---[ end trace ]---
--- drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c +1 -1
@@ -1852,7 +1852,7 @@ static struct link_encoder *dcn21_link_ekzalloc (sizeof (struct dcn21_link_encoder ),GFP_KERNEL );int link_regs_id; -if (!enc21) +if (!enc21 || enc_init_data->hpd_source >=ARRAY_SIZE (link_enc_hpd_regs))return NULL ; link_regs_id =
Greg Kroah-Hartman
maintainerPATCH 215/373 drm/amd/display: Add null checks for stream and plane before dereferencing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
commit 15c2990e0f0108b9c3752d7072a97d45d4283aea upstream.
This commit adds null checks for the 'stream' and 'plane' variables in the dcn30_apply_idle_power_optimizations function. These variables were previously assumed to be null at line 922, but they were used later in the code without checking if they were null. This could potentially lead to a null pointer dereference, which would cause a crash.
The null checks ensure that 'stream' and 'plane' are not null before they are used, preventing potential crashes.
Fixes the below static smatch checker:drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:938 dcn30_apply_idle_power_optimizations() error: we previously assumed 'stream' could be null (see line 922) drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:940 dcn30_apply_idle_power_optimizations() error: we previously assumed 'plane' could be null (see line 922)
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +3 -0
@@ -784,6 +784,9 @@ bool dcn30_apply_idle_power_optimization stream = dc->current_state->streams[0 ]; plane = (stream ? dc->current_state->stream_status[0 ].plane_states[0 ] :NULL ); +if (!stream || !plane) +return false; +if (stream && plane) { cursor_cache_enable = stream->cursor_position.enable && plane->address.grph.cursor_cache_addr.quad_part;
Greg Kroah-Hartman
maintainerPATCH 216/373 drm/amdgpu: fix usage slab after free
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaly Prosyak <[email protected]>
commit b61badd20b443eabe132314669bb51a263982e5c upstream.
[ +0.000021] BUG: KASAN: slab-use-after-free in drm_sched_entity_flush+0x6cb/0x7a0 [gpu_sched] [ +0.000027] Read of size 8 at addr ffff8881b8605f88 by task amd_pci_unplug/2147
[ +0.000023] CPU: 6 PID: 2147 Comm: amd_pci_unplug Not tainted 6.10.0+ #1 [ +0.000016] Hardware name: ASUS System Product Name/ROG STRIX B550-F GAMING (WI-FI), BIOS 1401 12/03/2020 [ +0.000016] Call Trace: [ +0.000008] <TASK> [ +0.000009] dump_stack_lvl+0x76/0xa0 [ +0.000017] print_report+0xce/0x5f0 [ +0.000017] ? drm_sched_entity_flush+0x6cb/0x7a0 [gpu_sched] [ +0.000019] ? srso_return_thunk+0x5/0x5f [ +0.000015] ? kasan_complete_mode_report_info+0x72/0x200 [ +0.000016] ? drm_sched_entity_flush+0x6cb/0x7a0 [gpu_sched] [ +0.000019] kasan_report+0xbe/0x110 [ +0.000015] ? drm_sched_entity_flush+0x6cb/0x7a0 [gpu_sched] [ +0.000023] __asan_report_load8_noabort+0x14/0x30 [ +0.000014] drm_sched_entity_flush+0x6cb/0x7a0 [gpu_sched] [ +0.000020] ? srso_return_thunk+0x5/0x5f [ +0.000013] ? __kasan_check_write+0x14/0x30 [ +0.000016] ? __pfx_drm_sched_entity_flush+0x10/0x10 [gpu_sched] [ +0.000020] ? srso_return_thunk+0x5/0x5f [ +0.000013] ? __kasan_check_write+0x14/0x30 [ +0.000013] ? srso_return_thunk+0x5/0x5f [ +0.000013] ? enable_work+0x124/0x220 [ +0.000015] ? __pfx_enable_work+0x10/0x10 [ +0.000013] ? srso_return_thunk+0x5/0x5f [ +0.000014] ? free_large_kmalloc+0x85/0xf0 [ +0.000016] drm_sched_entity_destroy+0x18/0x30 [gpu_sched] [ +0.000020] amdgpu_vce_sw_fini+0x55/0x170 [amdgpu] [ +0.000735] ? __kasan_check_read+0x11/0x20 [ +0.000016] vce_v4_0_sw_fini+0x80/0x110 [amdgpu] [ +0.000726] amdgpu_device_fini_sw+0x331/0xfc0 [amdgpu] [ +0.000679] ? mutex_unlock+0x80/0xe0 [ +0.000017] ? __pfx_amdgpu_device_fini_sw+0x10/0x10 [amdgpu] [ +0.000662] ? srso_return_thunk+0x5/0x5f [ +0.000014] ? __kasan_check_write+0x14/0x30 [ +0.000013] ? srso_return_thunk+0x5/0x5f [ +0.000013] ? mutex_unlock+0x80/0xe0 [ +0.000016] amdgpu_driver_release_kms+0x16/0x80 [amdgpu] [ +0.000663] drm_minor_release+0xc9/0x140 [drm] [ +0.000081] drm_release+0x1fd/0x390 [drm] [ +0.000082] __fput+0x36c/0xad0 [ +0.000018] __fput_sync+0x3c/0x50 [ +0.000014] __x64_sys_close+0x7d/0xe0 [ +0.000014] x64_sys_call+0x1bc6/0x2680 [ +0.000014] do_syscall_64+0x70/0x130 [ +0.000014] ? srso_return_thunk+0x5/0x5f [ +0.000014] ? irqentry_exit_to_user_mode+0x60/0x190 [ +0.000015] ? srso_return_thunk+0x5/0x5f [ +0.000014] ? irqentry_exit+0x43/0x50 [ +0.000012] ? srso_return_thunk+0x5/0x5f [ +0.000013] ? exc_page_fault+0x7c/0x110 [ +0.000015] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ +0.000014] RIP: 0033:0x7ffff7b14f67 [ +0.000013] Code: ff e8 0d 16 02 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 41 c3 48 83 ec 18 89 7c 24 0c e8 73 ba f7 ff [ +0.000026] RSP: 002b:00007fffffffe378 EFLAGS: 00000246 ORIG_RAX: 0000000000000003 [ +0.000019] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ffff7b14f67 [ +0.000014] RDX: 0000000000000000 RSI: 00007ffff7f6f47a RDI: 0000000000000003 [ +0.000014] RBP: 00007fffffffe3a0 R08: 0000555555569890 R09: 0000000000000000 [ +0.000014] R10: 0000000000000000 R11: 0000000000000246 R12: 00007fffffffe5c8 [ +0.000013] R13: 00005555555552a9 R14: 0000555555557d48 R15: 00007ffff7ffd040 [ +0.000020] </TASK>
[ +0.000016] Allocated by task 383 on cpu 7 at 26.880319s: [ +0.000014] kasan_save_stack+0x28/0x60 [ +0.000008] kasan_save_track+0x18/0x70 [ +0.000007] kasan_save_alloc_info+0x38/0x60 [ +0.000007] __kasan_kmalloc+0xc1/0xd0 [ +0.000007] kmalloc_trace_noprof+0x180/0x380 [ +0.000007] drm_sched_init+0x411/0xec0 [gpu_sched] [ +0.000012] amdgpu_device_init+0x695f/0xa610 [amdgpu] [ +0.000658] amdgpu_driver_load_kms+0x1a/0x120 [amdgpu] [ +0.000662] amdgpu_pci_probe+0x361/0xf30 [amdgpu] [ +0.000651] local_pci_probe+0xe7/0x1b0 [ +0.000009] pci_device_probe+0x248/0x890 [ +0.000008] really_probe+0x1fd/0x950 [ +0.000008] __driver_probe_device+0x307/0x410 [ +0.000007] driver_probe_device+0x4e/0x150 [ +0.000007] __driver_attach+0x223/0x510 [ +0.000006] bus_for_each_dev+0x102/0x1a0 [ +0.000007] driver_attach+0x3d/0x60 [ +0.000006] bus_add_driver+0x2ac/0x5f0 [ +0.000006] driver_register+0x13d/0x490 [ +0.000008] __pci_register_driver+0x1ee/0x2b0 [ +0.000007] llc_sap_close+0xb0/0x160 [llc] [ +0.000009] do_one_initcall+0x9c/0x3e0 [ +0.000008] do_init_module+0x241/0x760 [ +0.000008] load_module+0x51ac/0x6c30 [ +0.000006] __do_sys_init_module+0x234/0x270 [ +0.000007] __x64_sys_init_module+0x73/0xc0 [ +0.000006] x64_sys_call+0xe3/0x2680 [ +0.000006] do_syscall_64+0x70/0x130 [ +0.000007] entry_SYSCALL_64_after_hwframe+0x76/0x7e
[ +0.000015] Freed by task 2147 on cpu 6 at 160.507651s: [ +0.000013] kasan_save_stack+0x28/0x60 [ +0.000007] kasan_save_track+0x18/0x70 [ +0.000007] kasan_save_free_info+0x3b/0x60 [ +0.000007] poison_slab_object+0x115/0x1c0 [ +0.000007] __kasan_slab_free+0x34/0x60 [ +0.000007] kfree+0xfa/0x2f0 [ +0.000007] drm_sched_fini+0x19d/0x410 [gpu_sched] [ +0.000012] amdgpu_fence_driver_sw_fini+0xc4/0x2f0 [amdgpu] [ +0.000662] amdgpu_device_fini_sw+0x77/0xfc0 [amdgpu] [ +0.000653] amdgpu_driver_release_kms+0x16/0x80 [amdgpu] [ +0.000655] drm_minor_release+0xc9/0x140 [drm] [ +0.000071] drm_release+0x1fd/0x390 [drm] [ +0.000071] __fput+0x36c/0xad0 [ +0.000008] __fput_sync+0x3c/0x50 [ +0.000007] __x64_sys_close+0x7d/0xe0 [ +0.000007] x64_sys_call+0x1bc6/0x2680 [ +0.000007] do_syscall_64+0x70/0x130 [ +0.000007] entry_SYSCALL_64_after_hwframe+0x76/0x7e
[ +0.000014] The buggy address belongs to the object at ffff8881b8605f80
which belongs to the cache kmalloc-64 of size 64
[ +0.000020] The buggy address is located 8 bytes inside of
freed 64-byte region [ffff8881b8605f80, ffff8881b8605fc0)
[ +0.000028] The buggy address belongs to the physical page: [ +0.000011] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1b8605 [ +0.000008] anon flags: 0x17ffffc0000000(node=0|zone=2|lastcpupid=0x1fffff) [ +0.000007] page_type: 0xffffefff(slab) [ +0.000009] raw: 0017ffffc0000000 ffff8881000428c0 0000000000000000 dead000000000001 [ +0.000006] raw: 0000000000000000 0000000000200020 00000001ffffefff 0000000000000000 [ +0.000006] page dumped because: kasan: bad access detected
[ +0.000012] Memory state around the buggy address: [ +0.000011] ffff8881b8605e80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc [ +0.000015] ffff8881b8605f00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc [ +0.000015] >ffff8881b8605f80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc [ +0.000013] ^ [ +0.000011] ffff8881b8606000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc [ +0.000014] ffff8881b8606080: fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb fb [ +0.000013] ==================================================================
The issue reproduced on VG20 during the IGT pci_unplug test.
The root cause of the issue is that the function drm_sched_fini is called before drm_sched_entity_kill. In drm_sched_fini, the drm_sched_rq structure is freed, but this structure is later accessed by each entity within the run queue, leading to invalid memory access.
To resolve this, the order of cleanup calls is updated:
Before:
amdgpu_fence_driver_sw_fini
amdgpu_device_ip_fini
After:
amdgpu_device_ip_fini
amdgpu_fence_driver_sw_fini
This updated order ensures that all entities in the IPs are cleaned up first, followed by proper cleanup of the schedulers.
Additional Investigation:
During debugging, another issue was identified in the amdgpu_vce_sw_fini function. The vce.vcpu_bo buffer must be freed only as the final step in the cleanup process to prevent any premature access during earlier cleanup stages.
v2: Using Christian suggestion call drm_sched_entity_destroy before drm_sched_fini.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -4008,8 +4008,8 @@ void amdgpu_device_fini_hw(struct amdgpuvoid amdgpu_device_fini_sw (struct amdgpu_device *adev) { -amdgpu_fence_driver_sw_fini (adev);amdgpu_device_ip_fini (adev); +amdgpu_fence_driver_sw_fini (adev);release_firmware (adev->firmware.gpu_info_fw); adev->firmware.gpu_info_fw =NULL ; adev->accel_working = false;
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +3 -3
@@ -220,15 +220,15 @@ int amdgpu_vce_sw_fini(struct amdgpu_devdrm_sched_entity_destroy (&adev->vce.entity); -amdgpu_bo_free_kernel (&adev->vce.vcpu_bo, &adev->vce.gpu_addr, - (void **)&adev->vce.cpu_addr); -for (i =0 ; i < adev->vce.num_rings; i++)amdgpu_ring_fini (&adev->vce.ring[i]);release_firmware (adev->vce.fw);mutex_destroy (&adev->vce.idle_mutex); +amdgpu_bo_free_kernel (&adev->vce.vcpu_bo, &adev->vce.gpu_addr, + (void **)&adev->vce.cpu_addr); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 217/373 landlock: Add the errata interface
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <[email protected]>
commit 15383a0d63dbcd63dc7e8d9ec1bf3a0f7ebf64ac upstream.
Some fixes may require user space to check if they are applied on the running kernel before using a specific feature. For instance, this applies when a restriction was previously too restrictive and is now getting relaxed (e.g. for compatibility reasons). However, non-visible changes for legitimate use (e.g. security fixes) do not require an erratum.
Because fixes are backported down to a specific Landlock ABI, we need a way to avoid cherry-pick conflicts. The solution is to only update a file related to the lower ABI impacted by this issue. All the ABI files are then used to create a bitmask of fixes.
The new errata interface is similar to the one used to get the supported Landlock ABI version, but it returns a bitmask instead because the order of fixes may not match the order of versions, and not all fixes may apply to all versions.
The actual errata will come with dedicated commits. The description is not actually used in the code but serves as documentation.
Create the landlock_abi_version symbol and use its value to check errata consistency.
Update test_base's create_ruleset_checks_ordering tests and add errata tests.
This commit is backportable down to the first version of Landlock.
--- include/uapi/linux/landlock.h | 2 security/landlock/errata.h | 87 +++++++++++++++++++++++++++ security/landlock/setup.c | 30 +++++++++ security/landlock/setup.h | 3 security/landlock/syscalls.c | 22 +++++- tools/testing/selftests/landlock/base_test.c | 46 +++++++++++++- 6 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 security/landlock/errata.h
include/uapi/linux/landlock.h +2 -0
@@ -32,9 +32,11 @@ struct landlock_ruleset_attr {* * - %LANDLOCK_CREATE_RULESET_VERSION: Get the highest supported Landlock ABI * version. +* - %LANDLOCK_CREATE_RULESET_ERRATA: Get a bitmask of fixed issues. */ /* clang-format off */ #define LANDLOCK_CREATE_RULESET_VERSION (1U << 0) +#define LANDLOCK_CREATE_RULESET_ERRATA (1U << 1)/* clang-format on */ /**
security/landlock/errata.h new file +87 -0
87 lines not on this page · raw message
security/landlock/setup.c +30 -0
@@ -6,11 +6,13 @@* Copyright © 2018-2020 ANSSI */ +#include <linux/bits.h> #include <linux/init.h> #include <linux/lsm_hooks.h> #include "common.h" #include "cred.h" +#include "errata.h" #include "fs.h" #include "ptrace.h" #include "setup.h"
@@ -23,8 +25,36 @@ struct lsm_blob_sizes landlock_blob_size .lbs_superblock = sizeof(struct landlock_superblock_security), }; +int landlock_errata__ro_after_init ; + +static void __init compute_errata (void ) +{ +size_t i; + +#ifndef __has_include +/* +* This is a safeguard to make sure the compiler implements +* __has_include (see errata.h). +*/ +WARN_ON_ONCE (1 ); +return ; +#endif + +for (i =0 ; landlock_errata_init[i].number; i++) { +const int prev_errata = landlock_errata; + +if (WARN_ON_ONCE (landlock_errata_init[i].abi > + landlock_abi_version)) +continue ; + + landlock_errata |=BIT (landlock_errata_init[i].number -1 ); +WARN_ON_ONCE (prev_errata == landlock_errata); + } +} +static int __init landlock_init (void ) { +compute_errata ();landlock_add_cred_hooks ();landlock_add_ptrace_hooks ();landlock_add_fs_hooks ();
security/landlock/setup.h +3 -0
@@ -11,7 +11,10 @@#include <linux/lsm_hooks.h> +extern const int landlock_abi_version; +extern bool landlock_initialized; +extern int landlock_errata;extern struct lsm_blob_sizes landlock_blob_sizes;
security/landlock/syscalls.c +18 -4
@@ -150,7 +150,9 @@ static const struct file_operations rule* the new ruleset. * @size: Size of the pointed &struct landlock_ruleset_attr (needed for * backward and forward compatibility). -* @flags: Supported value: %LANDLOCK_CREATE_RULESET_VERSION. +* @flags: Supported value: +* - %LANDLOCK_CREATE_RULESET_VERSION +* - %LANDLOCK_CREATE_RULESET_ERRATA * * This system call enables to create a new Landlock ruleset, and returns the * related file descriptor on success.
@@ -159,6 +161,10 @@ static const struct file_operations rule* 0, then the returned value is the highest supported Landlock ABI version * (starting at 1). * +* If @flags is %LANDLOCK_CREATE_RULESET_ERRATA and @attr is NULL and @size is +* 0, then the returned value is a bitmask of fixed issues for the current +* Landlock ABI version. +* * Possible returned errors are: * * - EOPNOTSUPP: Landlock is supported by the kernel but disabled at boot time;
@@ -181,9 +187,15 @@ SYSCALL_DEFINE3(landlock_create_ruleset,return -EOPNOTSUPP ;if (flags) { -if ((flags ==LANDLOCK_CREATE_RULESET_VERSION ) && !attr && - !size) -return LANDLOCK_ABI_VERSION ; +if (attr || size) +return -EINVAL ; + +if (flags ==LANDLOCK_CREATE_RULESET_VERSION ) +return landlock_abi_version; + +if (flags ==LANDLOCK_CREATE_RULESET_ERRATA ) +return landlock_errata; +return -EINVAL ; }
@@ -213,6 +225,8 @@ SYSCALL_DEFINE3(landlock_create_ruleset,return ruleset_fd; } +const int landlock_abi_version =LANDLOCK_ABI_VERSION ; +/* * Returns an owned ruleset from a FD. It is thus needed to call * landlock_put_ruleset() on the return value.
tools/testing/selftests/landlock/base_test.c +45 -1
55 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 218/373 nvmet-fc: Remove unused functions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit 1b304c006b0fb4f0517a8c4ba8c46e88f48a069c upstream.
The functions nvmet_fc_iodnum() and nvmet_fc_fodnum() are currently unutilized.
Following commit c53432030d86 ("nvme-fabrics: Add target support for FC transport"), which introduced these two functions, they have not been used at all in practice.
Remove them to resolve the compiler warnings.
Fix follow errors with clang-19 when W=1e:
drivers/nvme/target/fc.c:177:1: error: unused function 'nvmet_fc_iodnum' [-Werror,-Wunused-function]
177 | nvmet_fc_iodnum(struct nvmet_fc_ls_iod *iodptr)
| ^~~~~~~~~~~~~~~
drivers/nvme/target/fc.c:183:1: error: unused function 'nvmet_fc_fodnum' [-Werror,-Wunused-function]
183 | nvmet_fc_fodnum(struct nvmet_fc_fcp_iod *fodptr)
| ^~~~~~~~~~~~~~~
2 errors generated.
make[8]: *** [scripts/Makefile.build:207: drivers/nvme/target/fc.o] Error 1 make[7]: *** [scripts/Makefile.build:465: drivers/nvme/target] Error 2
make[6]: *** [scripts/Makefile.build:465: drivers/nvme] Error 2
make[6]: *** Waiting for unfinished jobs....
--- drivers/nvme/target/fc.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/nvme/target/fc.c +0 -14
@@ -173,20 +173,6 @@ struct nvmet_fc_tgt_assoc {struct rcu_head rcu; }; - -static inline int -nvmet_fc_iodnum (struct nvmet_fc_ls_iod *iodptr) -{ -return (iodptr - iodptr->tgtport->iod); -} - -static inline int -nvmet_fc_fodnum (struct nvmet_fc_fcp_iod *fodptr) -{ -return (fodptr - fodptr->queue->fod); -} - -/* * Association and Connection IDs: *
Greg Kroah-Hartman
maintainerPATCH 219/373 smb: client: fix potential UAF in cifs_dump_full_key()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 58acd1f497162e7d282077f816faa519487be045 upstream.
Skip sessions that are being teared down (status == SES_EXITING) to avoid UAF.
[ This patch removes lock/unlock operation in routine cifs_dump_full_key()
for ses_lock is not present in v5.15 and not ported yet. ses->status is protected by a global lock, cifs_tcp_ses_lock, in v5.15. ]
--- fs/cifs/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/ioctl.c +2 -1
@@ -232,7 +232,8 @@ static int cifs_dump_full_key(struct cifspin_lock (&cifs_tcp_ses_lock);list_for_each_entry (server_it, &cifs_tcp_ses_list, tcp_ses_list) {list_for_each_entry (ses_it, &server_it->smb_ses_list, smb_ses_list) { -if (ses_it->Suid == out.session_id) { +if (ses_it->status != CifsExiting && + ses_it->Suid == out.session_id) { ses = ses_it;/* * since we are using the session outside the crit
Greg Kroah-Hartman
maintainerPATCH 220/373 ksmbd: fix potencial out-of-bounds when buffer offset is invalid
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit c6cd2e8d2d9aa7ee35b1fa6a668e32a22a9753da upstream.
I found potencial out-of-bounds when buffer offset fields of a few requests is invalid. This patch set the minimum value of buffer offset field to ->Buffer offset to validate buffer length.
--- fs/ksmbd/smb2misc.c | 22 ++++++++++++++++------ fs/ksmbd/smb2pdu.c | 47 +++++++++++++++++++++++++---------------------- 2 files changed, 41 insertions(+), 28 deletions(-)
fs/ksmbd/smb2misc.c +16 -6
@@ -102,7 +102,9 @@ static int smb2_get_data_area_len(unsign *len =le16_to_cpu (((struct smb2_sess_setup_req *)hdr)->SecurityBufferLength);break ;case SMB2_TREE_CONNECT : - *off =le16_to_cpu (((struct smb2_tree_connect_req *)hdr)->PathOffset); + *off = max_t(unsigned short int, +le16_to_cpu (((struct smb2_tree_connect_req *)hdr)->PathOffset), + offsetof(struct smb2_tree_connect_req , Buffer)); *len =le16_to_cpu (((struct smb2_tree_connect_req *)hdr)->PathLength);break ;case SMB2_CREATE :
@@ -129,11 +131,15 @@ static int smb2_get_data_area_len(unsignbreak ; }case SMB2_QUERY_INFO : - *off =le16_to_cpu (((struct smb2_query_info_req *)hdr)->InputBufferOffset); + *off = max_t(unsigned int, +le16_to_cpu (((struct smb2_query_info_req *)hdr)->InputBufferOffset), + offsetof(struct smb2_query_info_req , Buffer)); *len =le32_to_cpu (((struct smb2_query_info_req *)hdr)->InputBufferLength);break ;case SMB2_SET_INFO : - *off =le16_to_cpu (((struct smb2_set_info_req *)hdr)->BufferOffset); + *off = max_t(unsigned int, +le16_to_cpu (((struct smb2_set_info_req *)hdr)->BufferOffset), + offsetof(struct smb2_set_info_req , Buffer)); *len =le32_to_cpu (((struct smb2_set_info_req *)hdr)->BufferLength);break ;case SMB2_READ :
@@ -143,7 +149,7 @@ static int smb2_get_data_area_len(unsigncase SMB2_WRITE :if (((struct smb2_write_req *)hdr)->DataOffset || ((struct smb2_write_req *)hdr)->Length) { - *off = max_t(unsigned int, + *off = max_t(unsigned short int,le16_to_cpu (((struct smb2_write_req *)hdr)->DataOffset), offsetof(struct smb2_write_req , Buffer) -4 ); *len =le32_to_cpu (((struct smb2_write_req *)hdr)->Length);
@@ -154,7 +160,9 @@ static int smb2_get_data_area_len(unsign *len =le16_to_cpu (((struct smb2_write_req *)hdr)->WriteChannelInfoLength);break ;case SMB2_QUERY_DIRECTORY : - *off =le16_to_cpu (((struct smb2_query_directory_req *)hdr)->FileNameOffset); + *off = max_t(unsigned short int, +le16_to_cpu (((struct smb2_query_directory_req *)hdr)->FileNameOffset), + offsetof(struct smb2_query_directory_req , Buffer)); *len =le16_to_cpu (((struct smb2_query_directory_req *)hdr)->FileNameLength);break ;case SMB2_LOCK :
@@ -169,7 +177,9 @@ static int smb2_get_data_area_len(unsignbreak ; }case SMB2_IOCTL : - *off =le32_to_cpu (((struct smb2_ioctl_req *)hdr)->InputOffset); + *off = max_t(unsigned int, +le32_to_cpu (((struct smb2_ioctl_req *)hdr)->InputOffset), + offsetof(struct smb2_ioctl_req , Buffer)); *len =le32_to_cpu (((struct smb2_ioctl_req *)hdr)->InputCount);break ;default :
fs/ksmbd/smb2pdu.c +25 -22
191 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 221/373 net: make sock_inuse_add() available
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit d477eb9004845cb2dc92ad5eed79a437738a868a upstream.
MPTCP hard codes it, let us instead provide this helper.
--- include/net/sock.h | 10 ++++++++++ net/core/sock.c | 10 ---------- net/mptcp/subflow.c | 4 +--- 3 files changed, 11 insertions(+), 13 deletions(-)
include/net/sock.h +10 -0
@@ -1472,6 +1472,12 @@ static inline void sock_prot_inuse_add(c {this_cpu_add (net->core.prot_inuse->val[prot->inuse_idx], val); } + +static inline void sock_inuse_add (const struct net *net,int val) +{ +this_cpu_add (*net->core.sock_inuse, val); +} +int sock_prot_inuse_get (struct net *net,struct proto *proto);int sock_inuse_get (struct net *net);#else
@@ -1479,6 +1485,10 @@ static inline void sock_prot_inuse_add(c const struct proto *prot, int val) { } + +static inline void sock_inuse_add (const struct net *net,int val) +{ +}#endif
net/core/sock.c +0 -10
@@ -144,8 +144,6 @@static DEFINE_MUTEX (proto_list_mutex);static LIST_HEAD (proto_list); -static void sock_inuse_add (struct net *net,int val); -/** * sk_ns_capable - General socket capability test * @sk: Socket to use a capability on or through
@@ -3519,11 +3517,6 @@ int sock_prot_inuse_get(struct net *net, }EXPORT_SYMBOL_GPL (sock_prot_inuse_get); -static void sock_inuse_add (struct net *net,int val) -{ -this_cpu_add (*net->core.sock_inuse, val); -} -int sock_inuse_get (struct net *net) {int cpu, res =0 ;
@@ -3602,9 +3595,6 @@ static inline void release_proto_idx(str { } -static void sock_inuse_add (struct net *net,int val) -{ -}#endif static void tw_prot_cleanup (struct timewait_sock_ops *twsk_prot)
net/mptcp/subflow.c +1 -3
@@ -1584,9 +1584,7 @@ int mptcp_subflow_create_socket(struct s*/ sf->sk->sk_net_refcnt =1 ;get_net (net); -#ifdef CONFIG_PROC_FS -this_cpu_add (*net->core.sock_inuse,1 ); -#endif +sock_inuse_add (net,1 ); err =tcp_set_ulp (sf->sk,"mptcp" );release_sock (sf->sk);
Greg Kroah-Hartman
maintainerPATCH 222/373 smb: client: fix use-after-free bug in cifs_debug_data_proc_show()
In reply to Greg Kroah-Hartman5.15-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
[ This patch removed lock/unlock operation due to ses_lock is not present in v5.15 and not ported yet. ses->status is protected by a global lock, cifs_tcp_ses_lock, in v5.15. ]
--- fs/cifs/cifs_debug.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/cifs_debug.c +2 -0
@@ -382,6 +382,8 @@ skip_rdma:list_for_each (tmp2, &server->smb_ses_list) { ses = list_entry(tmp2, struct cifs_ses, smb_ses_list); +if (ses->status == CifsExiting) +continue ; i++; if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
Greg Kroah-Hartman
maintainerPATCH 223/373 cifs: Fix UAF in cifs_demultiplex_thread()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Xiaoxu <[email protected]>
commit d527f51331cace562393a8038d870b3e9916686f upstream.
There is a UAF when xfstests on cifs:
BUG: KASAN: use-after-free in smb2_is_network_name_deleted+0x27/0x160 Read of size 4 at addr ffff88810103fc08 by task cifsd/923 CPU: 1 PID: 923 Comm: cifsd Not tainted 6.1.0-rc4+ #45 ... Call Trace: <TASK> dump_stack_lvl+0x34/0x44 print_report+0x171/0x472 kasan_report+0xad/0x130 kasan_check_range+0x145/0x1a0 smb2_is_network_name_deleted+0x27/0x160 cifs_demultiplex_thread.cold+0x172/0x5a4 kthread+0x165/0x1a0 ret_from_fork+0x1f/0x30 </TASK> Allocated by task 923: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 __kasan_slab_alloc+0x54/0x60 kmem_cache_alloc+0x147/0x320 mempool_alloc+0xe1/0x260 cifs_small_buf_get+0x24/0x60 allocate_buffers+0xa1/0x1c0 cifs_demultiplex_thread+0x199/0x10d0 kthread+0x165/0x1a0 ret_from_fork+0x1f/0x30 Freed by task 921: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 kasan_save_free_info+0x2a/0x40 ____kasan_slab_free+0x143/0x1b0 kmem_cache_free+0xe3/0x4d0 cifs_small_buf_release+0x29/0x90 SMB2_negotiate+0x8b7/0x1c60 smb2_negotiate+0x51/0x70 cifs_negotiate_protocol+0xf0/0x160 cifs_get_smb_ses+0x5fa/0x13c0 mount_get_conns+0x7a/0x750 cifs_mount+0x103/0xd00 cifs_smb3_do_mount+0x1dd/0xcb0 smb3_get_tree+0x1d5/0x300 vfs_get_tree+0x41/0xf0 path_mount+0x9b3/0xdd0 __x64_sys_mount+0x190/0x1d0 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0
The UAF is because:
mount(pid: 921) | cifsd(pid: 923)
-------------------------------|-------------------------------
| cifs_demultiplex_thread
SMB2_negotiate |
cifs_send_recv |
compound_send_recv |
smb_send_rqst |
wait_for_response |
wait_event_state [1] |
| standard_receive3
| cifs_handle_standard
| handle_mid
| mid->resp_buf = buf; [2]
| dequeue_mid [3]
KILL the process [4] |
resp_iov[i].iov_base = buf |
free_rsp_buf [5] |
| is_network_name_deleted [6]
| callback1. After send request to server, wait the response until
mid->mid_state != SUBMITTED;
2. Receive response from server, and set it to mid;
3. Set the mid state to RECEIVED;
4. Kill the process, the mid state already RECEIVED, get 0;
5. Handle and release the negotiate response;
6. UAF.
It can be easily reproduce with add some delay in [3] - [6].
Only sync call has the problem since async call's callback is executed in cifsd process.
Add an extra state to mark the mid state to READY before wakeup the waitter, then it can get the resp safely.
[fs/cifs was moved to fs/smb/client since38c8a9a52082 ("smb: move client and server files to common directory fs/smb"). We apply the patch to fs/cifs with some minor context changes.]
--- fs/cifs/cifsglob.h | 1 + fs/cifs/transport.c | 34 +++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-)
fs/cifs/cifsglob.h +1 -0
@@ -1719,6 +1719,7 @@ static inline bool is_retryable_error(in#define MID_RETRY_NEEDED 8/* session closed while this request out */ #define MID_RESPONSE_MALFORMED 0x10#define MID_SHUTDOWN 0x20 +#define MID_RESPONSE_READY 0x40/* ready for other process handle the rsp */ /* Flags */ #define MID_WAIT_CANCELLED 1/* Cancelled while waiting for response */
fs/cifs/transport.c +23 -11
@@ -34,6 +34,8 @@void cifs_wake_up_task (struct mid_q_entry *mid) { +if (mid->mid_state ==MID_RESPONSE_RECEIVED ) + mid->mid_state =MID_RESPONSE_READY ;wake_up_process (mid->callback_data); }
@@ -86,7 +88,8 @@ static void _cifs_mid_q_entry_release(ststruct TCP_Server_Info *server = midEntry->server;if (midEntry->resp_buf && (midEntry->mid_flags &MID_WAIT_CANCELLED ) && - midEntry->mid_state ==MID_RESPONSE_RECEIVED && + (midEntry->mid_state ==MID_RESPONSE_RECEIVED || + midEntry->mid_state ==MID_RESPONSE_READY ) && server->ops->handle_cancelled_mid) server->ops->handle_cancelled_mid (midEntry, server);
@@ -762,7 +765,8 @@ wait_for_response(struct TCP_Server_Infoint error; error =wait_event_freezekillable_unsafe (server->response_q, - midQ->mid_state !=MID_REQUEST_SUBMITTED ); + midQ->mid_state !=MID_REQUEST_SUBMITTED && + midQ->mid_state !=MID_RESPONSE_RECEIVED );if (error <0 )return -ERESTARTSYS ;
@@ -914,7 +918,7 @@ cifs_sync_mid_result(struct mid_q_entryspin_lock (&GlobalMid_Lock);switch (mid->mid_state) { -case MID_RESPONSE_RECEIVED : +case MID_RESPONSE_READY :spin_unlock (&GlobalMid_Lock);return rc;case MID_RETRY_NEEDED :
@@ -1013,6 +1017,9 @@ cifs_compound_callback(struct mid_q_entr credits.instance = server->reconnect_instance;add_credits (server, &credits, mid->optype); + +if (mid->mid_state ==MID_RESPONSE_RECEIVED ) + mid->mid_state =MID_RESPONSE_READY ; } static void
@@ -1204,7 +1211,8 @@ compound_send_recv(const unsigned int xisend_cancel (server, &rqst[i], midQ[i]);spin_lock (&GlobalMid_Lock); midQ[i]->mid_flags |=MID_WAIT_CANCELLED ; -if (midQ[i]->mid_state ==MID_REQUEST_SUBMITTED ) { +if (midQ[i]->mid_state ==MID_REQUEST_SUBMITTED || + midQ[i]->mid_state ==MID_RESPONSE_RECEIVED ) { midQ[i]->callback = cifs_cancelled_callback; cancelled_mid[i] = true; credits[i].value =0 ;
@@ -1225,7 +1233,7 @@ compound_send_recv(const unsigned int xi }if (!midQ[i]->resp_buf || - midQ[i]->mid_state !=MID_RESPONSE_RECEIVED ) { + midQ[i]->mid_state !=MID_RESPONSE_READY ) { rc = -EIO ;cifs_dbg (FYI ,"Bad MID state?\n" ); goto out;
@@ -1404,7 +1412,8 @@ SendReceive(const unsigned int xid, struif (rc !=0 ) {send_cancel (server, &rqst, midQ);spin_lock (&GlobalMid_Lock); -if (midQ->mid_state ==MID_REQUEST_SUBMITTED ) { +if (midQ->mid_state ==MID_REQUEST_SUBMITTED || + midQ->mid_state ==MID_RESPONSE_RECEIVED ) {/* no longer considered to be "in-flight" */ midQ->callback = DeleteMidQEntry;spin_unlock (&GlobalMid_Lock);
@@ -1421,7 +1430,7 @@ SendReceive(const unsigned int xid, stru }if (!midQ->resp_buf || !out_buf || - midQ->mid_state !=MID_RESPONSE_RECEIVED ) { + midQ->mid_state !=MID_RESPONSE_READY ) { rc = -EIO ;cifs_server_dbg (VFS ,"Bad MID state?\n" ); goto out;
@@ -1541,13 +1550,15 @@ SendReceiveBlockingLock(const unsigned i/* Wait for a reply - allow signals to interrupt. */ rc =wait_event_interruptible (server->response_q, - (!(midQ->mid_state ==MID_REQUEST_SUBMITTED )) || + (!(midQ->mid_state ==MID_REQUEST_SUBMITTED || + midQ->mid_state ==MID_RESPONSE_RECEIVED )) || ((server->tcpStatus != CifsGood) && (server->tcpStatus != CifsNew)));/* Were we interrupted by a signal ? */ if ((rc == -ERESTARTSYS ) && - (midQ->mid_state ==MID_REQUEST_SUBMITTED ) && + (midQ->mid_state ==MID_REQUEST_SUBMITTED || + midQ->mid_state ==MID_RESPONSE_RECEIVED ) && ((server->tcpStatus == CifsGood) || (server->tcpStatus == CifsNew))) {
@@ -1577,7 +1588,8 @@ SendReceiveBlockingLock(const unsigned iif (rc) {send_cancel (server, &rqst, midQ);spin_lock (&GlobalMid_Lock); -if (midQ->mid_state ==MID_REQUEST_SUBMITTED ) { +if (midQ->mid_state ==MID_REQUEST_SUBMITTED || + midQ->mid_state ==MID_RESPONSE_RECEIVED ) {/* no longer considered to be "in-flight" */ midQ->callback = DeleteMidQEntry;spin_unlock (&GlobalMid_Lock);
@@ -1595,7 +1607,7 @@ SendReceiveBlockingLock(const unsigned ireturn rc;/* rcvd frame is ok */ -if (out_buf ==NULL || midQ->mid_state !=MID_RESPONSE_RECEIVED ) { +if (out_buf ==NULL || midQ->mid_state !=MID_RESPONSE_READY ) { rc = -EIO ;cifs_tcon_dbg (VFS ,"Bad MID state?\n" ); goto out;
Greg Kroah-Hartman
maintainerPATCH 224/373 smb: client: fix UAF in async decryption
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Enzo Matsumiya <[email protected]>
commit b0abcd65ec545701b8793e12bc27dc98042b151a upstream.
Doing an async decryption (large read) crashes with a slab-use-after-free way down in the crypto API.
Reproducer:
# mount.cifs -o ...,seal,esize=1 //srv/share /mnt
# dd if=/mnt/largefile of=/dev/null
...
[ 194.196391] ==================================================================
[ 194.196844] BUG: KASAN: slab-use-after-free in gf128mul_4k_lle+0xc1/0x110
[ 194.197269] Read of size 8 at addr ffff888112bd0448 by task kworker/u77:2/899
[ 194.197707]
[ 194.197818] CPU: 12 UID: 0 PID: 899 Comm: kworker/u77:2 Not tainted 6.11.0-lku-00028-gfca3ca14a17a-dirty #43
[ 194.198400] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.2-3-gd478f380-prebuilt.qemu.org 04/01/2014
[ 194.199046] Workqueue: smb3decryptd smb2_decrypt_offload [cifs]
[ 194.200032] Call Trace:
[ 194.200191] <TASK>
[ 194.200327] dump_stack_lvl+0x4e/0x70
[ 194.200558] ? gf128mul_4k_lle+0xc1/0x110
[ 194.200809] print_report+0x174/0x505
[ 194.201040] ? __pfx__raw_spin_lock_irqsave+0x10/0x10
[ 194.201352] ? srso_return_thunk+0x5/0x5f
[ 194.201604] ? __virt_addr_valid+0xdf/0x1c0
[ 194.201868] ? gf128mul_4k_lle+0xc1/0x110
[ 194.202128] kasan_report+0xc8/0x150
[ 194.202361] ? gf128mul_4k_lle+0xc1/0x110
[ 194.202616] gf128mul_4k_lle+0xc1/0x110
[ 194.202863] ghash_update+0x184/0x210
[ 194.203103] shash_ahash_update+0x184/0x2a0
[ 194.203377] ? __pfx_shash_ahash_update+0x10/0x10
[ 194.203651] ? srso_return_thunk+0x5/0x5f
[ 194.203877] ? crypto_gcm_init_common+0x1ba/0x340
[ 194.204142] gcm_hash_assoc_remain_continue+0x10a/0x140
[ 194.204434] crypt_message+0xec1/0x10a0 [cifs]
[ 194.206489] ? __pfx_crypt_message+0x10/0x10 [cifs]
[ 194.208507] ? srso_return_thunk+0x5/0x5f
[ 194.209205] ? srso_return_thunk+0x5/0x5f
[ 194.209925] ? srso_return_thunk+0x5/0x5f
[ 194.210443] ? srso_return_thunk+0x5/0x5f
[ 194.211037] decrypt_raw_data+0x15f/0x250 [cifs]
[ 194.212906] ? __pfx_decrypt_raw_data+0x10/0x10 [cifs]
[ 194.214670] ? srso_return_thunk+0x5/0x5f
[ 194.215193] smb2_decrypt_offload+0x12a/0x6c0 [cifs]This is because TFM is being used in parallel.
Fix this by allocating a new AEAD TFM for async decryption, but keep the existing one for synchronous READ cases (similar to what is done in smb3_calc_signature()).
Also remove the calls to aead_request_set_callback() and crypto_wait_req() since it's always going to be a synchronous operation.
--- fs/cifs/smb2ops.c | 48 ++++++++++++++++++++++++++++-------------------- fs/cifs/smb2pdu.c | 6 ++++++ 2 files changed, 34 insertions(+), 20 deletions(-)
fs/cifs/smb2ops.c +28 -20
@@ -4541,7 +4541,7 @@ smb2_get_enc_key(struct TCP_Server_Info*/ static int crypt_message (struct TCP_Server_Info *server,int num_rqst, -struct smb_rqst *rqst,int enc) +struct smb_rqst *rqst,int enc,struct crypto_aead *tfm) {struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)rqst[0 ].rq_iov[0 ].iov_base;
@@ -4552,8 +4552,6 @@ crypt_message(struct TCP_Server_Info *seu8 key[SMB3_ENC_DEC_KEY_SIZE ];struct aead_request *req;u8 *iv; -DECLARE_CRYPTO_WAIT (wait); -struct crypto_aead *tfm;unsigned int crypt_len =le32_to_cpu (tr_hdr->OriginalMessageSize);void *creq;
@@ -4564,15 +4562,6 @@ crypt_message(struct TCP_Server_Info *sereturn rc; } - rc =smb3_crypto_aead_allocate (server); -if (rc) { -cifs_server_dbg (VFS ,"%s: crypto alloc failed\n" , __func__); -return rc; - } - - tfm = enc ? server->secmech.ccmaesencrypt : - server->secmech.ccmaesdecrypt; -if ((server->cipher_type ==SMB2_ENCRYPTION_AES256_CCM ) || (server->cipher_type ==SMB2_ENCRYPTION_AES256_GCM )) rc =crypto_aead_setkey (tfm, key,SMB3_GCM256_CRYPTKEY_SIZE );
@@ -4611,11 +4600,7 @@ crypt_message(struct TCP_Server_Info *seaead_request_set_crypt (req, sg, sg, crypt_len, iv);aead_request_set_ad (req, assoc_data_len); -aead_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); - - rc =crypto_wait_req (enc ?crypto_aead_encrypt (req) - :crypto_aead_decrypt (req), &wait); + rc = enc ?crypto_aead_encrypt (req) :crypto_aead_decrypt (req);if (!rc && enc)memcpy (&tr_hdr->Signature, sign,SMB2_SIGNATURE_SIZE );
@@ -4704,7 +4689,7 @@ smb3_init_transform_rq(struct TCP_Server/* fill the 1st iov with a transform header */ fill_transform_hdr (tr_hdr, orig_len, old_rq, server->cipher_type); - rc =crypt_message (server, num_rqst, new_rq,1 ); + rc =crypt_message (server, num_rqst, new_rq,1 , server->secmech.ccmaesencrypt);cifs_dbg (FYI ,"Encrypt message returned %d\n" , rc);if (rc) goto err_free;
@@ -4730,8 +4715,9 @@ decrypt_raw_data(struct TCP_Server_Info unsigned int npages, unsigned int page_data_size, bool is_offloaded) { - struct kvec iov[2]; + struct crypto_aead *tfm;struct smb_rqst rqst = {NULL }; +struct kvec iov[2 ];int rc; iov[0 ].iov_base = buf;
@@ -4746,9 +4732,31 @@ decrypt_raw_data(struct TCP_Server_Info rqst.rq_pagesz =PAGE_SIZE ; rqst.rq_tailsz = (page_data_size %PAGE_SIZE ) ? :PAGE_SIZE ; - rc =crypt_message (server,1 , &rqst,0 ); +if (is_offloaded) { +if ((server->cipher_type ==SMB2_ENCRYPTION_AES128_GCM ) || + (server->cipher_type ==SMB2_ENCRYPTION_AES256_GCM )) + tfm =crypto_alloc_aead ("gcm(aes)" ,0 ,0 ); +else + tfm =crypto_alloc_aead ("ccm(aes)" ,0 ,0 ); +if (IS_ERR (tfm)) { + rc =PTR_ERR (tfm); +cifs_server_dbg (VFS ,"%s: Failed alloc decrypt TFM, rc=%d\n" , __func__, rc); + +return rc; + } + }else { +if (unlikely (!server->secmech.ccmaesdecrypt)) +return -EIO ; + + tfm = server->secmech.ccmaesdecrypt; + } + + rc =crypt_message (server,1 , &rqst,0 , tfm);cifs_dbg (FYI ,"Decrypt message returned %d\n" , rc); +if (is_offloaded) +crypto_free_aead (tfm); +if (rc)return rc;
fs/cifs/smb2pdu.c +6 -0
@@ -1063,6 +1063,12 @@ SMB2_negotiate(const unsigned int xid, selse cifs_server_dbg (VFS ,"Missing expected negotiate contexts\n" ); } + +if (server->cipher_type && !rc) { + rc =smb3_crypto_aead_allocate (server); +if (rc) +cifs_server_dbg (VFS ,"%s: crypto alloc failed, rc=%d\n" , __func__, rc); + } neg_exit:free_rsp_buf (resp_buftype, rsp);return rc;
Greg Kroah-Hartman
maintainerPATCH 225/373 smb: client: fix NULL ptr deref in crypto_aead_setkey()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 4bdec0d1f658f7c98749bd2c5a486e6cfa8565d2 upstream.
Neither SMB3.0 or SMB3.02 supports encryption negotiate context, so when SMB2_GLOBAL_CAP_ENCRYPTION flag is set in the negotiate response, the client uses AES-128-CCM as the default cipher. See MS-SMB2 3.3.5.4.
Commit b0abcd65ec54 ("smb: client: fix UAF in async decryption") added a @server->cipher_type check to conditionally call smb3_crypto_aead_allocate(), but that check would always be false as @server->cipher_type is unset for SMB3.02.
Fix the following KASAN splat by setting @server->cipher_type for SMB3.02 as well.
mount.cifs //srv/share /mnt -o vers=3.02,seal,...
BUG: KASAN: null-ptr-deref in crypto_aead_setkey+0x2c/0x130 Read of size 8 at addr 0000000000000020 by task mount.cifs/1095 CPU: 1 UID: 0 PID: 1095 Comm: mount.cifs Not tainted 6.12.0 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-3.fc41 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x5d/0x80 ? crypto_aead_setkey+0x2c/0x130 kasan_report+0xda/0x110 ? crypto_aead_setkey+0x2c/0x130 crypto_aead_setkey+0x2c/0x130 crypt_message+0x258/0xec0 [cifs] ? __asan_memset+0x23/0x50 ? __pfx_crypt_message+0x10/0x10 [cifs] ? mark_lock+0xb0/0x6a0 ? hlock_class+0x32/0xb0 ? mark_lock+0xb0/0x6a0 smb3_init_transform_rq+0x352/0x3f0 [cifs] ? lock_acquire.part.0+0xf4/0x2a0 smb_send_rqst+0x144/0x230 [cifs] ? __pfx_smb_send_rqst+0x10/0x10 [cifs] ? hlock_class+0x32/0xb0 ? smb2_setup_request+0x225/0x3a0 [cifs] ? __pfx_cifs_compound_last_callback+0x10/0x10 [cifs] compound_send_recv+0x59b/0x1140 [cifs] ? __pfx_compound_send_recv+0x10/0x10 [cifs] ? __create_object+0x5e/0x90 ? hlock_class+0x32/0xb0 ? do_raw_spin_unlock+0x9a/0xf0 cifs_send_recv+0x23/0x30 [cifs] SMB2_tcon+0x3ec/0xb30 [cifs] ? __pfx_SMB2_tcon+0x10/0x10 [cifs] ? lock_acquire.part.0+0xf4/0x2a0 ? __pfx_lock_release+0x10/0x10 ? do_raw_spin_trylock+0xc6/0x120 ? lock_acquire+0x3f/0x90 ? _get_xid+0x16/0xd0 [cifs] ? __pfx_SMB2_tcon+0x10/0x10 [cifs] ? cifs_get_smb_ses+0xcdd/0x10a0 [cifs] cifs_get_smb_ses+0xcdd/0x10a0 [cifs] ? __pfx_cifs_get_smb_ses+0x10/0x10 [cifs] ? cifs_get_tcp_session+0xaa0/0xca0 [cifs] cifs_mount_get_session+0x8a/0x210 [cifs] dfs_mount_share+0x1b0/0x11d0 [cifs] ? __pfx___lock_acquire+0x10/0x10 ? __pfx_dfs_mount_share+0x10/0x10 [cifs] ? lock_acquire.part.0+0xf4/0x2a0 ? find_held_lock+0x8a/0xa0 ? hlock_class+0x32/0xb0 ? lock_release+0x203/0x5d0 cifs_mount+0xb3/0x3d0 [cifs] ? do_raw_spin_trylock+0xc6/0x120 ? __pfx_cifs_mount+0x10/0x10 [cifs] ? lock_acquire+0x3f/0x90 ? find_nls+0x16/0xa0 ? smb3_update_mnt_flags+0x372/0x3b0 [cifs] cifs_smb3_do_mount+0x1e2/0xc80 [cifs] ? __pfx_vfs_parse_fs_string+0x10/0x10 ? __pfx_cifs_smb3_do_mount+0x10/0x10 [cifs] smb3_get_tree+0x1bf/0x330 [cifs] vfs_get_tree+0x4a/0x160 path_mount+0x3c1/0xfb0 ? kasan_quarantine_put+0xc7/0x1d0 ? __pfx_path_mount+0x10/0x10 ? kmem_cache_free+0x118/0x3e0 ? user_path_at+0x74/0xa0 __x64_sys_mount+0x1a6/0x1e0 ? __pfx___x64_sys_mount+0x10/0x10 ? mark_held_locks+0x1a/0x90 do_syscall_64+0xbb/0x1d0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
[Commit b0abcd65ec54 ("smb: client: fix UAF in async decryption") fixes CVE-2024-50047 but brings NULL-pointer dereferebce. So commit 4bdec0d1f658 ("smb: client: fix NULL ptr deref in crypto_aead_setkey()") should be backported too.]
--- fs/cifs/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +3 -1
@@ -1028,7 +1028,9 @@ SMB2_negotiate(const unsigned int xid, s* SMB3.0 supports only 1 cipher and doesn't have a encryption neg context * Set the cipher type manually. */ -if (server->dialect ==SMB30_PROT_ID && (server->capabilities &SMB2_GLOBAL_CAP_ENCRYPTION )) +if ((server->dialect ==SMB30_PROT_ID || + server->dialect ==SMB302_PROT_ID ) && + (server->capabilities &SMB2_GLOBAL_CAP_ENCRYPTION )) server->cipher_type =SMB2_ENCRYPTION_AES128_CCM ; security_blob = smb2_get_data_area_len(&blob_offset, &blob_length,
Greg Kroah-Hartman
maintainerPATCH 226/373 smb/server: fix potential null-ptr-deref of lease_ctx_info in smb2_open()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
commit 4e8771a3666c8f216eefd6bd2fd50121c6c437db upstream.
null-ptr-deref will occur when (req_op_level == SMB2_OPLOCK_LEVEL_LEASE) and parse_lease_state() return NULL.
Fix this by check if 'lease_ctx_info' is NULL.
Additionally, remove the redundant parentheses inparse_durable_handle_context().
[ Drop the parentheses clean-up since the parentheses was introduced by
c8efcc786146 ("ksmbd: add support for durable handles v1/v2") in v6.9 Minor context change fixed ]
--- fs/ksmbd/oplock.c | 2 +- fs/ksmbd/smb2pdu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ksmbd/oplock.c +1 -1
@@ -1498,7 +1498,7 @@ void create_lease_buf(u8 *rbuf, struct l* @open_req: buffer containing smb2 file open(create) request * @is_dir: whether leasing file is directory * -* Return: oplock state, -ENOENT if create lease context not found +* Return: allocated lease context object on success, otherwise NULL */ struct lease_ctx_info *parse_lease_state (void *open_req,bool is_dir) {
fs/ksmbd/smb2pdu.c +1 -1
@@ -3230,7 +3230,7 @@ int smb2_open(struct ksmbd_work *work) goto err_out1; } }else { -if (req_op_level ==SMB2_OPLOCK_LEVEL_LEASE ) { +if (req_op_level ==SMB2_OPLOCK_LEVEL_LEASE && lc) {/* * Compare parent lease using parent key. If there is no * a lease that has same parent key, Send lease break
Greg Kroah-Hartman
maintainerPATCH 227/373 smb: client: fix potential deadlock when releasing mids
In reply to Greg Kroah-Hartman5.15-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*
[cifs_mid_q_entry_release() is renamed to release_mid() and
_cifs_mid_q_entry_release() is renamed to __release_mid() by commit 70f08f914a37 ("cifs: remove useless DeleteMidQEntry()") which is integrated into v6.0, so preserve old names in v5.15.]
--- fs/cifs/cifsproto.h | 7 ++++++- fs/cifs/smb2misc.c | 2 +- fs/cifs/transport.c | 9 +-------- 3 files changed, 8 insertions(+), 10 deletions(-)
fs/cifs/cifsproto.h +6 -1
@@ -83,7 +83,7 @@ extern struct mid_q_entry *AllocMidQEntr struct TCP_Server_Info *server);extern void DeleteMidQEntry (struct mid_q_entry *midEntry);extern void cifs_delete_mid (struct mid_q_entry *mid); -extern void cifs_mid_q_entry_release (struct mid_q_entry *midEntry); +void _cifs_mid_q_entry_release (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);
@@ -637,4 +637,9 @@ static inline int cifs_create_options(ststruct super_block *cifs_get_tcon_super (struct cifs_tcon *tcon);void cifs_put_tcon_super (struct super_block *sb); +static inline void cifs_mid_q_entry_release (struct mid_q_entry *midEntry) +{ +kref_put (&midEntry->refcount, _cifs_mid_q_entry_release); +} +#endif /* _CIFSPROTO_H */
fs/cifs/smb2misc.c +1 -1
@@ -759,7 +759,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/cifs/transport.c +1 -8
@@ -75,7 +75,7 @@ AllocMidQEntry(const struct smb_hdr *smbreturn temp; } -static void _cifs_mid_q_entry_release (struct kref *refcount) +void _cifs_mid_q_entry_release (struct kref *refcount) {struct mid_q_entry *midEntry = container_of(refcount, struct mid_q_entry, refcount);
@@ -155,13 +155,6 @@ static void _cifs_mid_q_entry_release(stmempool_free (midEntry, cifs_mid_poolp); } -void cifs_mid_q_entry_release (struct mid_q_entry *midEntry) -{ -spin_lock (&GlobalMid_Lock); -kref_put (&midEntry->refcount, _cifs_mid_q_entry_release); -spin_unlock (&GlobalMid_Lock); -} -void DeleteMidQEntry (struct mid_q_entry *midEntry) {cifs_mid_q_entry_release (midEntry);
Greg Kroah-Hartman
maintainerPATCH 228/373 smb: client: fix potential UAF in cifs_stats_proc_show()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 0865ffefea197b437ba78b5dd8d8e256253efd65 upstream.
Skip sessions that are being teared down (status == SES_EXITING) to avoid UAF.
[ cifs_debug.c was moved from fs/cifs to fs/smb/client since
38c8a9a52082 ("smb: move client and server files to common directory fs/smb"). The cifs_ses_exiting() was introduced to cifs_debug.c since ca545b7f0823 ("smb: client: fix potential UAF in cifs_debug_files_proc_show()") which has been sent to upstream already. ]
--- fs/cifs/cifs_debug.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/cifs_debug.c +2 -0
@@ -613,6 +613,8 @@ static int cifs_stats_proc_show(struct slist_for_each (tmp2, &server->smb_ses_list) { ses = list_entry(tmp2, struct cifs_ses, smb_ses_list); +if (cifs_ses_exiting (ses)) +continue ;list_for_each (tmp3, &ses->tcon_list) { tcon = list_entry(tmp3, struct cifs_tcon,
Greg Kroah-Hartman
maintainerPATCH 229/373 sched/task_stack: fix object_is_on_stack() for KASAN tagged pointers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qun-Wei Lin <[email protected]>
commit fd7b4f9f46d46acbc7af3a439bb0d869efdc5c58 upstream.
When CONFIG_KASAN_SW_TAGS and CONFIG_KASAN_STACK are enabled, the object_is_on_stack() function may produce incorrect results due to the presence of tags in the obj pointer, while the stack pointer does not have tags. This discrepancy can lead to incorrect stack object detection and subsequently trigger warnings if CONFIG_DEBUG_OBJECTS is also enabled.
Example of the warning:
ODEBUG: object 3eff800082ea7bb0 is NOT on stack ffff800082ea0000, but annotated.
------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at lib/debugobjects.c:557 __debug_object_init+0x330/0x364 Modules linked in: CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.12.0-rc5 #4 Hardware name: linux,dummy-virt (DT) pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : __debug_object_init+0x330/0x364 lr : __debug_object_init+0x330/0x364
sp : ffff800082ea7b40
x29: ffff800082ea7b40 x28: 98ff0000c0164518 x27: 98ff0000c0164534
x26: ffff800082d93ec8 x25: 0000000000000001 x24: 1cff0000c00172a0
x23: 0000000000000000 x22: ffff800082d93ed0 x21: ffff800081a24418
x20: 3eff800082ea7bb0 x19: efff800000000000 x18: 0000000000000000
x17: 00000000000000ff x16: 0000000000000047 x15: 206b63617473206e
x14: 0000000000000018 x13: ffff800082ea7780 x12: 0ffff800082ea78e
x11: 0ffff800082ea790 x10: 0ffff800082ea79d x9 : 34d77febe173e800 x8 : 34d77febe173e800 x7 : 0000000000000001 x6 : 0000000000000001 x5 : feff800082ea74b8 x4 : ffff800082870a90 x3 : ffff80008018d3c4 x2 : 0000000000000001 x1 : ffff800082858810 x0 : 0000000000000050
Call trace: __debug_object_init+0x330/0x364 debug_object_init_on_stack+0x30/0x3c schedule_hrtimeout_range_clock+0xac/0x26c schedule_hrtimeout+0x1c/0x30 wait_task_inactive+0x1d4/0x25c kthread_bind_mask+0x28/0x98 init_rescuer+0x1e8/0x280 workqueue_init+0x1a0/0x3cc kernel_init_freeable+0x118/0x200 kernel_init+0x28/0x1f0 ret_from_fork+0x10/0x20 ---[ end trace 0000000000000000 ]--- ODEBUG: object 3eff800082ea7bb0 is NOT on stack ffff800082ea0000, but annotated. ------------[ cut here ]------------
--- include/linux/sched/task_stack.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/sched/task_stack.h +2 -0
@@ -8,6 +8,7 @@#include <linux/sched.h> #include <linux/magic.h> +#include <linux/kasan.h> #ifdef CONFIG_THREAD_INFO_IN_TASK
@@ -86,6 +87,7 @@ static inline int object_is_on_stack(con {void *stack =task_stack_page (current); + obj =kasan_reset_tag (obj);return (obj >= stack) && (obj < (stack +THREAD_SIZE )); }
Greg Kroah-Hartman
maintainerPATCH 230/373 bpf: avoid holding freeze_mutex during mmap operation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrii Nakryiko <[email protected]>
commit bc27c52eea189e8f7492d40739b7746d67b65beb upstream.
We use map->freeze_mutex to prevent races between map_freeze() and memory mapping BPF map contents with writable permissions. The way we naively do this means we'll hold freeze_mutex for entire duration of all the mm and VMA manipulations, which is completely unnecessary. This can potentially also lead to deadlocks, as reported by syzbot in [0].
So, instead, hold freeze_mutex only during writeability checks, bump (proactively) "write active" count for the map, unlock the mutex and proceed with mmap logic. And only if something went wrong during mmap logic, then undo that "write active" counter increment.
[0] https://lore.kernel.org/bpf/[email protected]/
--- kernel/bpf/syscall.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
kernel/bpf/syscall.c +10 -7
@@ -654,7 +654,7 @@ static const struct vm_operations_structstatic int bpf_map_mmap (struct file *filp,struct vm_area_struct *vma) {struct bpf_map *map = filp->private_data; -int err; +int err =0 ;if (!map->ops->map_mmap ||map_value_has_spin_lock (map) ||map_value_has_timer (map))
@@ -679,7 +679,12 @@ static int bpf_map_mmap(struct file *fil err = -EACCES ; goto out; } +bpf_map_write_active_inc (map); } +out: +mutex_unlock (&map->freeze_mutex); +if (err) +return err;/* set default open/close callbacks */ vma->vm_ops = &bpf_map_default_vmops;
@@ -690,13 +695,11 @@ static int bpf_map_mmap(struct file *fil vma->vm_flags &= ~VM_MAYWRITE ; err = map->ops->map_mmap (map, vma); -if (err) - goto out; +if (err) { +if (vma->vm_flags &VM_WRITE ) +bpf_map_write_active_dec (map); + } -if (vma->vm_flags &VM_MAYWRITE ) -bpf_map_write_active_inc (map); -out: -mutex_unlock (&map->freeze_mutex);return err; }
Greg Kroah-Hartman
maintainerPATCH 231/373 bpf: Check rcu_read_lock_trace_held() before calling bpf map helpers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
commit 169410eba271afc9f0fb476d996795aa26770c6d upstream.
These three bpf_map_{lookup,update,delete}_elem() helpers are also available for sleepable bpf program, so add the corresponding lock assertion for sleepable bpf program, otherwise the following warning will be reported when a sleepable bpf program manipulates bpf map under interpreter mode (aka bpf_jit_enable=0):
WARNING: CPU: 3 PID: 4985 at kernel/bpf/helpers.c:40 ...... CPU: 3 PID: 4985 Comm: test_progs Not tainted 6.6.0+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) ...... RIP: 0010:bpf_map_lookup_elem+0x54/0x60 ...... Call Trace: <TASK> ? __warn+0xa5/0x240 ? bpf_map_lookup_elem+0x54/0x60 ? report_bug+0x1ba/0x1f0 ? handle_bug+0x40/0x80 ? exc_invalid_op+0x18/0x50 ? asm_exc_invalid_op+0x1b/0x20 ? __pfx_bpf_map_lookup_elem+0x10/0x10 ? rcu_lockdep_current_cpu_online+0x65/0xb0 ? rcu_is_watching+0x23/0x50 ? bpf_map_lookup_elem+0x54/0x60 ? __pfx_bpf_map_lookup_elem+0x10/0x10 ___bpf_prog_run+0x513/0x3b70 __bpf_prog_run32+0x9d/0xd0 ? __bpf_prog_enter_sleepable_recur+0xad/0x120 ? __bpf_prog_enter_sleepable_recur+0x3e/0x120 bpf_trampoline_6442580665+0x4d/0x1000 __x64_sys_getpgid+0x5/0x30 ? do_syscall_64+0x36/0xb0 entry_SYSCALL_64_after_hwframe+0x6e/0x76 </TASK>
--- kernel/bpf/helpers.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
kernel/bpf/helpers.c +9 -5
@@ -3,6 +3,7 @@*/ #include <linux/bpf.h> #include <linux/rcupdate.h> +#include <linux/rcupdate_trace.h> #include <linux/random.h> #include <linux/smp.h> #include <linux/topology.h>
@@ -24,12 +25,13 @@* * Different map implementations will rely on rcu in map methods * lookup/update/delete, therefore eBPF programs must run under rcu lock -* if program is allowed to access maps, so check rcu_read_lock_held in -* all three functions. +* if program is allowed to access maps, so check rcu_read_lock_held() or +* rcu_read_lock_trace_held() in all three functions. */ BPF_CALL_2(bpf_map_lookup_elem, struct bpf_map *, map, void *, key) { -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && + !rcu_read_lock_bh_held ());return (unsigned long ) map->ops->map_lookup_elem (map, key); }
@@ -45,7 +47,8 @@ const struct bpf_func_proto bpf_map_look BPF_CALL_4(bpf_map_update_elem, struct bpf_map *, map, void *, key, void *, value, u64, flags) { -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && + !rcu_read_lock_bh_held ());return map->ops->map_update_elem (map, key, value, flags); }
@@ -62,7 +65,8 @@ const struct bpf_func_proto bpf_map_upda BPF_CALL_2(bpf_map_delete_elem, struct bpf_map *, map, void *, key) { -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && + !rcu_read_lock_bh_held ());return map->ops->map_delete_elem (map, key); }
Greg Kroah-Hartman
maintainerPATCH 232/373 blk-cgroup: support to track if policy is online
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit dfd6200a095440b663099d8d42f1efb0175a1ce3 upstream.
A new field 'online' is added to blkg_policy_data to fix following 2 problem:
1) In blkcg_activate_policy(), if pd_alloc_fn() with 'GFP_NOWAIT' failed, 'queue_lock' will be dropped and pd_alloc_fn() will try again without 'GFP_NOWAIT'. In the meantime, remove cgroup can race with it, and pd_offline_fn() will be called without pd_init_fn() and pd_online_fn(). This way null-ptr-deference can be triggered.
2) In order to synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy(), 'list_del_init(&blkg->q_node)' will be delayed to blkg_free_workfn(), hence pd_offline_fn() can be called first in blkg_destroy(), and then blkcg_deactivate_policy() will call it again, we must prevent it.
The new field 'online' will be set after pd_online_fn() and will be cleared after pd_offline_fn(), in the meantime pd_offline_fn() will only be called if 'online' is set.
--- block/blk-cgroup.c | 24 +++++++++++++++++------- include/linux/blk-cgroup.h | 1 + 2 files changed, 18 insertions(+), 7 deletions(-)
block/blk-cgroup.c +17 -7
@@ -192,6 +192,7 @@ static struct blkcg_gq *blkg_alloc(struc blkg->pd[i] = pd; pd->blkg = blkg; pd->plid = i; + pd->online = false; }return blkg;
@@ -289,8 +290,11 @@ static struct blkcg_gq *blkg_create(strufor (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i]; -if (blkg->pd[i] && pol->pd_online_fn) - pol->pd_online_fn (blkg->pd[i]); +if (blkg->pd[i]) { +if (pol->pd_online_fn) + pol->pd_online_fn (blkg->pd[i]); + blkg->pd[i]->online = true; + } } } blkg->online = true;
@@ -390,8 +394,11 @@ static void blkg_destroy(struct blkcg_gqfor (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i]; -if (blkg->pd[i] && pol->pd_offline_fn) - pol->pd_offline_fn (blkg->pd[i]); +if (blkg->pd[i] && blkg->pd[i]->online) { +if (pol->pd_offline_fn) + pol->pd_offline_fn (blkg->pd[i]); + blkg->pd[i]->online = false; + } } blkg->online = false;
@@ -1367,6 +1374,7 @@ retry: blkg->pd[pol->plid] = pd; pd->blkg = blkg; pd->plid = pol->plid; + pd->online = false; }/* all allocated, init in the same order */
@@ -1374,9 +1382,11 @@ retry:list_for_each_entry_reverse (blkg, &q->blkg_list, q_node) pol->pd_init_fn (blkg->pd[pol->plid]); -if (pol->pd_online_fn) -list_for_each_entry_reverse (blkg, &q->blkg_list, q_node) +list_for_each_entry_reverse (blkg, &q->blkg_list, q_node) { +if (pol->pd_online_fn) pol->pd_online_fn (blkg->pd[pol->plid]); + blkg->pd[pol->plid]->online = true; + }__set_bit (pol->plid, q->blkcg_pols); ret =0 ;
@@ -1438,7 +1448,7 @@ void blkcg_deactivate_policy(struct requspin_lock (&blkcg->lock);if (blkg->pd[pol->plid]) { -if (pol->pd_offline_fn) +if (blkg->pd[pol->plid]->online && pol->pd_offline_fn) pol->pd_offline_fn (blkg->pd[pol->plid]); pol->pd_free_fn (blkg->pd[pol->plid]); blkg->pd[pol->plid] =NULL ;
include/linux/blk-cgroup.h +1 -0
@@ -92,6 +92,7 @@ struct blkg_policy_data {/* the blkg and policy id this per-policy data belongs to */ struct blkcg_gq *blkg;int plid; +bool online; };/*
Greg Kroah-Hartman
maintainerPATCH 233/373 blk-iocost: do not WARN if iocg was already offlined
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
commit 01bc4fda9ea0a6b52f12326486f07a4910666cf6 upstream.
In iocg_pay_debt(), warn is triggered if 'active_list' is empty, which is intended to confirm iocg is active when it has debt. However, warn can be triggered during a blkcg or disk removal, if iocg_waitq_timer_fn() is run at that time:
WARNING: CPU: 0 PID: 2344971 at block/blk-iocost.c:1402 iocg_pay_debt+0x14c/0x190 Call trace: iocg_pay_debt+0x14c/0x190 iocg_kick_waitq+0x438/0x4c0 iocg_waitq_timer_fn+0xd8/0x130 __run_hrtimer+0x144/0x45c __hrtimer_run_queues+0x16c/0x244 hrtimer_interrupt+0x2cc/0x7b0
The warn in this situation is meaningless. Since this iocg is being removed, the state of the 'active_list' is irrelevant, and 'waitq_timer' is canceled after removing 'active_list' in ioc_pd_free(), which ensures iocg is freed after iocg_waitq_timer_fn() returns.
Therefore, add the check if iocg was already offlined to avoid warn when removing a blkcg or disk.
--- block/blk-iocost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
block/blk-iocost.c +5 -2
@@ -1435,8 +1435,11 @@ static void iocg_pay_debt(struct ioc_gqlockdep_assert_held (&iocg->ioc->lock);lockdep_assert_held (&iocg->waitq.lock); -/* make sure that nobody messed with @iocg */ -WARN_ON_ONCE (list_empty (&iocg->active_list)); +/* +* make sure that nobody messed with @iocg. Check iocg->pd.online +* to avoid warn when removing blkcg or disk. +*/ +WARN_ON_ONCE (list_empty (&iocg->active_list) && iocg->pd.online);WARN_ON_ONCE (iocg->inuse >1 ); iocg->abs_vdebt -=min (abs_vpay, iocg->abs_vdebt);
Greg Kroah-Hartman
maintainerPATCH 234/373 ext4: fix timer use-after-free on failed mount
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaxi Shen <[email protected]>
commit 0ce160c5bdb67081a62293028dc85758a8efb22a upstream.
Syzbot has found an ODEBUG bug in ext4_fill_super
The del_timer_sync function cancels the s_err_report timer, which reminds about filesystem errors daily. We should guarantee the timer is no longer active before kfree(sbi).
When filesystem mounting fails, the flow goes to failed_mount3, where an error occurs when ext4_stop_mmpd is called, causing a read I/O failure. This triggers the ext4_handle_error function that ultimately re-arms the timer,
leaving the s_err_report timer active before kfree(sbi) is called.
Fix the issue by canceling the s_err_report timer after calling ext4_stop_mmpd.
--- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/super.c +1 -1
@@ -5085,8 +5085,8 @@ failed_mount3a: failed_mount3:/* flush s_error_work before sbi destroy */ flush_work (&sbi->s_error_work); -del_timer_sync (&sbi->s_err_report);ext4_stop_mmpd (sbi); +del_timer_sync (&sbi->s_err_report); failed_mount2:rcu_read_lock (); group_desc =rcu_dereference (sbi->s_group_desc);
Greg Kroah-Hartman
maintainerPATCH 235/373 ipvs: properly dereference pe in ip_vs_add_service
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Hanxiao <[email protected]>
commit cbd070a4ae62f119058973f6d2c984e325bce6e7 upstream.
Use pe directly to resolve sparse warning:
net/netfilter/ipvs/ip_vs_ctl.c:1471:27: warning: dereference of noderef expression
--- net/netfilter/ipvs/ip_vs_ctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +5 -5
@@ -1384,20 +1384,20 @@ ip_vs_add_service(struct netns_ipvs *ipv sched =NULL ; } -/* Bind the ct retriever */ -RCU_INIT_POINTER (svc->pe, pe); - pe =NULL ; -/* Update the virtual service counters */ if (svc->port ==FTPPORT )atomic_inc (&ipvs->ftpsvc_counter);else if (svc->port ==0 )atomic_inc (&ipvs->nullsvc_counter); -if (svc->pe && svc->pe->conn_out) +if (pe && pe->conn_out)atomic_inc (&ipvs->conn_out_counter);ip_vs_start_estimator (ipvs, &svc->stats); +/* Bind the ct retriever */ +RCU_INIT_POINTER (svc->pe, pe); + pe =NULL ; +/* Count only IPv4 services for old get/setsockopt interface */ if (svc->af ==AF_INET ) ipvs->num_services++;
Greg Kroah-Hartman
maintainerPATCH 236/373 net: openvswitch: fix race on port output
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Huettner <[email protected]>
commit 066b86787fa3d97b7aefb5ac0a99a22dad2d15f8 upstream.
assume the following setup on a single machine:
1. An openvswitch instance with one bridge and default flows
2. two network namespaces "server" and "client"
3. two ovs interfaces "server" and "client" on the bridge
4. for each ovs interface a veth pair with a matching name and 32 rx and tx queues
5. move the ends of the veth pairs to the respective network namespaces
6. assign ip addresses to each of the veth ends in the namespaces (needs to be the same subnet)
7. start some http server on the server network namespace
8. test if a client in the client namespace can reach the http server
when following the actions below the host has a chance of getting a cpu stuck in a infinite loop:
1. send a large amount of parallel requests to the http server (around 3000 curls should work)
2. in parallel delete the network namespace (do not delete interfaces or stop the server, just kill the namespace)
there is a low chance that this will cause the below kernel cpu stuck message. If this does not happen just retry.
Below there is also the output of bpftrace for the functions mentioned in the output.
The series of events happening here is:
1. the network namespace is deleted calling unregister_netdevice_many_notify somewhere in the process
2. this sets first NETREG_UNREGISTERING on both ends of the veth and then runs synchronize_net
3. it then calls call_netdevice_notifiers with NETDEV_UNREGISTER
4. this is then handled by dp_device_event which calls ovs_netdev_detach_dev (if a vport is found, which is the case for the veth interface attached to ovs)
5. this removes the rx_handlers of the device but does not prevent packages to be sent to the device
6. dp_device_event then queues the vport deletion to work in background as a ovs_lock is needed that we do not hold in the unregistration path
7. unregister_netdevice_many_notify continues to call netdev_unregister_kobject which sets real_num_tx_queues to 0
8. port deletion continues (but details are not relevant for this issue)
9. at some future point the background task deletes the vport
If after 7. but before 9. a packet is send to the ovs vport (which is not deleted at this point in time) which forwards it to the dev_queue_xmit flow even though the device is unregistering. In skb_tx_hash (which is called in the dev_queue_xmit) path there is a while loop (if the packet has a rx_queue recorded) that is infinite if dev->real_num_tx_queues is zero.
To prevent this from happening we update do_output to handle devices without carrier the same as if the device is not found (which would be the code path after 9. is done).
Additionally we now produce a warning in skb_tx_hash if we will hit the infinite loop.
bpftrace (first word is function name):
__dev_queue_xmit server: real_num_tx_queues: 1, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 1 netdev_core_pick_tx server: addr: 0xffff9f0a46d4a000 real_num_tx_queues: 1, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 1 dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 2, reg_state: 1synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 6, reg_state: 2ovs_netdev_detach_dev server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, reg_state: 2netdev_rx_handler_unregister server: real_num_tx_queues: 1, cpu: 9, pid: 21024, tid: 21024, reg_state: 2synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024netdev_rx_handler_unregister ret server: real_num_tx_queues: 1, cpu: 9, pid: 21024, tid: 21024, reg_state: 2dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 27, reg_state: 2dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 22, reg_state: 2dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 18, reg_state: 2netdev_unregister_kobject: real_num_tx_queues: 1, cpu: 9, pid: 21024, tid: 21024synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024ovs_vport_send server: real_num_tx_queues: 0, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 2 __dev_queue_xmit server: real_num_tx_queues: 0, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 2 netdev_core_pick_tx server: addr: 0xffff9f0a46d4a000 real_num_tx_queues: 0, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 2 broken device server: real_num_tx_queues: 0, cpu: 2, pid: 28024, tid: 28024ovs_dp_detach_port server: real_num_tx_queues: 0 cpu 9, pid: 9124, tid: 9124, reg_state: 2synchronize_rcu_expedited: cpu 9, pid: 33604, tid: 33604
stuck message:
watchdog: BUG: soft lockup - CPU#5 stuck for 26s! [curl:1929279] Modules linked in: veth pktgen bridge stp llc ip_set_hash_net nft_counter xt_set nft_compat nf_tables ip_set_hash_ip ip_set nfnetlink_cttimeout nfnetlink openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 tls binfmt_misc nls_iso8859_1 input_leds joydev serio_raw dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua sch_fq_codel drm efi_pstore virtio_rng ip_tables x_tables autofs4 btrfs blake2b_generic zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear hid_generic usbhid hid crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel virtio_net ahci net_failover crypto_simd cryptd psmouse libahci virtio_blk failover CPU: 5 PID: 1929279 Comm: curl Not tainted 5.15.0-67-generic #74-Ubuntu Hardware name: OpenStack Foundation OpenStack Nova, BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:netdev_pick_tx+0xf1/0x320 Code: 00 00 8d 48 ff 0f b7 c1 66 39 ca 0f 86 e9 01 00 00 45 0f b7 ff 41 39 c7 0f 87 5b 01 00 00 44 29 f8 41 39 c7 0f 87 4f 01 00 00 <eb> f2 0f 1f 44 00 00 49 8b 94 24 28 04 00 00 48 85 d2 0f 84 53 01 RSP: 0018:ffffb78b40298820 EFLAGS: 00000246 RAX: 0000000000000000 RBX: ffff9c8773adc2e0 RCX: 000000000000083f RDX: 0000000000000000 RSI: ffff9c8773adc2e0 RDI: ffff9c870a25e000 RBP: ffffb78b40298858 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff9c870a25e000 R13: ffff9c870a25e000 R14: ffff9c87fe043480 R15: 0000000000000000 FS: 00007f7b80008f00(0000) GS:ffff9c8e5f740000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f7b80f6a0b0 CR3: 0000000329d66000 CR4: 0000000000350ee0 Call Trace: <IRQ> netdev_core_pick_tx+0xa4/0xb0 __dev_queue_xmit+0xf8/0x510 ? __bpf_prog_exit+0x1e/0x30 dev_queue_xmit+0x10/0x20 ovs_vport_send+0xad/0x170 [openvswitch] do_output+0x59/0x180 [openvswitch] do_execute_actions+0xa80/0xaa0 [openvswitch] ? kfree+0x1/0x250 ? kfree+0x1/0x250 ? kprobe_perf_func+0x4f/0x2b0 ? flow_lookup.constprop.0+0x5c/0x110 [openvswitch] ovs_execute_actions+0x4c/0x120 [openvswitch] ovs_dp_process_packet+0xa1/0x200 [openvswitch] ? ovs_ct_update_key.isra.0+0xa8/0x120 [openvswitch] ? ovs_ct_fill_key+0x1d/0x30 [openvswitch] ? ovs_flow_key_extract+0x2db/0x350 [openvswitch] ovs_vport_receive+0x77/0xd0 [openvswitch] ? __htab_map_lookup_elem+0x4e/0x60 ? bpf_prog_680e8aff8547aec1_kfree+0x3b/0x714 ? trace_call_bpf+0xc8/0x150 ? kfree+0x1/0x250 ? kfree+0x1/0x250 ? kprobe_perf_func+0x4f/0x2b0 ? kprobe_perf_func+0x4f/0x2b0 ? __mod_memcg_lruvec_state+0x63/0xe0 netdev_port_receive+0xc4/0x180 [openvswitch] ? netdev_port_receive+0x180/0x180 [openvswitch] netdev_frame_hook+0x1f/0x40 [openvswitch] __netif_receive_skb_core.constprop.0+0x23d/0xf00 __netif_receive_skb_one_core+0x3f/0xa0 __netif_receive_skb+0x15/0x60 process_backlog+0x9e/0x170 __napi_poll+0x33/0x180 net_rx_action+0x126/0x280 ? ttwu_do_activate+0x72/0xf0 __do_softirq+0xd9/0x2e7 ? rcu_report_exp_cpu_mult+0x1b0/0x1b0 do_softirq+0x7d/0xb0 </IRQ> <TASK> __local_bh_enable_ip+0x54/0x60 ip_finish_output2+0x191/0x460 __ip_finish_output+0xb7/0x180 ip_finish_output+0x2e/0xc0 ip_output+0x78/0x100 ? __ip_finish_output+0x180/0x180 ip_local_out+0x5e/0x70 __ip_queue_xmit+0x184/0x440 ? tcp_syn_options+0x1f9/0x300 ip_queue_xmit+0x15/0x20 __tcp_transmit_skb+0x910/0x9c0 ? __mod_memcg_state+0x44/0xa0 tcp_connect+0x437/0x4e0 ? ktime_get_with_offset+0x60/0xf0 tcp_v4_connect+0x436/0x530 __inet_stream_connect+0xd4/0x3a0 ? kprobe_perf_func+0x4f/0x2b0 ? aa_sk_perm+0x43/0x1c0 inet_stream_connect+0x3b/0x60 __sys_connect_file+0x63/0x70 __sys_connect+0xa6/0xd0 ? setfl+0x108/0x170 ? do_fcntl+0xe8/0x5a0 __x64_sys_connect+0x18/0x20 do_syscall_64+0x5c/0xc0 ? __x64_sys_fcntl+0xa9/0xd0 ? exit_to_user_mode_prepare+0x37/0xb0 ? syscall_exit_to_user_mode+0x27/0x50 ? do_syscall_64+0x69/0xc0 ? __sys_setsockopt+0xea/0x1e0 ? exit_to_user_mode_prepare+0x37/0xb0 ? syscall_exit_to_user_mode+0x27/0x50 ? __x64_sys_setsockopt+0x1f/0x30 ? do_syscall_64+0x69/0xc0 ? irqentry_exit+0x1d/0x30 ? exc_page_fault+0x89/0x170 entry_SYSCALL_64_after_hwframe+0x61/0xcb RIP: 0033:0x7f7b8101c6a7 Code: 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2a 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 18 89 54 24 0c 48 89 34 24 89 RSP: 002b:00007ffffd6b2198 EFLAGS: 00000246 ORIG_RAX: 000000000000002a RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f7b8101c6a7 RDX: 0000000000000010 RSI: 00007ffffd6b2360 RDI: 0000000000000005 RBP: 0000561f1370d560 R08: 00002795ad21d1ac R09: 0030312e302e302e R10: 00007ffffd73f080 R11: 0000000000000246 R12: 0000561f1370c410 R13: 0000000000000000 R14: 0000000000000005 R15: 0000000000000000 </TASK>
--- net/core/dev.c | 1 + net/openvswitch/actions.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
net/core/dev.c +1 -0
@@ -3231,6 +3231,7 @@ static u16 skb_tx_hash(const struct net_ }if (skb_rx_queue_recorded (skb)) { +BUILD_BUG_ON_INVALID (qcount ==0 ); hash =skb_get_rx_queue (skb);if (hash >= qoffset) hash -= qoffset;
net/openvswitch/actions.c +1 -1
@@ -913,7 +913,7 @@ static void do_output(struct datapath *d {struct vport *vport =ovs_vport_rcu (dp, out_port); -if (likely (vport)) { +if (likely (vport &&netif_carrier_ok (vport->dev))) {u16 mru =OVS_CB (skb)->mru;u32 cutlen =OVS_CB (skb)->cutlen;
Greg Kroah-Hartman
maintainerPATCH 237/373 openvswitch: fix lockup on tx to unregistering netdev with carrier
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
commit 47e55e4b410f7d552e43011baa5be1aab4093990 upstream.
Commit in a fixes tag attempted to fix the issue in the following sequence of calls:
do_output
-> ovs_vport_send
-> dev_queue_xmit
-> __dev_queue_xmit
-> netdev_core_pick_tx
-> skb_tx_hashWhen device is unregistering, the 'dev->real_num_tx_queues' goes to zero and the 'while (unlikely(hash >= qcount))' loop inside the 'skb_tx_hash' becomes infinite, locking up the core forever.
But unfortunately, checking just the carrier status is not enough to fix the issue, because some devices may still be in unregistering state while reporting carrier status OK.
One example of such device is a net/dummy. It sets carrier ON on start, but it doesn't implement .ndo_stop to set the carrier off. And it makes sense, because dummy doesn't really have a carrier. Therefore, while this device is unregistering, it's still easy to hit the infinite loop in the skb_tx_hash() from the OVS datapath. There might be other drivers that do the same, but dummy by itself is important for the OVS ecosystem, because it is frequently used as a packet sink for tcpdump while debugging OVS deployments. And when the issue is hit, the only way to recover is to reboot.
Fix that by also checking if the device is running. The running state is handled by the net core during unregistering, so it covers unregistering case better, and we don't really need to send packets to devices that are not running anyway.
While only checking the running state might be enough, the carrier check is preserved. The running and the carrier states seem disjoined throughout the code and different drivers. And other core functions like __dev_direct_xmit() check both before attempting to transmit a packet. So, it seems safer to check both flags in OVS as well.
--- net/openvswitch/actions.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/openvswitch/actions.c +3 -1
@@ -913,7 +913,9 @@ static void do_output(struct datapath *d {struct vport *vport =ovs_vport_rcu (dp, out_port); -if (likely (vport &&netif_carrier_ok (vport->dev))) { +if (likely (vport && +netif_running (vport->dev) && +netif_carrier_ok (vport->dev))) {u16 mru =OVS_CB (skb)->mru;u32 cutlen =OVS_CB (skb)->cutlen;
Greg Kroah-Hartman
maintainerPATCH 238/373 scsi: lpfc: Fix a possible data race in lpfc_unregister_fcf_rescan()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tuo Li <[email protected]>
commit 0e881c0a4b6146b7e856735226208f48251facd8 upstream.
The variable phba->fcf.fcf_flag is often protected by the lock phba->hbalock() when is accessed. Here is an example in lpfc_unregister_fcf_rescan():
spin_lock_irq(&phba->hbalock); phba->fcf.fcf_flag |= FCF_INIT_DISC; spin_unlock_irq(&phba->hbalock);
However, in the same function, phba->fcf.fcf_flag is assigned with 0 without holding the lock, and thus can cause a data race:
phba->fcf.fcf_flag = 0;
To fix this possible data race, a lock and unlock pair is added when accessing the variable phba->fcf.fcf_flag.
--- drivers/scsi/lpfc/lpfc_hbadisc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/lpfc/lpfc_hbadisc.c +2 -0
@@ -6954,7 +6954,9 @@ lpfc_unregister_fcf_rescan(struct lpfc_hif (rc)return ;/* Reset HBA FCF states after successful unregister FCF */ +spin_lock_irq (&phba->hbalock); phba->fcf.fcf_flag =0 ; +spin_unlock_irq (&phba->hbalock); phba->fcf.current_rec.flag =0 ;/*
Greg Kroah-Hartman
maintainerPATCH 239/373 scsi: ufs: bsg: Set bsg_queue to NULL after removal
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
commit 1e95c798d8a7f70965f0f88d4657b682ff0ec75f upstream.
Currently, this does not cause any issues, but I believe it is necessary to set bsg_queue to NULL after removing it to prevent potential use-after-free (UAF) access.
--- drivers/scsi/ufs/ufs_bsg.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufs_bsg.c +1 -0
@@ -175,6 +175,7 @@ void ufs_bsg_remove(struct ufs_hba *hba)return ;bsg_remove_queue (hba->bsg_queue); + hba->bsg_queue =NULL ;device_del (bsg_dev);put_device (bsg_dev);
Greg Kroah-Hartman
maintainerPATCH 240/373 net: defer final struct net free in netns dismantle
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 0f6ede9fbc747e2553612271bce108f7517e7a45 upstream.
Ilya reported a slab-use-after-free in dst_destroy [1]
Issue is in xfrm6_net_init() and xfrm4_net_init() :
They copy xfrm[46]_dst_ops_template into net->xfrm.xfrm[46]_dst_ops.
But net structure might be freed before all the dst callbacks are called. So when dst_destroy() calls later :
if (dst->ops->destroy)
dst->ops->destroy(dst);
dst->ops points to the old net->xfrm.xfrm[46]_dst_ops, which has been freed.
See a relevant issue fixed in :
ac888d58869b ("net: do not delay dst_entries_add() in dst_release()")
A fix is to queue the 'struct net' to be freed after one another cleanup_net() round (and existing rcu_barrier())
[1]
BUG: KASAN: slab-use-after-free in dst_destroy (net/core/dst.c:112) Read of size 8 at addr ffff8882137ccab0 by task swapper/37/0 Dec 03 05:46:18 kernel: CPU: 37 UID: 0 PID: 0 Comm: swapper/37 Kdump: loaded Not tainted 6.12.0 #67 Hardware name: Red Hat KVM/RHEL, BIOS 1.16.1-1.el9 04/01/2014 Call Trace: <IRQ>
dump_stack_lvl (lib/dump_stack.c:124)
print_address_description.constprop.0 (mm/kasan/report.c:378)
? dst_destroy (net/core/dst.c:112)print_report (mm/kasan/report.c:489)
? dst_destroy (net/core/dst.c:112)
? kasan_addr_to_slab (mm/kasan/common.c:37)kasan_report (mm/kasan/report.c:603)
? dst_destroy (net/core/dst.c:112)
? rcu_do_batch (kernel/rcu/tree.c:2567)dst_destroy (net/core/dst.c:112)rcu_do_batch (kernel/rcu/tree.c:2567)
? __pfx_rcu_do_batch (kernel/rcu/tree.c:2491)
? lockdep_hardirqs_on_prepare (kernel/locking/lockdep.c:4339 kernel/locking/lockdep.c:4406) rcu_core (kernel/rcu/tree.c:2825)handle_softirqs (kernel/softirq.c:554)__irq_exit_rcu (kernel/softirq.c:589 kernel/softirq.c:428 kernel/softirq.c:637) irq_exit_rcu (kernel/softirq.c:651)
sysvec_apic_timer_interrupt (arch/x86/kernel/apic/apic.c:1049 arch/x86/kernel/apic/apic.c:1049) </IRQ> <TASK> asm_sysvec_apic_timer_interrupt (./arch/x86/include/asm/idtentry.h:702) RIP: 0010:default_idle (./arch/x86/include/asm/irqflags.h:37 ./arch/x86/include/asm/irqflags.h:92 arch/x86/kernel/process.c:743) Code: 00 4d 29 c8 4c 01 c7 4c 29 c2 e9 6e ff ff ff 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 90 0f 00 2d c7 c9 27 00 fb f4 <fa> c3 cc cc cc cc 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 90 RSP: 0018:ffff888100d2fe00 EFLAGS: 00000246 RAX: 00000000001870ed RBX: 1ffff110201a5fc2 RCX: ffffffffb61a3e46 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffffb3d4d123 RBP: 0000000000000000 R08: 0000000000000001 R09: ffffed11c7e1835d R10: ffff888e3f0c1aeb R11: 0000000000000000 R12: 0000000000000000 R13: ffff888100d20000 R14: dffffc0000000000 R15: 0000000000000000
? ct_kernel_exit.constprop.0 (kernel/context_tracking.c:148) ? cpuidle_idle_call (kernel/sched/idle.c:186) default_idle_call (./include/linux/cpuidle.h:143 kernel/sched/idle.c:118) cpuidle_idle_call (kernel/sched/idle.c:186)
? __pfx_cpuidle_idle_call (kernel/sched/idle.c:168)
? lock_release (kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5848) ? lockdep_hardirqs_on_prepare (kernel/locking/lockdep.c:4347 kernel/locking/lockdep.c:4406) ? tsc_verify_tsc_adjust (arch/x86/kernel/tsc_sync.c:59) do_idle (kernel/sched/idle.c:326) cpu_startup_entry (kernel/sched/idle.c:423 (discriminator 1)) start_secondary (arch/x86/kernel/smpboot.c:202 arch/x86/kernel/smpboot.c:282) ? __pfx_start_secondary (arch/x86/kernel/smpboot.c:232) ? soft_restart_cpu (arch/x86/kernel/head_64.S:452) common_startup_64 (arch/x86/kernel/head_64.S:414) </TASK> Dec 03 05:46:18 kernel: Allocated by task 12184: kasan_save_stack (mm/kasan/common.c:48) kasan_save_track (./arch/x86/include/asm/current.h:49 mm/kasan/common.c:60 mm/kasan/common.c:69) __kasan_slab_alloc (mm/kasan/common.c:319 mm/kasan/common.c:345) kmem_cache_alloc_noprof (mm/slub.c:4085 mm/slub.c:4134 mm/slub.c:4141) copy_net_ns (net/core/net_namespace.c:421 net/core/net_namespace.c:480)
create_new_namespaces (kernel/nsproxy.c:110) unshare_nsproxy_namespaces (kernel/nsproxy.c:228 (discriminator 4)) ksys_unshare (kernel/fork.c:3313)__x64_sys_unshare (kernel/fork.c:3382)do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
Dec 03 05:46:18 kernel: Freed by task 11:
kasan_save_stack (mm/kasan/common.c:48)kasan_save_track (./arch/x86/include/asm/current.h:49 mm/kasan/common.c:60 mm/kasan/common.c:69) kasan_save_free_info (mm/kasan/generic.c:582)__kasan_slab_free (mm/kasan/common.c:271)
kmem_cache_free (mm/slub.c:4579 mm/slub.c:4681) cleanup_net (net/core/net_namespace.c:456 net/core/net_namespace.c:446 net/core/net_namespace.c:647)
process_one_work (kernel/workqueue.c:3229) worker_thread (kernel/workqueue.c:3304 kernel/workqueue.c:3391) kthread (kernel/kthread.c:389)ret_from_fork (arch/x86/kernel/process.c:147) ret_from_fork_asm (arch/x86/entry/entry_64.S:257)
Dec 03 05:46:18 kernel: Last potentially related work creation:
kasan_save_stack (mm/kasan/common.c:48)__kasan_record_aux_stack (mm/kasan/generic.c:541)insert_work (./include/linux/instrumented.h:68 ./include/asm-generic/bitops/instrumented-non-atomic.h:141 kernel/workqueue.c:788 kernel/workqueue.c:795 kernel/workqueue.c:2186) __queue_work (kernel/workqueue.c:2340)queue_work_on (kernel/workqueue.c:2391)xfrm_policy_insert (net/xfrm/xfrm_policy.c:1610)xfrm_add_policy (net/xfrm/xfrm_user.c:2116)xfrm_user_rcv_msg (net/xfrm/xfrm_user.c:3321)netlink_rcv_skb (net/netlink/af_netlink.c:2536)xfrm_netlink_rcv (net/xfrm/xfrm_user.c:3344)netlink_unicast (net/netlink/af_netlink.c:1316 net/netlink/af_netlink.c:1342)netlink_sendmsg (net/netlink/af_netlink.c:1886)
sock_write_iter (net/socket.c:729 net/socket.c:744 net/socket.c:1165) vfs_write (fs/read_write.c:590 fs/read_write.c:683) ksys_write (fs/read_write.c:736) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) Dec 03 05:46:18 kernel: Second to last potentially related work creation:
kasan_save_stack (mm/kasan/common.c:48)__kasan_record_aux_stack (mm/kasan/generic.c:541)insert_work (./include/linux/instrumented.h:68 ./include/asm-generic/bitops/instrumented-non-atomic.h:141 kernel/workqueue.c:788 kernel/workqueue.c:795 kernel/workqueue.c:2186) __queue_work (kernel/workqueue.c:2340)queue_work_on (kernel/workqueue.c:2391)
__xfrm_state_insert (./include/linux/workqueue.h:723 net/xfrm/xfrm_state.c:1150 net/xfrm/xfrm_state.c:1145 net/xfrm/xfrm_state.c:1513) xfrm_state_update (./include/linux/spinlock.h:396 net/xfrm/xfrm_state.c:1940)
xfrm_add_sa (net/xfrm/xfrm_user.c:912)xfrm_user_rcv_msg (net/xfrm/xfrm_user.c:3321)netlink_rcv_skb (net/netlink/af_netlink.c:2536)xfrm_netlink_rcv (net/xfrm/xfrm_user.c:3344)netlink_unicast (net/netlink/af_netlink.c:1316 net/netlink/af_netlink.c:1342) netlink_sendmsg (net/netlink/af_netlink.c:1886)
sock_write_iter (net/socket.c:729 net/socket.c:744 net/socket.c:1165) vfs_write (fs/read_write.c:590 fs/read_write.c:683)
ksys_write (fs/read_write.c:736)do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
--- include/net/net_namespace.h | 1 + net/core/net_namespace.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
include/net/net_namespace.h +1 -0
@@ -80,6 +80,7 @@ struct net {* or to unregister pernet ops * (pernet_ops_rwsem write locked). */ +struct llist_node defer_free_list;struct llist_node cleanup_list;/* namespaces on death row */ #ifdef CONFIG_KEYS
net/core/net_namespace.c +20 -1
@@ -440,11 +440,28 @@ out_free: goto out; } +static LLIST_HEAD (defer_free_list); + +static void net_complete_free (void ) +{ +struct llist_node *kill_list; +struct net *net, *next; + +/* Get the list of namespaces to free from last round. */ + kill_list =llist_del_all (&defer_free_list); + +llist_for_each_entry_safe (net, next, kill_list, defer_free_list) +kmem_cache_free (net_cachep, net); + +} +static void net_free (struct net *net) {if (refcount_dec_and_test (&net->passive)) {kfree (rcu_access_pointer (net->gen)); -kmem_cache_free (net_cachep, net); + +/* Wait for an extra rcu_barrier() before final free. */ +llist_add (&net->defer_free_list, &defer_free_list); } }
@@ -628,6 +645,8 @@ static void cleanup_net(struct work_stru*/ rcu_barrier (); +net_complete_free (); +/* Finally it is safe to free my network namespace structure */ list_for_each_entry_safe (net, tmp, &net_exit_list, exit_list) {list_del_init (&net->exit_list);
Greg Kroah-Hartman
maintainerPATCH 241/373 MIPS: dec: Declare which_prom() as static
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit 55fa5868519bc48a7344a4c070efa2f4468f2167 upstream.
Declare which_prom() as static to suppress gcc compiler warning that 'missing-prototypes'. This function is not intended to be called from other parts.
Fix follow error with gcc-14 when -Werror:
arch/mips/dec/prom/init.c:45:13: error: no previous prototype for ‘which_prom’ [-Werror=missing-prototypes]
45 | void __init which_prom(s32 magic, s32 *prom_vec)
| ^~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:207: arch/mips/dec/prom/init.o] Error 1 make[5]: *** [scripts/Makefile.build:465: arch/mips/dec/prom] Error 2 make[5]: *** Waiting for unfinished jobs....
--- arch/mips/dec/prom/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/dec/prom/init.c +1 -1
@@ -42,7 +42,7 @@ int (*__pmax_close)(int);* Detect which PROM the DECSTATION has, and set the callback vectors * appropriately. */ -void __init which_prom (s32 magic,s32 *prom_vec) +static void __init which_prom (s32 magic,s32 *prom_vec) {/* * No sign of the REX PROM's magic number means we assume a non-REX
Greg Kroah-Hartman
maintainerPATCH 242/373 MIPS: cevt-ds1287: Add missing ds1287.h include
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit f3be225f338a578851a7b607a409f476354a8deb upstream.
Address the issue of cevt-ds1287.c not including the ds1287.h header file.
Fix follow errors with gcc-14 when -Werror:
arch/mips/kernel/cevt-ds1287.c:15:5: error: no previous prototype for ‘ds1287_timer_state’ [-Werror=missing-prototypes]
15 | int ds1287_timer_state(void)
| ^~~~~~~~~~~~~~~~~~
arch/mips/kernel/cevt-ds1287.c:20:5: error: no previous prototype for ‘ds1287_set_base_clock’ [-Werror=missing-prototypes]
20 | int ds1287_set_base_clock(unsigned int hz)
| ^~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/cevt-ds1287.c:103:12: error: no previous prototype for ‘ds1287_clockevent_init’ [-Werror=missing-prototypes]
103 | int __init ds1287_clockevent_init(int irq)
| ^~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
make[7]: *** [scripts/Makefile.build:207: arch/mips/kernel/cevt-ds1287.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [scripts/Makefile.build:465: arch/mips/kernel] Error 2 make[6]: *** Waiting for unfinished jobs....
--- arch/mips/kernel/cevt-ds1287.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/kernel/cevt-ds1287.c +1 -0
@@ -10,6 +10,7 @@#include <linux/mc146818rtc.h> #include <linux/irq.h> +#include <asm/ds1287.h> #include <asm/time.h> int ds1287_timer_state (void )
Greg Kroah-Hartman
maintainerPATCH 243/373 MIPS: ds1287: Match ds1287_set_base_clock() function types
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit a759109b234385b74d2f5f4c86b5f59b3201ec12 upstream.
Synchronize the declaration of ds1287_set_base_clock() between cevt-ds1287.c and ds1287.h.
Fix follow error with gcc-14 when -Werror:
arch/mips/kernel/cevt-ds1287.c:21:5: error: conflicting types for ‘ds1287_set_base_clock’; have ‘int(unsigned int)’
21 | int ds1287_set_base_clock(unsigned int hz)
| ^~~~~~~~~~~~~~~~~~~~~
In file included from arch/mips/kernel/cevt-ds1287.c:13:
./arch/mips/include/asm/ds1287.h:11:13: note: previous declaration of ‘ds1287_set_base_clock’ with type ‘void(unsigned int)’
11 | extern void ds1287_set_base_clock(unsigned int clock);
| ^~~~~~~~~~~~~~~~~~~~~make[7]: *** [scripts/Makefile.build:207: arch/mips/kernel/cevt-ds1287.o] Error 1 make[6]: *** [scripts/Makefile.build:465: arch/mips/kernel] Error 2 make[6]: *** Waiting for unfinished jobs....
--- arch/mips/include/asm/ds1287.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/ds1287.h +1 -1
@@ -8,7 +8,7 @@#define __ASM_DS1287_Hextern int ds1287_timer_state (void ); -extern void ds1287_set_base_clock (unsigned int clock); +extern int ds1287_set_base_clock (unsigned int hz);extern int ds1287_clockevent_init (int irq);#endif
Greg Kroah-Hartman
maintainerPATCH 244/373 jfs: Fix shift-out-of-bounds in dbDiscardAG
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Li <[email protected]>
commit 7063b80268e2593e58bee8a8d709c2f3ff93e2f2 upstream.
When searching for the next smaller log2 block, BLKSTOL2() returned 0, causing shift exponent -1 to be negative.
This patch fixes the issue by exiting the loop directly when negative shift is found.
--- fs/jfs/jfs_dmap.c | 2 ++ 1 file changed, 2 insertions(+)
fs/jfs/jfs_dmap.c +2 -0
@@ -1698,6 +1698,8 @@ s64 dbDiscardAG(struct inode *ip, int ag }else if (rc == -ENOSPC ) {/* search for next smaller log2 block */ l2nb =BLKSTOL2 (nblocks) -1 ; +if (unlikely (l2nb <0 )) +break ; nblocks =1LL << l2nb; }else {/* Trim any already allocated blocks */
Greg Kroah-Hartman
maintainerPATCH 245/373 dm cache: fix flushing uninitialized delayed_work on cache_ctr error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming-Hung Tsai <[email protected]>
commit 135496c208ba26fd68cdef10b64ed7a91ac9a7ff upstream.
An unexpected WARN_ON from flush_work() may occur when cache creation fails, caused by destroying the uninitialized delayed_work waker in the error path of cache_create(). For example, the warning appears on the superblock checksum error.
Reproduce steps:
dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 65536 linear /dev/sdc 8192" dmsetup create corig --table "0 524288 linear /dev/sdc 262144" dd if=/dev/urandom of=/dev/mapper/cmeta bs=4k count=1 oflag=direct dmsetup create cache --table "0 524288 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0"
Kernel logs:
(snip)
WARNING: CPU: 0 PID: 84 at kernel/workqueue.c:4178 __flush_work+0x5d4/0x890
Fix by pulling out the cancel_delayed_work_sync() from the constructor's error path. This patch doesn't affect the use-after-free fix for concurrent dm_resume and dm_destroy (commit 6a459d8edbdb ("dm cache: Fix UAF in destroy()")) as cache_dtr is not changed.
--- drivers/md/dm-cache-target.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/md/dm-cache-target.c +15 -9
@@ -1890,16 +1890,13 @@ static void check_migrations(struct work* This function gets called on the error paths of the constructor, so we * have to cope with a partially initialised struct. */ -static void destroy (struct cache *cache) +static void __destroy (struct cache *cache) { -unsigned i; -mempool_exit (&cache->migration_pool);if (cache->prison)dm_bio_prison_destroy_v2 (cache->prison); -cancel_delayed_work_sync (&cache->waker);if (cache->wq)destroy_workqueue (cache->wq);
@@ -1927,13 +1924,22 @@ static void destroy(struct cache *cache)if (cache->policy)dm_cache_policy_destroy (cache->policy); +bioset_exit (&cache->bs); + +kfree (cache); +} + +static void destroy (struct cache *cache) +{ +unsigned int i; + +cancel_delayed_work_sync (&cache->waker); +for (i =0 ; i < cache->nr_ctr_args ; i++)kfree (cache->ctr_args[i]);kfree (cache->ctr_args); -bioset_exit (&cache->bs); - -kfree (cache); +__destroy (cache); }static void cache_dtr (struct dm_target *ti)
@@ -2546,7 +2552,7 @@ static int cache_create(struct cache_arg *result = cache;return 0 ; bad: -destroy (cache); +__destroy (cache);return r; }
@@ -2597,7 +2603,7 @@ static int cache_ctr(struct dm_target *t r =copy_ctr_args (cache, argc -3 , (const char **)argv +3 );if (r) { -destroy (cache); +__destroy (cache); goto out; }
Greg Kroah-Hartman
maintainerPATCH 246/373 drm/i915/gt: Cleanup partial engine discovery failures
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit 78a033433a5ae4fee85511ee075bc9a48312c79e upstream.
If we abort driver initialisation in the middle of gt/engine discovery, some engines will be fully setup and some not. Those incompletely setup engines only have 'engine->release == NULL' and so will leak any of the common objects allocated.
v2:
- Drop the destroy_pinned_context() helper for now. It's not really worth it with just a single callsite at the moment. (Janusz)
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +6 -1
@@ -983,8 +983,13 @@ int intel_engines_init(struct intel_gt *return err; err =setup (engine); -if (err) +if (err) { +intel_engine_cleanup_common (engine);return err; + } + +/* The backend should now be responsible for cleanup */ +GEM_BUG_ON (engine->release ==NULL ); err =engine_init_common (engine);if (err)
Greg Kroah-Hartman
maintainerPATCH 247/373 fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Nesterov <[email protected]>
commit 7601df8031fd67310af891897ef6cc0df4209305 upstream.
lock_task_sighand() can trigger a hard lockup. If NR_CPUS threads call do_task_stat() at the same time and the process has NR_THREADS, it will spin with irqs disabled O(NR_CPUS * NR_THREADS) time.
Change do_task_stat() to use sig->stats_lock to gather the statistics outside of ->siglock protected section, in the likely case this code will run lockless.
--- fs/proc/array.c | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-)
fs/proc/array.c +29 -24
@@ -462,12 +462,12 @@ static int do_task_stat(struct seq_fileint permitted;struct mm_struct *mm;unsigned long long start_time; -unsigned long cmin_flt =0 , cmaj_flt =0 ; -unsigned long min_flt =0 , maj_flt =0 ; -u64 cutime, cstime, utime, stime; -u64 cgtime, gtime; +unsigned long cmin_flt, cmaj_flt, min_flt, maj_flt; +u64 cutime, cstime, cgtime, utime, stime, gtime;unsigned long rsslim =0 ;unsigned long flags; +struct signal_struct *sig = task->signal; +unsigned int seq =1 ; state = *get_task_state (task); vsize = eip = esp =0 ;
@@ -495,12 +495,8 @@ static int do_task_stat(struct seq_filesigemptyset (&sigign);sigemptyset (&sigcatch); - cutime = cstime =0 ; - cgtime = gtime =0 ;if (lock_task_sighand (task, &flags)) { -struct signal_struct *sig = task->signal; -if (sig->tty) {struct pid *pgrp =tty_get_pgrp (sig->tty); tty_pgrp =pid_nr_ns (pgrp, ns);
@@ -511,36 +507,45 @@ static int do_task_stat(struct seq_file num_threads =get_nr_threads (task);collect_sigign_sigcatch (task, &sigign, &sigcatch); + rsslim =READ_ONCE (sig->rlim[RLIMIT_RSS ].rlim_cur); + + sid =task_session_nr_ns (task, ns); + ppid =task_tgid_nr_ns (task->real_parent, ns); + pgid =task_pgrp_nr_ns (task, ns); + +unlock_task_sighand (task, &flags); + } + +if (permitted && (!whole || num_threads <2 )) + wchan = !task_is_running (task); + + do { + seq++; /* 2 on the 1st/lockless path, otherwise odd */ + flags = read_seqbegin_or_lock_irqsave(&sig->stats_lock, &seq); + cmin_flt = sig->cmin_flt; cmaj_flt = sig->cmaj_flt; cutime = sig->cutime; cstime = sig->cstime; cgtime = sig->cgtime; - rsslim =READ_ONCE (sig->rlim[RLIMIT_RSS ].rlim_cur); -/* add up live thread stats at the group level */ if (whole) { struct task_struct *t = task; + + min_flt = sig->min_flt; + maj_flt = sig->maj_flt; + gtime = sig->gtime; + + rcu_read_lock(); do { min_flt += t->min_flt; maj_flt += t->maj_flt; gtime += task_gtime(t); } while_each_thread(task, t); - - min_flt += sig->min_flt; - maj_flt += sig->maj_flt; - gtime += sig->gtime; + rcu_read_unlock(); } - - sid = task_session_nr_ns(task, ns); - ppid = task_tgid_nr_ns(task->real_parent, ns); - pgid = task_pgrp_nr_ns(task, ns); - - unlock_task_sighand(task, &flags); - } - - if (permitted && (!whole || num_threads < 2)) - wchan = !task_is_running(task); + } while (need_seqretry(&sig->stats_lock, seq)); + done_seqretry_irqrestore(&sig->stats_lock, seq, flags); if (whole) { thread_group_cputime_adjusted(task, &utime, &stime);
Greg Kroah-Hartman
maintainerPATCH 248/373 mm: fix apply_to_existing_page_range()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kirill A. Shutemov <[email protected]>
commit a995199384347261bb3f21b2e171fa7f988bd2f8 upstream.
In the case of apply_to_existing_page_range(), apply_to_pte_range() is reached with 'create' set to false. When !create, the loop over the PTE page table is broken.
apply_to_pte_range() will only move to the next PTE entry if 'create' is true or if the current entry is not pte_none().
This means that the user of apply_to_existing_page_range() will not have 'fn' called for any entries after the first pte_none() in the PTE page table.
Fix the loop logic in apply_to_pte_range().
There are no known runtime issues from this, but the fix is trivial enough for stable@ even without a known buggy user.
--- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memory.c +2 -2
@@ -2570,11 +2570,11 @@ static int apply_to_pte_range(struct mm_if (fn) {do {if (create || !pte_none (*pte)) { - err =fn (pte++, addr, data); + err =fn (pte, addr, data);if (err)break ; } - }while (addr +=PAGE_SIZE , addr != end); + }while (pte++, addr +=PAGE_SIZE , addr != end); } *mask |=PGTBL_PTE_MODIFIED ;
Greg Kroah-Hartman
maintainerPATCH 249/373 f2fs: check validation of fault attrs in f2fs_build_fault_attr()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit 4ed886b187f47447ad559619c48c086f432d2b77 upstream.
- It missed to check validation of fault attrs in parse_options(), let's fix to add check condition in f2fs_build_fault_attr().
- Use f2fs_build_fault_attr() in __sbi_store() to clean up code.
--- fs/f2fs/f2fs.h | 12 ++++++++---- fs/f2fs/super.c | 27 ++++++++++++++++++++------- fs/f2fs/sysfs.c | 14 ++++++++++---- 3 files changed, 38 insertions(+), 15 deletions(-)
fs/f2fs/f2fs.h +8 -4
@@ -64,7 +64,7 @@ enum {struct f2fs_fault_info {atomic_t inject_ops; -unsigned int inject_rate; +int inject_rate;unsigned int inject_type; };
@@ -4373,10 +4373,14 @@ static inline bool f2fs_need_verity(cons }#ifdef CONFIG_F2FS_FAULT_INJECTION -extern void f2fs_build_fault_attr (struct f2fs_sb_info *sbi,unsigned int rate, -unsigned int type); +extern int f2fs_build_fault_attr (struct f2fs_sb_info *sbi,unsigned long rate, +unsigned long type);#else -#define f2fs_build_fault_attr (sbi, rate, type) do { } while (0) +static int f2fs_build_fault_attr (struct f2fs_sb_info *sbi,unsigned long rate, +unsigned long type) +{ +return 0 ; +}#endif static inline bool is_journalled_quota (struct f2fs_sb_info *sbi)
fs/f2fs/super.c +20 -7
@@ -61,21 +61,31 @@ const char *f2fs_fault_name[FAULT_MAX] = [FAULT_DQUOT_INIT] = "dquot initialize", }; -void f2fs_build_fault_attr (struct f2fs_sb_info *sbi,unsigned int rate, -unsigned int type) +int f2fs_build_fault_attr (struct f2fs_sb_info *sbi,unsigned long rate, +unsigned long type) {struct f2fs_fault_info *ffi = &F2FS_OPTION (sbi).fault_info;if (rate) { +if (rate >INT_MAX ) +return -EINVAL ;atomic_set (&ffi->inject_ops,0 ); - ffi->inject_rate = rate; + ffi->inject_rate = (int )rate; } -if (type) - ffi->inject_type = type; +if (type) { +if (type >=BIT (FAULT_MAX )) +return -EINVAL ; + ffi->inject_type = (unsigned int )type; + }if (!rate && !type)memset (ffi,0 ,sizeof (struct f2fs_fault_info )); +else +f2fs_info (sbi, +"build fault injection attr: rate: %lu, type: 0x%lx" , + rate, type); +return 0 ; }#endif
@@ -901,14 +911,17 @@ static int parse_options(struct super_blcase Opt_fault_injection:if (args->from &&match_int (args, &arg))return -EINVAL ; -f2fs_build_fault_attr (sbi, arg,F2FS_ALL_FAULT_TYPE ); +if (f2fs_build_fault_attr (sbi, arg, +F2FS_ALL_FAULT_TYPE )) +return -EINVAL ;set_opt (sbi,FAULT_INJECTION );break ;case Opt_fault_type:if (args->from &&match_int (args, &arg))return -EINVAL ; -f2fs_build_fault_attr (sbi,0 , arg); +if (f2fs_build_fault_attr (sbi,0 , arg)) +return -EINVAL ;set_opt (sbi,FAULT_INJECTION );break ;#else
fs/f2fs/sysfs.c +10 -4
@@ -407,10 +407,16 @@ out:if (ret <0 )return ret;#ifdef CONFIG_F2FS_FAULT_INJECTION -if (a->struct_type ==FAULT_INFO_TYPE && t >= (1 <<FAULT_MAX )) -return -EINVAL ; -if (a->struct_type ==FAULT_INFO_RATE && t >=UINT_MAX ) -return -EINVAL ; +if (a->struct_type ==FAULT_INFO_TYPE ) { +if (f2fs_build_fault_attr (sbi,0 , t)) +return -EINVAL ; +return count; + } +if (a->struct_type ==FAULT_INFO_RATE ) { +if (f2fs_build_fault_attr (sbi, t,0 )) +return -EINVAL ; +return count; + }#endif if (a->struct_type ==RESERVED_BLOCKS ) {spin_lock (&sbi->stat_lock);
Greg Kroah-Hartman
maintainerPATCH 250/373 pmdomain: ti: Add a null pointer check to the omap_prm_domain_init
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunwu Chan <[email protected]>
commit 5d7f58ee08434a33340f75ac7ac5071eea9673b3 upstream.
devm_kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity.
--- drivers/soc/ti/omap_prm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/ti/omap_prm.c +2 -0
@@ -696,6 +696,8 @@ static int omap_prm_domain_init(struct d data = prm->data; name =devm_kasprintf (dev,GFP_KERNEL ,"prm_%s" , data->name); +if (!name) +return -ENOMEM ; prmd->dev = dev; prmd->prm = prm;
Greg Kroah-Hartman
maintainerPATCH 251/373 scsi: lpfc: Fix null pointer dereference after failing to issue FLOGI and PLOGI
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Smart <[email protected]>
commit 577a942df3de2666f6947bdd3a5c9e8d30073424 upstream.
If lpfc_issue_els_flogi() fails and returns non-zero status, the node reference count is decremented to trigger the release of the nodelist structure. However, if there is a prior registration or dev-loss-evt work pending, the node may be released prematurely. When dev-loss-evt completes, the released node is referenced causing a use-after-free null pointer dereference.
Similarly, when processing non-zero ELS PLOGI completion status in lpfc_cmpl_els_plogi(), the ndlp flags are checked for a transport registration before triggering node removal. If dev-loss-evt work is pending, the node may be released prematurely and a subsequent call to lpfc_dev_loss_tmo_handler() results in a use after free ndlp dereference.
Add test for pending dev-loss before decrementing the node reference count for FLOGI, PLOGI, PRLI, and ADISC handling.
--- drivers/scsi/lpfc/lpfc_els.c | 51 +++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 16 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +35 -16
@@ -1517,10 +1517,13 @@ lpfc_initial_flogi(struct lpfc_vport *vp }if (lpfc_issue_els_flogi (vport, ndlp,0 )) { -/* This decrement of reference count to node shall kick off -* the release of the node. +/* A node reference should be retained while registered with a +* transport or dev-loss-evt work is pending. +* Otherwise, decrement node reference to trigger release. */ -lpfc_nlp_put (ndlp); +if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD |NVME_XPT_REGD )) && + !(ndlp->nlp_flag &NLP_IN_DEV_LOSS )) +lpfc_nlp_put (ndlp);return 0 ; }return 1 ;
@@ -1563,10 +1566,13 @@ lpfc_initial_fdisc(struct lpfc_vport *vp }if (lpfc_issue_els_fdisc (vport, ndlp,0 )) { -/* decrement node reference count to trigger the release of -* the node. +/* A node reference should be retained while registered with a +* transport or dev-loss-evt work is pending. +* Otherwise, decrement node reference to trigger release. */ -lpfc_nlp_put (ndlp); +if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD |NVME_XPT_REGD )) && + !(ndlp->nlp_flag &NLP_IN_DEV_LOSS )) +lpfc_nlp_put (ndlp);return 0 ; }return 1 ;
@@ -1967,6 +1973,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phbstruct lpfc_dmabuf *prsp;int disc;struct serv_parm *sp =NULL ; +bool release_node = false;/* we pass cmdiocb to state machine which needs rspiocb as well */ cmdiocb->context_un.rsp_iocb = rspiocb;
@@ -2047,19 +2054,21 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phbspin_unlock_irq (&ndlp->lock); goto out; } -spin_unlock_irq (&ndlp->lock);/* No PLOGI collision and the node is not registered with the * scsi or nvme transport. It is no longer an active node. Just * start the device remove process. */ if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD |NVME_XPT_REGD ))) { -spin_lock_irq (&ndlp->lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC ; -spin_unlock_irq (&ndlp->lock); +if (!(ndlp->nlp_flag &NLP_IN_DEV_LOSS )) + release_node = true; + } +spin_unlock_irq (&ndlp->lock); + +if (release_node)lpfc_disc_state_machine (vport, ndlp, cmdiocb,NLP_EVT_DEVICE_RM ); - } }else {/* Good status, call state machine */ prsp = list_entry(((struct lpfc_dmabuf *)
@@ -2269,6 +2278,7 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phbastruct lpfc_nodelist *ndlp;char *mode;u32 loglevel; +bool release_node = false;/* we pass cmdiocb to state machine which needs rspiocb as well */ cmdiocb->context_un.rsp_iocb = rspiocb;
@@ -2335,14 +2345,18 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba* it is no longer an active node. Otherwise devloss * handles the final cleanup. */ +spin_lock_irq (&ndlp->lock);if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD |NVME_XPT_REGD )) && !ndlp->fc4_prli_sent) { -spin_lock_irq (&ndlp->lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC ; -spin_unlock_irq (&ndlp->lock); +if (!(ndlp->nlp_flag &NLP_IN_DEV_LOSS )) + release_node = true; + } +spin_unlock_irq (&ndlp->lock); + +if (release_node)lpfc_disc_state_machine (vport, ndlp, cmdiocb,NLP_EVT_DEVICE_RM ); - } }else {/* Good status, call state machine. However, if another * PRLI is outstanding, don't call the state machine
@@ -2713,6 +2727,7 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phbIOCB_t *irsp;struct lpfc_nodelist *ndlp;int disc; +bool release_node = false;/* we pass cmdiocb to state machine which needs rspiocb as well */ cmdiocb->context_un.rsp_iocb = rspiocb;
@@ -2771,13 +2786,17 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phb* transport, it is no longer an active node. Otherwise * devloss handles the final cleanup. */ +spin_lock_irq (&ndlp->lock);if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD |NVME_XPT_REGD ))) { -spin_lock_irq (&ndlp->lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC ; -spin_unlock_irq (&ndlp->lock); +if (!(ndlp->nlp_flag &NLP_IN_DEV_LOSS )) + release_node = true; + } +spin_unlock_irq (&ndlp->lock); + +if (release_node)lpfc_disc_state_machine (vport, ndlp, cmdiocb,NLP_EVT_DEVICE_RM ); - } }else /* Good status, call state machine */ lpfc_disc_state_machine(vport, ndlp, cmdiocb,
Greg Kroah-Hartman
maintainerPATCH 252/373 f2fs: Add inline to f2fs_build_fault_attr() stub
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 0d8968287a1cf7b03d07387dc871de3861b9f6b9 upstream.
When building without CONFIG_F2FS_FAULT_INJECTION, there is a warning from each file that includes f2fs.h because the stub for f2fs_build_fault_attr() is missing inline:
In file included from fs/f2fs/segment.c:21:
fs/f2fs/f2fs.h:4605:12: warning: 'f2fs_build_fault_attr' defined but not used [-Wunused-function]
4605 | static int f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned long rate,
| ^~~~~~~~~~~~~~~~~~~~~
Add the missing inline to resolve all of the warnings for this configuration.
--- fs/f2fs/f2fs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/f2fs.h +2 -2
@@ -4376,8 +4376,8 @@ static inline bool f2fs_need_verity(consextern int f2fs_build_fault_attr (struct f2fs_sb_info *sbi,unsigned long rate,unsigned long type);#else -static int f2fs_build_fault_attr (struct f2fs_sb_info *sbi,unsigned long rate, -unsigned long type) +static inline int f2fs_build_fault_attr (struct f2fs_sb_info *sbi, +unsigned long rate,unsigned long type) {return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 253/373 Bluetooth: SCO: Fix UAF on sco_sock_timeout
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
commit 1bf4470a3939c678fb822073e9ea77a0560bc6bb upstream.
conn->sk maybe have been unlinked/freed while waiting for sco_conn_lock so this checks if the conn->sk is still valid by checking if it part of sco_sk_list.
--- include/net/bluetooth/bluetooth.h | 1 + net/bluetooth/af_bluetooth.c | 22 ++++++++++++++++++++++ net/bluetooth/sco.c | 18 ++++++++++++------ 3 files changed, 35 insertions(+), 6 deletions(-)
include/net/bluetooth/bluetooth.h +1 -0
@@ -314,6 +314,7 @@ int bt_sock_register(int proto, const svoid bt_sock_unregister (int proto);void bt_sock_link (struct bt_sock_list *l,struct sock *s);void bt_sock_unlink (struct bt_sock_list *l,struct sock *s); +bool bt_sock_linked (struct bt_sock_list *l,struct sock *s);int bt_sock_recvmsg (struct socket *sock,struct msghdr *msg,size_t len,int flags); int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
net/bluetooth/af_bluetooth.c +22 -0
@@ -154,6 +154,28 @@ void bt_sock_unlink(struct bt_sock_list }EXPORT_SYMBOL (bt_sock_unlink); +bool bt_sock_linked (struct bt_sock_list *l,struct sock *s) +{ +struct sock *sk; + +if (!l || !s) +return false; + +read_lock (&l->lock); + +sk_for_each (sk, &l->head) { +if (s == sk) { +read_unlock (&l->lock); +return true; + } + } + +read_unlock (&l->lock); + +return false; +} +EXPORT_SYMBOL (bt_sock_linked); +void bt_accept_enqueue (struct sock *parent,struct sock *sk,bool bh) {BT_DBG ("parent %p, sk %p" , parent, sk);
net/bluetooth/sco.c +12 -6
@@ -76,6 +76,16 @@ struct sco_pinfo {#define SCO_CONN_TIMEOUT (HZ * 40)#define SCO_DISCONN_TIMEOUT (HZ * 2) +static struct sock *sco_sock_hold (struct sco_conn *conn) +{ +if (!conn || !bt_sock_linked (&sco_sk_list, conn->sk)) +return NULL ; + +sock_hold (conn->sk); + +return conn->sk; +} +static void sco_sock_timeout (struct work_struct *work) { struct sco_conn *conn = container_of(work, struct sco_conn,
@@ -87,9 +97,7 @@ static void sco_sock_timeout(struct worksco_conn_unlock (conn);return ; } - sk = conn->sk; -if (sk) -sock_hold (sk); + sk =sco_sock_hold (conn);sco_conn_unlock (conn);if (!sk)
@@ -191,9 +199,7 @@ static void sco_conn_del(struct hci_conn/* Kill socket */ sco_conn_lock (conn); - sk = conn->sk; -if (sk) -sock_hold (sk); + sk =sco_sock_hold (conn);sco_conn_unlock (conn);if (sk) {
Greg Kroah-Hartman
maintainerPATCH 254/373 module: sign with sha512 instead of sha1 by default
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Leemhuis <[email protected]>
commit f3b93547b91ad849b58eb5ab2dd070950ad7beb3 upstream.
Switch away from using sha1 for module signing by default and use the more modern sha512 instead, which is what among others Arch, Fedora, RHEL, and Ubuntu are currently using for their kernels.
Sha1 has not been considered secure against well-funded opponents since 2005[1]; since 2011 the NIST and other organizations furthermore recommended its replacement[2]. This is why OpenSSL on RHEL9, Fedora Linux 41+[3], and likely some other current and future distributions reject the creation of sha1 signatures, which leads to a build error of allmodconfig configurations:
80A20474797F0000:error:03000098:digital envelope routines:do_sigver_init:invalid digest:crypto/evp/m_sigver.c:342:
make[4]: *** [.../certs/Makefile:53: certs/signing_key.pem] Error 1
make[4]: *** Deleting file 'certs/signing_key.pem'
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [.../scripts/Makefile.build:478: certs] Error 2
make[2]: *** [.../Makefile:1936: .] Error 2
make[1]: *** [.../Makefile:224: __sub-make] Error 2
make[1]: Leaving directory '...'
make: *** [Makefile:224: __sub-make] Error 2
This change makes allmodconfig work again and sets a default that is more appropriate for current and future users, too.
--- init/Kconfig | 1 + 1 file changed, 1 insertion(+)
init/Kconfig +1 -0
@@ -2194,6 +2194,7 @@ comment "Do not forget to sign required choice prompt "Which hash algorithm should modules be signed with?" depends on MODULE_SIG || IMA_APPRAISE_MODSIG + default MODULE_SIG_SHA512 help This determines which sort of hashing algorithm will be used during signature generation. This algorithm _must_ be built into the kernel
Greg Kroah-Hartman
maintainerPATCH 255/373 media: streamzap: remove unnecessary ir_raw_event_reset and handle
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 4bed9306050497f49cbe77b842f0d812f4f27593 ]
There is no reason to have a reset after an IR timeout. Calling ir_raw_event_handle() twice for the same interrupt has no affect.
Stable-dep-of: f656cfbc7a29 ("media: streamzap: fix race between device disconnection and urb callback")
--- drivers/media/rc/streamzap.c | 2 -- 1 file changed, 2 deletions(-)
drivers/media/rc/streamzap.c +0 -2
@@ -215,8 +215,6 @@ static void sz_process_ir_data(struct streamzap_ir *sz, int len) sz->idle = true;if (sz->timeout_enabled)sz_push (sz, rawir); -ir_raw_event_handle (sz->rdev); -ir_raw_event_reset (sz->rdev); }else {sz_push_full_space (sz, sz->buf_in[i]); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 256/373 media: streamzap: no need for usb pid/vid in device name
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 7a25e6849ad73de5aa01d62da43071bc02b8530c ]
The usb pid/vid can be found elsewhere, the idVendor/idProduct usb sysfs files for example.
Stable-dep-of: f656cfbc7a29 ("media: streamzap: fix race between device disconnection and urb callback")
--- drivers/media/rc/streamzap.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/media/rc/streamzap.c +1 -5
@@ -88,7 +88,6 @@ struct streamzap_ir {ktime_t signal_start;bool timeout_enabled; -char name[128 ];char phys[64 ]; };
@@ -285,13 +284,10 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) goto out; } -snprintf (sz->name,sizeof (sz->name),"Streamzap PC Remote Infrared Receiver (%04x:%04x)" , -le16_to_cpu (sz->usbdev->descriptor.idVendor), -le16_to_cpu (sz->usbdev->descriptor.idProduct));usb_make_path (sz->usbdev, sz->phys,sizeof (sz->phys));strlcat (sz->phys,"/input0" ,sizeof (sz->phys)); - rdev->device_name = sz->name; + rdev->device_name ="Streamzap PC Remote Infrared Receiver" ; rdev->input_phys = sz->phys;usb_to_input_id (sz->usbdev, &rdev->input_id); rdev->dev.parent = dev;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 257/373 media: streamzap: less chatter
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 35088717ad24140b6ab0ec00ef357709be607526 ]
Remove superfluous messages which add no information.
Stable-dep-of: f656cfbc7a29 ("media: streamzap: fix race between device disconnection and urb callback")
--- drivers/media/rc/streamzap.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/media/rc/streamzap.c +1 -19
@@ -26,7 +26,6 @@#include <linux/usb/input.h> #include <media/rc-core.h> -#define DRIVER_VERSION "1.61"#define DRIVER_NAME "streamzap"#define DRIVER_DESC "Streamzap Remote Control driver"
@@ -279,10 +278,8 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)int ret; rdev =rc_allocate_device (RC_DRIVER_IR_RAW ); -if (!rdev) { -dev_err (dev,"remote dev allocation failed\n" ); +if (!rdev) goto out; - }usb_make_path (sz->usbdev, sz->phys,sizeof (sz->phys));strlcat (sz->phys,"/input0" ,sizeof (sz->phys));
@@ -322,7 +319,6 @@ static int streamzap_probe(struct usb_interface *intf,struct usb_device *usbdev =interface_to_usbdev (intf);struct usb_host_interface *iface_host;struct streamzap_ir *sz =NULL ; -char buf[63 ], name[128 ] ="" ;int retval = -ENOMEM ;int pipe, maxp;
@@ -381,17 +377,6 @@ static int streamzap_probe(struct usb_interface *intf, sz->dev = &intf->dev; sz->buf_in_len = maxp; -if (usbdev->descriptor.iManufacturer - &&usb_string (usbdev, usbdev->descriptor.iManufacturer, - buf,sizeof (buf)) >0 ) -strscpy (name, buf,sizeof (name)); - -if (usbdev->descriptor.iProduct - &&usb_string (usbdev, usbdev->descriptor.iProduct, - buf,sizeof (buf)) >0 ) -snprintf (name +strlen (name),sizeof (name) -strlen (name), -" %s" , buf); - sz->rdev =streamzap_init_rc_dev (sz);if (!sz->rdev) goto rc_dev_fail;
@@ -422,9 +407,6 @@ static int streamzap_probe(struct usb_interface *intf,if (usb_submit_urb (sz->urb_in,GFP_ATOMIC ))dev_err (sz->dev,"urb submit failed\n" ); -dev_info (sz->dev,"Registered %s on usb%d:%d\n" , name, - usbdev->bus->busnum, usbdev->devnum); -return 0 ; rc_dev_fail:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 258/373 media: streamzap: remove unused struct members
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 4df69e46c352df9bdbe859824da33428a3ce8a1d ]
These struct members do not serve any purpose.
Stable-dep-of: f656cfbc7a29 ("media: streamzap: fix race between device disconnection and urb callback")
--- drivers/media/rc/streamzap.c | 37 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 23 deletions(-)
drivers/media/rc/streamzap.c +14 -23
@@ -66,9 +66,6 @@ struct streamzap_ir {struct device *dev;/* usb */ -struct usb_device *usbdev; -struct usb_interface *interface; -struct usb_endpoint_descriptor *endpoint;struct urb *urb_in;/* buffer & dma */
@@ -85,7 +82,6 @@ struct streamzap_ir {/* start time of signal; necessary for gap tracking */ ktime_t signal_last;ktime_t signal_start; -bool timeout_enabled;char phys[64 ]; };
@@ -211,8 +207,7 @@ static void sz_process_ir_data(struct streamzap_ir *sz, int len) .duration = sz->rdev->timeout }; sz->idle = true; -if (sz->timeout_enabled) -sz_push (sz, rawir); +sz_push (sz, rawir); }else {sz_push_full_space (sz, sz->buf_in[i]); }
@@ -271,7 +266,8 @@ static void streamzap_callback(struct urb *urb)usb_submit_urb (urb,GFP_ATOMIC ); } -static struct rc_dev *streamzap_init_rc_dev (struct streamzap_ir *sz) +static struct rc_dev *streamzap_init_rc_dev (struct streamzap_ir *sz, +struct usb_device *usbdev) {struct rc_dev *rdev;struct device *dev = sz->dev;
@@ -281,12 +277,12 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)if (!rdev) goto out; -usb_make_path (sz->usbdev, sz->phys,sizeof (sz->phys)); +usb_make_path (usbdev, sz->phys,sizeof (sz->phys));strlcat (sz->phys,"/input0" ,sizeof (sz->phys)); rdev->device_name ="Streamzap PC Remote Infrared Receiver" ; rdev->input_phys = sz->phys; -usb_to_input_id (sz->usbdev, &rdev->input_id); +usb_to_input_id (usbdev, &rdev->input_id); rdev->dev.parent = dev; rdev->priv = sz; rdev->allowed_protocols =RC_PROTO_BIT_ALL_IR_DECODER ;
@@ -317,6 +313,7 @@ static int streamzap_probe(struct usb_interface *intf, const struct usb_device_id *id) {struct usb_device *usbdev =interface_to_usbdev (intf); +struct usb_endpoint_descriptor *endpoint;struct usb_host_interface *iface_host;struct streamzap_ir *sz =NULL ;int retval = -ENOMEM ;
@@ -327,9 +324,6 @@ static int streamzap_probe(struct usb_interface *intf,if (!sz)return -ENOMEM ; - sz->usbdev = usbdev; - sz->interface = intf; -/* Check to ensure endpoint information matches requirements */ iface_host = intf->cur_altsetting;
@@ -340,22 +334,22 @@ static int streamzap_probe(struct usb_interface *intf, goto free_sz; } - sz->endpoint = &(iface_host->endpoint[0 ].desc); -if (!usb_endpoint_dir_in (sz->endpoint)) { + endpoint = &iface_host->endpoint[0 ].desc; +if (!usb_endpoint_dir_in (endpoint)) {dev_err (&intf->dev,"%s: endpoint doesn't match input device 02%02x\n" , - __func__, sz->endpoint->bEndpointAddress); + __func__, endpoint->bEndpointAddress); retval = -ENODEV ; goto free_sz; } -if (!usb_endpoint_xfer_int (sz->endpoint)) { +if (!usb_endpoint_xfer_int (endpoint)) {dev_err (&intf->dev,"%s: endpoint attributes don't match xfer 02%02x\n" , - __func__, sz->endpoint->bmAttributes); + __func__, endpoint->bmAttributes); retval = -ENODEV ; goto free_sz; } - pipe =usb_rcvintpipe (usbdev, sz->endpoint->bEndpointAddress); + pipe =usb_rcvintpipe (usbdev, endpoint->bEndpointAddress); maxp =usb_maxpacket (usbdev, pipe,usb_pipeout (pipe));if (maxp ==0 ) {
@@ -377,14 +371,13 @@ static int streamzap_probe(struct usb_interface *intf, sz->dev = &intf->dev; sz->buf_in_len = maxp; - sz->rdev =streamzap_init_rc_dev (sz); + sz->rdev =streamzap_init_rc_dev (sz, usbdev);if (!sz->rdev) goto rc_dev_fail; sz->idle = true; sz->decoder_state = PulseSpace;/* FIXME: don't yet have a way to set this */ - sz->timeout_enabled = true; sz->rdev->timeout =SZ_TIMEOUT *SZ_RESOLUTION ;#if 0 /* not yet supported, depends on patches from maxim */
@@ -397,8 +390,7 @@ static int streamzap_probe(struct usb_interface *intf,/* Complete final initialisations */ usb_fill_int_urb (sz->urb_in, usbdev, pipe, sz->buf_in, - maxp, (usb_complete_t )streamzap_callback, - sz, sz->endpoint->bInterval); + maxp, streamzap_callback, sz, endpoint->bInterval); sz->urb_in->transfer_dma = sz->dma_in; sz->urb_in->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;
@@ -439,7 +431,6 @@ static void streamzap_disconnect(struct usb_interface *interface)if (!sz)return ; - sz->usbdev =NULL ;rc_unregister_device (sz->rdev);usb_kill_urb (sz->urb_in);usb_free_urb (sz->urb_in);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 259/373 media: streamzap: fix race between device disconnection and urb callback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Murad Masimov <[email protected]>
[ Upstream commit f656cfbc7a293a039d6a0c7100e1c846845148c1 ]
Syzkaller has reported a general protection fault at function ir_raw_event_store_with_filter(). This crash is caused by a NULL pointer dereference of dev->raw pointer, even though it is checked for NULL in the same function, which means there is a race condition. It occurs due to the incorrect order of actions in the streamzap_disconnect() function:rc_unregister_device() is called before usb_kill_urb(). The dev->raw pointer is freed and set to NULL in rc_unregister_device(), and only after that usb_kill_urb() waits for in-progress requests to finish.
If rc_unregister_device() is called while streamzap_callback() handler is not finished, this can lead to accessing freed resources. Thus rc_unregister_device() should be called after usb_kill_urb().
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/media/rc/streamzap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/streamzap.c +1 -1
@@ -431,8 +431,8 @@ static void streamzap_disconnect(struct usb_interface *interface)if (!sz)return ; -rc_unregister_device (sz->rdev);usb_kill_urb (sz->urb_in); +rc_unregister_device (sz->rdev);usb_free_urb (sz->urb_in);usb_free_coherent (usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 260/373 auxdisplay: hd44780: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 9ea02f7cc39d484d16e8a14f3713fefcd33407c0 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: 9b98a7d2e5f4 ("auxdisplay: hd44780: Fix an API misuse in hd44780.c")
--- drivers/auxdisplay/hd44780.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/auxdisplay/hd44780.c +2 -3
@@ -319,7 +319,7 @@ static int hd44780_probe(struct platform_device *pdev)return ret; } -static int hd44780_remove (struct platform_device *pdev) +static void hd44780_remove (struct platform_device *pdev) {struct charlcd *lcd =platform_get_drvdata (pdev);struct hd44780_common *hdc = lcd->drvdata;
@@ -329,7 +329,6 @@ static int hd44780_remove(struct platform_device *pdev)kfree (lcd->drvdata);kfree (lcd); -return 0 ; }static const struct of_device_id hd44780_of_match[] = {
@@ -340,7 +339,7 @@ MODULE_DEVICE_TABLE(of, hd44780_of_match);static struct platform_driver hd44780_driver = { .probe = hd44780_probe, - .remove = hd44780_remove, + .remove_new = hd44780_remove, .driver = { .name ="hd44780" , .of_match_table = hd44780_of_match,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 261/373 auxdisplay: hd44780: Fix an API misuse in hd44780.c
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
[ Upstream commit 9b98a7d2e5f4e2beeff88f6571da0cdc5883c7fb ]
Variable allocated by charlcd_alloc() should be released by charlcd_free(). The following patch changed kfree() to charlcd_free() to fix an API misuse.
--- drivers/auxdisplay/hd44780.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/auxdisplay/hd44780.c +2 -2
@@ -313,7 +313,7 @@ static int hd44780_probe(struct platform_device *pdev) fail3:kfree (hd); fail2: -kfree (lcd); +charlcd_free (lcd); fail1:kfree (hdc);return ret;
@@ -328,7 +328,7 @@ static void hd44780_remove(struct platform_device *pdev)kfree (hdc->hd44780);kfree (lcd->drvdata); -kfree (lcd); +charlcd_free (lcd); }static const struct of_device_id hd44780_of_match[] = {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 262/373 net: dsa: mv88e6xxx: fix VTU methods for 6320 family
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Behún <[email protected]>
[ Upstream commit f9a457722cf5e3534be5ffab549d6b49737fca72 ]
The VTU registers of the 6320 family use the 6352 semantics, not 6185. Fix it.
--- drivers/net/dsa/mv88e6xxx/chip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +4 -4
@@ -4621,8 +4621,8 @@ static const struct mv88e6xxx_ops mv88e6320_ops = { .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, - .vtu_getnext = mv88e6185_g1_vtu_getnext, - .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, + .vtu_getnext = mv88e6352_g1_vtu_getnext, + .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, .gpio_ops = &mv88e6352_gpio_ops, .avb_ops = &mv88e6352_avb_ops, .ptp_ops = &mv88e6352_ptp_ops,
@@ -4667,8 +4667,8 @@ static const struct mv88e6xxx_ops mv88e6321_ops = { .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, - .vtu_getnext = mv88e6185_g1_vtu_getnext, - .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, + .vtu_getnext = mv88e6352_g1_vtu_getnext, + .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, .gpio_ops = &mv88e6352_gpio_ops, .avb_ops = &mv88e6352_avb_ops, .ptp_ops = &mv88e6352_ptp_ops,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 263/373 soc: samsung: exynos-chipid: avoid soc_device_to_device()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit d1141886c8d72ad77920e6e4b617d366e6e3ee8a ]
soc_device_to_device() seems to be discouraged [1] so remove it in favor of printing info message with platform device. This will only change the prefix in the info message from "soc soc0: " to "exynos-chipid 10000000.chipid:".
[1] https://lore.kernel.org/lkml/[email protected]/
Stable-dep-of: c8222ef6cf29 ("soc: samsung: exynos-chipid: Add NULL pointer check in exynos_chipid_probe()")
--- drivers/soc/samsung/exynos-chipid.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/samsung/exynos-chipid.c +1 -2
@@ -104,8 +104,7 @@ static int exynos_chipid_probe(struct platform_device *pdev)platform_set_drvdata (pdev, soc_dev); -dev_info (soc_device_to_device (soc_dev), -"Exynos: CPU[%s] PRO_ID[0x%x] REV[0x%x] Detected\n" , +dev_info (&pdev->dev,"Exynos: CPU[%s] PRO_ID[0x%x] REV[0x%x] Detected\n" , soc_dev_attr->soc_id, product_id, revision);return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 264/373 soc: samsung: exynos-chipid: Pass revision reg offsets
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sam Protsenko <[email protected]>
[ Upstream commit c072c4ef7ef09e1d6470c48cf52570487589b76a ]
Old Exynos SoCs have both Product ID and Revision ID in one single register, while new SoCs tend to have two separate registers for those IDs. Implement handling of both cases by passing Revision ID register offsets in driver data.
Previously existing macros for Exynos4210 (removed in this patch) were incorrect:
#define EXYNOS_SUBREV_MASK (0xf << 4)
#define EXYNOS_MAINREV_MASK (0xf << 0)Actual format of PRO_ID register in Exynos4210 (offset 0x0):
[31:12] Product ID
[9:8] Package information
[7:4] Main Revision Number
[3:0] Sub Revision Number
This patch doesn't change the behavior on existing platforms, so '/sys/devices/soc0/revision' will show the same string as before.
Stable-dep-of: c8222ef6cf29 ("soc: samsung: exynos-chipid: Add NULL pointer check in exynos_chipid_probe()")
--- drivers/soc/samsung/exynos-chipid.c | 69 +++++++++++++++++++---- include/linux/soc/samsung/exynos-chipid.h | 6 +- 2 files changed, 60 insertions(+), 15 deletions(-)
drivers/soc/samsung/exynos-chipid.c +58 -11
@@ -16,6 +16,7 @@#include <linux/errno.h> #include <linux/mfd/syscon.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/slab.h>
@@ -24,6 +25,17 @@#include "exynos-asv.h" +struct exynos_chipid_variant { +unsigned int rev_reg;/* revision register offset */ +unsigned int main_rev_shift;/* main revision offset in rev_reg */ +unsigned int sub_rev_shift;/* sub revision offset in rev_reg */ +}; + +struct exynos_chipid_info { +u32 product_id; +u32 revision; +}; + static const struct exynos_soc_id { const char *name; unsigned int id;
@@ -49,31 +61,57 @@ static const char *product_id_to_soc_id(unsigned int product_id)int i;for (i =0 ; i <ARRAY_SIZE (soc_ids); i++) -if ((product_id &EXYNOS_MASK ) == soc_ids[i].id) +if (product_id == soc_ids[i].id)return soc_ids[i].name;return NULL ; } +static int exynos_chipid_get_chipid_info (struct regmap *regmap, +const struct exynos_chipid_variant *data, +struct exynos_chipid_info *soc_info) +{ +int ret; +unsigned int val, main_rev, sub_rev; + + ret =regmap_read (regmap,EXYNOS_CHIPID_REG_PRO_ID , &val); +if (ret <0 ) +return ret; + soc_info->product_id = val &EXYNOS_MASK ; + +if (data->rev_reg !=EXYNOS_CHIPID_REG_PRO_ID ) { + ret =regmap_read (regmap, data->rev_reg, &val); +if (ret <0 ) +return ret; + } + main_rev = (val >> data->main_rev_shift) &EXYNOS_REV_PART_MASK ; + sub_rev = (val >> data->sub_rev_shift) &EXYNOS_REV_PART_MASK ; + soc_info->revision = (main_rev <<EXYNOS_REV_PART_SHIFT ) | sub_rev; + +return 0 ; +} +static int exynos_chipid_probe (struct platform_device *pdev) { +const struct exynos_chipid_variant *drv_data; +struct exynos_chipid_info soc_info;struct soc_device_attribute *soc_dev_attr;struct soc_device *soc_dev;struct device_node *root;struct regmap *regmap; -u32 product_id; -u32 revision;int ret; + drv_data =of_device_get_match_data (&pdev->dev); +if (!drv_data) +return -EINVAL ; + regmap =device_node_to_regmap (pdev->dev.of_node);if (IS_ERR (regmap))return PTR_ERR (regmap); - ret =regmap_read (regmap,EXYNOS_CHIPID_REG_PRO_ID , &product_id); + ret =exynos_chipid_get_chipid_info (regmap, drv_data, &soc_info);if (ret <0 )return ret; - revision = product_id &EXYNOS_REV_MASK ; - soc_dev_attr =devm_kzalloc (&pdev->dev,sizeof (*soc_dev_attr),GFP_KERNEL );if (!soc_dev_attr)
@@ -86,8 +124,8 @@ static int exynos_chipid_probe(struct platform_device *pdev)of_node_put (root); soc_dev_attr->revision =devm_kasprintf (&pdev->dev,GFP_KERNEL , -"%x" , revision); - soc_dev_attr->soc_id =product_id_to_soc_id (product_id); +"%x" , soc_info.revision); + soc_dev_attr->soc_id =product_id_to_soc_id (soc_info.product_id);if (!soc_dev_attr->soc_id) {pr_err ("Unknown SoC\n" );return -ENODEV ;
@@ -105,7 +143,7 @@ static int exynos_chipid_probe(struct platform_device *pdev)platform_set_drvdata (pdev, soc_dev);dev_info (&pdev->dev,"Exynos: CPU[%s] PRO_ID[0x%x] REV[0x%x] Detected\n" , - soc_dev_attr->soc_id, product_id, revision); + soc_dev_attr->soc_id, soc_info.product_id, soc_info.revision);return 0 ;
@@ -124,9 +162,18 @@ static int exynos_chipid_remove(struct platform_device *pdev)return 0 ; } +static const struct exynos_chipid_variant exynos4210_chipid_drv_data = { + .rev_reg =0x0 , + .main_rev_shift =4 , + .sub_rev_shift =0 , +}; +static const struct of_device_id exynos_chipid_of_device_ids[] = { - { .compatible ="samsung,exynos4210-chipid" }, - {} + { + .compatible ="samsung,exynos4210-chipid" , + .data = &exynos4210_chipid_drv_data, + }, + { } };static struct platform_driver exynos_chipid_driver = {
include/linux/soc/samsung/exynos-chipid.h +2 -4
@@ -9,10 +9,8 @@#define __LINUX_SOC_EXYNOS_CHIPID_H#define EXYNOS_CHIPID_REG_PRO_ID 0x00 -#define EXYNOS_SUBREV_MASK (0xf << 4) -#define EXYNOS_MAINREV_MASK (0xf << 0) -#define EXYNOS_REV_MASK (EXYNOS_SUBREV_MASK | \ - EXYNOS_MAINREV_MASK) +#define EXYNOS_REV_PART_MASK 0xf +#define EXYNOS_REV_PART_SHIFT 4#define EXYNOS_MASK 0xfffff000#define EXYNOS_CHIPID_REG_PKG_ID 0x04
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 265/373 soc: samsung: exynos-chipid: Add NULL pointer check in exynos_chipid_probe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenyuan Yang <[email protected]>
[ Upstream commit c8222ef6cf29dd7cad21643228f96535cc02b327 ]
soc_dev_attr->revision could be NULL, thus,
a pointer check is added to prevent potential NULL pointer dereference. This is similar to the fix in commit 3027e7b15b02
("ice: Fix some null pointer dereference issues in ice_ptp.c").
This issue is found by our static analysis tool.
--- drivers/soc/samsung/exynos-chipid.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/samsung/exynos-chipid.c +2 -0
@@ -125,6 +125,8 @@ static int exynos_chipid_probe(struct platform_device *pdev) soc_dev_attr->revision =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%x" , soc_info.revision); +if (!soc_dev_attr->revision) +return -ENOMEM ; soc_dev_attr->soc_id =product_id_to_soc_id (soc_info.product_id);if (!soc_dev_attr->soc_id) {pr_err ("Unknown SoC\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 266/373 iio: adc: ad7768-1: Move setting of val a bit later to avoid unnecessary return value check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Cameron <[email protected]>
[ Upstream commit 0af1c801a15225304a6328258efbf2bee245c654 ]
The data used is all in local variables so there is no advantage in setting *val = ret with the direct mode claim held. Move it later to after error check.
Stable-dep-of: 8236644f5ecb ("iio: adc: ad7768-1: Fix conversion result sign")
--- drivers/iio/adc/ad7768-1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/adc/ad7768-1.c +1 -2
@@ -370,12 +370,11 @@ static int ad7768_read_raw(struct iio_dev *indio_dev,return ret; ret =ad7768_scan_direct (indio_dev); -if (ret >=0 ) - *val = ret;iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; + *val = ret;return IIO_VAL_INT ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 267/373 iio: adc: ad7768-1: Fix conversion result sign
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergiu Cuciurean <[email protected]>
[ Upstream commit 8236644f5ecb180e80ad92d691c22bc509b747bb ]
The ad7768-1 ADC output code is two's complement, meaning that the voltage conversion result is a signed value.. Since the value is a 24 bit one, stored in a 32 bit variable, the sign should be extended in order to get the correct representation.
Also the channel description has been updated to signed representation, to match the ADC specifications.
--- drivers/iio/adc/ad7768-1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ad7768-1.c +2 -2
@@ -142,7 +142,7 @@ static const struct iio_chan_spec ad7768_channels[] = { .channel = 0, .scan_index = 0, .scan_type = { - .sign = 'u', + .sign = 's', .realbits = 24, .storagebits = 32, .shift = 8,
@@ -374,7 +374,7 @@ static int ad7768_read_raw(struct iio_dev *indio_dev,iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; - *val = ret; + *val =sign_extend32 (ret, chan->scan_type.realbits -1 );return IIO_VAL_INT ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 268/373 backlight: led_bl: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit c4c4fa57fd3cc00020152baa169337521f90b2ad ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void.
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: 276822a00db3 ("backlight: led_bl: Hold led_access lock when calling led_sysfs_disable()")
--- drivers/video/backlight/led_bl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/video/backlight/led_bl.c +2 -4
@@ -217,7 +217,7 @@ static int led_bl_probe(struct platform_device *pdev)return 0 ; } -static int led_bl_remove (struct platform_device *pdev) +static void led_bl_remove (struct platform_device *pdev) {struct led_bl_data *priv =platform_get_drvdata (pdev);struct backlight_device *bl = priv->bl_dev;
@@ -228,8 +228,6 @@ static int led_bl_remove(struct platform_device *pdev)led_bl_power_off (priv);for (i =0 ; i < priv->nb_leds; i++)led_sysfs_enable (priv->leds[i]); - -return 0 ; }static const struct of_device_id led_bl_of_match[] = {
@@ -245,7 +243,7 @@ static struct platform_driver led_bl_driver = { .of_match_table = of_match_ptr(led_bl_of_match), }, .probe = led_bl_probe, - .remove = led_bl_remove, + .remove_new = led_bl_remove, };module_platform_driver (led_bl_driver);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 269/373 backlight: led_bl: Hold led_access lock when calling led_sysfs_disable()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herve Codina <[email protected]>
[ Upstream commit 276822a00db3c1061382b41e72cafc09d6a0ec30 ]
Lockdep detects the following issue on led-backlight removal:
[ 142.315935] ------------[ cut here ]------------ [ 142.315954] WARNING: CPU: 2 PID: 292 at drivers/leds/led-core.c:455 led_sysfs_enable+0x54/0x80 ... [ 142.500725] Call trace: [ 142.503176] led_sysfs_enable+0x54/0x80 (P) [ 142.507370] led_bl_remove+0x80/0xa8 [led_bl] [ 142.511742] platform_remove+0x30/0x58 [ 142.515501] device_remove+0x54/0x90 ...
Indeed, led_sysfs_enable() has to be called with the led_access lock held.
Hold the lock when calling led_sysfs_disable().
--- drivers/video/backlight/led_bl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/video/backlight/led_bl.c +4 -1
@@ -226,8 +226,11 @@ static void led_bl_remove(struct platform_device *pdev)backlight_device_unregister (bl);led_bl_power_off (priv); -for (i =0 ; i < priv->nb_leds; i++) +for (i =0 ; i < priv->nb_leds; i++) { +mutex_lock (&priv->leds[i]->led_access);led_sysfs_enable (priv->leds[i]); +mutex_unlock (&priv->leds[i]->led_access); + } }static const struct of_device_id led_bl_of_match[] = {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 270/373 cifs: print TIDs as hex
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Enzo Matsumiya <[email protected]>
[ Upstream commit 71081e7ac16c93acdd18afa65daa468620bb1b64 ]
Makes these debug messages easier to read
Stable-dep-of: b4885bd5935b ("cifs: avoid NULL pointer dereference in dbg call")
--- fs/cifs/connect.c | 2 +- fs/cifs/smb2misc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/cifs/connect.c +1 -1
@@ -1683,7 +1683,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb3_fs_context *ctx) goto out; } -cifs_dbg (FYI ,"IPC tcon rc = %d ipc tid = %d\n" , rc, tcon->tid); +cifs_dbg (FYI ,"IPC tcon rc=%d ipc tid=0x%x\n" , rc, tcon->tid); ses->tcon_ipc = tcon; out:
fs/cifs/smb2misc.c +1 -1
@@ -791,7 +791,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,if (tcon->ses) server = tcon->ses->server; -cifs_server_dbg (FYI ,"tid=%u: tcon is closing, skipping async close retry of fid %llu %llu\n" , +cifs_server_dbg (FYI ,"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n" , tcon->tid, persistent_fid, volatile_fid);return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 271/373 cifs: avoid NULL pointer dereference in dbg call
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandra Diupina <[email protected]>
[ Upstream commit b4885bd5935bb26f0a414ad55679a372e53f9b9b ]
cifs_server_dbg() implies server to be non-NULL so move call under condition to avoid NULL pointer dereference.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/cifs/smb2misc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/cifs/smb2misc.c +5 -4
@@ -788,11 +788,12 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,WARN_ONCE (tcon->tc_count <0 ,"tcon refcount is negative" );spin_unlock (&cifs_tcp_ses_lock); -if (tcon->ses) +if (tcon->ses) { server = tcon->ses->server; - -cifs_server_dbg (FYI ,"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n" , - tcon->tid, persistent_fid, volatile_fid); +cifs_server_dbg (FYI , +"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n" , + tcon->tid, persistent_fid, volatile_fid); + }return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 272/373 cifs: fix integer overflow in match_server()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Smirnov <[email protected]>
[ Upstream commit 2510859475d7f46ed7940db0853f3342bf1b65ee ]
The echo_interval is not limited in any way during mounting, which makes it possible to write a large number to it. This can cause an overflow when multiplying ctx->echo_interval by HZ in match_server().
Add constraints for echo_interval to smb3_fs_context_parse_param().
Found by Linux Verification Center (linuxtesting.org) with Svace.
--- fs/cifs/fs_context.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/cifs/fs_context.c +5 -0
@@ -1088,6 +1088,11 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, ctx->closetimeo =HZ * result.uint_32;break ;case Opt_echo_interval: +if (result.uint_32 <SMB_ECHO_INTERVAL_MIN || + result.uint_32 >SMB_ECHO_INTERVAL_MAX ) { +cifs_errorf (fc,"echo interval is out of bounds\n" ); + goto cifs_parse_mount_err; + } ctx->echo_interval = result.uint_32;break ;case Opt_snapshot:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 273/373 gpio: tegra186: Force one interrupt per bank
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thierry Reding <[email protected]>
[ Upstream commit ca038748068f454d20ad1bb120cbe36599f81db6 ]
Newer chips support up to 8 interrupts per bank, which can be useful to balance the load and decrease latency. However, it also required a very complicated interrupt routing to be set up. To keep things simple for now, ensure that a single interrupt per bank is enforced, even if all possible interrupts are described in device tree.
Stable-dep-of: 8323f3a69de6 ("gpio: tegra186: fix resource handling in ACPI probe path")
--- drivers/gpio/gpio-tegra186.c | 68 ++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 6 deletions(-)
drivers/gpio/gpio-tegra186.c +62 -6
@@ -81,6 +81,8 @@ struct tegra_gpio {unsigned int *irq;const struct tegra_gpio_soc *soc; +unsigned int num_irqs_per_bank; +unsigned int num_banks;void __iomem *secure;void __iomem *base;
@@ -600,6 +602,28 @@ static void tegra186_gpio_init_route_mapping(struct tegra_gpio *gpio) } } +static unsigned int tegra186_gpio_irqs_per_bank (struct tegra_gpio *gpio) +{ +struct device *dev = gpio->gpio.parent; + +if (gpio->num_irq > gpio->num_banks) { +if (gpio->num_irq % gpio->num_banks !=0 ) + goto error; + } + +if (gpio->num_irq < gpio->num_banks) + goto error; + + gpio->num_irqs_per_bank = gpio->num_irq / gpio->num_banks; + +return 0 ; + +error: +dev_err (dev,"invalid number of interrupts (%u) for %u banks\n" , + gpio->num_irq, gpio->num_banks); +return -EINVAL ; +} +static int tegra186_gpio_probe (struct platform_device *pdev) {unsigned int i, j, offset;
@@ -614,7 +638,17 @@ static int tegra186_gpio_probe(struct platform_device *pdev)return -ENOMEM ; gpio->soc =device_get_match_data (&pdev->dev); + gpio->gpio.label = gpio->soc->name; + gpio->gpio.parent = &pdev->dev; + +/* count the number of banks in the controller */ +for (i =0 ; i < gpio->soc->num_ports; i++) +if (gpio->soc->ports[i].bank > gpio->num_banks) + gpio->num_banks = gpio->soc->ports[i].bank; + + gpio->num_banks++; +/* get register apertures */ gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" );if (IS_ERR (gpio->secure)) { gpio->secure =devm_platform_ioremap_resource (pdev,0 );
@@ -635,6 +669,10 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->num_irq = err; + err =tegra186_gpio_irqs_per_bank (gpio); +if (err <0 ) +return err; + gpio->irq =devm_kcalloc (&pdev->dev, gpio->num_irq,sizeof (*gpio->irq),GFP_KERNEL );if (!gpio->irq)
@@ -648,9 +686,6 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->irq[i] = err; } - gpio->gpio.label = gpio->soc->name; - gpio->gpio.parent = &pdev->dev; - gpio->gpio.request = gpiochip_generic_request; gpio->gpio.free = gpiochip_generic_free; gpio->gpio.get_direction = tegra186_gpio_get_direction;
@@ -714,7 +749,30 @@ static int tegra186_gpio_probe(struct platform_device *pdev) irq->parent_handler = tegra186_gpio_irq; irq->parent_handler_data = gpio; irq->num_parents = gpio->num_irq; - irq->parents = gpio->irq; + +/* +* To simplify things, use a single interrupt per bank for now. Some +* chips support up to 8 interrupts per bank, which can be useful to +* distribute the load and decrease the processing latency for GPIOs +* but it also requires a more complicated interrupt routing than we +* currently program. +*/ +if (gpio->num_irqs_per_bank >1 ) { + irq->parents =devm_kcalloc (&pdev->dev, gpio->num_banks, +sizeof (*irq->parents),GFP_KERNEL ); +if (!irq->parents) +return -ENOMEM ; + +for (i =0 ; i < gpio->num_banks; i++) + irq->parents[i] = gpio->irq[i * gpio->num_irqs_per_bank]; + + irq->num_parents = gpio->num_banks; + }else { + irq->num_parents = gpio->num_irq; + irq->parents = gpio->irq; + } + +tegra186_gpio_init_route_mapping (gpio); np =of_find_matching_node (NULL , tegra186_pmc_of_match);if (np) {
@@ -725,8 +783,6 @@ static int tegra186_gpio_probe(struct platform_device *pdev)return -EPROBE_DEFER ; } -tegra186_gpio_init_route_mapping (gpio); - irq->map =devm_kcalloc (&pdev->dev, gpio->gpio.ngpio,sizeof (*irq->map),GFP_KERNEL );if (!irq->map)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 274/373 gpio: tegra186: fix resource handling in ACPI probe path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 8323f3a69de6f6e96bf22f32dd8e2920766050c2 ]
When the Tegra186 GPIO controller is probed through ACPI matching, the driver emits two error messages during probing:
"tegra186-gpio NVDA0508:00: invalid resource (null)" "tegra186-gpio NVDA0508:00: invalid resource (null)"
Fix this by getting resource first and then do the ioremap.
--- drivers/gpio/gpio-tegra186.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/gpio/gpio-tegra186.c +14 -13
@@ -630,6 +630,7 @@ static int tegra186_gpio_probe(struct platform_device *pdev)struct gpio_irq_chip *irq;struct tegra_gpio *gpio;struct device_node *np; +struct resource *res;char **names;int err;
@@ -649,19 +650,19 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->num_banks++;/* get register apertures */ - gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) { - gpio->secure =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); - } - - gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) { - gpio->base =devm_platform_ioremap_resource (pdev,1 ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base); - } + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"security" ); +if (!res) + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + gpio->secure =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (gpio->secure)) +return PTR_ERR (gpio->secure); + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"gpio" ); +if (!res) + res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); + gpio->base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (gpio->base)) +return PTR_ERR (gpio->base); err =platform_irq_count (pdev);if (err <0 )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 275/373 PCI: Coalesce host bridge contiguous apertures
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai-Heng Feng <[email protected]>
[ Upstream commit 7c3855c423b17f6ca211858afb0cef20569914c7 ]
Built-in graphics at 07:00.0 on HP EliteDesk 805 G6 doesn't work because graphics can't get the BAR it needs. The BIOS configuration is
correct: BARs 0 and 2 both fit in the 00:08.1 bridge window.
But that 00:08.1 window covers two host bridge apertures from _CRS. Previously we assumed this was illegal, so we clipped the window to fit into one aperture (see 0f7e7aee2f37 ("PCI: Add pci_bus_clip_resource() to clip to fit upstream window")).
pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
pci 0000:00:08.1: bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
pci 0000:07:00.0: reg 0x10: [mem 0x10030000000-0x1003fffffff 64bit pref] pci 0000:07:00.0: reg 0x18: [mem 0x10040000000-0x100401fffff 64bit pref]
pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
pci 0000:00:08.1: bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window pci 0000:07:00.0: can't claim BAR 2 [mem 0x10040000000-0x100401fffff 64bit pref]: no compatible bridge window
However, the host bridge apertures are contiguous, so there's no need to clip in this case. Coalesce contiguous apertures so we can allocate from the entire contiguous region.
Previous commit 65db04053efe ("PCI: Coalesce host bridge contiguous apertures") was similar but sorted the apertures, and Guenter Roeck reported a regression in ppc:sam460ex qemu emulation from nvme; see
https://lore.kernel.org/all/[email protected]/
[bhelgaas: commit log]
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
Stable-dep-of: 804443c1f278 ("PCI: Fix reference leak in pci_register_host_bridge()")
--- drivers/pci/probe.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
drivers/pci/probe.c +27 -4
@@ -883,11 +883,11 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus)static int pci_register_host_bridge (struct pci_host_bridge *bridge) {struct device *parent = bridge->dev.parent; -struct resource_entry *window, *n; +struct resource_entry *window, *next, *n;struct pci_bus *bus, *b; -resource_size_t offset; +resource_size_t offset, next_offset;LIST_HEAD (resources); -struct resource *res; +struct resource *res, *next_res;char addr[64 ], *fmt;const char *name;int err;
@@ -969,11 +969,34 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)if (nr_node_ids >1 &&pcibus_to_node (bus) ==NUMA_NO_NODE )dev_warn (&bus->dev,"Unknown NUMA node; performance will be reduced\n" ); +/* Coalesce contiguous windows */ +resource_list_for_each_entry_safe (window, n, &resources) { +if (list_is_last (&window->node, &resources)) +break ; + + next =list_next_entry (window, node); + offset = window->offset; + res = window->res; + next_offset = next->offset; + next_res = next->res; + +if (res->flags != next_res->flags || offset != next_offset) +continue ; + +if (res->end +1 == next_res->start) { + next_res->start = res->start; + res->flags = res->start = res->end =0 ; + } + } +/* Add initial resources to the bus */ resource_list_for_each_entry_safe (window, n, &resources) { -list_move_tail (&window->node, &bridge->windows); offset = window->offset; res = window->res; +if (!res->end) +continue ; + +list_move_tail (&window->node, &bridge->windows);if (res->flags &IORESOURCE_BUS )pci_bus_insert_busn_res (bus, bus->number, res->end);
Signature · 1 line
2.39.5